Skip to content

Commit d7dceda

Browse files
andreiborzaclaude
andauthored
ref(node): Remove vendored express instrumentation (#22749)
## What Removes the dead OpenTelemetry `ExpressInstrumentation` class (and `instrumentExpress`) from `@sentry/node`. Keeps `setupExpressErrorHandler` / `expressErrorHandler`. ## Why The express integration is now provided by the channel-based implementation in `@sentry/server-utils` (the default since #22501). The vendored instrumentation is no longer wired up; only the Sentry-specific error handler remains user-facing. Ref: #22346 Co-authored-by: Claude Opus 4.8 <[email protected]>
1 parent a168f75 commit d7dceda

1 file changed

Lines changed: 1 addition & 56 deletions

File tree

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
1-
// Automatic istrumentation for Express using OTel
2-
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
3-
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
4-
5-
import { generateInstrumentOnce } from '../../otel/instrument';
61
import { ensureIsWrapped } from '../../utils/ensureIsWrapped';
7-
import {
8-
type ExpressIntegrationOptions,
9-
debug,
10-
patchExpressModule,
11-
SDK_VERSION,
12-
setupExpressErrorHandler as coreSetupExpressErrorHandler,
13-
type ExpressHandlerOptions,
14-
} from '@sentry/core';
2+
import { setupExpressErrorHandler as coreSetupExpressErrorHandler, type ExpressHandlerOptions } from '@sentry/core';
153
export { expressErrorHandler } from '@sentry/core';
16-
import { DEBUG_BUILD } from '../../debug-build';
17-
import { setHttpServerSpanRouteAttribute } from '../../utils/setHttpServerSpanRouteAttribute';
18-
19-
const INTEGRATION_NAME = 'Express' as const;
20-
const SUPPORTED_VERSIONS = ['>=4.0.0 <6'];
214

225
export function setupExpressErrorHandler(
236
//oxlint-disable-next-line no-explicit-any
@@ -27,41 +10,3 @@ export function setupExpressErrorHandler(
2710
coreSetupExpressErrorHandler(app, options);
2811
ensureIsWrapped(app.use, 'express');
2912
}
30-
31-
export type ExpressInstrumentationConfig = InstrumentationConfig &
32-
Omit<ExpressIntegrationOptions, 'express' | 'onRouteResolved'>;
33-
34-
export const instrumentExpress = generateInstrumentOnce(
35-
INTEGRATION_NAME,
36-
(options?: ExpressInstrumentationConfig) => new ExpressInstrumentation(options),
37-
);
38-
39-
export class ExpressInstrumentation extends InstrumentationBase<ExpressInstrumentationConfig> {
40-
public constructor(config: ExpressInstrumentationConfig = {}) {
41-
super('sentry-express', SDK_VERSION, config);
42-
}
43-
public init(): InstrumentationNodeModuleDefinition {
44-
const module = new InstrumentationNodeModuleDefinition(
45-
'express',
46-
SUPPORTED_VERSIONS,
47-
express => {
48-
try {
49-
patchExpressModule(express, () => ({
50-
...this.getConfig(),
51-
onRouteResolved(route) {
52-
if (route) {
53-
setHttpServerSpanRouteAttribute(route);
54-
}
55-
},
56-
}));
57-
} catch (e) {
58-
DEBUG_BUILD && debug.error('Failed to patch express module:', e);
59-
}
60-
return express;
61-
},
62-
// we do not ever actually unpatch in our SDKs
63-
express => express,
64-
);
65-
return module;
66-
}
67-
}

0 commit comments

Comments
 (0)