Skip to content

Commit b28f605

Browse files
s1gr1dmydea
andcommitted
Apply suggestions from code review
Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
1 parent 35b5ac8 commit b28f605

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { flushQueue } from './utils/responseEnd';
2020
import { withIsolationScopeOrReuseFromRootSpan } from './utils/withIsolationScopeOrReuseFromRootSpan';
2121

2222
/** As our own HTTP integration is disabled (src/server/index.ts) the rootSpan comes from Next.js.
23-
* In case there is not root span, we start a new span. */
23+
* In case there is no root span, we start a new span. */
2424
function startOrUpdateSpan(spanName: string, cb: (rootSpan: Span) => Promise<Response>): Promise<Response> {
2525
const activeSpan = getActiveSpan();
2626
const rootSpan = activeSpan && getRootSpan(activeSpan);

packages/nextjs/src/server/requestIsolationScopeIntegration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
getCapturedScopesOnSpan,
55
getCurrentScope,
66
getIsolationScope,
7+
getRootSpan,
78
setCapturedScopesOnSpan,
89
spanToJSON,
910
} from '@sentry/core';
@@ -25,7 +26,7 @@ export const requestIsolationScopeIntegration = defineIntegration(() => {
2526
const data = spanJson.data || {};
2627

2728
// The following check is a heuristic to determine whether the started span is a span that tracks an incoming HTTP request
28-
if ((getSpanKind(span) === SpanKind.SERVER && data['http.method']) || data['next.route']) {
29+
if ((getSpanKind(span) === SpanKind.SERVER && data['http.method']) || (span === getRootSpan(span) && data['next.route'])) {
2930
const scopes = getCapturedScopesOnSpan(span);
3031

3132
// Update the isolation scope, isolate this request

0 commit comments

Comments
 (0)