NAME
Sentry::Transport::Http - Sends envelopes to Sentry via HTTP
DESCRIPTION
The default Sentry::Transport. It posts envelopes to the envelope endpoint of the DSN's Sentry, honors rate limits and suspends sending while Sentry fails. In processes serving many requests (see "background_sender" in Sentry::SDK) it hands envelopes to a sender process of its own (Sentry::Transport::SenderProcess), inside a running Mojo::IOLoop of an application using Mojolicious it sends in the background with Mojo::UserAgent, else it sends with HTTP::Tiny and waits for the response (see "SENDING" in Sentry::SDK). Certificates are always verified, redirects are not followed.
METHODS
new
my $transport = Sentry::Transport::Http->new(dsn => $dsn);
dsn is a Sentry::DSN; http_proxy, https_proxy, ca_certs, http_timeout, shutdown_timeout, transport_compression_level, send_client_reports, transport_queue_size and background_sender are optional, see "init" in Sentry::SDK. Dies on unknown attributes.
from_options
Creates the transport for the options of the client.
send_envelope, send_envelopes
Sends envelopes, see Sentry::Transport. While a framework plugin holds sending for a request (Sentry::Transport::Queue), envelopes that would be sent with HTTP::Tiny are queued until the request has ended, at most transport_queue_size of them.
send_now
$transport->send_now($envelope, $deadline);
Sends the envelope without holding it back; the request ends by the epoch time $deadline at the latest, if given.
client_reports
The client reports of all transports of the process sending to the same Sentry.
is_healthy
my $healthy = $transport->is_healthy;
See "is_healthy" in Sentry::Transport. False while Sentry rate-limits any category, while sending is suspended after network errors (see "SENDING" in Sentry::SDK), while the sender process reported either of them or its queue ("transport_queue_size" in Sentry::SDK) or socket is full, and while Mojo::IOLoop has as many requests pending as it takes. Unlike sentry-python, only rate limits of transactions, spans or all categories count: a limit of e.g. logs does not sample traces down that Sentry still takes. Sending without sender process and event loop, a slow Sentry that still answers within "http_timeout" in Sentry::SDK does not count; only its network errors do, by the backoff they cause.
throttled_until
Internal: the epoch until which this process drops traces for this Sentry on its own, by rate limits of transactions, spans or all categories, or by backoff; in the past while it sends. The sender process reports it to its worker.
for_sender_process
Internal: the transport of the sender process, sending like the worker's transport whose configuration it gets (see Sentry::Transport::SenderProcess).
send_client_report
$transport->send_client_report($deadline);
Sends the pending client reports in an envelope of their own, the request ending by the epoch time $deadline if given.
disconnect
$transport->disconnect;
Closes the connection that HTTP::Tiny keeps open for the next envelope; the next one opens a new connection. For servers forking their workers after the SDK sent something, e.g. the Mojolicious plugin with a preforking server: each worker would otherwise keep a copy of the parent's connection open. A sender process of this process ends after sending what it got; the next envelope starts a new one.
closes_at, close_idle
my $epoch = $transport->closes_at;
$transport->close_idle;
When the connection kept open for the next envelope is due to be closed, 30 seconds after its last request, or undef if none is kept; close_idle closes it once that time has come. Sending does so itself; a process waiting for envelopes, like the sender process, calls close_idle then.
flush
my $all_sent = $transport->flush($timeout);
Within $timeout seconds (default 2): sends the envelopes held back, the pending client reports, and waits for envelopes sent in the background, see "flush" in Sentry::SDK.