diff --git a/packages/node/src/integrations/tracing/hapi/index.ts b/packages/node/src/integrations/tracing/hapi/index.ts index e87ff70a0412..595c23cfda4c 100644 --- a/packages/node/src/integrations/tracing/hapi/index.ts +++ b/packages/node/src/integrations/tracing/hapi/index.ts @@ -1,3 +1,4 @@ +import { isWrapped } from '@opentelemetry/core'; import { HapiInstrumentation } from '@opentelemetry/instrumentation-hapi'; import { SDK_VERSION, @@ -11,7 +12,7 @@ import { } from '@sentry/core'; import { addOpenTelemetryInstrumentation } from '@sentry/opentelemetry'; import type { IntegrationFn } from '@sentry/types'; -import { logger } from '@sentry/utils'; +import { consoleSandbox, logger } from '@sentry/utils'; import { DEBUG_BUILD } from '../../../debug-build'; import type { Boom, RequestEvent, ResponseObject, Server } from './types'; @@ -92,4 +93,14 @@ export const hapiErrorPlugin = { */ export async function setupHapiErrorHandler(server: Server): Promise { await server.register(hapiErrorPlugin); + + // eslint-disable-next-line @typescript-eslint/unbound-method + if (!isWrapped(server.register)) { + consoleSandbox(() => { + // eslint-disable-next-line no-console + console.warn( + '[Sentry] Hapi is not instrumented. This is likely because you required/imported hapi before calling `Sentry.init()`.', + ); + }); + } }