55 */
66export let _compasSentryExport = undefined ;
77
8+ /**
9+ * Send queries executed via `query` from @compas/store as a sentry span.
10+ *
11+ * @type {boolean }
12+ */
13+ export let _compasSentryEnableQuerySpans = false ;
14+
815/**
916 * Enable Sentry support. This comes with the following changes:
1017 *
1118 * Stdlib:
1219 * - Logger: both info and error logs are added as breadcrumbs to the current active span.
1320 * - Event: Events are propagated to Sentry as (inactive) spans.
1421 * Meaning that further logs are not necessarily correlated to the correct event.
15- * This can be inferred based on the timeline .
22+ * The final event callstack is not logged .
1623 *
1724 * Server:
1825 * - Starts a new root span for each incoming request.
@@ -22,19 +29,22 @@ export let _compasSentryExport = undefined;
2229 * Note that if a custom list of `allowHeaders` is provided in the CORS options,
2330 * 'sentry-trace' and 'baggage' should be allowed as well.
2431 * - 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.
32+ * It is advised to set 'normalizeDepth ' to '0' in your Sentry config, and to enable the 'extraErrorDataIntegration' integration.
2633 *
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 .
34+ * Store :
35+ * - Starts a new root span for each handled Job in the QueueWorker
36+ * The span name is based on the job name. Unhandled errors are captured as exceptions .
37+ * - Supports passing queries to Sentry as spans. Requires { @link opts.sendQueriesAsSpans} to be set .
3138 *
3239 * 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.
40+ * - All error logs in Compas package code are captured as exceptions.
3541 *
3642 * @param {import("@sentry/node") } instance
43+ * @param {{
44+ * sendQueriesAsSpans?: boolean
45+ * }} [opts]
3746 */
38- export function compasWithSentry ( instance ) {
47+ export function compasWithSentry ( instance , { sendQueriesAsSpans } = { } ) {
3948 _compasSentryExport = instance ;
49+ _compasSentryEnableQuerySpans = sendQueriesAsSpans ?? false ;
4050}
0 commit comments