Skip to content

Commit d7e536e

Browse files
committed
use isolationScope for consistency, guard for defaultIsolationScope
1 parent 1d001ed commit d7e536e

File tree

1 file changed

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

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ import {
77
defineIntegration,
88
getActiveSpan,
99
getCurrentScope,
10+
getDefaultIsolationScope,
11+
getIsolationScope,
1012
getRootSpan,
1113
} from '@sentry/core';
1214
import type { IntegrationFn } from '@sentry/types';
15+
import { logger } from '@sentry/utils';
16+
import { DEBUG_BUILD } from '../../../debug-build';
1317
import type { Boom, RequestEvent, ResponseObject, Server } from './types';
1418

1519
const _hapiIntegration = (() => {
@@ -59,9 +63,14 @@ export const hapiErrorPlugin = {
5963
const server = serverArg as unknown as Server;
6064

6165
server.events.on('request', (request, event) => {
62-
const route = request.route;
63-
if (route && route.path) {
64-
getCurrentScope().setTransactionName(`${route.method?.toUpperCase() || 'GET'} ${route.path}`);
66+
if (getIsolationScope() !== getDefaultIsolationScope()) {
67+
const route = request.route;
68+
if (route && route.path) {
69+
getIsolationScope().setTransactionName(`${route.method?.toUpperCase() || 'GET'} ${route.path}`);
70+
}
71+
} else {
72+
DEBUG_BUILD &&
73+
logger.warn('Isolation scope is still the default isolation scope - skipping setting transactionName');
6574
}
6675

6776
const activeSpan = getActiveSpan();

0 commit comments

Comments
 (0)