Files
klz-cables.com/.pnpm-store/v10/files/15/f3cef3ba4be615eb0dc5aa8d7304bdd5f5c771eecac15349410c21091acbf86fbf3fc82ee6e1187f5a029a6c64ead666789bb2938dac362c2b00a617206e71
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

1 line
6.6 KiB
Plaintext

{"version":3,"file":"handleOnSpanStart.js","sources":["../../../src/server/handleOnSpanStart.ts"],"sourcesContent":["import { context } from '@opentelemetry/api';\nimport { ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_ROUTE, SEMATTRS_HTTP_METHOD } from '@opentelemetry/semantic-conventions';\nimport type { Span } from '@sentry/core';\nimport {\n getCapturedScopesOnSpan,\n getCurrentScope,\n getIsolationScope,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n setCapturedScopesOnSpan,\n spanToJSON,\n} from '@sentry/core';\nimport { getScopesFromContext } from '@sentry/opentelemetry';\nimport { ATTR_NEXT_ROUTE, ATTR_NEXT_SPAN_NAME, ATTR_NEXT_SPAN_TYPE } from '../common/nextSpanAttributes';\nimport { addHeadersAsAttributes } from '../common/utils/addHeadersAsAttributes';\nimport { dropMiddlewareTunnelRequests } from '../common/utils/dropMiddlewareTunnelRequests';\nimport { maybeEnhanceServerComponentSpanName } from '../common/utils/tracingUtils';\nimport { maybeStartCronCheckIn } from './vercelCronsMonitoring';\n\n/**\n * Handles the on span start event for Next.js spans.\n * This function is used to enhance the span with additional information such as the route, the method, the headers, etc.\n * It is called for every span that is started by Next.js.\n * @param span The span that is starting.\n */\nexport function handleOnSpanStart(span: Span): void {\n const spanAttributes = spanToJSON(span).data;\n const rootSpan = getRootSpan(span);\n const rootSpanAttributes = spanToJSON(rootSpan).data;\n const isRootSpan = span === rootSpan;\n\n dropMiddlewareTunnelRequests(span, spanAttributes);\n\n // What we do in this glorious piece of code, is hoist any information about parameterized routes from spans emitted\n // by Next.js via the `next.route` attribute, up to the transaction by setting the http.route attribute.\n if (typeof spanAttributes?.[ATTR_NEXT_ROUTE] === 'string') {\n // Only hoist the http.route attribute if the transaction doesn't already have it\n if (\n // eslint-disable-next-line deprecation/deprecation\n (rootSpanAttributes?.[ATTR_HTTP_REQUEST_METHOD] || rootSpanAttributes?.[SEMATTRS_HTTP_METHOD]) &&\n !rootSpanAttributes?.[ATTR_HTTP_ROUTE]\n ) {\n const route = spanAttributes[ATTR_NEXT_ROUTE].replace(/\\/route$/, '');\n rootSpan.updateName(route);\n rootSpan.setAttribute(ATTR_HTTP_ROUTE, route);\n // Preserving the original attribute despite internally not depending on it\n rootSpan.setAttribute(ATTR_NEXT_ROUTE, route);\n\n // Check if this is a Vercel cron request and start a check-in\n maybeStartCronCheckIn(rootSpan, route);\n }\n }\n\n if (spanAttributes?.[ATTR_NEXT_SPAN_TYPE] === 'Middleware.execute') {\n const middlewareName = spanAttributes[ATTR_NEXT_SPAN_NAME];\n if (typeof middlewareName === 'string') {\n rootSpan.updateName(middlewareName);\n rootSpan.setAttribute(ATTR_HTTP_ROUTE, middlewareName);\n rootSpan.setAttribute(ATTR_NEXT_SPAN_NAME, middlewareName);\n }\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto');\n }\n\n // We want to skip span data inference for any spans generated by Next.js. Reason being that Next.js emits spans\n // with patterns (e.g. http.server spans) that will produce confusing data.\n if (spanAttributes?.[ATTR_NEXT_SPAN_TYPE] !== undefined) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto');\n }\n\n if (isRootSpan) {\n const headers = getIsolationScope().getScopeData().sdkProcessingMetadata?.normalizedRequest?.headers;\n addHeadersAsAttributes(headers, rootSpan);\n }\n\n // We want to fork the isolation scope for incoming requests\n if (spanAttributes?.[ATTR_NEXT_SPAN_TYPE] === 'BaseServer.handleRequest' && isRootSpan) {\n const scopes = getCapturedScopesOnSpan(span);\n\n const isolationScope = (scopes.isolationScope || getIsolationScope()).clone();\n const scope = scopes.scope || getCurrentScope();\n\n const currentScopesPointer = getScopesFromContext(context.active());\n if (currentScopesPointer) {\n currentScopesPointer.isolationScope = isolationScope;\n }\n\n setCapturedScopesOnSpan(span, scope, isolationScope);\n }\n\n maybeEnhanceServerComponentSpanName(span, spanAttributes, rootSpanAttributes);\n}\n"],"names":["spanToJSON","getRootSpan","dropMiddlewareTunnelRequests","ATTR_NEXT_ROUTE","ATTR_HTTP_REQUEST_METHOD","SEMATTRS_HTTP_METHOD","ATTR_HTTP_ROUTE","maybeStartCronCheckIn","ATTR_NEXT_SPAN_TYPE","ATTR_NEXT_SPAN_NAME","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getIsolationScope","addHeadersAsAttributes","getCapturedScopesOnSpan","getCurrentScope","getScopesFromContext","context","setCapturedScopesOnSpan","maybeEnhanceServerComponentSpanName"],"mappings":";;;;;;;;;;;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,IAAI,EAAc;AACpD,EAAE,MAAM,iBAAiBA,eAAU,CAAC,IAAI,CAAC,CAAC,IAAI;AAC9C,EAAE,MAAM,QAAA,GAAWC,gBAAW,CAAC,IAAI,CAAC;AACpC,EAAE,MAAM,qBAAqBD,eAAU,CAAC,QAAQ,CAAC,CAAC,IAAI;AACtD,EAAE,MAAM,UAAA,GAAa,IAAA,KAAS,QAAQ;;AAEtC,EAAEE,yDAA4B,CAAC,IAAI,EAAE,cAAc,CAAC;;AAEpD;AACA;AACA,EAAE,IAAI,OAAO,cAAc,GAAGC,kCAAe,CAAA,KAAM,QAAQ,EAAE;AAC7D;A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