File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/nextjs/src/server Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 getIsolationScope ,
1919 getRootSpan ,
2020 GLOBAL_OBJ ,
21+ hasSpansEnabled ,
2122 SEMANTIC_ATTRIBUTE_SENTRY_OP ,
2223 SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
2324 SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
@@ -106,9 +107,12 @@ export function init(options: NodeOptions): NodeClient | undefined {
106107 } ) ,
107108 ) ;
108109
109- // Turn off Next.js' own fetch instrumentation
110+ // Turn off Next.js' own fetch instrumentation (only when Sentry spans are enabled, and we manage OTEL)
110111 // https://github.com/lforst/nextjs-fork/blob/1994fd186defda77ad971c36dc3163db263c993f/packages/next/src/server/lib/patch-fetch.ts#L245
111- process . env . NEXT_OTEL_FETCH_DISABLED = '1' ;
112+ // Enable with custom OTel setup: https://github.com/getsentry/sentry-javascript/issues/17581
113+ if ( hasSpansEnabled ( options ) && ! options . skipOpenTelemetrySetup ) {
114+ process . env . NEXT_OTEL_FETCH_DISABLED = '1' ;
115+ }
112116
113117 // This value is injected at build time, based on the output directory specified in the build config. Though a default
114118 // is set there, we set it here as well, just in case something has gone wrong with the injection.
You can’t perform that action at this time.
0 commit comments