From b15754a6b4c2b592a126d657d9601be36dca6ab7 Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Tue, 28 Jul 2026 12:16:25 +0200 Subject: [PATCH] ref(node): Remove vendored express instrumentation Removes the dead OpenTelemetry `ExpressInstrumentation` from `@sentry/node`. The express integration is provided by the channel-based implementation in `@sentry/server-utils` (default since #22501); only the Sentry-specific `setupExpressErrorHandler` is kept here. Ref: #22346 Co-Authored-By: Claude Opus 4.8 --- .../node/src/integrations/tracing/express.ts | 57 +------------------ 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/packages/node/src/integrations/tracing/express.ts b/packages/node/src/integrations/tracing/express.ts index fe48ec31bac3..d7212ac5b009 100644 --- a/packages/node/src/integrations/tracing/express.ts +++ b/packages/node/src/integrations/tracing/express.ts @@ -1,23 +1,6 @@ -// Automatic istrumentation for Express using OTel -import type { InstrumentationConfig } from '@opentelemetry/instrumentation'; -import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation'; - -import { generateInstrumentOnce } from '../../otel/instrument'; import { ensureIsWrapped } from '../../utils/ensureIsWrapped'; -import { - type ExpressIntegrationOptions, - debug, - patchExpressModule, - SDK_VERSION, - setupExpressErrorHandler as coreSetupExpressErrorHandler, - type ExpressHandlerOptions, -} from '@sentry/core'; +import { setupExpressErrorHandler as coreSetupExpressErrorHandler, type ExpressHandlerOptions } from '@sentry/core'; export { expressErrorHandler } from '@sentry/core'; -import { DEBUG_BUILD } from '../../debug-build'; -import { setHttpServerSpanRouteAttribute } from '../../utils/setHttpServerSpanRouteAttribute'; - -const INTEGRATION_NAME = 'Express' as const; -const SUPPORTED_VERSIONS = ['>=4.0.0 <6']; export function setupExpressErrorHandler( //oxlint-disable-next-line no-explicit-any @@ -27,41 +10,3 @@ export function setupExpressErrorHandler( coreSetupExpressErrorHandler(app, options); ensureIsWrapped(app.use, 'express'); } - -export type ExpressInstrumentationConfig = InstrumentationConfig & - Omit; - -export const instrumentExpress = generateInstrumentOnce( - INTEGRATION_NAME, - (options?: ExpressInstrumentationConfig) => new ExpressInstrumentation(options), -); - -export class ExpressInstrumentation extends InstrumentationBase { - public constructor(config: ExpressInstrumentationConfig = {}) { - super('sentry-express', SDK_VERSION, config); - } - public init(): InstrumentationNodeModuleDefinition { - const module = new InstrumentationNodeModuleDefinition( - 'express', - SUPPORTED_VERSIONS, - express => { - try { - patchExpressModule(express, () => ({ - ...this.getConfig(), - onRouteResolved(route) { - if (route) { - setHttpServerSpanRouteAttribute(route); - } - }, - })); - } catch (e) { - DEBUG_BUILD && debug.error('Failed to patch express module:', e); - } - return express; - }, - // we do not ever actually unpatch in our SDKs - express => express, - ); - return module; - } -}