Skip to content

Commit 3702f19

Browse files
mydeaandreiborza
authored andcommitted
feat(hapi): Warn if hapi is not instrumented (#11937)
Aaand another one...
1 parent ff1193c commit 3702f19

File tree

1 file changed

+12
-1
lines changed
  • packages/node/src/integrations/tracing/hapi

1 file changed

+12
-1
lines changed

packages/node/src/integrations/tracing/hapi/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isWrapped } from '@opentelemetry/core';
12
import { HapiInstrumentation } from '@opentelemetry/instrumentation-hapi';
23
import {
34
SDK_VERSION,
@@ -11,7 +12,7 @@ import {
1112
} from '@sentry/core';
1213
import { addOpenTelemetryInstrumentation } from '@sentry/opentelemetry';
1314
import type { IntegrationFn } from '@sentry/types';
14-
import { logger } from '@sentry/utils';
15+
import { consoleSandbox, logger } from '@sentry/utils';
1516
import { DEBUG_BUILD } from '../../../debug-build';
1617
import type { Boom, RequestEvent, ResponseObject, Server } from './types';
1718

@@ -92,4 +93,14 @@ export const hapiErrorPlugin = {
9293
*/
9394
export async function setupHapiErrorHandler(server: Server): Promise<void> {
9495
await server.register(hapiErrorPlugin);
96+
97+
// eslint-disable-next-line @typescript-eslint/unbound-method
98+
if (!isWrapped(server.register)) {
99+
consoleSandbox(() => {
100+
// eslint-disable-next-line no-console
101+
console.warn(
102+
'[Sentry] Hapi is not instrumented. This is likely because you required/imported hapi before calling `Sentry.init()`.',
103+
);
104+
});
105+
}
95106
}

0 commit comments

Comments
 (0)