|
1 | 1 | import type * as http from 'node:http'; |
2 | 2 | import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'; |
3 | | -import { |
4 | | - SEMANTIC_ATTRIBUTE_SENTRY_OP, |
5 | | - defineIntegration, |
6 | | - getDefaultIsolationScope, |
7 | | - hasTracingEnabled, |
8 | | - isEnabled, |
9 | | - spanToJSON, |
10 | | -} from '@sentry/core'; |
| 3 | +import { SEMANTIC_ATTRIBUTE_SENTRY_OP, defineIntegration, getDefaultIsolationScope, spanToJSON } from '@sentry/core'; |
11 | 4 | import { captureException, getClient, getIsolationScope } from '@sentry/core'; |
12 | 5 | import { addOpenTelemetryInstrumentation } from '@sentry/opentelemetry'; |
13 | 6 | import type { IntegrationFn } from '@sentry/types'; |
14 | | - |
15 | | -import { isWrapped } from '@opentelemetry/core'; |
16 | | -import { consoleSandbox, logger } from '@sentry/utils'; |
| 7 | +import { logger } from '@sentry/utils'; |
17 | 8 | import { DEBUG_BUILD } from '../../debug-build'; |
18 | 9 | import type { NodeClient } from '../../sdk/client'; |
19 | | -import { isCjs } from '../../sdk/init'; |
20 | 10 | import { addOriginToSpan } from '../../utils/addOriginToSpan'; |
| 11 | +import { ensureIsWrapped } from '../../utils/ensureIsWrapped'; |
21 | 12 |
|
22 | 13 | const _expressIntegration = (() => { |
23 | 14 | return { |
@@ -140,24 +131,7 @@ export function expressErrorHandler(options?: { |
140 | 131 | */ |
141 | 132 | export function setupExpressErrorHandler(app: { use: (middleware: ExpressMiddleware) => unknown }): void { |
142 | 133 | app.use(expressErrorHandler()); |
143 | | - |
144 | | - if (!isWrapped(app.use) && isEnabled() && hasTracingEnabled()) { |
145 | | - consoleSandbox(() => { |
146 | | - consoleSandbox(() => { |
147 | | - if (isCjs()) { |
148 | | - // eslint-disable-next-line no-console |
149 | | - console.warn( |
150 | | - '[Sentry] Express is not instrumented. This is likely because you required/imported express before calling `Sentry.init()`.', |
151 | | - ); |
152 | | - } else { |
153 | | - // eslint-disable-next-line no-console |
154 | | - console.warn( |
155 | | - '[Sentry] Express is not instrumented. Please make sure to initialize Sentry in a separate file that you `--import` when running node, see: https://docs.sentry.io/platforms/javascript/guides/express/install/esm/.', |
156 | | - ); |
157 | | - } |
158 | | - }); |
159 | | - }); |
160 | | - } |
| 134 | + ensureIsWrapped(app.use, 'express'); |
161 | 135 | } |
162 | 136 |
|
163 | 137 | function getStatusCodeFromResponse(error: MiddlewareError): number { |
|
0 commit comments