From d7e536e5211e7e58e5f47ebc0aad6c3d92dd4462 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 9 Apr 2024 15:47:33 +0200 Subject: [PATCH] use isolationScope for consistency, guard for defaultIsolationScope --- .../node/src/integrations/tracing/hapi/index.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/node/src/integrations/tracing/hapi/index.ts b/packages/node/src/integrations/tracing/hapi/index.ts index f5d760efd292..1d3e1a5965af 100644 --- a/packages/node/src/integrations/tracing/hapi/index.ts +++ b/packages/node/src/integrations/tracing/hapi/index.ts @@ -7,9 +7,13 @@ import { defineIntegration, getActiveSpan, getCurrentScope, + getDefaultIsolationScope, + getIsolationScope, getRootSpan, } from '@sentry/core'; import type { IntegrationFn } from '@sentry/types'; +import { logger } from '@sentry/utils'; +import { DEBUG_BUILD } from '../../../debug-build'; import type { Boom, RequestEvent, ResponseObject, Server } from './types'; const _hapiIntegration = (() => { @@ -59,9 +63,14 @@ export const hapiErrorPlugin = { const server = serverArg as unknown as Server; server.events.on('request', (request, event) => { - const route = request.route; - if (route && route.path) { - getCurrentScope().setTransactionName(`${route.method?.toUpperCase() || 'GET'} ${route.path}`); + if (getIsolationScope() !== getDefaultIsolationScope()) { + const route = request.route; + if (route && route.path) { + getIsolationScope().setTransactionName(`${route.method?.toUpperCase() || 'GET'} ${route.path}`); + } + } else { + DEBUG_BUILD && + logger.warn('Isolation scope is still the default isolation scope - skipping setting transactionName'); } const activeSpan = getActiveSpan();