NAME
Sentry::Client - Turns captured data into events and hands them to the transport
SYNOPSIS
my $client = Sentry::SDK->get_client;
if (my $dbi = $client->get_integration('Sentry::Integration::DBI')) {
...
}
$client->flush(5) or warn 'not everything was sent to Sentry';
DESCRIPTION
"init" in Sentry::SDK creates the client from the options and puts it on the global scope; "get_client" in Sentry::SDK returns it (before init, and without DSN and transport, a Sentry::Client::NoOp with the same interface). The client applies the options (sampling, "ignore_errors" in Sentry::SDK, "before_send" in Sentry::SDK, limits...) and the data of the scopes to an event and passes it to its Sentry::Transport.
Applications capture through Sentry::SDK, which adds the data of the scopes in effect; there is no need to create a client.
METHODS
is_active
False once the client is closed (see "close"): it captures nothing then.
get_options
my $release = $client->get_options->{release};
The options the client uses, an immutable Sentry::Options: validated, with defaults and the SENTRY_* environment variables applied.
get_integration
my $integration = $client->get_integration('Sentry::Integration::DBI');
The instance of the given integration class the client uses, undef if it uses none.
flush
my $all_sent = $client->flush($timeout);
Sends what is pending within $timeout seconds (default: "shutdown_timeout" in Sentry::SDK) and returns whether all of it was sent, see "flush" in Sentry::SDK.
close
my $all_sent = $client->close($timeout);
Like "flush", but the client captures nothing afterwards.
INTERNAL METHODS
Used by the SDK and its integrations; not part of the public API, may change without notice.
new
my $client = Sentry::Client->new(_options => \%options);
Creates a client from the options of "init" in Sentry::SDK, with its transport; dies if the transport cannot be created.
transport, integrations, setup_integrations, update_callbacks
The transport and the integrations of the client, installing the integrations, and replacing the callback options ("before_send" in Sentry::SDK etc.) of a persistent process per request.
local_variables
What takes the variables of the frames of thrown exceptions (a Sentry::Stacktrace::LocalVariables), undef if "include_local_variables" in Sentry::SDK is off or PadWalker is missing.
should_propagate_trace, org_id, is_tracing_enabled, dynamic_sampling_context
What distributed tracing needs of the options, see "DISTRIBUTED TRACING" in Sentry::SDK.
downsample_factor
While the transport is unhealthy, transactions are sampled with their rate divided by 2 to the power of this, see "enable_backpressure_handling" in Sentry::SDK. 0 while tracing is disabled.
capture_message, capture_exception, capture_event
my $event_id = $client->capture_message($message, $level, \%hint, $scope);
my $event_id = $client->capture_exception($exception, \%hint, $scope);
my $event_id = $client->capture_event(\%event, \%hint, $scope);
Capture with the data of $scope only (none if not given) and return the event id, or undef if the event was not sent. Use the functions of Sentry::SDK, which pass the data of all scopes in effect.
start_session, continue_application_session, end_session, end_application_session, capture_session
my $session = $client->start_session($isolation_scope, $mode);
$client->end_session($session, $status);
The sessions of "RELEASE HEALTH" in Sentry::SDK (Sentry::Session): of the program (mode application, one per client, continued by the client of the next "init" in Sentry::SDK) or of a request (mode request, see Sentry::Web::Request). Ended sessions wait to be sent together: by "flush", or when one ends a minute or more after the first of them. start_session returns undef without release.
capture_check_in
my $check_in_id = $client->capture_check_in($check_in);
Sends a Sentry::CheckIn with release and environment of the client, see "capture_check_in" in Sentry::SDK.
capture_feedback
my $event_id = $client->capture_feedback(\%feedback, \%hint, $scope);
Captures feedback, see "capture_feedback" in Sentry::SDK.
capture_log, capture_metric
$client->capture_log(
{ level => 'info', body => 'Order placed', attributes => \%attributes },
$scope);
$client->capture_metric(
{ type => 'counter', name => 'orders', value => 1, unit => 'order' },
$scope);
Add the default attributes and the trace of $scope (else of the isolation scope), pass the log or metric value to "before_send_log" in Sentry::SDK or "before_send_metric" in Sentry::SDK and buffer it for sending in a batch. Use "logger" in Sentry::SDK and "metrics" in Sentry::SDK.
send_buffered
$client->send_buffered;
$client->send_buffered('log');
Sends what is buffered and must not wait for the next request, e.g. when a request has ended: the logs and metrics. Ended sessions wait to be counted until they are due. Or only the named buffers: log, trace_metric, sessions; dies on others. "flush" sends everything.
send_due
$client->disconnect if $client->send_due;
Sends the buffers that are due: those full, or whose oldest item has waited long enough (5 seconds for logs and metrics, 60 for ended sessions). Cheap enough to be called in every pass of a loop when nothing is due; what is due is sent right away, waiting for Sentry outside of a running Mojo::IOLoop (at most http_timeout per envelope). For processes serving no requests that would otherwise send what they buffered only at exit, such as the manager of a preforking server (see "Deployment" in Mojolicious::Plugin::SentrySDK and Sentry::Integration::NetServer). Returns whether anything was sent.
disconnect
$client->disconnect;
Closes the connection the transport keeps open for the next envelope, if it has one (see "disconnect" in Sentry::Transport::Http), e.g. before a server forks its workers.
event_from_message, event_from_exception
The event data of a message or an exception.
stacktrace_options
my $stacktrace = Sentry::Stacktrace->from_caller($client->stacktrace_options);
The arguments of Sentry::Stacktrace that the options (project_root, in_app_include, in_app_exclude, include_source_context) imply.
record_lost_event
$client->record_lost_event($reason, $category, $quantity);
Records data the SDK dropped for the client reports, see "record_lost_event" in Sentry::Transport.