Sentry
Kino builds on the @sentry/node SDK. Pass its options in sentry to turn it on:
import Kino from '@fca.gg/kino';
Kino.init({
sentry: {
dsn: process.env.SENTRY_DSN,
environment: 'production',
},
packages: ['knex', 'mysql2'],
ANR: true,
});
Without a sentry option, Kino does not initialize Sentry and only logs to the console.
Applied settings
Kino initializes Sentry with these values, which your sentry options override:
tracesSampleRate:0.1;maxBreadcrumbs:5;sendClientReports:false;- Sentry's default integrations are turned off, unless you pass
defaultIntegrations.
Instead, Kino turns on a selection of integrations: linked errors, console (levels error, warn, debug, trace), fetch and HTTP requests, context lines, child processes and the module list.
If you pass integrations yourself in sentry, your list replaces Kino's.
Options
packages: turns on the Sentry integrations of these libraries. Recognized values:'knex'and'mysql2'.ANR: detects event loop stalls (Application Not Responding) and reports them with the stack trace.autoCaptureUnhandledRejections: see below.
Unhandled errors
Two behaviors depending on autoCaptureUnhandledRejections:
falseor unset: Kino adds Sentry's integrations for unhandled exceptions and promise rejections. They behave like the default SDK.true: Kino does not add them, and listens tounhandledRejectionanduncaughtExceptionitself: every error goes throughKino.error(), so it is logged to the console and sent to Sentry when configured. Kino does not stop the process.
SDK access
Kino.Sentry returns the Sentry SDK, and Kino.withIsolationScope its function of the same name, to isolate the context of a request or an interaction:
Kino.withIsolationScope((scope) => {
scope.setTag('guild', interaction.guildId ?? 'dm');
// errors reported here carry the "guild" tag
});
The package re-exports Sentry's Scope type.