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">
This commit is contained in:
parent
af97755e3c
commit
bdd0f545c2
2 changed files with 8 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
import type { StaticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage'
|
||||
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 { CACHE_ONE_YEAR } from '../../lib/constants'
|
||||
|
||||
|
@ -100,8 +100,12 @@ export function patchFetch({
|
|||
const fetchStart = Date.now()
|
||||
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(
|
||||
AppRenderSpan.fetch,
|
||||
isInternal ? NextNodeServerSpan.internalFetch : AppRenderSpan.fetch,
|
||||
{
|
||||
kind: SpanKind.CLIENT,
|
||||
spanName: ['fetch', method, fetchUrl].filter(Boolean).join(' '),
|
||||
|
@ -131,7 +135,7 @@ export function patchFetch({
|
|||
// fetch implementation.
|
||||
if (
|
||||
!staticGenerationStore ||
|
||||
(init?.next as any)?.internal ||
|
||||
isInternal ||
|
||||
staticGenerationStore.isDraftMode
|
||||
) {
|
||||
return originFetch(input, init)
|
||||
|
|
|
@ -64,6 +64,7 @@ enum NextNodeServerSpan {
|
|||
route = 'route',
|
||||
onProxyReq = 'onProxyReq',
|
||||
apiResolver = 'apiResolver',
|
||||
internalFetch = 'internalFetch',
|
||||
}
|
||||
|
||||
enum StartServerSpan {
|
||||
|
|
Loading…
Reference in a new issue