NAME
Sentry::Envelope - The unit of data a transport sends to Sentry
SYNOPSIS
sub send_envelope ($self, $envelope) {
my $body = $envelope->serialize;
for my $item ($envelope->items->@*) {
say $item->type; # event or transaction
}
...
}
DESCRIPTION
An envelope: headers (event id, DSN, SDK, the dynamic sampling context of the trace) and items (Sentry::Envelope::Item). The client creates one per event, with the event or transaction and its attachments, and one per batch of logs or metrics, and passes it to the Sentry::Transport; Sentry::Transport::Http adds client reports itself. Sentry::Transport::Memory keeps the envelopes for tests.
ATTRIBUTES
headers
The envelope headers, a hash reference.
items
The Sentry::Envelope::Item objects, an array reference.
METHODS
parse
my $envelope = Sentry::Envelope->parse($bytes);
The envelope of the bytes made by "serialize", e.g. in the sender process (Sentry::Transport::SenderProcess). Payloads stay bytes and are sent as they are; only client reports are decoded. Dies on malformed input.
serialize
my $bytes = $envelope->serialize;
The envelope in the format of Sentry's envelope endpoint, with sent_at set to now: the headers as a JSON line, followed by each item: its header line and its payload.
INTERNAL METHODS
Used by the SDK; not part of the public API, may change without notice.
for_event
my $envelope = Sentry::Envelope->for_event(\%event, $dsn,
\%sampling_context, @attachment_items);
The envelope of an event, transaction or feedback, with further items of it (attachments).
for_items
my $envelope = Sentry::Envelope->for_items($dsn, \%sdk, @items);
An envelope of other items than events, e.g. sessions or check-ins.
has_event
Whether the envelope carries an event (an error or message), which is sent before others when not all may be sent in time.
add_item, remove_items
$envelope->add_item($item);
my @removed = $envelope->remove_items(sub ($item) { ... });
Add an item (returning the envelope), and remove the items the callback returns true for (returning them), e.g. those of rate-limited categories.