Skip to content

Commit 487d802

Browse files
mydeaandreiborza
authored andcommitted
feat(connect): Warn if connect is not instrumented (#11936)
Another one...!
1 parent 3702f19 commit 487d802

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/node/src/integrations/tracing/connect.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { isWrapped } from '@opentelemetry/core';
12
import { ConnectInstrumentation } from '@opentelemetry/instrumentation-connect';
23
import { captureException, defineIntegration } from '@sentry/core';
34
import { addOpenTelemetryInstrumentation } from '@sentry/opentelemetry';
45
import type { IntegrationFn } from '@sentry/types';
6+
import { consoleSandbox } from '@sentry/utils';
57

68
type ConnectApp = {
79
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -27,4 +29,13 @@ function connectErrorMiddleware(err: any, req: any, res: any, next: any): void {
2729

2830
export const setupConnectErrorHandler = (app: ConnectApp): void => {
2931
app.use(connectErrorMiddleware);
32+
33+
if (!isWrapped(app.use)) {
34+
consoleSandbox(() => {
35+
// eslint-disable-next-line no-console
36+
console.warn(
37+
'[Sentry] Connect is not instrumented. This is likely because you required/imported connect before calling `Sentry.init()`.',
38+
);
39+
});
40+
}
3041
};

0 commit comments

Comments
 (0)