Skip to content

Commit

Permalink
feat(connect): Warn if connect is not instrumented
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed May 7, 2024
1 parent d64d458 commit ec2087f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/node/src/integrations/tracing/connect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { isWrapped } from '@opentelemetry/core';
import { ConnectInstrumentation } from '@opentelemetry/instrumentation-connect';
import { captureException, defineIntegration } from '@sentry/core';
import { addOpenTelemetryInstrumentation } from '@sentry/opentelemetry';
import type { IntegrationFn } from '@sentry/types';
import { consoleSandbox } from '@sentry/utils';

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

export const setupConnectErrorHandler = (app: ConnectApp): void => {
app.use(connectErrorMiddleware);

if (!isWrapped(app.use)) {
consoleSandbox(() => {
// eslint-disable-next-line no-console
console.warn(
'[Sentry] Connect is not instrumented. This is likely because you required/imported connect before calling `Sentry.init()`.',
);
});
}
};

0 comments on commit ec2087f

Please sign in to comment.