Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(node): Always set up express, fastify, koa, hapi integrations#23473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
fe3a7f94c5fb709beccc21a715f8ce3a3015c6aafefd550a4feb3deef99b7607741e30d8d0ab1410aec15ec9fc26a8f86648af0461e7e1fcc642d5aee17f3dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // <reference lib="deno.ns" /> | ||
| import { channel } from 'node:diagnostics_channel'; | ||
| import type { DenoClient } from '@sentry/deno'; | ||
| import { init } from '@sentry/deno'; | ||
| import { assert } from 'https://deno.land/std@0.212.0/assert/assert.ts'; | ||
| import { assertEquals } from 'https://deno.land/std@0.212.0/assert/assert_equals.ts'; | ||
| import { assertExists } from 'https://deno.land/std@0.212.0/assert/assert_exists.ts'; | ||
| import { errorSink, resetGlobals, withTimeout } from '../../src/index.ts'; | ||
| Deno.test('fastify instrumentation: included in default integrations (Deno 2.8.0+)', () => { | ||
| resetGlobals(); | ||
| const client = init({ traceLifecycle: 'static', dsn: 'https://username@domain/123' }) as DenoClient; | ||
| const names = client.getOptions().integrations.map(i => i.name); | ||
| assert(names.includes('Fastify'), `Fastify should be in defaults, got ${names.join(', ')}`); | ||
| }); | ||
| Deno.test('fastify instrumentation: tracing:fastify.request.handler:error channel captures the error', async () => { | ||
| resetGlobals(); | ||
| const sink = errorSink(); | ||
| init({ | ||
| traceLifecycle: 'static', | ||
| dsn: 'https://username@domain/123', | ||
| beforeSend: sink.beforeSend, | ||
| }); | ||
| const error = new Error('fastify boom'); | ||
| // Fastify v5 publishes this native diagnostics channel when a request handler errors; the | ||
| // integration subscribes to it directly (no orchestrion injection needed). A 5xx reply passes the | ||
| // default `shouldHandleError`, so the error is captured. | ||
| channel('tracing:fastify.request.handler:error').publish({ | ||
| error, | ||
| request: { method: 'GET', routeOptions: { url: '/boom' } }, | ||
| reply: { statusCode: 500 }, | ||
| }); | ||
| const event = await withTimeout( | ||
| sink.waitFor(e => e.exception?.values?.[0]?.value === 'fastify boom'), | ||
| 5000, | ||
| "the captured 'fastify boom' error", | ||
| ); | ||
| assertExists(event.exception?.values?.[0]); | ||
| assertEquals(event.exception?.values?.[0]?.mechanism?.type, 'auto.function.fastify'); | ||
| assertEquals(event.exception?.values?.[0]?.mechanism?.handled, false); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| const Sentry = require('@sentry/node'); | ||
| const { waitForDebuggerReady } = require('@sentry-internal/test-utils'); | ||
| setTimeout(() => { | ||
| process.exit(); | ||
| @@ -52,7 +53,9 @@ setTimeout(() => { | ||
| setTimeout(() => { | ||
| anr.startWorker(); | ||
| setTimeout(() => { | ||
| // Wait for the restarted worker's debugger session to reconnect before blocking the event | ||
| // loop, otherwise on slow CI the worker isn't ready to sample and the ANR is missed entirely. | ||
| waitForDebuggerReady(() => { | ||
cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| longWork(); | ||
| }); | ||
| }, 2000); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -11,32 +11,7 @@ import { | ||
| requestDataIntegration, | ||
| stackParserFromStackParserOptions, | ||
| } from '@sentry/core'; | ||
| import { | ||
| amqplibIntegration, | ||
| anthropicAIIntegration, | ||
| awsIntegration, | ||
| expressIntegration, | ||
| firebaseIntegration, | ||
| genericPoolIntegration, | ||
| googleGenAIIntegration, | ||
| graphqlIntegration, | ||
| hapiIntegration, | ||
| kafkaIntegration, | ||
| koaIntegration, | ||
| langChainIntegration, | ||
| langGraphIntegration, | ||
| lruMemoizerIntegration, | ||
| mongoIntegration, | ||
| mongooseIntegration, | ||
| mysqlIntegration, | ||
| mysql2Integration, | ||
| openAIIntegration, | ||
| postgresIntegration, | ||
| postgresJsIntegration, | ||
| tediousIntegration, | ||
| vercelAIIntegration, | ||
| redisIntegration, | ||
| } from '@sentry/server-utils'; | ||
| import { getTracingIntegrations, getErrorIntegrations } from '@sentry/server-utils'; | ||
| import { DenoClient } from './client'; | ||
| import { breadcrumbsIntegration } from './integrations/breadcrumbs'; | ||
| import { denoContextIntegration } from './integrations/context'; | ||
| @@ -64,39 +39,12 @@ export function getDefaultIntegrations(_options: Options): Integration[] { | ||
| denoContextIntegration(), | ||
| denoServeIntegration(), | ||
| denoHttpIntegration(), | ||
| redisIntegration(), | ||
| graphqlIntegration(), | ||
| vercelAIIntegration(), | ||
| // orchestrion-based instrumentations. We add a deliberate list here rather | ||
| // than every channel integration: each one needs a Deno test proving it | ||
| // records spans. | ||
| // | ||
| // The orchestrion channels may be injected after (or while) the SDK loads. | ||
| // If they never load, these are no-ops. | ||
| amqplibIntegration(), | ||
| anthropicAIIntegration(), | ||
| awsIntegration(), | ||
| expressIntegration(), | ||
| firebaseIntegration(), | ||
| genericPoolIntegration(), | ||
| googleGenAIIntegration(), | ||
| hapiIntegration(), | ||
| kafkaIntegration(), | ||
| koaIntegration(), | ||
| langChainIntegration(), | ||
| langGraphIntegration(), | ||
| lruMemoizerIntegration(), | ||
| mongoIntegration(), | ||
| mongooseIntegration(), | ||
| mysqlIntegration(), | ||
| mysql2Integration(), | ||
| openAIIntegration(), | ||
| postgresIntegration(), | ||
| postgresJsIntegration(), | ||
| tediousIntegration(), | ||
| contextLinesIntegration(), | ||
| normalizePathsIntegration(), | ||
| globalHandlersIntegration(), | ||
| // server-utils integrations | ||
| ...getErrorIntegrations(), | ||
| ...getTracingIntegrations(), | ||
sentry[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ]; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.