NAME
Sentry::Transport - Base class of the transports sending envelopes to Sentry
SYNOPSIS
package My::Transport;
use parent 'Sentry::Transport';
use feature 'signatures';
sub send_envelope ($self, $envelope) {
my $bytes = $envelope->serialize;
...
}
# elsewhere
Sentry::SDK->init({ dsn => ..., transport => 'My::Transport' });
DESCRIPTION
A transport takes envelopes (Sentry::Envelope) from the client and delivers them. The default is Sentry::Transport::Http; Sentry::Transport::Memory keeps them for tests. Pass a class name or an instance as the option transport of "init" in Sentry::SDK to use another one.
Transports must not die: whatever goes wrong while sending is logged and the envelope is recorded as lost.
ATTRIBUTES
client_reports
The client reports of the transport: what was discarded, why, and how much. A Sentry::Transport::ClientReports object (internal).
METHODS
from_options
my $transport = My::Transport->from_options(\%options);
Creates the transport for the (normalized) options of the client when the option transport is a class name. The default calls new without arguments.
"init" in Sentry::SDK calls it: if it dies, the SDK warns and stays off. Servers often call init before forking their workers, so a transport should open connections or start processes on the first envelope, not here.
send_envelope
$transport->send_envelope($envelope);
Sends the envelope. Every transport implements it.
send_envelopes
$transport->send_envelopes(@envelopes);
Sends several envelopes, by default one after the other.
flush
my $all_sent = $transport->flush($timeout);
Waits up to $timeout seconds until the envelopes sent in the background are delivered and returns whether all were. The default returns true.
is_healthy
my $healthy = $transport->is_healthy;
Whether the transport keeps up with sending. While it does not, the SDK samples fewer transactions, like sentry-python (see "enable_backpressure_handling" in Sentry::SDK). It is asked at most every 10 seconds, when a transaction starts, so it must be cheap and must not wait. The default returns true.
record_lost_event
$transport->record_lost_event($reason, $category, $quantity);
Records discarded events for the client reports: the reason (e.g. before_send), the data category (e.g. error, transaction, span) and their number (default 1).
record_lost_item, record_lost_envelope
$transport->record_lost_item($reason, $item);
$transport->record_lost_envelope($reason, $envelope);
Records the content of an envelope item or of all items of an envelope as discarded. A transaction also counts its spans.