Unverified Commit bdd0f545 authored by Dima Voytenko's avatar Dima Voytenko Committed by GitHub

OpenTel: remove the internal (ipc) fetched from traces in a non-verbose mode (#54083)

The internal IPC fetches are an internal framework detail and they shouldn't pollute the tracing in a non-verbose mode.

Examples of internal fetch output:

<img width="600" alt="image" src="https://github.com/vercel/next.js/assets/726049/64a25c02-bf39-4f54-8fe3-86018c7720dc">


<img width="1369" alt="image" src="https://github.com/vercel/next.js/assets/726049/f8f1d65c-5444-42c7-9e7d-6cdf9865eace">
parent af97755e
import type { StaticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage' import type { StaticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage'
import type * as ServerHooks from '../../client/components/hooks-server-context' import type * as ServerHooks from '../../client/components/hooks-server-context'
import { AppRenderSpan } from './trace/constants' import { AppRenderSpan, NextNodeServerSpan } from './trace/constants'
import { getTracer, SpanKind } from './trace/tracer' import { getTracer, SpanKind } from './trace/tracer'
import { CACHE_ONE_YEAR } from '../../lib/constants' import { CACHE_ONE_YEAR } from '../../lib/constants'
...@@ -100,8 +100,12 @@ export function patchFetch({ ...@@ -100,8 +100,12 @@ export function patchFetch({
const fetchStart = Date.now() const fetchStart = Date.now()
const method = init?.method?.toUpperCase() || 'GET' const method = init?.method?.toUpperCase() || 'GET'
// Do create a new span trace for internal fetches in the
// non-verbose mode.
const isInternal = (init?.next as any)?.internal === true
return await getTracer().trace( return await getTracer().trace(
AppRenderSpan.fetch, isInternal ? NextNodeServerSpan.internalFetch : AppRenderSpan.fetch,
{ {
kind: SpanKind.CLIENT, kind: SpanKind.CLIENT,
spanName: ['fetch', method, fetchUrl].filter(Boolean).join(' '), spanName: ['fetch', method, fetchUrl].filter(Boolean).join(' '),
...@@ -131,7 +135,7 @@ export function patchFetch({ ...@@ -131,7 +135,7 @@ export function patchFetch({
// fetch implementation. // fetch implementation.
if ( if (
!staticGenerationStore || !staticGenerationStore ||
(init?.next as any)?.internal || isInternal ||
staticGenerationStore.isDraftMode staticGenerationStore.isDraftMode
) { ) {
return originFetch(input, init) return originFetch(input, init)
......
...@@ -64,6 +64,7 @@ enum NextNodeServerSpan { ...@@ -64,6 +64,7 @@ enum NextNodeServerSpan {
route = 'route', route = 'route',
onProxyReq = 'onProxyReq', onProxyReq = 'onProxyReq',
apiResolver = 'apiResolver', apiResolver = 'apiResolver',
internalFetch = 'internalFetch',
} }
enum StartServerSpan { enum StartServerSpan {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment