NAME

Sentry::Integration::MojoIOLoop - Scopes and errors of Mojo::IOLoop callbacks

DESCRIPTION

Enabled by default.

Callbacks of Mojo::Promise (then, catch, finally, await in async subs), of Mojo::IOLoop timers (timer, recurring, next_tick, as class or instance method) and of non-blocking Mojo::UserAgent requests run in the scopes that were in effect when they were registered (see "SCOPES" in Sentry::SDK), not in those of whatever runs the event loop when they are called. So data set in a callback stays in its request, and events captured there get the request's data. Other callbacks (e.g. of Mojo::EventEmitter events, or watchers registered with the reactor directly) can be bound with "bind_scopes" in Sentry::Scope.

Exceptions of callbacks the event loop runs (timers, callbacks of non-blocking requests, I/O watchers), which Mojo::IOLoop only warns about, are captured as unhandled with the mechanism auto.function.mojo_reactor, in the scopes the callback ran in. Exceptions of promise callbacks reject the promise and are not captured here. Errors nobody else subscribed to stay fatal (see "error" in Mojo::Reactor).

When the process exits with events still being sent in the background (e.g. a prefork worker stopped gracefully), the SDK runs the stopped loop until Sentry has answered (see "flush" in Sentry::SDK). The callbacks of timers and requests above (and with them those of promises, which settle through timers) do not run then: the application has ended. Events of streams and other event emitters still do.

Runs of Mojo::IOLoop::Subprocess are recorded as span (op subprocess) of the active span. The span ends when the parent callback gets the results. The child runs in clones of the scopes the subprocess was started in, and sends its events before it exits. Spans it starts are lost: their transaction lives in the parent. The child never sends events its parent held back or had pending. Events captured in the child before its callback starts are dropped: with Mojolicious before 9, resetting the loop in the child runs callbacks of the parent's pending requests there (with Premature connection close), errors that did not happen in the parent.

It relies on internals of Mojolicious (the private Mojo::IOLoop::Subprocess::_start, the error event of the reactor and, since Mojolicious 9, Mojo::Promise::AWAIT_ON_READY). If they are missing, it warns once and disables itself.

ATTRIBUTES

See "ATTRIBUTES" in Sentry::Integration::Base, and:

async_context

Carry the scopes into callbacks. Default: 1.

capture_errors

Capture exceptions of event loop callbacks. Default: 1.

METHODS

setup_once

Registers the event processor dropping events of subprocess children captured before their callback starts, and calls install. See "setup_once" in Sentry::Integration::Base.

install

See "install" in Sentry::Integration::Base.

incompatibility

See "incompatibility" in Sentry::Integration::Base.

SPAN ORIGIN

origin

The spans of this integration have the origin auto.function.mojo_ioloop (see "origin" in Sentry::Integration::Base).