Skip to content

Commit

Permalink
use isolationScope for consistency, guard for defaultIsolationScope
Browse files Browse the repository at this point in the history
  • Loading branch information
Lms24 committed Apr 9, 2024
1 parent 1d001ed commit d7e536e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/node/src/integrations/tracing/hapi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (() => {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit d7e536e

Please sign in to comment.