UNPKG

1.69 kBJavaScriptView Raw
1/**
2 * The Sentry version that all Compas packages use if set via {@link compasWithSentry}.
3 *
4 * @type {undefined|import("@sentry/node")}
5 */
6export let _compasSentryExport = undefined;
7
8/**
9 * Enable Sentry support. This comes with the following changes:
10 *
11 * Stdlib:
12 * - Logger: both info and error logs are added as breadcrumbs to the current active span.
13 * - Event: Events are propagated to Sentry as (inactive) spans.
14 * Meaning that further logs are not necessarily correlated to the correct event.
15 * This can be inferred based on the timeline.
16 *
17 * Server:
18 * - Starts a new root span for each incoming request.
19 * - Tries to name it based on the finalized name of `ctx.event`.
20 * This is most likely in the format `router.foo.bar` for matched routes by the generated router.
21 * - Uses the sentry-trace header when provided.
22 * Note that if a custom list of `allowHeaders` is provided in the CORS options,
23 * 'sentry-trace' and 'baggage' should be allowed as well.
24 * - If the error handler retrieves an unknown or AppError.serverError, it is reported as an uncaught exception.
25 * It is advised to set 'maxDepth' to '0' in your Sentry config, and to enable the 'extraErrorDataIntegration' integration.
26 *
27 * Queue:
28 * - Starts a new root span for each handled Job
29 * - Names it based on the job name.
30 * - Reports unhandled errors as exceptions.
31 *
32 * All:
33 * - Each package that has error logs, will report an exception as well.
34 * - Note that we still execute the logs for now. Which may be removed in a future release.
35 *
36 * @param {import("@sentry/node")} instance
37 */
38export function compasWithSentry(instance) {
39 _compasSentryExport = instance;
40}