@sentry/core 10.47.0 → 10.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/attributes.js +43 -0
- package/build/cjs/attributes.js.map +1 -1
- package/build/cjs/client.js +13 -6
- package/build/cjs/client.js.map +1 -1
- package/build/cjs/envelope.js +4 -3
- package/build/cjs/envelope.js.map +1 -1
- package/build/cjs/fetch.js +36 -17
- package/build/cjs/fetch.js.map +1 -1
- package/build/cjs/index.js +53 -18
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integration.js +6 -0
- package/build/cjs/integration.js.map +1 -1
- package/build/cjs/integrations/conversationId.js +11 -0
- package/build/cjs/integrations/conversationId.js.map +1 -1
- package/build/cjs/integrations/express/index.js +243 -0
- package/build/cjs/integrations/express/index.js.map +1 -0
- package/build/cjs/integrations/express/patch-layer.js +257 -0
- package/build/cjs/integrations/express/patch-layer.js.map +1 -0
- package/build/cjs/integrations/express/request-layer-store.js +25 -0
- package/build/cjs/integrations/express/request-layer-store.js.map +1 -0
- package/build/cjs/integrations/express/set-sdk-processing-metadata.js +17 -0
- package/build/cjs/integrations/express/set-sdk-processing-metadata.js.map +1 -0
- package/build/cjs/integrations/express/types.js +17 -0
- package/build/cjs/integrations/express/types.js.map +1 -0
- package/build/cjs/integrations/express/utils.js +238 -0
- package/build/cjs/integrations/express/utils.js.map +1 -0
- package/build/cjs/integrations/mcp-server/correlation.js +5 -1
- package/build/cjs/integrations/mcp-server/correlation.js.map +1 -1
- package/build/cjs/integrations/mcp-server/handlers.js +18 -10
- package/build/cjs/integrations/mcp-server/handlers.js.map +1 -1
- package/build/cjs/integrations/mcp-server/index.js +2 -1
- package/build/cjs/integrations/mcp-server/index.js.map +1 -1
- package/build/cjs/integrations/mcp-server/transport.js +1 -1
- package/build/cjs/integrations/mcp-server/transport.js.map +1 -1
- package/build/cjs/integrations/mcp-server/validation.js +7 -5
- package/build/cjs/integrations/mcp-server/validation.js.map +1 -1
- package/build/cjs/integrations/requestdata.js.map +1 -1
- package/build/cjs/integrations/spanStreaming.js +48 -0
- package/build/cjs/integrations/spanStreaming.js.map +1 -0
- package/build/cjs/semanticAttributes.js +35 -3
- package/build/cjs/semanticAttributes.js.map +1 -1
- package/build/cjs/tracing/ai/gen-ai-attributes.js +3 -89
- package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
- package/build/cjs/tracing/ai/utils.js +74 -0
- package/build/cjs/tracing/ai/utils.js.map +1 -1
- package/build/cjs/tracing/anthropic-ai/index.js +6 -17
- package/build/cjs/tracing/anthropic-ai/index.js.map +1 -1
- package/build/cjs/tracing/anthropic-ai/streaming.js +2 -100
- package/build/cjs/tracing/anthropic-ai/streaming.js.map +1 -1
- package/build/cjs/tracing/anthropic-ai/utils.js +4 -2
- package/build/cjs/tracing/anthropic-ai/utils.js.map +1 -1
- package/build/cjs/tracing/dynamicSamplingContext.js +2 -1
- package/build/cjs/tracing/dynamicSamplingContext.js.map +1 -1
- package/build/cjs/tracing/google-genai/constants.js +1 -6
- package/build/cjs/tracing/google-genai/constants.js.map +1 -1
- package/build/cjs/tracing/google-genai/index.js +40 -35
- package/build/cjs/tracing/google-genai/index.js.map +1 -1
- package/build/cjs/tracing/google-genai/streaming.js +2 -23
- package/build/cjs/tracing/google-genai/streaming.js.map +1 -1
- package/build/cjs/tracing/langchain/embeddings.js +132 -0
- package/build/cjs/tracing/langchain/embeddings.js.map +1 -0
- package/build/cjs/tracing/langchain/index.js +3 -0
- package/build/cjs/tracing/langchain/index.js.map +1 -1
- package/build/cjs/tracing/langchain/utils.js +12 -4
- package/build/cjs/tracing/langchain/utils.js.map +1 -1
- package/build/cjs/tracing/langgraph/index.js +4 -3
- package/build/cjs/tracing/langgraph/index.js.map +1 -1
- package/build/cjs/tracing/openai/index.js +14 -34
- package/build/cjs/tracing/openai/index.js.map +1 -1
- package/build/cjs/tracing/openai/streaming.js +3 -34
- package/build/cjs/tracing/openai/streaming.js.map +1 -1
- package/build/cjs/tracing/openai/utils.js +78 -204
- package/build/cjs/tracing/openai/utils.js.map +1 -1
- package/build/cjs/tracing/sentryNonRecordingSpan.js +7 -0
- package/build/cjs/tracing/sentryNonRecordingSpan.js.map +1 -1
- package/build/cjs/tracing/sentrySpan.js +39 -0
- package/build/cjs/tracing/sentrySpan.js.map +1 -1
- package/build/cjs/tracing/spans/beforeSendSpan.js +43 -0
- package/build/cjs/tracing/spans/beforeSendSpan.js.map +1 -0
- package/build/cjs/tracing/spans/captureSpan.js +126 -0
- package/build/cjs/tracing/spans/captureSpan.js.map +1 -0
- package/build/cjs/tracing/spans/envelope.js +38 -0
- package/build/cjs/tracing/spans/envelope.js.map +1 -0
- package/build/cjs/tracing/spans/estimateSize.js +41 -0
- package/build/cjs/tracing/spans/estimateSize.js.map +1 -0
- package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js +11 -0
- package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
- package/build/cjs/tracing/spans/spanBuffer.js +158 -0
- package/build/cjs/tracing/spans/spanBuffer.js.map +1 -0
- package/build/cjs/tracing/trace.js +83 -13
- package/build/cjs/tracing/trace.js.map +1 -1
- package/build/cjs/tracing/utils.js +3 -37
- package/build/cjs/tracing/utils.js.map +1 -1
- package/build/cjs/tracing/vercel-ai/constants.js +15 -23
- package/build/cjs/tracing/vercel-ai/constants.js.map +1 -1
- package/build/cjs/tracing/vercel-ai/index.js +32 -45
- package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
- package/build/cjs/tracing/vercel-ai/utils.js +11 -42
- package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
- package/build/cjs/tracing/vercel-ai/vercel-ai-attributes.js +4 -1
- package/build/cjs/tracing/vercel-ai/vercel-ai-attributes.js.map +1 -1
- package/build/cjs/utils/browser.js +2 -3
- package/build/cjs/utils/browser.js.map +1 -1
- package/build/cjs/utils/featureFlags.js +6 -0
- package/build/cjs/utils/featureFlags.js.map +1 -1
- package/build/cjs/utils/object.js +33 -0
- package/build/cjs/utils/object.js.map +1 -1
- package/build/cjs/utils/spanUtils.js +116 -13
- package/build/cjs/utils/spanUtils.js.map +1 -1
- package/build/cjs/utils/stacktrace.js +3 -1
- package/build/cjs/utils/stacktrace.js.map +1 -1
- package/build/cjs/utils/string.js +3 -0
- package/build/cjs/utils/string.js.map +1 -1
- package/build/cjs/utils/version.js +1 -1
- package/build/cjs/utils/weakRef.js +62 -0
- package/build/cjs/utils/weakRef.js.map +1 -0
- package/build/esm/attributes.js +43 -1
- package/build/esm/attributes.js.map +1 -1
- package/build/esm/client.js +8 -1
- package/build/esm/client.js.map +1 -1
- package/build/esm/envelope.js +2 -1
- package/build/esm/envelope.js.map +1 -1
- package/build/esm/fetch.js +36 -17
- package/build/esm/fetch.js.map +1 -1
- package/build/esm/index.js +12 -3
- package/build/esm/index.js.map +1 -1
- package/build/esm/integration.js +6 -0
- package/build/esm/integration.js.map +1 -1
- package/build/esm/integrations/conversationId.js +11 -0
- package/build/esm/integrations/conversationId.js.map +1 -1
- package/build/esm/integrations/express/index.js +239 -0
- package/build/esm/integrations/express/index.js.map +1 -0
- package/build/esm/integrations/express/patch-layer.js +255 -0
- package/build/esm/integrations/express/patch-layer.js.map +1 -0
- package/build/esm/integrations/express/request-layer-store.js +22 -0
- package/build/esm/integrations/express/request-layer-store.js.map +1 -0
- package/build/esm/integrations/express/set-sdk-processing-metadata.js +15 -0
- package/build/esm/integrations/express/set-sdk-processing-metadata.js.map +1 -0
- package/build/esm/integrations/express/types.js +10 -0
- package/build/esm/integrations/express/types.js.map +1 -0
- package/build/esm/integrations/express/utils.js +225 -0
- package/build/esm/integrations/express/utils.js.map +1 -0
- package/build/esm/integrations/mcp-server/correlation.js +5 -1
- package/build/esm/integrations/mcp-server/correlation.js.map +1 -1
- package/build/esm/integrations/mcp-server/handlers.js +18 -10
- package/build/esm/integrations/mcp-server/handlers.js.map +1 -1
- package/build/esm/integrations/mcp-server/index.js +2 -1
- package/build/esm/integrations/mcp-server/index.js.map +1 -1
- package/build/esm/integrations/mcp-server/transport.js +1 -1
- package/build/esm/integrations/mcp-server/transport.js.map +1 -1
- package/build/esm/integrations/mcp-server/validation.js +7 -5
- package/build/esm/integrations/mcp-server/validation.js.map +1 -1
- package/build/esm/integrations/requestdata.js.map +1 -1
- package/build/esm/integrations/spanStreaming.js +46 -0
- package/build/esm/integrations/spanStreaming.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/semanticAttributes.js +26 -4
- package/build/esm/semanticAttributes.js.map +1 -1
- package/build/esm/tracing/ai/gen-ai-attributes.js +3 -76
- package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
- package/build/esm/tracing/ai/utils.js +73 -2
- package/build/esm/tracing/ai/utils.js.map +1 -1
- package/build/esm/tracing/anthropic-ai/index.js +8 -19
- package/build/esm/tracing/anthropic-ai/index.js.map +1 -1
- package/build/esm/tracing/anthropic-ai/streaming.js +3 -101
- package/build/esm/tracing/anthropic-ai/streaming.js.map +1 -1
- package/build/esm/tracing/anthropic-ai/utils.js +5 -3
- package/build/esm/tracing/anthropic-ai/utils.js.map +1 -1
- package/build/esm/tracing/dynamicSamplingContext.js +2 -1
- package/build/esm/tracing/dynamicSamplingContext.js.map +1 -1
- package/build/esm/tracing/google-genai/constants.js +2 -5
- package/build/esm/tracing/google-genai/constants.js.map +1 -1
- package/build/esm/tracing/google-genai/index.js +42 -37
- package/build/esm/tracing/google-genai/index.js.map +1 -1
- package/build/esm/tracing/google-genai/streaming.js +2 -23
- package/build/esm/tracing/google-genai/streaming.js.map +1 -1
- package/build/esm/tracing/langchain/embeddings.js +129 -0
- package/build/esm/tracing/langchain/embeddings.js.map +1 -0
- package/build/esm/tracing/langchain/index.js +4 -1
- package/build/esm/tracing/langchain/index.js.map +1 -1
- package/build/esm/tracing/langchain/utils.js +13 -5
- package/build/esm/tracing/langchain/utils.js.map +1 -1
- package/build/esm/tracing/langgraph/index.js +5 -4
- package/build/esm/tracing/langgraph/index.js.map +1 -1
- package/build/esm/tracing/openai/index.js +16 -36
- package/build/esm/tracing/openai/index.js.map +1 -1
- package/build/esm/tracing/openai/streaming.js +4 -35
- package/build/esm/tracing/openai/streaming.js.map +1 -1
- package/build/esm/tracing/openai/utils.js +79 -196
- package/build/esm/tracing/openai/utils.js.map +1 -1
- package/build/esm/tracing/sentryNonRecordingSpan.js +7 -0
- package/build/esm/tracing/sentryNonRecordingSpan.js.map +1 -1
- package/build/esm/tracing/sentrySpan.js +40 -1
- package/build/esm/tracing/sentrySpan.js.map +1 -1
- package/build/esm/tracing/spans/beforeSendSpan.js +40 -0
- package/build/esm/tracing/spans/beforeSendSpan.js.map +1 -0
- package/build/esm/tracing/spans/captureSpan.js +122 -0
- package/build/esm/tracing/spans/captureSpan.js.map +1 -0
- package/build/esm/tracing/spans/envelope.js +36 -0
- package/build/esm/tracing/spans/envelope.js.map +1 -0
- package/build/esm/tracing/spans/estimateSize.js +39 -0
- package/build/esm/tracing/spans/estimateSize.js.map +1 -0
- package/build/esm/tracing/spans/hasSpanStreamingEnabled.js +9 -0
- package/build/esm/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
- package/build/esm/tracing/spans/spanBuffer.js +156 -0
- package/build/esm/tracing/spans/spanBuffer.js.map +1 -0
- package/build/esm/tracing/trace.js +84 -14
- package/build/esm/tracing/trace.js.map +1 -1
- package/build/esm/tracing/utils.js +3 -37
- package/build/esm/tracing/utils.js.map +1 -1
- package/build/esm/tracing/vercel-ai/constants.js +15 -19
- package/build/esm/tracing/vercel-ai/constants.js.map +1 -1
- package/build/esm/tracing/vercel-ai/index.js +29 -42
- package/build/esm/tracing/vercel-ai/index.js.map +1 -1
- package/build/esm/tracing/vercel-ai/utils.js +14 -44
- package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
- package/build/esm/tracing/vercel-ai/vercel-ai-attributes.js +4 -1
- package/build/esm/tracing/vercel-ai/vercel-ai-attributes.js.map +1 -1
- package/build/esm/utils/browser.js +2 -3
- package/build/esm/utils/browser.js.map +1 -1
- package/build/esm/utils/featureFlags.js +6 -0
- package/build/esm/utils/featureFlags.js.map +1 -1
- package/build/esm/utils/object.js +33 -1
- package/build/esm/utils/object.js.map +1 -1
- package/build/esm/utils/spanUtils.js +112 -14
- package/build/esm/utils/spanUtils.js.map +1 -1
- package/build/esm/utils/stacktrace.js +3 -1
- package/build/esm/utils/stacktrace.js.map +1 -1
- package/build/esm/utils/string.js +3 -0
- package/build/esm/utils/string.js.map +1 -1
- package/build/esm/utils/version.js +1 -1
- package/build/esm/utils/weakRef.js +59 -0
- package/build/esm/utils/weakRef.js.map +1 -0
- package/build/types/attributes.d.ts +5 -0
- package/build/types/attributes.d.ts.map +1 -1
- package/build/types/build-time-plugins/buildTimeOptionsBase.d.ts +13 -0
- package/build/types/build-time-plugins/buildTimeOptionsBase.d.ts.map +1 -1
- package/build/types/client.d.ts +35 -1
- package/build/types/client.d.ts.map +1 -1
- package/build/types/envelope.d.ts.map +1 -1
- package/build/types/fetch.d.ts +12 -8
- package/build/types/fetch.d.ts.map +1 -1
- package/build/types/index.d.ts +16 -5
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integration.d.ts.map +1 -1
- package/build/types/integrations/conversationId.d.ts.map +1 -1
- package/build/types/integrations/express/index.d.ts +82 -0
- package/build/types/integrations/express/index.d.ts.map +1 -0
- package/build/types/integrations/express/patch-layer.d.ts +32 -0
- package/build/types/integrations/express/patch-layer.d.ts.map +1 -0
- package/build/types/integrations/express/request-layer-store.d.ts +32 -0
- package/build/types/integrations/express/request-layer-store.d.ts.map +1 -0
- package/build/types/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
- package/build/types/integrations/express/set-sdk-processing-metadata.d.ts.map +1 -0
- package/build/types/integrations/express/types.d.ts +158 -0
- package/build/types/integrations/express/types.d.ts.map +1 -0
- package/build/types/integrations/express/utils.d.ts +93 -0
- package/build/types/integrations/express/utils.d.ts.map +1 -0
- package/build/types/integrations/mcp-server/correlation.d.ts +2 -1
- package/build/types/integrations/mcp-server/correlation.d.ts.map +1 -1
- package/build/types/integrations/mcp-server/handlers.d.ts +9 -4
- package/build/types/integrations/mcp-server/handlers.d.ts.map +1 -1
- package/build/types/integrations/mcp-server/index.d.ts +2 -1
- package/build/types/integrations/mcp-server/index.d.ts.map +1 -1
- package/build/types/integrations/mcp-server/types.d.ts +40 -7
- package/build/types/integrations/mcp-server/types.d.ts.map +1 -1
- package/build/types/integrations/mcp-server/validation.d.ts +4 -1
- package/build/types/integrations/mcp-server/validation.d.ts.map +1 -1
- package/build/types/integrations/requestdata.d.ts.map +1 -1
- package/build/types/integrations/spanStreaming.d.ts +2 -0
- package/build/types/integrations/spanStreaming.d.ts.map +1 -0
- package/build/types/semanticAttributes.d.ts +23 -3
- package/build/types/semanticAttributes.d.ts.map +1 -1
- package/build/types/tracing/ai/gen-ai-attributes.d.ts +4 -44
- package/build/types/tracing/ai/gen-ai-attributes.d.ts.map +1 -1
- package/build/types/tracing/ai/utils.d.ts +32 -2
- package/build/types/tracing/ai/utils.d.ts.map +1 -1
- package/build/types/tracing/anthropic-ai/index.d.ts.map +1 -1
- package/build/types/tracing/anthropic-ai/streaming.d.ts.map +1 -1
- package/build/types/tracing/anthropic-ai/types.d.ts +5 -0
- package/build/types/tracing/anthropic-ai/types.d.ts.map +1 -1
- package/build/types/tracing/anthropic-ai/utils.d.ts +1 -1
- package/build/types/tracing/anthropic-ai/utils.d.ts.map +1 -1
- package/build/types/tracing/dynamicSamplingContext.d.ts.map +1 -1
- package/build/types/tracing/google-genai/constants.d.ts +1 -3
- package/build/types/tracing/google-genai/constants.d.ts.map +1 -1
- package/build/types/tracing/google-genai/index.d.ts.map +1 -1
- package/build/types/tracing/google-genai/streaming.d.ts.map +1 -1
- package/build/types/tracing/google-genai/types.d.ts +5 -0
- package/build/types/tracing/google-genai/types.d.ts.map +1 -1
- package/build/types/tracing/index.d.ts +1 -0
- package/build/types/tracing/index.d.ts.map +1 -1
- package/build/types/tracing/langchain/embeddings.d.ts +27 -0
- package/build/types/tracing/langchain/embeddings.d.ts.map +1 -0
- package/build/types/tracing/langchain/index.d.ts +1 -0
- package/build/types/tracing/langchain/index.d.ts.map +1 -1
- package/build/types/tracing/langchain/types.d.ts +5 -0
- package/build/types/tracing/langchain/types.d.ts.map +1 -1
- package/build/types/tracing/langchain/utils.d.ts +2 -2
- package/build/types/tracing/langchain/utils.d.ts.map +1 -1
- package/build/types/tracing/langgraph/index.d.ts.map +1 -1
- package/build/types/tracing/langgraph/types.d.ts +5 -0
- package/build/types/tracing/langgraph/types.d.ts.map +1 -1
- package/build/types/tracing/openai/index.d.ts.map +1 -1
- package/build/types/tracing/openai/streaming.d.ts.map +1 -1
- package/build/types/tracing/openai/types.d.ts +5 -0
- package/build/types/tracing/openai/types.d.ts.map +1 -1
- package/build/types/tracing/openai/utils.d.ts +4 -49
- package/build/types/tracing/openai/utils.d.ts.map +1 -1
- package/build/types/tracing/sentryNonRecordingSpan.d.ts +12 -1
- package/build/types/tracing/sentryNonRecordingSpan.d.ts.map +1 -1
- package/build/types/tracing/sentrySpan.d.ts +10 -1
- package/build/types/tracing/sentrySpan.d.ts.map +1 -1
- package/build/types/tracing/spans/beforeSendSpan.d.ts +35 -0
- package/build/types/tracing/spans/beforeSendSpan.d.ts.map +1 -0
- package/build/types/tracing/spans/captureSpan.d.ts +26 -0
- package/build/types/tracing/spans/captureSpan.d.ts.map +1 -0
- package/build/types/tracing/spans/envelope.d.ts +8 -0
- package/build/types/tracing/spans/envelope.d.ts.map +1 -0
- package/build/types/tracing/spans/estimateSize.d.ts +12 -0
- package/build/types/tracing/spans/estimateSize.d.ts.map +1 -0
- package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
- package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts.map +1 -0
- package/build/types/tracing/spans/spanBuffer.d.ts +60 -0
- package/build/types/tracing/spans/spanBuffer.d.ts.map +1 -0
- package/build/types/tracing/trace.d.ts.map +1 -1
- package/build/types/tracing/utils.d.ts.map +1 -1
- package/build/types/tracing/vercel-ai/constants.d.ts +2 -5
- package/build/types/tracing/vercel-ai/constants.d.ts.map +1 -1
- package/build/types/tracing/vercel-ai/index.d.ts.map +1 -1
- package/build/types/tracing/vercel-ai/utils.d.ts +1 -5
- package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
- package/build/types/tracing/vercel-ai/vercel-ai-attributes.d.ts +0 -480
- package/build/types/tracing/vercel-ai/vercel-ai-attributes.d.ts.map +1 -1
- package/build/types/types-hoist/envelope.d.ts +22 -2
- package/build/types/types-hoist/envelope.d.ts.map +1 -1
- package/build/types/types-hoist/integration.d.ts +8 -0
- package/build/types/types-hoist/integration.d.ts.map +1 -1
- package/build/types/types-hoist/link.d.ts +2 -2
- package/build/types/types-hoist/link.d.ts.map +1 -1
- package/build/types/types-hoist/options.d.ts +26 -2
- package/build/types/types-hoist/options.d.ts.map +1 -1
- package/build/types/types-hoist/span.d.ts +35 -0
- package/build/types/types-hoist/span.d.ts.map +1 -1
- package/build/types/types-hoist/view-hierarchy.d.ts +1 -0
- package/build/types/types-hoist/view-hierarchy.d.ts.map +1 -1
- package/build/types/utils/browser.d.ts +1 -1
- package/build/types/utils/browser.d.ts.map +1 -1
- package/build/types/utils/featureFlags.d.ts.map +1 -1
- package/build/types/utils/object.d.ts +10 -0
- package/build/types/utils/object.d.ts.map +1 -1
- package/build/types/utils/spanUtils.d.ts +27 -2
- package/build/types/utils/spanUtils.d.ts.map +1 -1
- package/build/types/utils/stacktrace.d.ts.map +1 -1
- package/build/types/utils/string.d.ts +2 -2
- package/build/types/utils/string.d.ts.map +1 -1
- package/build/types/utils/weakRef.d.ts +34 -0
- package/build/types/utils/weakRef.d.ts.map +1 -0
- package/build/types-ts3.8/attributes.d.ts +5 -0
- package/build/types-ts3.8/build-time-plugins/buildTimeOptionsBase.d.ts +13 -0
- package/build/types-ts3.8/client.d.ts +35 -1
- package/build/types-ts3.8/fetch.d.ts +14 -10
- package/build/types-ts3.8/index.d.ts +16 -5
- package/build/types-ts3.8/integrations/express/index.d.ts +82 -0
- package/build/types-ts3.8/integrations/express/patch-layer.d.ts +32 -0
- package/build/types-ts3.8/integrations/express/request-layer-store.d.ts +32 -0
- package/build/types-ts3.8/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
- package/build/types-ts3.8/integrations/express/types.d.ts +158 -0
- package/build/types-ts3.8/integrations/express/utils.d.ts +96 -0
- package/build/types-ts3.8/integrations/mcp-server/correlation.d.ts +2 -1
- package/build/types-ts3.8/integrations/mcp-server/handlers.d.ts +9 -4
- package/build/types-ts3.8/integrations/mcp-server/index.d.ts +2 -1
- package/build/types-ts3.8/integrations/mcp-server/types.d.ts +40 -7
- package/build/types-ts3.8/integrations/mcp-server/validation.d.ts +4 -1
- package/build/types-ts3.8/integrations/spanStreaming.d.ts +2 -0
- package/build/types-ts3.8/semanticAttributes.d.ts +23 -3
- package/build/types-ts3.8/tracing/ai/gen-ai-attributes.d.ts +4 -44
- package/build/types-ts3.8/tracing/ai/utils.d.ts +32 -2
- package/build/types-ts3.8/tracing/anthropic-ai/types.d.ts +5 -0
- package/build/types-ts3.8/tracing/anthropic-ai/utils.d.ts +1 -1
- package/build/types-ts3.8/tracing/google-genai/constants.d.ts +1 -3
- package/build/types-ts3.8/tracing/google-genai/types.d.ts +5 -0
- package/build/types-ts3.8/tracing/index.d.ts +1 -0
- package/build/types-ts3.8/tracing/langchain/embeddings.d.ts +27 -0
- package/build/types-ts3.8/tracing/langchain/index.d.ts +1 -0
- package/build/types-ts3.8/tracing/langchain/types.d.ts +5 -0
- package/build/types-ts3.8/tracing/langchain/utils.d.ts +2 -2
- package/build/types-ts3.8/tracing/langgraph/types.d.ts +5 -0
- package/build/types-ts3.8/tracing/openai/types.d.ts +5 -0
- package/build/types-ts3.8/tracing/openai/utils.d.ts +4 -49
- package/build/types-ts3.8/tracing/sentryNonRecordingSpan.d.ts +12 -1
- package/build/types-ts3.8/tracing/sentrySpan.d.ts +10 -1
- package/build/types-ts3.8/tracing/spans/beforeSendSpan.d.ts +35 -0
- package/build/types-ts3.8/tracing/spans/captureSpan.d.ts +26 -0
- package/build/types-ts3.8/tracing/spans/envelope.d.ts +8 -0
- package/build/types-ts3.8/tracing/spans/estimateSize.d.ts +12 -0
- package/build/types-ts3.8/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
- package/build/types-ts3.8/tracing/spans/spanBuffer.d.ts +60 -0
- package/build/types-ts3.8/tracing/vercel-ai/constants.d.ts +2 -5
- package/build/types-ts3.8/tracing/vercel-ai/utils.d.ts +1 -5
- package/build/types-ts3.8/tracing/vercel-ai/vercel-ai-attributes.d.ts +0 -480
- package/build/types-ts3.8/types-hoist/envelope.d.ts +22 -2
- package/build/types-ts3.8/types-hoist/integration.d.ts +8 -0
- package/build/types-ts3.8/types-hoist/link.d.ts +2 -2
- package/build/types-ts3.8/types-hoist/options.d.ts +26 -2
- package/build/types-ts3.8/types-hoist/span.d.ts +35 -0
- package/build/types-ts3.8/types-hoist/view-hierarchy.d.ts +1 -0
- package/build/types-ts3.8/utils/browser.d.ts +1 -1
- package/build/types-ts3.8/utils/object.d.ts +10 -0
- package/build/types-ts3.8/utils/spanUtils.d.ts +27 -2
- package/build/types-ts3.8/utils/string.d.ts +2 -2
- package/build/types-ts3.8/utils/weakRef.d.ts +34 -0
- package/package.json +1 -1
|
@@ -9,6 +9,8 @@ const baggage = require('../utils/baggage.js');
|
|
|
9
9
|
const debugLogger = require('../utils/debug-logger.js');
|
|
10
10
|
const handleCallbackErrors = require('../utils/handleCallbackErrors.js');
|
|
11
11
|
const hasSpansEnabled = require('../utils/hasSpansEnabled.js');
|
|
12
|
+
const shouldIgnoreSpan = require('../utils/should-ignore-span.js');
|
|
13
|
+
const hasSpanStreamingEnabled = require('./spans/hasSpanStreamingEnabled.js');
|
|
12
14
|
const parseSampleRate = require('../utils/parseSampleRate.js');
|
|
13
15
|
const propagationContext = require('../utils/propagationContext.js');
|
|
14
16
|
const randomSafeContext = require('../utils/randomSafeContext.js');
|
|
@@ -69,7 +71,12 @@ function startSpan(options, callback) {
|
|
|
69
71
|
scope,
|
|
70
72
|
});
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
// Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them
|
|
75
|
+
// and descendants are also non-recording. Ignored child spans don't need this because
|
|
76
|
+
// the parent span is already on scope.
|
|
77
|
+
if (!_isIgnoredSpan(activeSpan) || !parentSpan) {
|
|
78
|
+
spanOnScope._setSpanForScope(scope, activeSpan);
|
|
79
|
+
}
|
|
73
80
|
|
|
74
81
|
return handleCallbackErrors.handleCallbackErrors(
|
|
75
82
|
() => callback(activeSpan),
|
|
@@ -127,7 +134,11 @@ function startSpanManual(options, callback) {
|
|
|
127
134
|
scope,
|
|
128
135
|
});
|
|
129
136
|
|
|
130
|
-
|
|
137
|
+
// We don't set ignored child spans onto the scope because there likely is an active,
|
|
138
|
+
// unignored span on the scope already.
|
|
139
|
+
if (!_isIgnoredSpan(activeSpan) || !parentSpan) {
|
|
140
|
+
spanOnScope._setSpanForScope(scope, activeSpan);
|
|
141
|
+
}
|
|
131
142
|
|
|
132
143
|
return handleCallbackErrors.handleCallbackErrors(
|
|
133
144
|
// We pass the `finish` function to the callback, so the user can finish the span manually
|
|
@@ -328,6 +339,20 @@ function createChildOrRootSpan({
|
|
|
328
339
|
return span;
|
|
329
340
|
}
|
|
330
341
|
|
|
342
|
+
const client = currentScopes.getClient();
|
|
343
|
+
if (_shouldIgnoreStreamedSpan(client, spanArguments)) {
|
|
344
|
+
if (!_isTracingSuppressed(scope)) {
|
|
345
|
+
// if tracing is actively suppressed (Sentry.suppressTracing(...)),
|
|
346
|
+
// we don't want to record a client outcome for the ignored span
|
|
347
|
+
client?.recordDroppedEvent('ignored', 'span');
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return new sentryNonRecordingSpan.SentryNonRecordingSpan({
|
|
351
|
+
dropReason: 'ignored',
|
|
352
|
+
traceId: parentSpan?.spanContext().traceId ?? scope.getPropagationContext().traceId,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
|
|
331
356
|
const isolationScope = currentScopes.getIsolationScope();
|
|
332
357
|
|
|
333
358
|
let span;
|
|
@@ -427,9 +452,9 @@ function _startRootSpan(spanArguments, scope, parentSampled) {
|
|
|
427
452
|
const finalAttributes = mutableSpanSamplingData.spanAttributes;
|
|
428
453
|
|
|
429
454
|
const currentPropagationContext = scope.getPropagationContext();
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
]
|
|
455
|
+
const isTracingSuppressed = _isTracingSuppressed(scope);
|
|
456
|
+
|
|
457
|
+
const [sampled, sampleRate, localSampleRateWasApplied] = isTracingSuppressed
|
|
433
458
|
? [false]
|
|
434
459
|
: sampling.sampleSpan(
|
|
435
460
|
options,
|
|
@@ -453,9 +478,9 @@ function _startRootSpan(spanArguments, scope, parentSampled) {
|
|
|
453
478
|
sampled,
|
|
454
479
|
});
|
|
455
480
|
|
|
456
|
-
if (!sampled && client) {
|
|
481
|
+
if (!sampled && client && !isTracingSuppressed) {
|
|
457
482
|
debugBuild.DEBUG_BUILD && debugLogger.debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');
|
|
458
|
-
client.recordDroppedEvent('sample_rate', 'transaction');
|
|
483
|
+
client.recordDroppedEvent('sample_rate', hasSpanStreamingEnabled.hasSpanStreamingEnabled(client) ? 'span' : 'transaction');
|
|
459
484
|
}
|
|
460
485
|
|
|
461
486
|
if (client) {
|
|
@@ -471,7 +496,8 @@ function _startRootSpan(spanArguments, scope, parentSampled) {
|
|
|
471
496
|
*/
|
|
472
497
|
function _startChildSpan(parentSpan, scope, spanArguments) {
|
|
473
498
|
const { spanId, traceId } = parentSpan.spanContext();
|
|
474
|
-
const
|
|
499
|
+
const isTracingSuppressed = _isTracingSuppressed(scope);
|
|
500
|
+
const sampled = isTracingSuppressed ? false : spanUtils.spanIsSampled(parentSpan);
|
|
475
501
|
|
|
476
502
|
const childSpan = sampled
|
|
477
503
|
? new sentrySpan.SentrySpan({
|
|
@@ -485,14 +511,33 @@ function _startChildSpan(parentSpan, scope, spanArguments) {
|
|
|
485
511
|
spanUtils.addChildSpanToSpan(parentSpan, childSpan);
|
|
486
512
|
|
|
487
513
|
const client = currentScopes.getClient();
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
514
|
+
|
|
515
|
+
if (!client) {
|
|
516
|
+
return childSpan;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (hasSpanStreamingEnabled.hasSpanStreamingEnabled(client) && childSpan instanceof sentryNonRecordingSpan.SentryNonRecordingSpan) {
|
|
520
|
+
if (parentSpan instanceof sentryNonRecordingSpan.SentryNonRecordingSpan && parentSpan.dropReason) {
|
|
521
|
+
// We land here if the parent span was a segment span that was ignored (`ignoreSpans`).
|
|
522
|
+
// In this case, the child was also ignored (see `sampled` above) but we need to
|
|
523
|
+
// record a client outcome for the child.
|
|
524
|
+
childSpan.dropReason = parentSpan.dropReason;
|
|
525
|
+
client.recordDroppedEvent(parentSpan.dropReason, 'span');
|
|
526
|
+
} else if (!isTracingSuppressed) {
|
|
527
|
+
// Otherwise, the child is not sampled due to sampling of the parent span,
|
|
528
|
+
// hence we record a sample_rate client outcome for the child.
|
|
529
|
+
childSpan.dropReason = 'sample_rate';
|
|
530
|
+
client.recordDroppedEvent('sample_rate', 'span');
|
|
493
531
|
}
|
|
494
532
|
}
|
|
495
533
|
|
|
534
|
+
client.emit('spanStart', childSpan);
|
|
535
|
+
// If it has an endTimestamp, it's already ended
|
|
536
|
+
if (spanArguments.endTimestamp) {
|
|
537
|
+
client.emit('spanEnd', childSpan);
|
|
538
|
+
client.emit('afterSpanEnd', childSpan);
|
|
539
|
+
}
|
|
540
|
+
|
|
496
541
|
return childSpan;
|
|
497
542
|
}
|
|
498
543
|
|
|
@@ -530,6 +575,31 @@ function getActiveSpanWrapper(parentSpan) {
|
|
|
530
575
|
: (callback) => callback();
|
|
531
576
|
}
|
|
532
577
|
|
|
578
|
+
/* Checks if `ignoreSpans` applies (extracted for bundle size)*/
|
|
579
|
+
function _shouldIgnoreStreamedSpan(client, spanArguments) {
|
|
580
|
+
const ignoreSpans = client?.getOptions().ignoreSpans;
|
|
581
|
+
|
|
582
|
+
if (!client || !hasSpanStreamingEnabled.hasSpanStreamingEnabled(client) || !ignoreSpans?.length) {
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
return shouldIgnoreSpan.shouldIgnoreSpan(
|
|
587
|
+
{
|
|
588
|
+
description: spanArguments.name || '',
|
|
589
|
+
op: spanArguments.attributes?.[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP] || spanArguments.op,
|
|
590
|
+
},
|
|
591
|
+
ignoreSpans,
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function _isIgnoredSpan(span) {
|
|
596
|
+
return span instanceof sentryNonRecordingSpan.SentryNonRecordingSpan && span.dropReason === 'ignored';
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function _isTracingSuppressed(scope) {
|
|
600
|
+
return scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] === true;
|
|
601
|
+
}
|
|
602
|
+
|
|
533
603
|
exports.continueTrace = continueTrace;
|
|
534
604
|
exports.startInactiveSpan = startInactiveSpan;
|
|
535
605
|
exports.startNewTrace = startNewTrace;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sources":["../../../src/tracing/trace.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { AsyncContextStrategy } from '../asyncContext/types';\nimport { getMainCarrier } from '../carrier';\nimport { getClient, getCurrentScope, getIsolationScope, withScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Scope } from '../scope';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes';\nimport type { DynamicSamplingContext } from '../types-hoist/envelope';\nimport type { ClientOptions } from '../types-hoist/options';\nimport type { SentrySpanArguments, Span, SpanTimeInput } from '../types-hoist/span';\nimport type { StartSpanOptions } from '../types-hoist/startSpanOptions';\nimport { baggageHeaderToDynamicSamplingContext } from '../utils/baggage';\nimport { debug } from '../utils/debug-logger';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { parseSampleRate } from '../utils/parseSampleRate';\nimport { generateTraceId } from '../utils/propagationContext';\nimport { safeMathRandom } from '../utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';\nimport { addChildSpanToSpan, getRootSpan, spanIsSampled, spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';\nimport { propagationContextFromHeaders, shouldContinueTrace } from '../utils/tracing';\nimport { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanStart } from './logSpans';\nimport { sampleSpan } from './sampling';\nimport { SentryNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { SentrySpan } from './sentrySpan';\nimport { SPAN_STATUS_ERROR } from './spanstatus';\nimport { setCapturedScopesOnSpan } from './utils';\n\nconst SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n // We still need to fork a potentially passed scope, as we set the active span on it\n // and we need to ensure that it is cleaned up properly once the span ends.\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n _setSpanForScope(scope, activeSpan);\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => {\n activeSpan.end();\n },\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. Use `span.end()` to end the span.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n _setSpanForScope(scope, activeSpan);\n\n return handleCallbackErrors(\n // We pass the `finish` function to the callback, so the user can finish the span manually\n // this is mainly here for historic purposes because previously, we instructed users to call\n // `finish` instead of `span.end()` to also clean up the scope. Nowadays, calling `span.end()`\n // or `finish` has the same effect and we simply leave it here to avoid breaking user code.\n () => callback(activeSpan, () => activeSpan.end()),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback: () => Span) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)\n : (callback: () => Span) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n\n if (shouldSkipSpan) {\n return new SentryNonRecordingSpan();\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from `<meta name=\"sentry-trace\">`\n * and `<meta name=\"baggage\">` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nexport const continueTrace = <V>(\n options: {\n sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];\n baggage: Parameters<typeof propagationContextFromHeaders>[1];\n },\n callback: () => V,\n): V => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {\n return startNewTrace(callback);\n }\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n _setSpanForScope(scope, undefined);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nexport function suppressTracing<T>(callback: () => T): T {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n // Note: We do not wait for the callback to finish before we reset the metadata\n // the reason for this is that otherwise, in the browser this can lead to very weird behavior\n // as there is only a single top scope, if the callback takes longer to finish,\n // other, unrelated spans may also be suppressed, which we do not want\n // so instead, we only suppress tracing synchronoysly in the browser\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n const res = callback();\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });\n return res;\n });\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nexport function startNewTrace<T>(callback: () => T): T {\n const acs = getAcs();\n if (acs.startNewTrace) {\n return acs.startNewTrace(callback);\n }\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}: {\n parentSpan: SentrySpan | undefined;\n spanArguments: SentrySpanArguments;\n forceTransaction?: boolean;\n scope: Scope;\n}): Span {\n if (!hasSpansEnabled()) {\n const span = new SentryNonRecordingSpan();\n\n // If this is a root span, we ensure to freeze a DSC\n // So we can have at least partial data here\n if (forceTransaction || !parentSpan) {\n const dsc = {\n sampled: 'false',\n sample_rate: '0',\n transaction: spanArguments.name,\n ...getDynamicSamplingContextFromSpan(span),\n } satisfies Partial<DynamicSamplingContext>;\n freezeDscOnSpan(span, dsc);\n }\n\n return span;\n }\n\n const isolationScope = getIsolationScope();\n\n let span: Span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options: StartSpanOptions): SentrySpanArguments {\n const exp = options.experimental || {};\n const initialCtx: SentrySpanArguments = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx: SentrySpanArguments & { startTime?: SpanTimeInput } = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs(): AsyncContextStrategy {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(spanArguments: SentrySpanArguments, scope: Scope, parentSampled?: boolean): SentrySpan {\n const client = getClient();\n const options: Partial<ClientOptions> = client?.getOptions() || {};\n\n const { name = '' } = spanArguments;\n\n const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name, parentSampled };\n\n // we don't care about the decision for the moment; this is just a placeholder\n client?.emit('beforeSampling', mutableSpanSamplingData, { decision: false });\n\n // If hook consumers override the parentSampled flag, we will use that value instead of the actual one\n const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;\n const finalAttributes = mutableSpanSamplingData.spanAttributes;\n\n const currentPropagationContext = scope.getPropagationContext();\n const [sampled, sampleRate, localSampleRateWasApplied] = scope.getScopeData().sdkProcessingMetadata[\n SUPPRESS_TRACING_KEY\n ]\n ? [false]\n : sampleSpan(\n options,\n {\n name,\n parentSampled: finalParentSampled,\n attributes: finalAttributes,\n parentSampleRate: parseSampleRate(currentPropagationContext.dsc?.sample_rate),\n },\n currentPropagationContext.sampleRand,\n );\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]:\n sampleRate !== undefined && localSampleRateWasApplied ? sampleRate : undefined,\n ...finalAttributes,\n },\n sampled,\n });\n\n if (!sampled && client) {\n DEBUG_BUILD && debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');\n client.recordDroppedEvent('sample_rate', 'transaction');\n }\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(parentSpan: Span, scope: Scope, spanArguments: SentrySpanArguments): Span {\n const { spanId, traceId } = parentSpan.spanContext();\n const sampled = scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n const client = getClient();\n if (client) {\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n }\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {\n // always use the passed in span directly\n if (customParentSpan) {\n return customParentSpan as SentrySpan;\n }\n\n // This is different from `undefined` as it means the user explicitly wants no parent span\n if (customParentSpan === null) {\n return undefined;\n }\n\n const span = _getSpanForScope(scope) as SentrySpan | undefined;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options: Partial<ClientOptions> = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) as SentrySpan;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n"],"names":["withScope","getCurrentScope","SentryNonRecordingSpan","_setSpanForScope","handleCallbackErrors","spanToJSON","SPAN_STATUS_ERROR","carrier","getMainCarrier","getAsyncContextStrategy","baggage","getClient","baggageHeaderToDynamicSamplingContext","shouldContinueTrace","propagationContextFromHeaders","generateTraceId","safeMathRandom","DEBUG_BUILD","debug","hasSpansEnabled","getDynamicSamplingContextFromSpan","freezeDscOnSpan","getIsolationScope","addChildSpanToSpan","spanIsSampled","logSpanStart","setCapturedScopesOnSpan","spanTimeInputToSeconds","sampleSpan","parseSampleRate","SentrySpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","_getSpanForScope","getRootSpan"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AA+BA,MAAM,oBAAA,GAAuB,6BAA6B;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS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AA,UAAA,KAAA;AACA,MAAA,CAAA,QAAA,KAAA;AACA,QAAA,OAAA,cAAA,CAAA,UAAA,EAAA,QAAA,CAAA;AACA,MAAA;AACA,MAAA,CAAA,QAAA,KAAA,QAAA,EAAA;AACA;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"trace.js","sources":["../../../src/tracing/trace.ts"],"sourcesContent":["/* eslint-disable max-lines */\n\nimport { getAsyncContextStrategy } from '../asyncContext';\nimport type { AsyncContextStrategy } from '../asyncContext/types';\nimport { getMainCarrier } from '../carrier';\nimport { getClient, getCurrentScope, getIsolationScope, withScope } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { Scope } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '../semanticAttributes';\nimport type { DynamicSamplingContext } from '../types-hoist/envelope';\nimport type { ClientOptions } from '../types-hoist/options';\nimport type { SentrySpanArguments, Span, SpanTimeInput } from '../types-hoist/span';\nimport type { StartSpanOptions } from '../types-hoist/startSpanOptions';\nimport { baggageHeaderToDynamicSamplingContext } from '../utils/baggage';\nimport { debug } from '../utils/debug-logger';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors';\nimport { hasSpansEnabled } from '../utils/hasSpansEnabled';\nimport { shouldIgnoreSpan } from '../utils/should-ignore-span';\nimport { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';\nimport { parseSampleRate } from '../utils/parseSampleRate';\nimport { generateTraceId } from '../utils/propagationContext';\nimport { safeMathRandom } from '../utils/randomSafeContext';\nimport { _getSpanForScope, _setSpanForScope } from '../utils/spanOnScope';\nimport { addChildSpanToSpan, getRootSpan, spanIsSampled, spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';\nimport { propagationContextFromHeaders, shouldContinueTrace } from '../utils/tracing';\nimport { freezeDscOnSpan, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';\nimport { logSpanStart } from './logSpans';\nimport { sampleSpan } from './sampling';\nimport { SentryNonRecordingSpan } from './sentryNonRecordingSpan';\nimport { SentrySpan } from './sentrySpan';\nimport { SPAN_STATUS_ERROR } from './spanstatus';\nimport { setCapturedScopesOnSpan } from './utils';\nimport type { Client } from '../client';\n\nconst SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n // We still need to fork a potentially passed scope, as we set the active span on it\n // and we need to ensure that it is cleaned up properly once the span ends.\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them\n // and descendants are also non-recording. Ignored child spans don't need this because\n // the parent span is already on scope.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => {\n activeSpan.end();\n },\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. Use `span.end()` to end the span.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan, scope: customScope } = options;\n\n const customForkedScope = customScope?.clone();\n\n return withScope(customForkedScope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper<T>(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n // We don't set ignored child spans onto the scope because there likely is an active,\n // unignored span on the scope already.\n if (!_isIgnoredSpan(activeSpan) || !parentSpan) {\n _setSpanForScope(scope, activeSpan);\n }\n\n return handleCallbackErrors(\n // We pass the `finish` function to the callback, so the user can finish the span manually\n // this is mainly here for historic purposes because previously, we instructed users to call\n // `finish` instead of `span.end()` to also clean up the scope. Nowadays, calling `span.end()`\n // or `finish` has the same effect and we simply leave it here to avoid breaking user code.\n () => callback(activeSpan, () => activeSpan.end()),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nexport function startInactiveSpan(options: StartSpanOptions): Span {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback: () => Span) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)\n : (callback: () => Span) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope, customParentSpan);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n\n if (shouldSkipSpan) {\n return new SentryNonRecordingSpan();\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from `<meta name=\"sentry-trace\">`\n * and `<meta name=\"baggage\">` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nexport const continueTrace = <V>(\n options: {\n sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];\n baggage: Parameters<typeof propagationContextFromHeaders>[1];\n },\n callback: () => V,\n): V => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n const client = getClient();\n const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);\n if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {\n return startNewTrace(callback);\n }\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n _setSpanForScope(scope, undefined);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nexport function suppressTracing<T>(callback: () => T): T {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n // Note: We do not wait for the callback to finish before we reset the metadata\n // the reason for this is that otherwise, in the browser this can lead to very weird behavior\n // as there is only a single top scope, if the callback takes longer to finish,\n // other, unrelated spans may also be suppressed, which we do not want\n // so instead, we only suppress tracing synchronoysly in the browser\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n const res = callback();\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });\n return res;\n });\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nexport function startNewTrace<T>(callback: () => T): T {\n const acs = getAcs();\n if (acs.startNewTrace) {\n return acs.startNewTrace(callback);\n }\n\n return withScope(scope => {\n scope.setPropagationContext({\n traceId: generateTraceId(),\n sampleRand: safeMathRandom(),\n });\n DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}: {\n parentSpan: SentrySpan | undefined;\n spanArguments: SentrySpanArguments;\n forceTransaction?: boolean;\n scope: Scope;\n}): Span {\n if (!hasSpansEnabled()) {\n const span = new SentryNonRecordingSpan();\n\n // If this is a root span, we ensure to freeze a DSC\n // So we can have at least partial data here\n if (forceTransaction || !parentSpan) {\n const dsc = {\n sampled: 'false',\n sample_rate: '0',\n transaction: spanArguments.name,\n ...getDynamicSamplingContextFromSpan(span),\n } satisfies Partial<DynamicSamplingContext>;\n freezeDscOnSpan(span, dsc);\n }\n\n return span;\n }\n\n const client = getClient();\n if (_shouldIgnoreStreamedSpan(client, spanArguments)) {\n if (!_isTracingSuppressed(scope)) {\n // if tracing is actively suppressed (Sentry.suppressTracing(...)),\n // we don't want to record a client outcome for the ignored span\n client?.recordDroppedEvent('ignored', 'span');\n }\n\n return new SentryNonRecordingSpan({\n dropReason: 'ignored',\n traceId: parentSpan?.spanContext().traceId ?? scope.getPropagationContext().traceId,\n });\n }\n\n const isolationScope = getIsolationScope();\n\n let span: Span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options: StartSpanOptions): SentrySpanArguments {\n const exp = options.experimental || {};\n const initialCtx: SentrySpanArguments = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx: SentrySpanArguments & { startTime?: SpanTimeInput } = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs(): AsyncContextStrategy {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(spanArguments: SentrySpanArguments, scope: Scope, parentSampled?: boolean): SentrySpan {\n const client = getClient();\n const options: Partial<ClientOptions> = client?.getOptions() || {};\n\n const { name = '' } = spanArguments;\n\n const mutableSpanSamplingData = { spanAttributes: { ...spanArguments.attributes }, spanName: name, parentSampled };\n\n // we don't care about the decision for the moment; this is just a placeholder\n client?.emit('beforeSampling', mutableSpanSamplingData, { decision: false });\n\n // If hook consumers override the parentSampled flag, we will use that value instead of the actual one\n const finalParentSampled = mutableSpanSamplingData.parentSampled ?? parentSampled;\n const finalAttributes = mutableSpanSamplingData.spanAttributes;\n\n const currentPropagationContext = scope.getPropagationContext();\n const isTracingSuppressed = _isTracingSuppressed(scope);\n\n const [sampled, sampleRate, localSampleRateWasApplied] = isTracingSuppressed\n ? [false]\n : sampleSpan(\n options,\n {\n name,\n parentSampled: finalParentSampled,\n attributes: finalAttributes,\n parentSampleRate: parseSampleRate(currentPropagationContext.dsc?.sample_rate),\n },\n currentPropagationContext.sampleRand,\n );\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]:\n sampleRate !== undefined && localSampleRateWasApplied ? sampleRate : undefined,\n ...finalAttributes,\n },\n sampled,\n });\n\n if (!sampled && client && !isTracingSuppressed) {\n DEBUG_BUILD && debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');\n client.recordDroppedEvent('sample_rate', hasSpanStreamingEnabled(client) ? 'span' : 'transaction');\n }\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(parentSpan: Span, scope: Scope, spanArguments: SentrySpanArguments): Span {\n const { spanId, traceId } = parentSpan.spanContext();\n const isTracingSuppressed = _isTracingSuppressed(scope);\n const sampled = isTracingSuppressed ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n const client = getClient();\n\n if (!client) {\n return childSpan;\n }\n\n if (hasSpanStreamingEnabled(client) && childSpan instanceof SentryNonRecordingSpan) {\n if (parentSpan instanceof SentryNonRecordingSpan && parentSpan.dropReason) {\n // We land here if the parent span was a segment span that was ignored (`ignoreSpans`).\n // In this case, the child was also ignored (see `sampled` above) but we need to\n // record a client outcome for the child.\n childSpan.dropReason = parentSpan.dropReason;\n client.recordDroppedEvent(parentSpan.dropReason, 'span');\n } else if (!isTracingSuppressed) {\n // Otherwise, the child is not sampled due to sampling of the parent span,\n // hence we record a sample_rate client outcome for the child.\n childSpan.dropReason = 'sample_rate';\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n client.emit('afterSpanEnd', childSpan);\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {\n // always use the passed in span directly\n if (customParentSpan) {\n return customParentSpan as SentrySpan;\n }\n\n // This is different from `undefined` as it means the user explicitly wants no parent span\n if (customParentSpan === null) {\n return undefined;\n }\n\n const span = _getSpanForScope(scope) as SentrySpan | undefined;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options: Partial<ClientOptions> = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) as SentrySpan;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {\n return parentSpan !== undefined\n ? (callback: () => T) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback: () => T) => callback();\n}\n\n/* Checks if `ignoreSpans` applies (extracted for bundle size)*/\nfunction _shouldIgnoreStreamedSpan(client: Client | undefined, spanArguments: SentrySpanArguments): boolean {\n const ignoreSpans = client?.getOptions().ignoreSpans;\n\n if (!client || !hasSpanStreamingEnabled(client) || !ignoreSpans?.length) {\n return false;\n }\n\n return shouldIgnoreSpan(\n {\n description: spanArguments.name || '',\n op: spanArguments.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP] || spanArguments.op,\n },\n ignoreSpans,\n );\n}\n\nfunction _isIgnoredSpan(span: Span): span is SentryNonRecordingSpan {\n return span instanceof SentryNonRecordingSpan && span.dropReason === 'ignored';\n}\n\nfunction _isTracingSuppressed(scope: Scope): boolean {\n return scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] === true;\n}\n"],"names":["withScope","getCurrentScope","SentryNonRecordingSpan","_setSpanForScope","handleCallbackErrors","spanToJSON","SPAN_STATUS_ERROR","carrier","getMainCarrier","getAsyncContextStrategy","baggage","getClient","baggageHeaderToDynamicSamplingContext","shouldContinueTrace","propagationContextFromHeaders","generateTraceId","safeMathRandom","DEBUG_BUILD","debug","hasSpansEnabled","getDynamicSamplingContextFromSpan","freezeDscOnSpan","getIsolationScope","addChildSpanToSpan","spanIsSampled","logSpanStart","setCapturedScopesOnSpan","spanTimeInputToSeconds","sampleSpan","parseSampleRate","SentrySpan","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","hasSpanStreamingEnabled","_getSpanForScope","getRootSpan","shouldIgnoreSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AAsCA,MAAM,oBAAA,GAAuB,6BAA6B;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAI,OAAO,EAAoB,QAAQ,EAAwB;AACxF,EAAE,MAAM,GAAA,GAAM,MAAM,EAAE;AACtB,EAAE,IAAI,GAAG,CAAC,SAAS,EAAE;AACrB,IAAI,OAAO,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC;AAC3C,EAAE;;AAEF,EAAE,MAAM,aAAA,GAAgB,wBAAwB,CAAC,OAAO,CAAC;AACzD,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,gBAAg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A,EAAA,IAAA,CAAA,MAAA,IAAA,CAAAF,+CAAA,CAAA,MAAA,CAAA,IAAA,CAAA,WAAA,EAAA,MAAA,EAAA;AACA,IAAA,OAAA,KAAA;AACA,EAAA;;AAEA,EAAA,OAAAG,iCAAA;AACA,IAAA;AACA,MAAA,WAAA,EAAA,aAAA,CAAA,IAAA,IAAA,EAAA;AACA,MAAA,EAAA,EAAA,aAAA,CAAA,UAAA,GAAAC,+CAAA,CAAA,IAAA,aAAA,CAAA,EAAA;AACA,KAAA;AACA,IAAA,WAAA;AACA,GAAA;AACA;;AAEA,SAAA,cAAA,CAAA,IAAA,EAAA;AACA,EAAA,OAAA,IAAA,YAAAnC,6CAAA,IAAA,IAAA,CAAA,UAAA,KAAA,SAAA;AACA;;AAEA,SAAA,oBAAA,CAAA,KAAA,EAAA;AACA,EAAA,OAAA,KAAA,CAAA,YAAA,EAAA,CAAA,qBAAA,CAAA,oBAAA,CAAA,KAAA,IAAA;AACA;;;;;;;;;;"}
|
|
@@ -1,49 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const object = require('../utils/object.js');
|
|
4
|
-
const
|
|
4
|
+
const weakRef = require('../utils/weakRef.js');
|
|
5
5
|
|
|
6
6
|
const SCOPE_ON_START_SPAN_FIELD = '_sentryScope';
|
|
7
7
|
const ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';
|
|
8
8
|
|
|
9
|
-
/** Wrap a scope with a WeakRef if available, falling back to a direct scope. */
|
|
10
|
-
function wrapScopeWithWeakRef(scope) {
|
|
11
|
-
try {
|
|
12
|
-
// @ts-expect-error - WeakRef is not available in all environments
|
|
13
|
-
const WeakRefClass = worldwide.GLOBAL_OBJ.WeakRef;
|
|
14
|
-
if (typeof WeakRefClass === 'function') {
|
|
15
|
-
return new WeakRefClass(scope);
|
|
16
|
-
}
|
|
17
|
-
} catch {
|
|
18
|
-
// WeakRef not available or failed to create
|
|
19
|
-
// We'll fall back to a direct scope
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return scope;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** Try to unwrap a scope from a potential WeakRef wrapper. */
|
|
26
|
-
function unwrapScopeFromWeakRef(scopeRef) {
|
|
27
|
-
if (!scopeRef) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (typeof scopeRef === 'object' && 'deref' in scopeRef && typeof scopeRef.deref === 'function') {
|
|
32
|
-
try {
|
|
33
|
-
return scopeRef.deref();
|
|
34
|
-
} catch {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Fallback to a direct scope
|
|
40
|
-
return scopeRef ;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
9
|
/** Store the scope & isolation scope for a span, which can the be used when it is finished. */
|
|
44
10
|
function setCapturedScopesOnSpan(span, scope, isolationScope) {
|
|
45
11
|
if (span) {
|
|
46
|
-
object.addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD,
|
|
12
|
+
object.addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, weakRef.makeWeakRef(isolationScope));
|
|
47
13
|
// We don't wrap the scope with a WeakRef here because webkit aggressively garbage collects
|
|
48
14
|
// and scopes are not held in memory for long periods of time.
|
|
49
15
|
object.addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);
|
|
@@ -59,7 +25,7 @@ function getCapturedScopesOnSpan(span) {
|
|
|
59
25
|
|
|
60
26
|
return {
|
|
61
27
|
scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],
|
|
62
|
-
isolationScope:
|
|
28
|
+
isolationScope: weakRef.derefWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),
|
|
63
29
|
};
|
|
64
30
|
}
|
|
65
31
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/tracing/utils.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Span } from '../types-hoist/span';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport {
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/tracing/utils.ts"],"sourcesContent":["import type { Scope } from '../scope';\nimport type { Span } from '../types-hoist/span';\nimport { addNonEnumerableProperty } from '../utils/object';\nimport { derefWeakRef, makeWeakRef, type MaybeWeakRef } from '../utils/weakRef';\n\nconst SCOPE_ON_START_SPAN_FIELD = '_sentryScope';\nconst ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';\n\ntype SpanWithScopes = Span & {\n [SCOPE_ON_START_SPAN_FIELD]?: Scope;\n [ISOLATION_SCOPE_ON_START_SPAN_FIELD]?: MaybeWeakRef<Scope>;\n};\n\n/** Store the scope & isolation scope for a span, which can the be used when it is finished. */\nexport function setCapturedScopesOnSpan(span: Span | undefined, scope: Scope, isolationScope: Scope): void {\n if (span) {\n addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, makeWeakRef(isolationScope));\n // We don't wrap the scope with a WeakRef here because webkit aggressively garbage collects\n // and scopes are not held in memory for long periods of time.\n addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);\n }\n}\n\n/**\n * Grabs the scope and isolation scope off a span that were active when the span was started.\n * If WeakRef was used and scopes have been garbage collected, returns undefined for those scopes.\n */\nexport function getCapturedScopesOnSpan(span: Span): { scope?: Scope; isolationScope?: Scope } {\n const spanWithScopes = span as SpanWithScopes;\n\n return {\n scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],\n isolationScope: derefWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),\n };\n}\n"],"names":["addNonEnumerableProperty","makeWeakRef","derefWeakRef"],"mappings":";;;;;AAKA,MAAM,yBAAA,GAA4B,cAAc;AAChD,MAAM,mCAAA,GAAsC,uBAAuB;;AAOnE;AACO,SAAS,uBAAuB,CAAC,IAAI,EAAoB,KAAK,EAAS,cAAc,EAAe;AAC3G,EAAE,IAAI,IAAI,EAAE;AACZ,IAAIA,+BAAwB,CAAC,IAAI,EAAE,mCAAmC,EAAEC,mBAAW,CAAC,cAAc,CAAC,CAAC;AACpG;AACA;AACA,IAAID,+BAAwB,CAAC,IAAI,EAAE,yBAAyB,EAAE,KAAK,CAAC;AACpE,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,IAAI,EAAmD;AAC/F,EAAE,MAAM,cAAA,GAAiB,IAAA;;AAEzB,EAAE,OAAO;AACT,IAAI,KAAK,EAAE,cAAc,CAAC,yBAAyB,CAAC;AACpD,IAAI,cAAc,EAAEE,oBAAY,CAAC,cAAc,CAAC,mCAAmC,CAAC,CAAC;AACrF,GAAG;AACH;;;;;"}
|
|
@@ -5,30 +5,22 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
// without keeping full Span objects (and their potentially large attributes) alive.
|
|
6
6
|
const toolCallSpanContextMap = new Map();
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'ai.
|
|
13
|
-
'ai.
|
|
14
|
-
'ai.
|
|
15
|
-
'ai.
|
|
8
|
+
/** Maps Vercel AI span names to standardized OpenTelemetry operation names. */
|
|
9
|
+
const SPAN_TO_OPERATION_NAME = new Map([
|
|
10
|
+
['ai.generateText', 'invoke_agent'],
|
|
11
|
+
['ai.streamText', 'invoke_agent'],
|
|
12
|
+
['ai.generateObject', 'invoke_agent'],
|
|
13
|
+
['ai.streamObject', 'invoke_agent'],
|
|
14
|
+
['ai.generateText.doGenerate', 'generate_content'],
|
|
15
|
+
['ai.streamText.doStream', 'generate_content'],
|
|
16
|
+
['ai.generateObject.doGenerate', 'generate_content'],
|
|
17
|
+
['ai.streamObject.doStream', 'generate_content'],
|
|
18
|
+
['ai.embed.doEmbed', 'embeddings'],
|
|
19
|
+
['ai.embedMany.doEmbed', 'embeddings'],
|
|
20
|
+
['ai.rerank.doRerank', 'rerank'],
|
|
21
|
+
['ai.toolCall', 'execute_tool'],
|
|
16
22
|
]);
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const RERANK_OPS = new Set(['ai.rerank.doRerank']);
|
|
21
|
-
|
|
22
|
-
const DO_SPAN_NAME_PREFIX = {
|
|
23
|
-
'ai.embed.doEmbed': 'embeddings',
|
|
24
|
-
'ai.embedMany.doEmbed': 'embeddings',
|
|
25
|
-
'ai.rerank.doRerank': 'rerank',
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
exports.DO_SPAN_NAME_PREFIX = DO_SPAN_NAME_PREFIX;
|
|
29
|
-
exports.EMBEDDINGS_OPS = EMBEDDINGS_OPS;
|
|
30
|
-
exports.GENERATE_CONTENT_OPS = GENERATE_CONTENT_OPS;
|
|
31
|
-
exports.INVOKE_AGENT_OPS = INVOKE_AGENT_OPS;
|
|
32
|
-
exports.RERANK_OPS = RERANK_OPS;
|
|
24
|
+
exports.SPAN_TO_OPERATION_NAME = SPAN_TO_OPERATION_NAME;
|
|
33
25
|
exports.toolCallSpanContextMap = toolCallSpanContextMap;
|
|
34
26
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/tracing/vercel-ai/constants.ts"],"sourcesContent":["import type { ToolCallSpanContext } from './types';\n\n// Global map to track tool call IDs to their corresponding span contexts.\n// This allows us to capture tool errors and link them to the correct span\n// without keeping full Span objects (and their potentially large attributes) alive.\nexport const toolCallSpanContextMap = new Map<string, ToolCallSpanContext>();\n\n
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/tracing/vercel-ai/constants.ts"],"sourcesContent":["import type { ToolCallSpanContext } from './types';\n\n// Global map to track tool call IDs to their corresponding span contexts.\n// This allows us to capture tool errors and link them to the correct span\n// without keeping full Span objects (and their potentially large attributes) alive.\nexport const toolCallSpanContextMap = new Map<string, ToolCallSpanContext>();\n\n/** Maps Vercel AI span names to standardized OpenTelemetry operation names. */\nexport const SPAN_TO_OPERATION_NAME = new Map<string, string>([\n ['ai.generateText', 'invoke_agent'],\n ['ai.streamText', 'invoke_agent'],\n ['ai.generateObject', 'invoke_agent'],\n ['ai.streamObject', 'invoke_agent'],\n ['ai.generateText.doGenerate', 'generate_content'],\n ['ai.streamText.doStream', 'generate_content'],\n ['ai.generateObject.doGenerate', 'generate_content'],\n ['ai.streamObject.doStream', 'generate_content'],\n ['ai.embed.doEmbed', 'embeddings'],\n ['ai.embedMany.doEmbed', 'embeddings'],\n ['ai.rerank.doRerank', 'rerank'],\n ['ai.toolCall', 'execute_tool'],\n]);\n"],"names":[],"mappings":";;AAEA;AACA;AACA;MACa,sBAAA,GAAyB,IAAI,GAAG;;AAE7C;AACO,MAAM,sBAAA,GAAyB,IAAI,GAAG,CAAiB;AAC9D,EAAE,CAAC,iBAAiB,EAAE,cAAc,CAAC;AACrC,EAAE,CAAC,eAAe,EAAE,cAAc,CAAC;AACnC,EAAE,CAAC,mBAAmB,EAAE,cAAc,CAAC;AACvC,EAAE,CAAC,iBAAiB,EAAE,cAAc,CAAC;AACrC,EAAE,CAAC,4BAA4B,EAAE,kBAAkB,CAAC;AACpD,EAAE,CAAC,wBAAwB,EAAE,kBAAkB,CAAC;AAChD,EAAE,CAAC,8BAA8B,EAAE,kBAAkB,CAAC;AACtD,EAAE,CAAC,0BAA0B,EAAE,kBAAkB,CAAC;AAClD,EAAE,CAAC,kBAAkB,EAAE,YAAY,CAAC;AACpC,EAAE,CAAC,sBAAsB,EAAE,YAAY,CAAC;AACxC,EAAE,CAAC,oBAAoB,EAAE,QAAQ,CAAC;AAClC,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC;AACjC,CAAC;;;;;"}
|
|
@@ -1,38 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
+
const currentScopes = require('../../currentScopes.js');
|
|
3
4
|
const semanticAttributes = require('../../semanticAttributes.js');
|
|
5
|
+
const utils = require('../ai/utils.js');
|
|
4
6
|
const spanUtils = require('../../utils/spanUtils.js');
|
|
5
7
|
const genAiAttributes = require('../ai/gen-ai-attributes.js');
|
|
6
8
|
const constants = require('./constants.js');
|
|
7
|
-
const utils = require('./utils.js');
|
|
9
|
+
const utils$1 = require('./utils.js');
|
|
8
10
|
const vercelAiAttributes = require('./vercel-ai-attributes.js');
|
|
9
11
|
|
|
10
|
-
/**
|
|
11
|
-
* Maps Vercel AI SDK operation names to OpenTelemetry semantic convention values
|
|
12
|
-
* @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/#llm-request-spans
|
|
13
|
-
*/
|
|
14
|
-
function mapVercelAiOperationName(operationName) {
|
|
15
|
-
// Top-level pipeline operations map to invoke_agent
|
|
16
|
-
if (constants.INVOKE_AGENT_OPS.has(operationName)) {
|
|
17
|
-
return 'invoke_agent';
|
|
18
|
-
}
|
|
19
|
-
// .do* operations are the actual LLM calls
|
|
20
|
-
if (constants.GENERATE_CONTENT_OPS.has(operationName)) {
|
|
21
|
-
return 'generate_content';
|
|
22
|
-
}
|
|
23
|
-
if (constants.EMBEDDINGS_OPS.has(operationName)) {
|
|
24
|
-
return 'embeddings';
|
|
25
|
-
}
|
|
26
|
-
if (constants.RERANK_OPS.has(operationName)) {
|
|
27
|
-
return 'rerank';
|
|
28
|
-
}
|
|
29
|
-
if (operationName === 'ai.toolCall') {
|
|
30
|
-
return 'execute_tool';
|
|
31
|
-
}
|
|
32
|
-
// Return the original value for unknown operations
|
|
33
|
-
return operationName;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
12
|
/**
|
|
37
13
|
* Post-process spans emitted by the Vercel AI SDK.
|
|
38
14
|
* This is supposed to be used in `client.on('spanStart', ...)
|
|
@@ -57,7 +33,13 @@ function onVercelAiSpanStart(span) {
|
|
|
57
33
|
return;
|
|
58
34
|
}
|
|
59
35
|
|
|
60
|
-
|
|
36
|
+
const client = currentScopes.getClient();
|
|
37
|
+
const integration = client?.getIntegrationByName('VercelAI')
|
|
38
|
+
|
|
39
|
+
;
|
|
40
|
+
const enableTruncation = utils.shouldEnableTruncation(integration?.options?.enableTruncation);
|
|
41
|
+
|
|
42
|
+
processGenerateSpan(span, name, attributes, enableTruncation);
|
|
61
43
|
}
|
|
62
44
|
|
|
63
45
|
function vercelAiEventProcessor(event) {
|
|
@@ -70,16 +52,16 @@ function vercelAiEventProcessor(event) {
|
|
|
70
52
|
processEndedVercelAiSpan(span);
|
|
71
53
|
|
|
72
54
|
// Accumulate token data for parent spans
|
|
73
|
-
utils.accumulateTokensForParent(span, tokenAccumulator);
|
|
55
|
+
utils$1.accumulateTokensForParent(span, tokenAccumulator);
|
|
74
56
|
}
|
|
75
57
|
|
|
76
58
|
// Second pass: apply tool descriptions and accumulated tokens
|
|
77
|
-
utils.applyToolDescriptionsAndTokens(event.spans, tokenAccumulator);
|
|
59
|
+
utils$1.applyToolDescriptionsAndTokens(event.spans, tokenAccumulator);
|
|
78
60
|
|
|
79
61
|
// Also apply to root when it is the invoke_agent pipeline
|
|
80
62
|
const trace = event.contexts?.trace;
|
|
81
63
|
if (trace?.op === 'gen_ai.invoke_agent') {
|
|
82
|
-
utils.applyAccumulatedTokens(trace, tokenAccumulator);
|
|
64
|
+
utils$1.applyAccumulatedTokens(trace, tokenAccumulator);
|
|
83
65
|
}
|
|
84
66
|
}
|
|
85
67
|
|
|
@@ -243,7 +225,7 @@ function processEndedVercelAiSpan(span) {
|
|
|
243
225
|
|
|
244
226
|
// Convert the available tools array to a JSON string
|
|
245
227
|
if (attributes[vercelAiAttributes.AI_PROMPT_TOOLS_ATTRIBUTE] && Array.isArray(attributes[vercelAiAttributes.AI_PROMPT_TOOLS_ATTRIBUTE])) {
|
|
246
|
-
attributes[vercelAiAttributes.AI_PROMPT_TOOLS_ATTRIBUTE] = utils.convertAvailableToolsToJsonString(
|
|
228
|
+
attributes[vercelAiAttributes.AI_PROMPT_TOOLS_ATTRIBUTE] = utils$1.convertAvailableToolsToJsonString(
|
|
247
229
|
attributes[vercelAiAttributes.AI_PROMPT_TOOLS_ATTRIBUTE] ,
|
|
248
230
|
);
|
|
249
231
|
}
|
|
@@ -251,7 +233,13 @@ function processEndedVercelAiSpan(span) {
|
|
|
251
233
|
// Rename AI SDK attributes to standardized gen_ai attributes
|
|
252
234
|
// Map operation.name to OpenTelemetry semantic convention values
|
|
253
235
|
if (attributes[vercelAiAttributes.OPERATION_NAME_ATTRIBUTE]) {
|
|
254
|
-
|
|
236
|
+
// V6+ sets ai.operationId to the bare operation (e.g. "ai.streamText") while
|
|
237
|
+
// operation.name appends functionId (e.g. "ai.streamText myAgent").
|
|
238
|
+
// When ai.operationId is present, use it for correct mapping.
|
|
239
|
+
const rawOperationName = attributes[vercelAiAttributes.AI_OPERATION_ID_ATTRIBUTE]
|
|
240
|
+
? (attributes[vercelAiAttributes.AI_OPERATION_ID_ATTRIBUTE] )
|
|
241
|
+
: (attributes[vercelAiAttributes.OPERATION_NAME_ATTRIBUTE] );
|
|
242
|
+
const operationName = constants.SPAN_TO_OPERATION_NAME.get(rawOperationName) ?? rawOperationName;
|
|
255
243
|
attributes[genAiAttributes.GEN_AI_OPERATION_NAME_ATTRIBUTE] = operationName;
|
|
256
244
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
257
245
|
delete attributes[vercelAiAttributes.OPERATION_NAME_ATTRIBUTE];
|
|
@@ -333,7 +321,7 @@ function processToolCallSpan(span, attributes) {
|
|
|
333
321
|
}
|
|
334
322
|
}
|
|
335
323
|
|
|
336
|
-
function processGenerateSpan(span, name, attributes) {
|
|
324
|
+
function processGenerateSpan(span, name, attributes, enableTruncation) {
|
|
337
325
|
span.setAttribute(semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.vercelai.otel');
|
|
338
326
|
|
|
339
327
|
const nameWthoutAi = name.replace('ai.', '');
|
|
@@ -345,22 +333,24 @@ function processGenerateSpan(span, name, attributes) {
|
|
|
345
333
|
span.setAttribute('gen_ai.function_id', functionId);
|
|
346
334
|
}
|
|
347
335
|
|
|
348
|
-
utils.requestMessagesFromPrompt(span, attributes);
|
|
336
|
+
utils$1.requestMessagesFromPrompt(span, attributes, enableTruncation);
|
|
349
337
|
|
|
350
338
|
if (attributes[vercelAiAttributes.AI_MODEL_ID_ATTRIBUTE] && !attributes[genAiAttributes.GEN_AI_RESPONSE_MODEL_ATTRIBUTE]) {
|
|
351
339
|
span.setAttribute(genAiAttributes.GEN_AI_RESPONSE_MODEL_ATTRIBUTE, attributes[vercelAiAttributes.AI_MODEL_ID_ATTRIBUTE]);
|
|
352
340
|
}
|
|
353
341
|
span.setAttribute('ai.streaming', name.includes('stream'));
|
|
354
342
|
|
|
355
|
-
// Set the op based on the
|
|
356
|
-
const
|
|
357
|
-
if (
|
|
358
|
-
span.setAttribute(semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP,
|
|
343
|
+
// Set the op based on the operation name registry
|
|
344
|
+
const operationName = constants.SPAN_TO_OPERATION_NAME.get(name);
|
|
345
|
+
if (operationName) {
|
|
346
|
+
span.setAttribute(semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP, `gen_ai.${operationName}`);
|
|
347
|
+
} else if (name.startsWith('ai.stream')) {
|
|
348
|
+
span.setAttribute(semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.run');
|
|
359
349
|
}
|
|
360
350
|
|
|
361
351
|
// For invoke_agent pipeline spans, use 'invoke_agent' as the description
|
|
362
352
|
// to be consistent with other AI integrations (e.g. LangGraph)
|
|
363
|
-
if (
|
|
353
|
+
if (operationName === 'invoke_agent') {
|
|
364
354
|
if (functionId && typeof functionId === 'string') {
|
|
365
355
|
span.updateName(`invoke_agent ${functionId}`);
|
|
366
356
|
} else {
|
|
@@ -370,11 +360,8 @@ function processGenerateSpan(span, name, attributes) {
|
|
|
370
360
|
}
|
|
371
361
|
|
|
372
362
|
const modelId = attributes[vercelAiAttributes.AI_MODEL_ID_ATTRIBUTE];
|
|
373
|
-
if (modelId) {
|
|
374
|
-
|
|
375
|
-
if (doSpanPrefix) {
|
|
376
|
-
span.updateName(`${doSpanPrefix} ${modelId}`);
|
|
377
|
-
}
|
|
363
|
+
if (modelId && operationName) {
|
|
364
|
+
span.updateName(`${operationName} ${modelId}`);
|
|
378
365
|
}
|
|
379
366
|
}
|
|
380
367
|
|