Skip to content

Commit 162143f

Browse files
authored
fix(nextjs): Enable fetch span when OTel setup is skipped (#17699)
Next.js has their own fetch instrumentation, but when people use their own OTel setup, we don't want to disable that. fixes #17581
1 parent 9b22c8a commit 162143f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/nextjs/src/server/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,12 @@ export function init(options: NodeOptions): NodeClient | undefined {
106106
}),
107107
);
108108

109-
// Turn off Next.js' own fetch instrumentation
109+
// Turn off Next.js' own fetch instrumentation (only when we manage OTEL)
110110
// 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';
111+
// Enable with custom OTel setup: https://github.com/getsentry/sentry-javascript/issues/17581
112+
if (!options.skipOpenTelemetrySetup) {
113+
process.env.NEXT_OTEL_FETCH_DISABLED = '1';
114+
}
112115

113116
// This value is injected at build time, based on the output directory specified in the build config. Though a default
114117
// is set there, we set it here as well, just in case something has gone wrong with the injection.

0 commit comments

Comments
 (0)