Changes for version 2.0.0 - 2026-12-04
- Upgrading from 1.x: read the migration guide first, MIGRATION.md in the distribution or https://github.com/heiseonline/perl-sentry-sdk/blob/master/MIGRATION.md
- 2.0.0 reworks most of the SDK to follow Sentry's current protocol and the behavior of the official SDKs; each incompatible change below names its migration step. Perl 5.30 or newer is required (see Dependencies).
- Incompatible changes
- Sending
- All events, errors included, are sent as envelopes to the envelope endpoint (/api/<project>/envelope/) instead of the deprecated store endpoint. The SDK identifies itself as sentry.perl/<version> (client name and User-Agent). Migration: proxies or firewalls that only let /api/<project>/store/ pass must allow the envelope endpoint; self-hosted Sentry needs version 20.6.0 or newer.
- Envelopes are sent with HTTP::Tiny instead of Mojo::UserAgent, which waits for Sentry's response: at most 2 seconds for the request as a whole (new option http_timeout; name resolution is not limited). Only inside a running Mojo::IOLoop they are sent in the background with Mojo::UserAgent, at most 30 at a time; further events are dropped. Of the connections of requests sent at once, one is kept for the next request, until it was unused for 30 seconds. The first events of a process are sent right away until its loop has iterated, so that a process forked inside a running loop does not lose them. If Mojolicious lacks the API this relies on or sending fails there, the SDK warns once and sends everything with HTTP::Tiny. The Mojolicious plugin sends in the background from the first request of a worker on. Migration: none.
- Pending events are sent at a normal exit within the new option shutdown_timeout (default 2, as in sentry-python), which is also the default timeout of flush and close now; exits that skip END blocks (POSIX::_exit, exec) lose them. Timers and callbacks of the application do not run while the SDK sends at exit. A forked child never sends events of its parent. Migration: applications ending a process with POSIX::_exit or exec must call Sentry::SDK->flush first.
- Without sender process (see below), events captured during a request of a CGI script, CGI::Application or the Plack middleware are held back and sent once the client has the response: for CGI::Application when run() has printed the response and flushed STDOUT, at most transport_queue_size (new option, default 100, as in sentry-python) per request, further ones are dropped, and no request is started after http_timeout seconds (the rest follows with the next request). If run() dies, the events are sent before the exception leaves run(): a persistent process would otherwise keep them until its next request, or lose them when it is stopped. The error page then waits for sending, at most http_timeout in all: a request still running then is cut off and counted as lost in the client reports, envelopes not yet sent follow with the next request, flush or the exit. Migration: none.
- Processes serving many requests under Plack servers (except CGI; also Mojolicious and CGI::Application run as PSGI applications) and FastCGI loops hand their envelopes to a sender process of their own, like the background thread of sentry-python: neither the response nor the worker waits for Sentry. It costs some 20 to 30 MB resident per worker, partly shared libraries; mod_perl and the Mojolicious daemons keep sending after the response and in their event loop, background_sender => 1 makes them use it as well. Each process starts its sender (a new perl, detached, no zombie, also with CHLD ignored and under taint mode, named "sentry sender of <pid>") on its first event; it ends with its worker after sending what it got within shutdown_timeout; flush and the exit wait for it. It keeps one connection to Sentry, closed once unused for 30 seconds. At most transport_queue_size envelopes wait for it (queue_overflow); when Sentry is slow, errors go before transactions. A sender that dies loses what it got (network_error), the process sends what it did not get and, for 30 seconds until another one may start, what follows; one that cannot start leaves sending to the process as before. Scripts, CGI and Windows send as before. Migration: none; the new option background_sender => 0 turns it off.
- Both ways of sending take the same path to Sentry. Certificates are always verified, also with MOJO_INSECURE, against the new option ca_certs or IO::Socket::SSL's default CAs (SSL_CERT_FILE, SSL_CERT_DIR, OpenSSL's, Mozilla::CA; where that is only a directory, HTTP::Tiny also trusts a bundle file); MOJO_CA_FILE is no longer read. Redirects are never followed, also with MOJO_MAX_REDIRECTS, so that credentials and events cannot end up elsewhere. Proxies are taken from the new options http_proxy and https_proxy (as in sentry-python; an empty string means none), else from the environment of the DSN's scheme (https_proxy, http_proxy, all_proxy, no_proxy). In CGI requests, where clients can set HTTP_PROXY with a Proxy header, the proxy of a plain http DSN comes from CGI_HTTP_PROXY, as in HTTP::Tiny, and on Windows, whose environment ignores case, never from http_proxy. Before, Mojo::UserAgent ignored proxy variables. Only http:// proxies work; others are ignored with a warning. Migration: set ca_certs instead of MOJO_CA_FILE; set https_proxy => '' if a proxy of the environment must not be used for Sentry.
- Sentry::Transport::Http sends envelopes (send_envelope) instead of events (send); Sentry::Client->transport replaces the internal _transport. Migration: code that called the transport directly captures the event with Sentry::SDK->capture_event instead.
- Privacy and request data
- Request data no longer contains the process environment, cookies, client IP headers or credentials. env only holds SERVER_NAME and SERVER_PORT, as in sentry-python's WSGI integration; Mojolicious takes the port from the request's connection instead of the process environment, which belongs to no request, and sends no SERVER_NAME, as it only knows the Host header the client sent. Cookies, the Cookie header, client IP headers (also e.g. CF-Connecting-IPv6 or Fly-Client-IP, and REMOTE_ADDR) and the headers with which authenticating proxies pass on the user (e.g. X-Forwarded-User, X-Amzn-Oidc-Data, Remote-User, client certificates) are only sent with the new option send_default_pii. Authorization headers and any header, cookie, query or body parameter whose name looks like a password, secret, token, key, session, CSRF token, one-time code, signature or connection URL are always replaced by [Filtered], also inside the Cookie header (up to the next ";"), as is the session cookie of Mojolicious applications. Ambiguous names are matched word by word, so e.g. `author` or `session_count` are kept (see Sentry::DataScrubber for the list; the new option denylist adds names). URLs are sent without fragment, also those in the Referer, Origin, X-Original-URL, X-Rewrite-URL, X-Original-URI, X-Forwarded-Uri and X-Forwarded-Url headers; sensitive query parameters in them (separated by "&" or ";", CGI.pm's default) read [Filtered], unescaped, which Sentry's own scrubber keeps (it would drop a whole header holding %5BFiltered%5D). Migration: set send_default_pii => 1 if you need cookies, client IPs or the user of an authenticating proxy; read environment values you need into tags or contexts yourself.
- Request data of both framework plugins: the URL is sent without query string, the query parameters as query_string and the form parameters as data (limited by the new option max_request_body_size, default "medium" = 10 KB). The CGI::Application plugin also sends JSON bodies, decoded and filtered; other bodies (e.g. POSTDATA) are never sent. Request headers of all web integrations are named as in HTTP/1.1 (User-Agent, Content-Type), whatever case the client sent (lowercase under HTTP/2), instead of after their CGI variable (HTTP_USER_AGENT), as sentry-python names those of WSGI, so that Sentry shows and filters them as those of the other SDKs; Content-Type and Content-Length are included. CGI::Application requests are read when they begin, so that FastCGI loops restoring %ENV after a request do not empty them, and their cookies are taken from the Cookie header as sent, without CGI's URL decoding. Migration: before_send hooks reading the old fields or the CGI header names must be adapted.
- Transactions carry only the request data that describes the request: method, URL, query string and the headers Accept, Content-Length, Content-Type, Host, Referer, User-Agent and X-Request-ID. Errors still get all of it (body, cookies, all headers, env). Bodies are parsed only when an error needs them. Migration: before_send_transaction hooks reading other request fields must be adapted.
- Credentials (and, without send_default_pii, keys such as ip_address) are filtered in what the application sets on events too, as with sentry-python's EventScrubber: extra, user, the data of breadcrumbs and spans, and a request set on an event; keys named like headers (e.g. HTTP_COOKIE in a copy of %ENV) like those headers. 1.x sent them unfiltered, although the denylist read as if it covered every key. The new option event_scrubber replaces the scrubber (e.g. a Sentry::DataScrubber with another denylist) or, set to 0, turns this off. Migration: set event_scrubber => 0 (or pass a scrubber of your own) if data the application sets is filtered that must not be.
- The DBI integration records bind values only with the new option record_sql_params. Migration: set record_sql_params => 1 to keep the old behavior.
- Issue grouping
- Sentry groups errors by exception type, value and stack trace frames, so the following changes may open new issues for known errors.
- Stack trace frames follow Sentry's protocol: `filename` instead of `file_name`, relative to the new option project_root or, for library modules, to their library directory. `function` is the subroutine containing the line, not the one called there; code outside of subroutines has none. Frames of perl's library directories, local::lib and Carton (local/lib/perl5) are never in_app, also inside the project root. Migration: adapt before_send hooks and fingerprint rules reading frames.
- Frames of scripts have no module: code of package main, of .psgi files loaded by Plack (package Plack::Sandbox::<encoded path>), of scripts of ModPerl::Registry, ModPerl::PerlRun and their subclasses (ModPerl::ROOT::<handler class>::<encoded path>) and of CGI::Compile (Plack's CGI wrappers). Sentry groups frames of Perl by module where there is one, else by the file's base name, never by line: a module shared by all scripts merged their errors into one issue, one named after the path opened new issues in every deploy directory (scripts of the same base name in different directories still share issues of the same call path). Their functions name Plack::Sandbox, ModPerl::ROOT::<handler class> or CGI::Compile::ROOT instead of the path package. Frames of Mojolicious templates are named like the template (`x.html.ep` instead of `template "x.html.ep"`, also from a DATA section). Migration: none; errors of scripts open new issues once.
- Stack traces leave out the frames of eval blocks, which repeated the place of the eval (a second frame at the eval for every `eval { ... }`), as other languages show no frame for a try block. Frames of eval strings and require stay. Migration: none.
- Stack traces of exceptions raised with Carp's croak or confess end at the code calling them, without a frame inside Carp, as for die. Migration: none; such errors open new issues once.
- Files below project_root are application code (in_app). It defaults to the working directory at init, in Mojolicious applications to the application's home; MOJO_HOME is no longer read by the SDK itself. Migration: set project_root if the working directory is not the application's directory (e.g. a daemon that changes to /).
- String exceptions are reported with type `Error` instead of `Mojo::Exception`. Exception values no longer contain the trailing newline, the stack trace appended by Carp::confess or Devel::StackTrace, or the source context of a Mojo::Exception; objects are described by their message method if they have one. Exceptions that are unblessed references are reported with their reference type (e.g. HASH) and a dump limited to three levels, scrubbed like request data; nested objects are dumped as their class name only. Migration: adapt alerts and fingerprint rules matching type or value.
- max_value_length defaults to 8192 instead of 250 characters and applies to all strings of an event, ellipsis included: also exception values, breadcrumbs (SQL statements), spans, request data, contexts and extra data. Exception values are cut at 65,536 characters first, also with max_value_length 0. Migration: set max_value_length => 250 to keep the old grouping of long messages.
- Scopes
- Scopes follow Sentry's current model of three scopes in effect at any time: the global scope (process-wide data and the client), the isolation scope (one per request or job: user, tags, breadcrumbs, last_event_id, the trace of errors outside transactions) and the current scope (one per with_scope block: the active span). Events get the data of all three, in this order of precedence, and the breadcrumbs of all three, merged in timestamp order (breadcrumbs with a timestamp that is not a number, such as an RFC 3339 string, stay behind their predecessor of the same scope). set_tag(s), set_extra(s), set_context, set_user, set_level, add_breadcrumb and configure_scope work on the isolation scope; with_scope clones the current scope, with_isolation_scope both. Scopes are switched with Perl's local, so leaving a block restores them, also by an exception; there is no scope stack to push and pop anymore. Migration: code that read data from Sentry::Hub->get_current_scope reads it from Sentry::SDK->get_isolation_scope; inside with_scope, change the scope given to the callback to keep data in the block.
- Sentry::Hub is removed. Migration (1.x -> 2.0): Sentry::Hub->get_current_hub -> not needed, use Sentry::SDK Sentry::Hub->init(\%attributes) -> Sentry::SDK->init(\%options) $hub->client -> Sentry::SDK->get_client (never undef: Sentry::Client::NoOp before init and without DSN) $hub->bind_client($client) -> Sentry::SDK->get_global_scope ->set_client($client) $hub->get_current_scope, $hub->get_scope -> Sentry::SDK->get_current_scope, or get_isolation_scope for request-wide data $hub->configure_scope($cb) -> Sentry::SDK->configure_scope($cb) $hub->push_scope / pop_scope -> Sentry::SDK->with_scope($cb), or with_isolation_scope($cb) around a request or job $hub->with_scope($cb) -> Sentry::SDK->with_scope($cb) $hub->run($cb) -> call the code directly $hub->scopes, $hub->reset -> gone (no scope stack) $hub->capture_message/ capture_exception/capture_event -> Sentry::SDK->capture_* (or ->get_current_scope->capture_* to pass a hint) $hub->add_breadcrumb -> Sentry::SDK->add_breadcrumb $hub->start_transaction -> Sentry::SDK->start_transaction $hub->sample -> gone (start_transaction samples) Custom integrations: setup_once gets no hub getter, the attribute initialized is gone; integrations patch in install with $self->patch, whose wrappers get ($integration, $orig, @args), and $get_current_hub->()->add_breadcrumb becomes $integration->add_breadcrumb (see MIGRATION.md).
- Sentry::Hub::Scope is now Sentry::Scope. Its clone copies one level deep instead of deeply: values such as a single context or breadcrumb are shared with the original, as are the span and the client. clear_breadcrumbs also hides the breadcrumbs the global and isolation scope hold at that moment from events of the scope, so inside with_scope it removes everything the event would get. Migration: rename; copy nested values before changing them in a clone.
- Spans set with configure_scope land on the isolation scope, but the framework plugins set the request's transaction on the current scope, which takes precedence. Migration: set them with Sentry::SDK->get_current_scope->set_span.
- Scope->set_transaction_name renames the transaction of the scope's span (on the isolation scope in effect: of the current scope's, i.e. the request's), with source custom, which the framework plugins keep. Transactions are no longer named after a scope they do not belong to, e.g. after a name set before they were started. Migration: set the name once the transaction runs, or give it to start_transaction. Transaction->set_name takes a source, custom by default.
- Transactions are sent in the scopes they were started in, not in those in effect when they finish. Migration: none.
- init flushes and closes the previous client when called again. Migration: none.
- Framework plugins
- Mojolicious::Plugin::SentrySDK clones the isolation and the current scope for each request and keeps them for the whole dispatch cycle (hooks, bridges, rendering); it no longer carries a span of the process scopes into requests. Breadcrumbs and spans recorded outside of requests are not attached to events of requests. Exceptions are captured in the reply.exception helper, which covers rejected promises and explicit calls. Transactions are finished once the response has been written, or when the connection ends for requests that are never rendered; requests whose connection closed before the response was complete end as cancelled (not those of a proxy closing right after the last byte). WebSocket transactions end with the handshake. Callbacks of promises, timers and non-blocking user agent requests run in the scopes of their request (see the new Mojo::IOLoop integration); the new helper sentry->run_in_scope enters them for other callbacks. Migration: code that read breadcrumbs or scope data of the process scopes after a request must be adapted; workarounds that copied request data into callbacks can go. (#28)
- Mojolicious::Plugin::SentrySDK initializes the SDK when it is registered instead of in before_server_start, so commands, job queue workers and code run at startup report as well, also under Mojo::Server::CGI before Mojolicious 9.16. Without options it keeps a client the application initialized itself. Migration: applications whose commands must not report pass no dsn there.
- Mojolicious::Plugin::SentrySDK records a transaction for every request but those of static files, also for those that reach no action (404, exceptions in before_dispatch hooks), named after method and path (e.g. "GET /not-found"). Routed requests are named after method and route (e.g. "GET /users/:id") instead of the route alone, as sentry-javascript names those of Express, so that GET and POST of a route are told apart and all web integrations name requests alike (method and path for Plack, mod_perl and FastCGI). Migration: adapt searches, alerts, dashboards and ignore_transactions patterns that use the names; drop unwanted transactions with ignore_transactions or lower traces_sample_rate.
- CGI::Application::Plugin::Sentry initializes the SDK at the first request and again only when sentry_options or the SENTRY_* variables change, instead of in every cgiapp_init, and no longer resets the scopes. Without sentry_options it keeps a client the application initialized itself. Callbacks such as before_send are still taken from every request, so closures created per request keep working. Every request runs in clones of the isolation and the current scope: the plugin wraps CGI::Application::run in with_isolation_scope, which restores the scopes of the process however the request ends. Breadcrumbs recorded before the request are not attached to its events; what an application overriding run does around the inherited run happens in the scopes of the process. Exceptions ending run outside of run modes (e.g. in cgiapp_prerun) are captured as unhandled too and end the transaction with internal_error at once, not when the application object is destroyed. The plugin's callbacks are added to every application object, so they run ahead of cgiapp_prerun. The tags runtime and server_name and the breadcrumbs prerun and postrun are gone; server_name is sent as event attribute. Migration: adapt searches and alerts that use the tags.
- CGI::Application transactions are named after the application's class and run mode, like the Controller#action of other SDKs (e.g. "My::Article#show", source component; a run mode chosen with prerun_mode, e.g. a login page, names it), instead of method and run mode ("GET show"): run modes of the same name in different applications are no longer merged. A run mode the application lacks names it AUTOLOAD (<unknown> without one), also in the runmode tag, so that values of the run mode parameter make no names of their own; the context cgiapp has the requested_run_mode. Migration: adapt searches, alerts and dashboards that use the transaction names.
- CGI::Application: exceptions that error_mode answers with a redirect or a client error (status 3xx or 4xx, e.g. 404 for a "not found" exception) are no longer captured, and their transaction gets the status of the response: like sentry-python, only server errors count as failed requests. Those answered with 5xx, an error page of status 200 or headers of the application's own are captured as before. Migration: capture_exception in error_mode where such exceptions should still become issues.
- Applications that call Sentry::SDK->init and run CGI::Application subclasses without the plugin now send their transactions and exceptions (see Sentry::Integration::CGIApplication below). Migration: lower traces_sample_rate if the transactions are unwanted.
- Integrations and tracing
- Span operations and data follow Sentry's conventions, so Sentry's Queries and Requests views work: `db` instead of `sql.query`, with the data sentry-python 3 sends (db.system.name, db.driver.name, db.namespace, db.query.text, server.address, server.port; not the deprecated db.system, db.name, db.operation, which Sentry renames); `http.client` for both HTTP clients (LWP used `http`), `template.render` instead of `mojo.template`, named after the template (`order.html.ep`; `<inline>` for inline templates, only the file name of absolute paths) instead of Mojo::Template's name (`template "order.html.ep" from DATA section`). HTTP spans and breadcrumbs carry url, http.query, http.request.method and http.response.status_code (a number), as in sentry-python: url and the span description ("GET https://example.com/") without query and credentials, whose sensitive values http.query has as [Filtered]; Sentry's own scrubber would otherwise filter the whole URL. Breadcrumbs of SQL statements have category `query` and the statement as message, those of HTTP requests category `http`. Migration: adapt dashboards, alerts and before_send hooks that match the old names.
- Integrations only record while the current client has them enabled; in particular nothing is recorded without a client. Migration: none.
- The DieHandler integration no longer turns string exceptions into Mojo::Exception objects. It records their stack trace instead and calls a previously installed $SIG{__DIE__} handler (not while that one runs, as perl does not). Migration: code that relied on $@ being a Mojo::Exception must handle strings.
- The LWP::UserAgent integration instruments simple_request instead of request, i.e. every request of a redirect chain gets its own span.
- The Mojo::UserAgent integration records non-blocking requests when the response arrives and adds their breadcrumb to the scope that was current when the request was started.
- Transactions no longer contain breadcrumbs, unfinished child spans and spans beyond max_spans (default 1000). Migration: finish spans before the transaction; raise max_spans if needed.
- Transactions no longer carry the tags __sentry_samplingMethod and __sentry_sampleRate; the values are available as sampling_method and sample_rate of the transaction. Migration: adapt searches and alerts using these tags.
- Without a DSN, start_transaction returns an unsampled transaction instead of undef.
- Services continue the trace of incoming requests (see "Distributed tracing" below) and follow the caller's sampling decision, also with traces_sample_rate 0: a sampled caller makes them send their transaction. Migration: leave traces_sample_rate unset to send no transactions at all.
- span_id, trace_id and parent_span_id of spans and transactions are Sentry::Tracing::SpanId/TraceId objects instead of strings. They stringify and compare with eq as before and serialize to hex strings via TO_JSON; events and sentry-trace headers contain plain strings. Migration: stringify them ("$id") before checking ref() or encoding them with a JSON encoder without convert_blessed.
- Capturing and hooks
- New option before_send_transaction for transactions. Without it, before_send still gets transactions as in 1.x; this is deprecated and will be removed in 3.0. Migration: move code handling transactions to before_send_transaction, which also keeps them from before_send.
- capture_message, capture_exception and capture_event return undef when the event was not sent (no DSN, sampled out, dropped by ignore_errors, before_send or an event processor, or an error inside the SDK). Migration: check the returned id for definedness before showing it.
- capture_message, capture_exception and capture_event never throw. Errors inside the client drop the event and are logged, those of before_send and before_send_transaction with the callback's name, those of event processors as such; a before_send returning undef is not logged as error.
- The capture context (second argument of capture_message, capture_exception and capture_event) supports exactly the keys contexts, extra, fingerprint, level, tags and user. Other keys are ignored with a debug warning instead of being mapped to set_<key>.
- with_scope rethrows exceptions of the callback instead of swallowing them (as Sentry::Hub->with_scope did), and returns the callback's result. Migration: callers relying on the silent behavior must catch exceptions themselves.
- Options and API
- Options are validated at init: invalid values are replaced by the default with a warning, single patterns become lists, unknown options are dropped with a warning (once per process; sentry-python raises an error). get_options of the client is public and returns an immutable Sentry::Options holding every option, defaults included: changing a value or reading an unknown name dies, so misspellings show. init no longer modifies the hash it is given, and capturing an event no longer adds the integrations to the options. Migration: fix values and names reported on STDERR; code that changed the hash of get_options passes the options to init instead; own transports taking options of their own get them from their constructor (transport => My::Transport->new(...)) instead of from_options.
- Integration constructors die on unknown arguments, which were ignored: only attributes count, methods like name or setup do not. Integrations get a per-client hook, setup($client), called at every init after the once-per-process setup_once, and may explain a missing DSN (missing_dsn_hint). Migration: fix the arguments reported; own integrations taking arguments of their own add them in a class method arguments (see Sentry::Integration::Base).
- Sentry::Client->from_config and Sentry::Client->scope are gone; they were unused.
- Scope->add_breadcrumb no longer modifies the given hash and returns the scope. Migration: read the breadcrumb from the scope if you relied on the added timestamp.
- Sentry::Util::around and restore_original are gone (internal).
- Sentry::Tracing::Span->request and Sentry::Tracing::Transaction-> context are gone: only a transaction's request was ever sent, and context was unused. Migration: set request data on the transaction (Transaction->request) or the scope.
- SDK objects are no longer Mojo::Base objects but hash-based objects of the internal Sentry::Base: Mojo::Base methods such as tap or with_roles are gone. Migration: subclasses of SDK classes (e.g. own integrations or transports) inherit with `use parent` or still with `use Mojo::Base "Sentry::...", -signatures` if the application has Mojolicious.
- Logging
- Debug output is controlled by SENTRY_DEBUG (or the debug option) only. The generic DEBUG variable is ignored. SENTRY_DEBUG=1 enables all contexts, otherwise it is a comma separated list of context names with `*` as wildcard (previously regexes, which could make logging die). Debug output goes to STDERR instead of STDOUT. Migration: replace DEBUG=<regex> with SENTRY_DEBUG=<contexts>.
- Warnings and errors of the SDK (e.g. Sentry unreachable, a failing integration) are always printed to STDERR, not only in debug mode. The same message is printed at most once per minute, unless debug output is enabled. Migration: none; redirect STDERR if needed.
- init warns about DSNs with http://: events, request data and source code would travel unencrypted. Hosts given as IP address of a loopback, private or link-local network (10/8, 172.16/12, 192.168/16, 169.254/16, fc00::/7, fe80::/10, also with zone id or as IPv4-mapped IPv6 address) and localhost are exempt, as relays there are local. Migration: use an https DSN.
- init without a DSN warns in CGI, FastCGI and mod_perl requests (once per process) and says so with debug output otherwise. Migration: none; dsn => '' turns the SDK off silently.
- New features
- Options
- send_default_pii, denylist, event_scrubber, max_request_body_size and record_sql_params (see above). send_default_pii defaults to SENTRY_SEND_DEFAULT_PII (true/t/yes/y/on/1 or false/f/no/n/off/0, as sentry-python reads flags; init ignores other values with a warning), so one application of a host can send personal data without a code change.
- before_send_transaction, before_breadcrumb, ignore_errors (class names or message regexes), ignore_transactions and sample_rate (for errors and messages).
- max_breadcrumbs (default 100, SENTRY_MAX_BREADCRUMBS; #22), max_spans, server_name, normalize_depth and normalize_max_breadth.
- project_root, ca_certs, http_proxy, https_proxy, http_timeout, shutdown_timeout, transport_queue_size and background_sender (see above).
- attach_stacktrace: messages carry the stack trace of the place they were captured at, and Sentry groups them by it instead of their text. Off by default, as in the official SDKs.
- include_source_context (default on; 0 sends no source code).
- trace_propagation_targets: hosts, URL prefixes or regexes the URL of an outgoing request must match to get the sentry-trace and baggage headers (default: all, third-party hosts included); a single pattern needs no array reference. Unlike in sentry-python and sentry-javascript, strings are no substrings, which would match foreign URLs containing them.
- in_app_include and in_app_exclude (module name prefixes).
- The documented option default_integrations is honored. (#34, #31)
- disabled_integrations (class names or instances) turns single integrations off, default ones included, as in sentry-python. A class that is neither an integration of the SDK nor one of the option integrations is reported with a warning (once per process).
- org_id and strict_trace_continuation decide whether traces of other Sentry organizations are continued (see "Distributed tracing").
- API
- Sentry::SDK->continue_trace(\%headers, $cb) continues a trace in a unit of work of its own, e.g. a message of a job queue; get_traceparent and get_baggage return the header values that continue the current trace, e.g. for meta tags of a browser SDK.
- Sentry::SDK->start_span({ op => ..., name => ... }) starts a child of the active span, or a transaction if none is active, like sentry-python's start_span. It takes a hash reference, as start_transaction and start_child do.
- Sentry::SDK functions set_tag, set_tags, set_extra, set_extras, set_context, set_user, set_level, with_scope, with_isolation_scope, get_global_scope, get_isolation_scope, get_current_scope, get_client, get_current_span and last_event_id.
- Sentry::SDK->set_transaction_name($name, $source) renames the transaction of the request (or job) and names its errors. Unlike sentry_sdk.set_transaction_name of Python, it sets the name on the isolation scope, as the other Sentry::SDK setters do.
- The option transport takes a Sentry::Transport class name or instance; transports deliver envelopes (send_envelope) and record what was discarded (record_lost_event). Sentry::Transport::Memory keeps the envelopes, e.g. for tests of applications; like Sentry::Test, its events are errors and messages, its transactions the transactions, and it has logs, metrics, feedback and the attachments of an event. With a transport given, events are captured also without DSN. init creates the transport (from_options of a class name): one that cannot be created leaves the SDK off with a warning instead of losing every event later. Connections and the sender process are still made on the first event, after a server forked its workers.
- Sentry::SDK->flush($timeout) waits for events sent in the background, Sentry::SDK->close($timeout) additionally disables the client. Both are available on Sentry::Client as well.
- Sentry::SDK::Auto initializes the SDK from the SENTRY_* environment variables when loaded: `perl -MSentry::SDK::Auto script.pl`, or PERL5OPT=-MSentry::SDK::Auto, reports the uncaught exceptions of scripts without a code change.
- Sentry::Scope->use_scopes($isolation, $current, $cb) puts given scopes in effect for the duration of $cb, and Sentry::Scope->bind_scopes($cb) returns a callback that runs in the scopes in effect now, e.g. for callbacks of non-blocking operations. Mojolicious helper sentry->run_in_scope($cb).
- Feature flags: Sentry::SDK->add_feature_flag($flag, $result) records a flag evaluation like sentry-python's add_feature_flag, so that Sentry shows which flags were on when an error happened. The isolation scope keeps the 100 flags evaluated last (an evaluated flag becomes the most recent), clones of a scope copy them, and errors and messages carry those of all scopes as flags context. The active span gets the data flag.evaluation.<flag> for the first 10 flags (Sentry::Tracing::Span->set_flag). Results are booleans by Perl's truth, as Sentry knows boolean flags only.
- Scope->clear resets the scope; error processors registered with add_error_processor are applied to events with an exception.
- Sentry::DataScrubber is documented, with is_sensitive and json_body.
- CGI::Application plugin: the hint of events captured during a request contains the application object as `cgiapp`, so before_send needs no closure over it.
- Sentry::Test captures what an application sends, for its tests: Sentry::Test->start, then events, transactions, logs, metrics, feedback, attachments($event), last_event, envelopes, discarded_events, clear and Sentry::Test->stop. It captures however and whenever the application initializes the SDK (before or after start, through a plugin, in a hook when a server starts), also without DSN; nothing is sent, nothing in the background.
- Release health and crons
- Release health (#11): with a release, the SDK sends sessions like sentry-python (option auto_session_tracking, default on). Each web request is a session, counted per minute and sent as aggregates; scripts and workers have one session per run, crashed by an uncaught exception. Sentry::SDK->start_session and end_session. Mojolicious applications count as web applications from the plugin on: their commands (hypnotoad deploys and stops, routes, job workers) send none.
- Cron monitoring: Sentry::SDK->capture_check_in and monitor($slug, $cb, \%monitor_config) check in a job like sentry-python's capture_checkin and monitor, with monitor upsert (crontab or interval schedule, checkin_margin, max_runtime, timezone etc.).
- Events and tracing
- Every event carries the runtime and os contexts and server_name.
- sdk.integrations lists only the integrations that instrument something in the process (e.g. DBI once DBI is loaded), as in the official SDKs. Integrations of other classes call the new Sentry::Integration::Base method activate when they do. sdk.packages names the SDK's CPAN distribution.
- Errors outside of transactions (and all errors while tracing is disabled) get the trace context of their scope, so errors of the same request are linked. Copies of a scope stay in its trace; Scope->set_new_propagation_context starts a new one, and every request of the web integrations has its own or continues the caller's. Forked processes (e.g. prefork workers of Mojolicious, Starman or Apache) start a trace of their own for errors outside of requests instead of joining the trace of their parent and siblings; a trace the parent continued (SENTRY_TRACE) goes on in the child.
- Events and transactions of web requests carry the tag request_id if the request has an X-Request-ID header, so that they can be matched with the logs of proxies and the application. CGI::Application requests also get the tag cgiapp.class.
- Transactions of the framework plugins carry how their name was made (transaction_info.source: route for Mojolicious routes, url for paths, component for CGI::Application run modes), so that Sentry groups and sanitizes them correctly. Transactions named after the path of the request (source url: the Plack middleware, mod_perl, FastCGI, unrouted Mojolicious requests) have ids and tokens in the path replaced by "*" (numbers, UUIDs, hexadecimal ids, long random tokens; slugs and file extensions stay), so that they neither carry secrets nor create a name per user or document.
- Distributed tracing: a Perl service called by another service continues its trace, so that Sentry shows one trace with the caller's http.client span as parent of the callee's transaction. The framework and server integrations (Mojolicious, Plack, CGI::Application, mod_perl, FastCGI) read the sentry-trace and baggage headers, a process started with SENTRY_TRACE and SENTRY_BAGGAGE continues their trace. Transactions follow the caller's sampling decision; without one, all services of a trace decide with the same random number (sample_rand). LWP::UserAgent and Mojo::UserAgent send the baggage header with the dynamic sampling context, merged into a baggage header of the application, and propagate the trace also without active span or with tracing disabled. Malformed headers are ignored; incoming baggage is parsed in linear time and limited to its first 8192 bytes and 180 members (the W3C limits); sentry-trace, baggage and X-Request-ID headers repeated with names differing in case only (or as CGI variable and header) are read in the order of their names.
- The option functions_to_trace records spans for the given functions (qualified_name, optionally op and description), also of modules loaded after init, like sentry-python's. Code references taken before init and packages defined later in files of another name are not traced: call init early.
- The option traces_sampler decides the sample rate per transaction, with the sampling context of sentry-python (transaction_context, parent_sampled, what start_transaction got) and the method, URL and headers of web requests; it takes precedence over the caller's decision and traces_sample_rate, and enables tracing on its own.
- Spans and transactions carry their origin: manual for the application's, auto.<category>.<name> for those of integrations (e.g. auto.db.dbi, auto.http.mojolicious), so that Sentry tells them apart. A framework adopting the request of a server integration names itself (e.g. auto.http.cgi_application under FastCGI or mod_perl), as sentry-python's Django integration under its WSGI middleware.
- Envelopes carry the dynamic sampling context (trace header) of the trace an event belongs to, as Sentry's dynamic sampling needs it: the one the trace came with, else made once from the transaction (without names made from URLs) and frozen, the same for errors and transactions of the trace.
- Attachments: Scope->add_attachment({ path | bytes, filename, content_type, attachment_type }) and clear_attachments; sent with the error, message and feedback events of the scope (not transactions), read when sent, in before_send's hint as `attachments`; larger than the new option max_attachment_size (default 20 MiB) or unreadable, they are left out with a warning.
- User feedback: Sentry::SDK->capture_feedback({ message, name, email, url, associated_event_id }) sends a feedback event (envelope item feedback), filtered by the new option before_send_feedback instead of before_send and never sampled.
- Logs and metrics
- Structured logs: Sentry::SDK->logger->info('Order %s', [$id], \%attributes) etc. (trace to fatal), sent in batches of up to 100 with trace and span id and the default attributes of the protocol; new option before_send_log. With the new option enable_logs (off by default) the Mojo::Log and Log4perl integrations send what the application logs from their new attribute logs_level (default info) on. A batch is sent when it is full, 5 seconds after its first log (with the next one), when a request ends, at flush and at exit.
- Metrics: Sentry::SDK->metrics->count, gauge and distribution, the trace-connected metrics of sentry-python (envelope item trace_metric), sent in batches of up to 1000 like logs; new option before_send_metric.
- The manager of a preforking server serves no requests, but sends its logs and metrics while it runs once they are due, instead of only at exit, and closes its connection to Sentry before it forks workers, so that no worker inherits it: the Mojolicious plugin under prefork and hypnotoad, while the manager waits for the heartbeats of its workers; Sentry::Integration::NetServer for preforking Net::Server servers (see below). For other such loops, Sentry::Client->send_due sends what is due and Sentry::Client->disconnect closes the connection.
- Exceptions
- Stack traces of exceptions carrying a Devel::StackTrace are reported: Exception::Class (trace), Throwable with StackTrace::Auto (stack_trace) and others.
- Causes of an exception (cause, previous or previous_exception) are reported as chained exceptions, up to five.
- Exceptions carry a mechanism, by default `generic` and handled. The hint of Sentry::Scope->capture_exception accepts `mechanism => { type => ..., handled => 0 }`. The framework plugins capture exceptions as unhandled with the types auto.http.mojolicious and auto.http.cgi_application, following Sentry's naming.
- An exception no eval catches, which ends the program (e.g. of a CGI or cron script, a Mojolicious server failing to start, also a script failing to compile), is captured as unhandled (mechanism auto.perl.uncaught_exception, level error, like sentry-python's excepthook integration) and sent before the process exits; the exit status stays as without the SDK. An exception captured before and rethrown, by the application or a framework integration, is not reported again. Turned off with `integrations => [Sentry::Integration::DieHandler->new(capture_uncaught => 0)]`. The value is the message without the `[<time>] <script>: ` stamp CGI::Carp puts in front of each line, which would make every event a title of its own; the server's error log still gets it.
- Frames of exceptions carry the values of the variables in scope where the exception was thrown (new option include_local_variables, on by default like in sentry-python). They are taken by the die handler and copied at once; limited to 5 frames, application code first, small values and 50 stacks per second, as this runs at every die. Scrubbed like the other event data: variables named like credentials are filtered, others (e.g. $email) are sent as they are, also without send_default_pii, as in sentry-python; include_local_variables => 0 turns it off. Messages with attach_stacktrace and exceptions without a known throw carry those of the place they were captured at, as in sentry-python. Objects among them are their own stringification ("" overload) or Class=HASH(0x...); no other overload runs, so a DBIx::Class result set in scope is not counted in the database at every die.
- Sending
- Rate limits are honored per category as X-Sentry-Rate-Limits says, also on successful responses, e.g. a limit on transactions does not stop errors; Retry-After of a 429 response is read as seconds or HTTP-date. As in the official SDKs, failed requests are not retried and server errors do not suspend sending. Only after repeated network errors of requests the application waits for (HTTP::Tiny), events are dropped for a while (2 seconds, doubling up to 5 minutes), so that an unreachable Sentry does not slow down every request. Requests in the background of Mojo::IOLoop never suspend sending: a timeout there may only mean that the application blocked the loop. Neither do requests cut short by the timeout of flush. A forked child keeps the rate limits and suspension of its parent instead of sending into them again.
- Client reports: Sentry learns how many events, transactions and spans the SDK dropped and why (sample_rate, before_send, event_processor for ignore_errors/ignore_transactions and event processors, callback_error, ratelimit_backoff, network_error, queue_overflow, send_error, buffer_overflow for spans beyond max_spans, internal_sdk_error). They travel with the next envelope at most every 30 seconds and on their own on flush and close, as in sentry-python. New option send_client_reports (default on).
- Envelopes of 30 KB or more are sent gzip-compressed, as in sentry-ruby (new option transport_compression_level, default 6; 0 sends them uncompressed).
- Backpressure handling, as in sentry-python (new option enable_backpressure_handling, default on): while Sentry rate-limits transactions or spans (unlike sentry-python, a limit of only other categories such as logs does not count), sending is suspended after network errors, or envelopes pile up (the sender process's queue or socket is full, Mojo::IOLoop has 30 requests pending), transactions are sampled less. Without a thread, the transport's health is checked when a transaction starts, with the first one and then at most every 10 seconds; each negative check halves the sample rate once more (down to 1/1024), the first positive one restores it. The sender process tells its worker until when it drops envelopes whenever that changes, so no message travels per transaction. Transactions only backpressure dropped are counted as backpressure in the client reports. Custom transports report their health with is_healthy.
- A transaction that does not follow the incoming sampling decision (traces_sampler, or a sentry-trace header without decision) puts the rate it was sampled with into the trace's incoming dynamic sampling context, as in sentry-python, so that Sentry extrapolates with it.
- Documentation
- Every module has POD. Spans, transactions and their status values, Sentry::Severity, Sentry::Client, Sentry::DSN and the envelopes a custom transport gets are documented; the other modules are marked as internal, i.e. they may change without notice.
- Sentry::SDK documents every option (also dist and SENTRY_TRACES_SAMPLE_RATE) by topic, the integrations, and what before_send_transaction gets and returns.
- Sentry::SDK::Manual: setup for scripts, CGI, CGI::Application, FastCGI, mod_perl, Plack and Mojolicious; recipes for capturing, scopes, tracing, filtering, privacy, sending, testing and troubleshooting; what each integration records and masks, with examples; release health, cron monitoring and local variables; commands under FastCGI (STDIN) and backticks in Mojolicious::Lite.
- CGI::Application::Plugin::Sentry is documented. Mojolicious::Plugin::SentrySDK documents deployment with the preforking servers (which stops let workers send their pending events, systemd) and behind a reverse proxy.
- MIGRATION.md: every incompatible change of 2.0 with before/after code, and what 2.0 sends by default that 1.x did not (sessions, local variables, the spans of the new integrations), the readpipe override and the trace passed on to commands.
- The GitHub README lists every integration, release health, crons, logs, metrics, user feedback, attachments and local variables, and tests with Sentry::Test.
- Integrations
- General
- Integrations are configured by passing an instance to `integrations`, which replaces the default instance of the same class, e.g. `integrations => [Sentry::Integration::DBI->new(breadcrumbs => 0)]`.
- Integrations instrument modules loaded after init as well, and never load modules or die when a module is not installed. An integration whose module lacks what it relies on (e.g. internals of Mojolicious used by MojoIOLoop) warns once and disables itself, and the application runs as without it.
- Instrumented calls no longer reset $@ (code checking $@ of an earlier eval after such a call found it empty) and leave $! and $? as the call set them; the original code sees $! and $? as the application left them. Their arguments are aliased as without the SDK, so functions assigning to them (e.g. IPC::Open3's handles) keep working. Spans of calls that die end with status internal_error; a failing integration does not break the call. The SDK's own requests to Sentry, and calls during global destruction, are never recorded.
- Wrapped calls (e.g. CGI::Application::run) no longer change where carp and croak report an error: the SDK's frames are hidden from Carp, so messages name the application's code, as without the SDK, also where a module calls a wrapped method of its own (e.g. Redis' commands calling its dispatcher) or a subclass calls an inherited one. Errors and warnings of C code the SDK wraps (DBI's RaiseError and PrintError, also of statements, and FCGI) name the application's statement again, e.g. "DBD::SQLite::db do failed: ... at script.pl line 12.", instead of the SDK's (1.x named the DBI integration).
- Without send_default_pii, the parts of cache keys, Redis keys and remote paths that look like ids or tokens become "*" in spans and breadcrumbs: session stores key by the session id, a credential like the filtered session cookie.
- Web frameworks and servers
- Plack::Middleware::SentrySDK: a transaction per PSGI request, its own scopes, exceptions captured as unhandled (auto.http.plack), and events sent after the server has written the response (in its psgix.cleanup phase, else when it closes the body, adding Content-Length to responses of known length so that the client need not wait for that: without it, it sees the end of the response (last chunk, closed connection) only after the body is closed; if the application dies on a server without psgix.cleanup, before the exception is rethrown). String exceptions keep the stack of their die also under Plack::Middleware::StackTrace (plackup's development default), whose die handler would hide the SDK's. Frameworks inside (Mojolicious, CGI::Application) adopt the request; a second SentrySDK middleware inside passes it through. A delayed response (Twiggy, Feersum and other servers of event loops) runs in the scopes of its request, as do the callbacks it sets up there. Plack is only required by the optional feature plack.
- Sentry::Integration::FCGI (default): every request a FastCGI loop accepts (FCGI, CGI::Fast) gets its own scopes and a transaction (named after method and path, ending with the HTTP status of the CGI header the application prints: its Status header, 302 for a redirect to another site, else 200); events are sent once the request is finished, when the client has the response. CGI::Application applications in the loop adopt the request and give it their name. So is the request in which the SDK is initialized (e.g. by CGI::Application::Plugin::Sentry in the first request of a process), if %ENV is its environment and it prints to STDOUT as CGI::Fast does; otherwise it gets scopes of its own, which are undone before the next request. A request whose object the loop drops without Finish is ended in the object's DESTROY. A child process forked during a request leaves the request to the parent, also when it calls Finish or Accept on its copy of the request object.
- Sentry::Integration::CGI (default): a CGI script's process is one request from init on: its events get the request data of the CGI environment (read at init), it gets a transaction (named after method and path, ending at exit with the HTTP status of the CGI header the script prints, read by a PerlIO layer on STDOUT that passes the output on unchanged; internal_error if it dies), and events are sent at exit within http_timeout. CGI::Application, Plack::Handler::CGI with the middleware and FCGI loops run as CGI adopt the request.
- Sentry::Integration::ModPerl (default): under mod_perl 2, every request of the server gets its own scopes and a transaction (named after method and path, ending with its HTTP status, cancelled if the client went away), whatever handles it: ModPerl::Registry and PerlRun scripts or handlers of any kind, not Apache's internal dummy connections (OPTIONS *); also the request the SDK is initialized in (e.g. by a ModPerl::Registry script), if mod_perl tells it (GlobalRequest). Sentry::SDK->init in the startup file is all it takes, also for virtual hosts sharing the main interpreter; virtual hosts with an interpreter of their own (PerlOptions +Parent) initialize in a <Perl> section or name the handler (PerlPostReadRequestHandler Sentry::Integration::ModPerl); where the SDK cannot tell which servers an initialization serves, it registers nothing and warns instead of breaking foreign servers. Errors a handler died with are captured, also behind internal redirects; events are sent in a cleanup of the request's pool after the response, next to the PerlCleanupHandlers of the configuration. CGI::Application applications adopt the request instead of starting a second transaction; events keep the request data of the server (URL and headers as the client sent them; CGI's %ENV is gone when the transaction ends) with the form body the application parsed. mod_perl hides the environment from Perl, so init warns once without a DSN; the examples pass SENTRY_DSN, SENTRY_RELEASE and SENTRY_ENVIRONMENT with PerlPassEnv. Prefork MPM only; it warns under threaded ones. Tested against Apache 2.4 with mod_perl 2.0.12 (Debian 12) in CI.
- Sentry::Integration::NetServer (default): the parent of a preforking Net::Server (Net::Server::PreFork, PreForkSimple, e.g. the master of Starman with the application preloaded) sends its logs and metrics from its loop once they are due (idle_loop_hook: Starman every second, Net::Server::PreFork every check_for_waiting seconds), not only at exit, and closes its connection before each fork (pre_fork_hook).
- Sentry::Integration::CGIApplication (default): every CGI::Application of the process gets a transaction per request and its exceptions captured as soon as Sentry::SDK->init has run, also applications that do not load CGI::Application::Plugin::Sentry (e.g. a mod_perl application initialized from its startup file). Exceptions in cgiapp_init and setup are captured, too. The plugin now only adds the initialization from sentry_options; loading it in several applications instruments them once.
- Databases and caches
- The DBI integration records do, select* and execute, also for drivers that implement select* in C.
- The DBI integration records connections made (connect, connect_cached on a miss, Apache::DBI) as span "connect" (op db), with db.system.name, db.namespace, server address and the user passed (db.user), never the password.
- DBI query spans carry the rows returned (db.response.returned_rows) and, for statement handles, the time spent fetching them (db.fetch.duration_ms), which the span of execute does not cover. Fetches of statements without span run DBI's own code alone.
- DBI statements on locks (GET_LOCK, RELEASE_LOCK, IS_FREE_LOCK and the like of MySQL, advisory locks of PostgreSQL, LOCK/UNLOCK TABLES) get the op db.lock, so that waiting for a lock stands out.
- Spans of database queries slower than db_query_source_threshold_ms (new option, default 100) name the application code that ran them (code.filepath, code.lineno, code.function, code.namespace), like sentry-python; enable_db_query_source => 0 (new option) disables it.
- Sentry::Integration::DBIxClass (default): the DBI spans of DBIx::Class statements name their result source (db.dbix_class.source) and table (db.collection.name), with the origin auto.db.dbix_class.
- Database transactions show where they begin and end, how long the commit or rollback took and whether it was rolled back: begin_work, commit and rollback of DBI, and turning AutoCommit off and on again (which commits), are spans BEGIN, COMMIT and ROLLBACK (op db, with db.operation.name) and breadcrumbs, like the transaction spans of sentry-python's Django integration and of sentry-java's JDBC integration, but on by default. A failing commit gets the status internal_error; a rollback is no error. No statement is added; storing other attributes costs some 0.2 microseconds more.
- DBIx::Class: txn_do is a span (op db.sql.transaction, named after the code if it is a named sub, else txn_do) around its BEGIN, statements and COMMIT or ROLLBACK, with the status internal_error if the code dies; the exception stays the application's, no event is sent for it. txn_begin and txn_scope_guard, which have no code to wrap, show their BEGIN and COMMIT or ROLLBACK. Savepoints of nested transactions are spans like SAVEPOINT savepoint_0, also where the storage sets them without SQL (DBD::Pg).
- Exceptions DBIx::Class throws from calls the SDK wraps, and carp and croak of wrapped Perl code (e.g. a failing DBI->connect) name the application's code again ("... at script.pl line 12"), not the SDK's.
- Sentry::Integration::MongoDB (default): commands of the official MongoDB driver as spans (op db) and breadcrumbs (category query), from its command monitoring, like sentry-python's PyMongo integration: the command as JSON, without send_default_pii with values as %s except collection and index names and options; with db.system.name, db.namespace, db.operation.name, db.collection.name, db.query.text and server address. Not the commands of the driver itself (handshake, heartbeats, authentication); commands of user management, which the driver redacts, by name only. Clients get a monitoring_callback, chaining the application's. Status ok or internal_error.
- Sentry::Integration::Elasticsearch (default): requests of Search::Elasticsearch to a node as spans (op db) and breadcrumbs (category elasticsearch), described by method and path (document ids as * without send_default_pii), never the body; with db.system.name, db.operation.name, the index as db.collection.name, server address and the response status (also of failed requests).
- Sentry::Integration::NetLDAP (default): bind, search, add, modify, delete, moddn, compare and start_tls of Net::LDAP as spans (op db.ldap) and breadcrumbs (category ldap), described by operation, DN and, for searches, scope and filter; never passwords or entry values, without send_default_pii also no filter values or RDN values naming entries; with the result code and the entries found, status ok or internal_error.
- Sentry::Integration::Redis (default): every command of Redis and Redis::Fast as span (op db.redis) and breadcrumb (category redis), like sentry-python: described by the command and its key, never values or AUTH credentials, with db.system.name, db.driver.name, db.operation.name, the database index as db.namespace, db.query.text and server.address and server.port. Commands with a callback (pipelining) get spans that end when their reply is read. With the option cache_prefixes, commands on matching keys also get a span for Sentry's Caches insight around it: cache.get (GET, MGET; cache.hit, cache.item_size), cache.put (SET, SETEX; cache.write, cache.item_size) and cache.remove (DEL, UNLINK; cache.write), with cache.key and network.peer.address/port.
- Sentry::Integration::CacheMemcached (default): operations of Cache::Memcached as spans for Sentry's Caches insight and breadcrumbs (category memcached): cache.get (get, get_multi; cache.hit, cache.item_size), cache.put (set, add, replace, append, prepend, incr, decr; cache.write, cache.item_size), cache.remove (delete, remove) and cache.flush (flush_all), described by the keys (also cache.key), never the values; with a single server also network.peer.address and network.peer.port.
- HTTP and network clients
- Sentry::Integration::HttpTiny (default): requests the application sends with HTTP::Tiny as span (op http.client) and breadcrumb, like LWP::UserAgent's; a redirect chain is one span, a request without response (status 599) has status internal_error. The trace headers go to each request of the chain matching trace_propagation_targets, in a copy of the options. The SDK's own requests are not recorded.
- Frames of Moose method modifiers are named after the method they wrap, e.g. My::Order::total (around), not Class::MOP::Class:::around.
- HTTP client spans (HTTP::Tiny, LWP::UserAgent, Mojo::UserAgent, AnyEvent::HTTP) record the size of the response body as http.response_content_length.
- Sentry::Integration::AnyEventHTTP (default): requests of AnyEvent::HTTP (http_request, http_get, http_post, http_head) as span (op http.client, with http.response_content_length) and breadcrumb, like HTTP::Tiny's; sentry-python's aiohttp client integration does the same. The span ends when the response arrives, the callback runs in the scopes of the request. A redirect chain is one span, a request without complete response (status 595 to 597, 599) has status internal_error, a cancelled one (guard dropped, on_header or on_body returning false) status cancelled. Trace headers as with HTTP::Tiny. Copies of http_request imported before init are instrumented, too.
- Sentry::Integration::GraphQLClient (default): requests of GraphQL::Client's execute, like sentry-python's gql integration. The http.client span and breadcrumb of the HTTP request get graphql.operation.type and graphql.operation.name, the span's description the operation after the URL ("POST <url> (query GetUser)"), as the JavaScript SDK's GraphQL client integration does; without operation name the operation is that of the query document, unknown if it has several. A response with errors (also those GraphQL::Client reports for the transport), returned, thrown (unpack) or in a Future, creates no event but a breadcrumb (category graphql); the events captured afterwards in the unit of work, e.g. the application's die after checking the errors, get the GraphQL request as request (api_target graphql), as sentry-python's gql integration adds it to the event of the error it raises. Only the last failed request is kept, until one succeeds or the unit of work ends. The document (also as graphql.document on the span), the variables and the error messages only with send_default_pii; without it, the parameters query and variables of GET requests are filtered from http.query.
- Sentry::Integration::SoapLite (default): calls of SOAP::Lite as span (op rpc, named after the method, with rpc.system soap, rpc.method and the endpoint without credentials), status internal_error on faults; the HTTP request is its child span.
- Sentry::Integration::NetAmazonS3 (default): every request of Net::Amazon::S3, classic API and Net::Amazon::S3::Client alike, as span (op http.client) named after the S3 operation (S3 GetObject, S3 PutObject, S3 CopyObject, ...) like sentry-python's boto3 integration, with aws.operation_name, aws.s3.bucket, aws.s3.key, aws.request.url and the HTTP status; the HTTP request is its child. Ids and tokens in keys become "*" without send_default_pii. Errors are handled by Net::Amazon::S3's error handler as before.
- Sentry::Integration::NetApnsSimple (default): every push notification Net::APNS::Simple sends as span (op http.client) and breadcrumb, from request to response, with its HTTP status and the reason APNs gives for a rejection (apns.reason). The device token is only part of the URL with send_default_pii, the payload never; no trace headers.
- Sentry::Integration::NetFTP (default): connecting with Net::FTP and its methods (login, cwd, ls, dir, get, put, delete, rename, mkdir, rmdir, ...) as spans (op ftp.client) and breadcrumbs (category ftp), described by the method and the remote path, with server.address and server.port; failures get status internal_error. Never credentials or the user; ids and tokens in paths become "*" without send_default_pii.
- Sentry::Integration::NetSMTP (default): connecting with Net::SMTP and its commands (hello, auth, mail, to, data, quit, ...) as spans (op smtp.client) with server.address and server.port, connecting and each message sent as breadcrumb (category smtp); rejected commands get status internal_error. Never the message or credentials; addresses only with send_default_pii. Covers MIME::Lite's SMTP too.
- Sentry::Integration::MIMELite (default): every message sent with MIME::Lite as span (op mail.send, named after the transport: smtp, sendmail, ...) with the SMTP commands as children, and breadcrumb (category mail); never the message, its addresses or the transport's arguments.
- Templates, files and images
- Sentry::Integration::TemplateToolkit (default): Template Toolkit rendering shows up in traces instead of as an unexplained gap, e.g. in CGI::Application applications using CGI::Application::Plugin::TT. Template->process (Template::Service) gets a span with op template.render, named after the template (or "<inline>" for template text and file handles, never their content), and the template files it renders in turn (INCLUDE, PROCESS, WRAPPER, PRE_PROCESS, POST_PROCESS) get child spans, which count against max_spans. BLOCKs get none, like partials elsewhere, so that a loop over 1000 rows does not use up max_spans; Sentry::Integration::TemplateToolkit->new(included_templates => 0) records Template->process only. Failing templates get status internal_error, also when a TRY catches the error; return values and errors of Template Toolkit are unchanged.
- Sentry::Integration::HTMLTemplate (default): HTML::Template (also CGI::Application's load_tmpl) gets spans named after the template file (or "<inline>"), template.parse for new(), which reads and parses it, and template.render for output(); rows of TMPL_LOOPs get none. Content and parameters are never recorded.
- Sentry::Integration::HTMLTemplatePro (default): output() of HTML::Template::Pro, which reads, parses and renders in C, as span template.render named after the template file (or "<inline>").
- Sentry::Integration::LibXSLT (default): XML::LibXSLT stylesheets as spans named after their file or document location (or "<inline>"), template.parse for parse_stylesheet(_file) and template.render for transform, transform_file and transform_into_chars. Documents and parameters are never recorded.
- Sentry::Integration::ArchiveZip (default): reading, writing, extracting and adding directory trees with Archive::Zip as spans (ops file.zip.read, file.zip.write, file.zip.extract, file.zip.add) named after the file, with file.size and file.zip.member_count; the path (file.path) only with send_default_pii. Status codes other than AZ_OK mark the span internal_error.
- Sentry::Integration::ImageMagick (default): Image::Magick (PerlMagick) as spans under the method name called, any alias: image.read (Read, Ping, BlobToImage), image.write (Write, ImageToBlob) and image.process (every Mogrify operation such as Resize, Crop or Composite, and Montage, Flatten, Layers and the like). Read and Write show the file names, masked like cache keys without send_default_pii; blobs and other arguments are never recorded. A returned error (Exception 400 and up) sets status internal_error. Graphics::Magick, the PerlMagick of GraphicsMagick, is recorded the same way (origin auto.image.graphics_magick), subclasses of either included: applications falling back from one to the other or adding methods in a subclass get the same spans.
- Logging, event loops and processes
- Sentry::Integration::MojoLog and Sentry::Integration::Log4perl (default): what the application logs with Mojo::Log (e.g. $app->log) or Log::Log4perl becomes breadcrumbs from info on, like sentry-python's logging integration (options level and event_level; Sentry::Integration::Logging->ignore_logger). As in sentry-python 3, no message becomes an event unless event_level is set (e.g. to error): errors reach Sentry as the exceptions the die handler and the framework integrations capture. Log4perl's logdie, logcroak, logconfess and error_die record a breadcrumb only, also with event_level, as the exception they throw is the event. Only what the logger writes counts, with the application's configuration as it is; the output is unchanged. A message carrying an exception ("Failed: $@", an exception object) is reported as that exception; one captured before, e.g. by the Mojolicious plugin, which Mojolicious logs as well, is no second event.
- Sentry::Integration::MojoIOLoop (default): callbacks of Mojo::Promise (then, catch, finally, await), Mojo::IOLoop timers (timer, recurring, next_tick) and non-blocking Mojo::UserAgent requests run in the scopes in effect when they were registered, so data set in them stays in their request and events get the request's data (#28). It also captures exceptions of callbacks the event loop runs (timers, requests, I/O watchers), which Mojo::IOLoop only warns about, as unhandled in the scopes of the callback (option capture_errors), and traces Mojo::IOLoop::Subprocess runs as spans with op "subprocess". Their child sends its events before it exits, which skips END blocks. Events captured in the child before its callback starts are dropped: with Mojolicious 8, the child's loop reset runs callbacks of the parent's pending requests ("Premature connection close"). As default integration it wraps Mojo::Promise, Mojo::IOLoop and Mojo::UserAgent methods and sends events for errors that were only warned about before. To turn it off, pass Sentry::Integration::MojoIOLoop->new(async_context => 0, capture_errors => 0) in the option integrations.
- Sentry::Integration::AnyEvent (default): callbacks of AnyEvent watchers (timer, io, idle, signal, child, also via AE::), condvars, AnyEvent::Handle reads and setters and DNS requests run in the scopes they were registered in, with any backend. While the loop waits, ended request sessions, logs and metrics go out once due, so a Twiggy server no longer keeps them until its next request. Twiggy ends on TERM without exit: give it a handler (see RELEASE HEALTH in Sentry::SDK).
- Sentry::Integration::Subprocess (default): commands run with backticks, qx// and readpipe, IPC::Open2/IPC::Open3 and IPC::Cmd's run as spans (op subprocess, with process.exit.code or process.pid) and breadcrumbs (category subprocess), like sentry-python's stdlib integration; credentials in the command line are filtered. The process gets the trace in SENTRY_TRACE and SENTRY_BAGGAGE. Backticks are recorded through an override of readpipe, installed when the SDK is loaded, which keeps warnings, errors, I/O layers, $? and $! as without it and calls an earlier override. system and exec are not recorded: an override of them breaks `system { $program } @args`.
- Fixes
- Security
- Strings with lone surrogates or code points beyond U+10FFFF (which Perl's lax UTF-8 decoding makes of client bytes such as %ED%A0%80) are encoded as U+FFFD: Cpanel::JSON::XS died on them and the whole event was dropped, so a client could keep its requests out of error monitoring; JSON::PP wrote invalid UTF-8.
- The response body of Sentry (or of whatever answers in its place) is dropped unread instead of parsed: Mojo::UserAgent asked for gzip and inflated the body to memory or disk, so a hostile endpoint or proxy could exhaust the application hosts.
- Breadcrumbs and spans of outgoing HTTP requests no longer contain credentials in the URL; sensitive query parameters (separated by "&" or ";") read [Filtered] in their http.query.
- Debug output of the transport no longer contains the sent events (personal data), only their ids and sizes.
- Source context is only read from Perl files and templates of up to 1 MB. File names of frames can be set by code (`#line`), so any readable file (e.g. /etc/passwd) could end up in an event. The source file cache is bounded to 10 MB.
- Exception messages can no longer make capturing take minutes: stripping an appended stack trace backtracked quadratically on crafted messages (e.g. containing user input).
- Span, trace and event ids come from /dev/urandom (rand() where it is missing, e.g. on Windows): ids derived from rand() revealed its state, so a sent id made the following ones predictable. Forked processes no longer repeat the ids and sampling decisions of their parent. An srand() of the application is kept. If /dev/urandom exists but cannot be read, a warning says so.
- Events that were lost
- Fixed set_extras, scalar fingerprints and the capture context keys `extra` and `contexts`, which silently dropped events.
- Fixed capturing unblessed references (`die { ... }`).
- Contexts, extra, user, request and breadcrumb data are normalized: reference cycles no longer hang the JSON encoder, objects without TO_JSON are sent as string, depth and breadth are limited. Globs (e.g. *STDERR as psgi.errors) are sent as string instead of failing the event; a hash a loop iterates over with `each` is left out, as listing its keys would restart the loop.
- An event processor returning undef drops the event instead of breaking the next processor.
- The DSN path prefix is now respected.
- FastCGI applications that initialize the SDK in a request (e.g. CGI::Application::Plugin::Sentry) read the SENTRY_* and proxy variables of the process, as it was when the SDK was loaded, instead of losing them: FCGI replaces %ENV with the request's parameters. Variables the web server passes with a request still take precedence, also empty ones. Migration: to turn a variable off at runtime, set it empty instead of deleting it from %ENV.
- Stability and resources
- Fixed memory leaks: every transaction (reference cycle) and, in the Mojolicious plugin, every controller.
- A failing SDK no longer changes the response of a Mojolicious app.
- Fixed both framework plugins crashing without a DSN.
- Fixed exceptions being swallowed while rendering Mojo templates.
- The Mojo::UserAgent integration always calls the caller's callback.
- Both framework plugins collect and scrub the request data (including decoding JSON bodies) only when an event or a sampled transaction needs it, instead of for every request (twice in the Mojolicious plugin).
- Stack traces and exceptions
- Stack traces no longer contain frames of the SDK (e.g. of the die handler integration), also not those of exception objects with a stack trace of their own: the SDK's frames are told by their file as well.
- The outermost frame of mod_perl's embedded interpreter (file -e) is no longer marked as application code; code of a `perl -e` one-liner still is.
- Exception objects without stack trace of their own (e.g. Template::Exception) and unblessed references get the stack of the place they were thrown, recorded by the die handler as for strings, instead of none (Sentry could not group them); without the die handler, the stack of the capture_exception call.
- A string exception thrown again with the same message from another place (e.g. `die "failed\n"` in two subroutines) is reported with its own stack trace instead of the one of the first throw. Rethrows keep the original stack trace, also from Try::Tiny catch blocks, from catch blocks of nested try blocks (Try::Tiny, Syntax::Keyword::Try) and from functions catch blocks call. Not yet those from the catch blocks of perl's own try/catch, which leave no trace in the stack.
- abs_path of frames is absolute also for files perl names relatively (a script started as `perl script.pl`, modules of `use lib 'lib'`): they are resolved against the working directory at the time the SDK was loaded, so that source context is found after a chdir, too.
- Source context of UTF-8 files is no longer garbled; undecodable bytes (e.g. Latin-1) are replaced by U+FFFD. (#33)
- Tracing
- Fixed the sentry-trace header for unsampled spans.
- No sentry-trace header without a DSN.
- Fixed span start timestamps defaulting to the module load time.
- Finishing a span or transaction again no longer moves its end or sends the transaction a second time.
- Errors captured while a child span is active keep the request data.
- CGI::Application plugin: transactions get the HTTP status of the response instead of always 200, and internal_error after an exception (see above for error_mode). Exceptions are captured as unhandled. Scope and transaction also end when the request dies. An exception error_mode rethrows (`die $error`) keeps the stack of the run mode it was thrown in.
- HTTP status 499 maps to the span status cancelled.
- LWP::UserAgent spans no longer contain stringified objects.
- Mojo templates rendered again from the renderer's cache (every render after the first of a process) get spans, and their exceptions the fixed stack frames; before, only the first render was recorded. Spans of templates that fail have status internal_error; Mojo::Template returns the exception instead of dying, which left the span without status.
- Envelopes no longer contain the made-up sample_rates item header.
- Other
- Events, transactions and spans leave out fields without a value (null, {} or []: e.g. dist, extra, tags, request cookies, trace context status), as sentry-python does.
- Event timestamps have sub-second precision.
- before_send can no longer change the breadcrumbs of the scope.
- Logger->enable works.
- Tag values are sent as strings, as Sentry's protocol requires, and truncated to 200 characters, beyond which Sentry drops them. Booleans and references to scalars become "true" or "false" instead of JSON booleans; tags set to undef are left out.
- Sentry::Client->capture_message without level sends level info; it sent none, as the caller's undef replaced the default.
- Dependencies
- Perl 5.30 or newer is required (was 5.24.1). Migration: stay with 1.x on older Perls.
- Mojolicious is no longer required, only recommended (8.0 or newer, as before) for the Mojolicious plugin and integrations, which are only active in applications that load it. Applications without Mojolicious no longer install it. Migration: none; Mojolicious applications bring it along.
- New requirements: HTTP::Tiny 0.076 or newer (the release of Perl 5.30; releases before 0.083 do not verify certificates by default, CVE-2023-31486, but the SDK always enables verification, so the HTTP::Tiny of Perl 5.30 to 5.36 needs no upgrade), IO::Socket::SSL 1.968 and Net::SSLeay 1.49 for https DSNs, JSON::PP (core), and PadWalker 2.0 for the variables of stack trace frames (include_local_variables; XS like Net::SSLeay, packaged by Debian and Ubuntu as libpadwalker-perl; should it fail to load, frames carry no variables). JSON is encoded with Cpanel::JSON::XS 3.0201 or newer if installed. Migration: none; cpanm installs them.
- No longer required: HTTP::Status (and with it HTTP-Message, URI, HTTP::Date, Encode::Locale, IO::HTML and LWP::MediaTypes), Try::Tiny (the SDK catches exceptions with a small internal module until perl's own try/catch is available to all supported perls), Clone, Readonly and UUID::Tiny (the scope copies itself, constants use the constant pragma and ids are made from /dev/urandom). The suggestions IO::Socket::Socks, Net::DNS::Native (only used by Mojo::UserAgent) and Role::Tiny (unused) are gone. Migration: applications that use one of them without declaring it add it to their own dependencies.
- Plack is the requirement of the new optional feature plack (the PSGI middleware).
- Tests: Perl::Critic, Test::Pod and Test::Pod::Coverage are only developer requirements, so installing the SDK no longer pulls in Perl::Critic, PPI and their dependencies; Devel::Cycle, PadWalker, Test::Exception and Test::Snapshot are no longer test requirements (the tests check that objects are freed with weak references and catch exceptions with eval). New test requirements are DBD::SQLite, Devel::StackTrace, Exception::Class, URI and Try::Tiny. List::Util needs no minimum version any more, the one of perl 5.30 has all the SDK uses.
- New test recommendations, whose tests are skipped without them: Mojolicious, AnyEvent and EV (the AnyEvent integration with the pure-Perl loop and with EV), Archive::Zip, Cache::Memcached, CGI::Application::Plugin::TT, CGI::Fast, CGI::PSGI, DBIx::Class, FCGI, Future::AsyncAwait (async subs resuming in their scopes), HTML::Template, HTML::Template::Pro, Image::Magick, Log::Log4perl, MIME::Lite, Net::Amazon::S3, Net::APNS::Simple, Net::LDAP, Plack, Redis, Redis::Fast, Search::Elasticsearch, SOAP::Lite, Starman (the middleware under a preforking server), Syntax::Keyword::Try (rethrows from its catch blocks), Template and XML::LibXSLT. The Redis and Cache::Memcached tests run against a fake server.
- For developers
- The distribution is built and released with Minilla instead of Dist::Milla, which needs a fraction of the dependencies.
- Perl::Tidy, Perl::Critic, PPI, App::perlimports and their test modules are pinned to exact versions, so that a new release of a tool cannot fail the style tests without a code change.
Modules
Sentry plugin for CGI::Application
Sentry plugin for Mojolicious
Sentry for PSGI applications
Internal: a response body that tells when it was written
A file sent along with error events
Internal: typed attributes of logs and metrics
Internal: base class and pragmas of the SDK's modules
Internal: a bounded cache for the life of the process
Internal: a check-in of a cron monitor
Turns captured data into events and hands them to the transport
Internal: items waiting to be sent in a batch
Internal: logs or metric values waiting to be sent
Internal: ended sessions waiting to be sent
Internal: samples fewer transactions while the transport is unhealthy
The client of an SDK that is not initialized
The parts of a Sentry DSN
Removes credentials and personal data from request data
The SDK's environment variables, also in FastCGI requests
The unit of data a transport sends to Sentry
One item of an envelope, e.g. an event
Internal: what Sentry needs to know about a thrown value
The feature flags evaluated in a scope
The operation of a GraphQL request
Internal: the integrations a client uses
Scopes of AnyEvent callbacks
Spans and breadcrumbs for AnyEvent::HTTP
Spans for Archive::Zip
Base class for integrations
The request of a CGI process
Internal: reads what a CGI script prints
Requests of every CGI::Application
Spans and breadcrumbs for Cache::Memcached
Internal: span data of cache and key-value store clients
Spans and breadcrumbs for DBI statements
Result sources and transactions of DBIx::Class
Stack traces and uncaught exceptions
Spans and breadcrumbs for Search::Elasticsearch requests
Requests of FastCGI processes
Spans for the functions of the option functions_to_trace
Operations and failed requests of GraphQL::Client
Spans for HTML::Template
Spans for HTML::Template::Pro
Spans and breadcrumbs for HTTP::Tiny
Spans for Image::Magick and Graphics::Magick
Spans for XML::LibXSLT
Breadcrumbs and events from Log::Log4perl
Base class of the logging integrations
Spans and breadcrumbs for LWP::UserAgent
Spans and breadcrumbs for MIME::Lite
Requests of a mod_perl 2 server
Scopes and errors of Mojo::IOLoop callbacks
Breadcrumbs and events from Mojo::Log
Spans for Mojo::Template
Spans and breadcrumbs for Mojo::UserAgent
Spans and breadcrumbs for MongoDB commands
Spans for Net::Amazon::S3
Internal: an error handler of Net::Amazon::S3 recording the response
Spans and breadcrumbs for Net::APNS::Simple
Internal: base of the integrations of libnet clients
Spans and breadcrumbs for Net::FTP
Spans and breadcrumbs for Net::LDAP operations
Spans and breadcrumbs for Net::SMTP
Sends what the parent of a preforking Net::Server buffered
Internal: install method wrappers once modules are loaded
Spans and breadcrumbs for Redis commands
Spans for SOAP::Lite calls
Spans and breadcrumbs for commands the application runs
Spans for Template Toolkit
Internal: JSON for the SDK's payloads
Internal: the SDK's diagnostic messages
Sends structured logs to Sentry
Sends metrics to Sentry
Internal: limits the data of events
The validated options of a client
Internal: the kind of process the SDK runs in
sentry.io integration
Initialize the SDK from the environment
Data attached to events, and the scopes in effect
Internal: a session of release health
The levels of events and breadcrumbs
Internal: the source lines around a frame of a stack trace
Internal: the lines before, at and after a line of a source file
Internal: the stack trace of an exception or message
Internal: one frame of a stack trace
Internal: the variables of the frames of a stack
Internal: application code or library
Internal: where recent exceptions were thrown
Captures what an application sends to Sentry, for its tests
Internal: the W3C baggage header
Internal: base class of trace and span ids
Internal: the trace of a unit of work
Matches URLs against trace_propagation_targets
Internal: how a transaction's sampling decision was made
A timed operation within a transaction
Internal: span id
The status values of spans and transactions
Internal: trace id
The root span of a unit of work, sent to Sentry with its spans
Base class of the transports sending envelopes to Sentry
Internal: suspends sending after repeated network errors
Internal: counts what the SDK dropped
Internal: proxy and certificates for the requests to Sentry
Internal: a timeout for a request as a whole
Sends envelopes to Sentry via HTTP
Keeps envelopes instead of sending them
Internal: envelopes held back until a request has ended
Internal: holds sending until released
Internal: the rate limits Sentry announced
Internal: an envelope ready to be posted
Internal: the response to an envelope
Internal: posts envelopes with HTTP::Tiny
Internal: posts envelopes in the background of Mojo::IOLoop
Internal: sends envelopes in a process of its own
Internal: messages to and from the sender process
Internal: the sender process
Internal: what the process knows about a Sentry server
Internal: catches exceptions without touching $@
Internal: the parts of a URL
Internal: helper functions of the SDK
Internal: the HTTP status of a CGI header
Internal: the request core of the web integrations
Internal: an adapter's part in a request
Internal: the request data of events
Internal: request data of an adopted request
Internal: request data of a CGI object
Internal: request data of a CGI environment
Internal: request data of a mod_perl request
Internal: request data of a Mojolicious request
Provides
in lib/Sentry/Integration/Log4perl.pm