@sentry/core 10.38.0 → 10.39.0-alpha.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.map +1 -1
- package/build/cjs/client.js +22 -12
- package/build/cjs/client.js.map +1 -1
- package/build/cjs/envelope.js +41 -7
- package/build/cjs/envelope.js.map +1 -1
- package/build/cjs/index.js +52 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integration.js +12 -0
- package/build/cjs/integration.js.map +1 -1
- package/build/cjs/integrations/eventFilters.js +1 -1
- package/build/cjs/integrations/eventFilters.js.map +1 -1
- package/build/cjs/integrations/mcp-server/correlation.js +54 -10
- package/build/cjs/integrations/mcp-server/correlation.js.map +1 -1
- package/build/cjs/integrations/mcp-server/sessionManagement.js +50 -16
- package/build/cjs/integrations/mcp-server/sessionManagement.js.map +1 -1
- package/build/cjs/integrations/requestdata.js +72 -6
- package/build/cjs/integrations/requestdata.js.map +1 -1
- package/build/cjs/integrations/spanStreaming.js +54 -0
- package/build/cjs/integrations/spanStreaming.js.map +1 -0
- package/build/cjs/metrics/public-api.js +3 -3
- package/build/cjs/metrics/public-api.js.map +1 -1
- package/build/cjs/scope.js +1 -1
- package/build/cjs/scope.js.map +1 -1
- package/build/cjs/semanticAttributes.js +84 -0
- package/build/cjs/semanticAttributes.js.map +1 -1
- package/build/cjs/spans/captureSpan.js +104 -0
- package/build/cjs/spans/captureSpan.js.map +1 -0
- package/build/cjs/spans/spanBuffer.js +121 -0
- package/build/cjs/spans/spanBuffer.js.map +1 -0
- package/build/cjs/spans/spanFirstUtils.js +186 -0
- package/build/cjs/spans/spanFirstUtils.js.map +1 -0
- package/build/cjs/tracing/ai/gen-ai-attributes.js +6 -0
- package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
- package/build/cjs/tracing/openai/index.js +134 -51
- package/build/cjs/tracing/openai/index.js.map +1 -1
- package/build/cjs/tracing/sentrySpan.js +32 -0
- package/build/cjs/tracing/sentrySpan.js.map +1 -1
- package/build/cjs/tracing/trace.js +1 -0
- package/build/cjs/tracing/trace.js.map +1 -1
- package/build/cjs/tracing/vercel-ai/constants.js +4 -0
- package/build/cjs/tracing/vercel-ai/constants.js.map +1 -1
- package/build/cjs/tracing/vercel-ai/index.js +14 -0
- package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
- package/build/cjs/tracing/vercel-ai/utils.js +71 -22
- package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
- package/build/cjs/transports/base.js +18 -2
- package/build/cjs/transports/base.js.map +1 -1
- package/build/cjs/transports/offline.js +16 -17
- package/build/cjs/transports/offline.js.map +1 -1
- package/build/cjs/utils/beforeSendSpan.js +36 -0
- package/build/cjs/utils/beforeSendSpan.js.map +1 -0
- package/build/cjs/utils/envToBool.js +32 -0
- package/build/cjs/utils/envToBool.js.map +1 -0
- package/build/cjs/utils/featureFlags.js +1 -0
- package/build/cjs/utils/featureFlags.js.map +1 -1
- package/build/cjs/utils/flushIfServerless.js.map +1 -1
- package/build/cjs/utils/hasSpanStreamingEnabled.js +21 -0
- package/build/cjs/utils/hasSpanStreamingEnabled.js.map +1 -0
- package/build/cjs/utils/prepareEvent.js +6 -1
- package/build/cjs/utils/prepareEvent.js.map +1 -1
- package/build/cjs/utils/promisebuffer.js +5 -3
- package/build/cjs/utils/promisebuffer.js.map +1 -1
- package/build/cjs/utils/scopeData.js +4 -0
- package/build/cjs/utils/scopeData.js.map +1 -1
- package/build/cjs/utils/sdkMetadata.js +7 -11
- package/build/cjs/utils/sdkMetadata.js.map +1 -1
- package/build/cjs/utils/should-ignore-span.js +31 -9
- package/build/cjs/utils/should-ignore-span.js.map +1 -1
- package/build/cjs/utils/spanUtils.js +90 -2
- package/build/cjs/utils/spanUtils.js.map +1 -1
- package/build/cjs/utils/timer.js +20 -0
- package/build/cjs/utils/timer.js.map +1 -0
- package/build/cjs/utils/tracePropagationTargets.js +38 -0
- package/build/cjs/utils/tracePropagationTargets.js.map +1 -0
- package/build/cjs/utils/version.js +1 -1
- package/build/cjs/utils/version.js.map +1 -1
- package/build/esm/attributes.js.map +1 -1
- package/build/esm/client.js +18 -8
- package/build/esm/client.js.map +1 -1
- package/build/esm/envelope.js +41 -8
- package/build/esm/envelope.js.map +1 -1
- package/build/esm/index.js +12 -3
- package/build/esm/index.js.map +1 -1
- package/build/esm/integration.js +12 -1
- package/build/esm/integration.js.map +1 -1
- package/build/esm/integrations/eventFilters.js +1 -1
- package/build/esm/integrations/eventFilters.js.map +1 -1
- package/build/esm/integrations/mcp-server/correlation.js +54 -10
- package/build/esm/integrations/mcp-server/correlation.js.map +1 -1
- package/build/esm/integrations/mcp-server/sessionManagement.js +50 -16
- package/build/esm/integrations/mcp-server/sessionManagement.js.map +1 -1
- package/build/esm/integrations/requestdata.js +72 -6
- package/build/esm/integrations/requestdata.js.map +1 -1
- package/build/esm/integrations/spanStreaming.js +52 -0
- package/build/esm/integrations/spanStreaming.js.map +1 -0
- package/build/esm/metrics/public-api.js +3 -3
- package/build/esm/metrics/public-api.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/scope.js +1 -1
- package/build/esm/scope.js.map +1 -1
- package/build/esm/semanticAttributes.js +57 -1
- package/build/esm/semanticAttributes.js.map +1 -1
- package/build/esm/spans/captureSpan.js +102 -0
- package/build/esm/spans/captureSpan.js.map +1 -0
- package/build/esm/spans/spanBuffer.js +119 -0
- package/build/esm/spans/spanBuffer.js.map +1 -0
- package/build/esm/spans/spanFirstUtils.js +182 -0
- package/build/esm/spans/spanFirstUtils.js.map +1 -0
- package/build/esm/tracing/ai/gen-ai-attributes.js +6 -1
- package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
- package/build/esm/tracing/openai/index.js +134 -51
- package/build/esm/tracing/openai/index.js.map +1 -1
- package/build/esm/tracing/sentrySpan.js +33 -1
- package/build/esm/tracing/sentrySpan.js.map +1 -1
- package/build/esm/tracing/trace.js +1 -0
- package/build/esm/tracing/trace.js.map +1 -1
- package/build/esm/tracing/vercel-ai/constants.js +4 -1
- package/build/esm/tracing/vercel-ai/constants.js.map +1 -1
- package/build/esm/tracing/vercel-ai/index.js +15 -1
- package/build/esm/tracing/vercel-ai/index.js.map +1 -1
- package/build/esm/tracing/vercel-ai/utils.js +73 -24
- package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
- package/build/esm/transports/base.js +18 -2
- package/build/esm/transports/base.js.map +1 -1
- package/build/esm/transports/offline.js +16 -17
- package/build/esm/transports/offline.js.map +1 -1
- package/build/esm/utils/beforeSendSpan.js +33 -0
- package/build/esm/utils/beforeSendSpan.js.map +1 -0
- package/build/esm/utils/envToBool.js +28 -0
- package/build/esm/utils/envToBool.js.map +1 -0
- package/build/esm/utils/featureFlags.js +1 -0
- package/build/esm/utils/featureFlags.js.map +1 -1
- package/build/esm/utils/flushIfServerless.js.map +1 -1
- package/build/esm/utils/hasSpanStreamingEnabled.js +19 -0
- package/build/esm/utils/hasSpanStreamingEnabled.js.map +1 -0
- package/build/esm/utils/prepareEvent.js +6 -1
- package/build/esm/utils/prepareEvent.js.map +1 -1
- package/build/esm/utils/promisebuffer.js +5 -3
- package/build/esm/utils/promisebuffer.js.map +1 -1
- package/build/esm/utils/scopeData.js +4 -0
- package/build/esm/utils/scopeData.js.map +1 -1
- package/build/esm/utils/sdkMetadata.js +7 -11
- package/build/esm/utils/sdkMetadata.js.map +1 -1
- package/build/esm/utils/should-ignore-span.js +31 -9
- package/build/esm/utils/should-ignore-span.js.map +1 -1
- package/build/esm/utils/spanUtils.js +87 -3
- package/build/esm/utils/spanUtils.js.map +1 -1
- package/build/esm/utils/timer.js +18 -0
- package/build/esm/utils/timer.js.map +1 -0
- package/build/esm/utils/tracePropagationTargets.js +36 -0
- package/build/esm/utils/tracePropagationTargets.js.map +1 -0
- package/build/esm/utils/version.js +1 -1
- package/build/esm/utils/version.js.map +1 -1
- package/build/types/attributes.d.ts +1 -1
- package/build/types/attributes.d.ts.map +1 -1
- package/build/types/client.d.ts +40 -2
- package/build/types/client.d.ts.map +1 -1
- package/build/types/envelope.d.ts +6 -1
- package/build/types/envelope.d.ts.map +1 -1
- package/build/types/index.d.ts +13 -4
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integration.d.ts +4 -0
- package/build/types/integration.d.ts.map +1 -1
- package/build/types/integrations/mcp-server/correlation.d.ts +6 -2
- package/build/types/integrations/mcp-server/correlation.d.ts.map +1 -1
- package/build/types/integrations/mcp-server/sessionManagement.d.ts +8 -2
- package/build/types/integrations/mcp-server/sessionManagement.d.ts.map +1 -1
- package/build/types/integrations/requestdata.d.ts.map +1 -1
- package/build/types/integrations/spanStreaming.d.ts +11 -0
- package/build/types/integrations/spanStreaming.d.ts.map +1 -0
- package/build/types/metrics/public-api.d.ts +3 -3
- package/build/types/semanticAttributes.d.ts +38 -0
- package/build/types/semanticAttributes.d.ts.map +1 -1
- package/build/types/spans/captureSpan.d.ts +10 -0
- package/build/types/spans/captureSpan.d.ts.map +1 -0
- package/build/types/spans/spanBuffer.d.ts +35 -0
- package/build/types/spans/spanBuffer.d.ts.map +1 -0
- package/build/types/spans/spanFirstUtils.d.ts +20 -0
- package/build/types/spans/spanFirstUtils.d.ts.map +1 -0
- package/build/types/tracing/ai/gen-ai-attributes.d.ts +4 -0
- package/build/types/tracing/ai/gen-ai-attributes.d.ts.map +1 -1
- package/build/types/tracing/openai/index.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/vercel-ai/constants.d.ts +1 -0
- 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 +2 -2
- package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
- package/build/types/transports/base.d.ts.map +1 -1
- package/build/types/transports/offline.d.ts.map +1 -1
- package/build/types/types-hoist/attributes.d.ts +19 -0
- package/build/types/types-hoist/attributes.d.ts.map +1 -0
- 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/feedback/index.d.ts.map +1 -1
- package/build/types/types-hoist/integration.d.ts +7 -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 +18 -2
- package/build/types/types-hoist/options.d.ts.map +1 -1
- package/build/types/types-hoist/span.d.ts +27 -0
- package/build/types/types-hoist/span.d.ts.map +1 -1
- package/build/types/utils/beforeSendSpan.d.ts +22 -0
- package/build/types/utils/beforeSendSpan.d.ts.map +1 -0
- package/build/types/utils/envToBool.d.ts +13 -0
- package/build/types/utils/envToBool.d.ts.map +1 -0
- package/build/types/utils/featureFlags.d.ts.map +1 -1
- package/build/types/utils/flushIfServerless.d.ts.map +1 -1
- package/build/types/utils/hasSpanStreamingEnabled.d.ts +9 -0
- package/build/types/utils/hasSpanStreamingEnabled.d.ts.map +1 -0
- package/build/types/utils/prepareEvent.d.ts.map +1 -1
- package/build/types/utils/promisebuffer.d.ts.map +1 -1
- package/build/types/utils/scopeData.d.ts.map +1 -1
- package/build/types/utils/sdkMetadata.d.ts.map +1 -1
- package/build/types/utils/should-ignore-span.d.ts +3 -3
- package/build/types/utils/should-ignore-span.d.ts.map +1 -1
- package/build/types/utils/spanUtils.d.ts +22 -2
- package/build/types/utils/spanUtils.d.ts.map +1 -1
- package/build/types/utils/timer.d.ts +11 -0
- package/build/types/utils/timer.d.ts.map +1 -0
- package/build/types/utils/tracePropagationTargets.d.ts +9 -0
- package/build/types/utils/tracePropagationTargets.d.ts.map +1 -0
- package/build/types-ts3.8/attributes.d.ts +1 -1
- package/build/types-ts3.8/client.d.ts +40 -2
- package/build/types-ts3.8/envelope.d.ts +6 -1
- package/build/types-ts3.8/index.d.ts +13 -4
- package/build/types-ts3.8/integration.d.ts +4 -0
- package/build/types-ts3.8/integrations/mcp-server/correlation.d.ts +6 -2
- package/build/types-ts3.8/integrations/mcp-server/sessionManagement.d.ts +8 -2
- package/build/types-ts3.8/integrations/spanStreaming.d.ts +11 -0
- package/build/types-ts3.8/metrics/public-api.d.ts +3 -3
- package/build/types-ts3.8/semanticAttributes.d.ts +38 -0
- package/build/types-ts3.8/spans/captureSpan.d.ts +10 -0
- package/build/types-ts3.8/spans/spanBuffer.d.ts +35 -0
- package/build/types-ts3.8/spans/spanFirstUtils.d.ts +20 -0
- package/build/types-ts3.8/tracing/ai/gen-ai-attributes.d.ts +4 -0
- package/build/types-ts3.8/tracing/sentrySpan.d.ts +10 -1
- package/build/types-ts3.8/tracing/vercel-ai/constants.d.ts +1 -0
- package/build/types-ts3.8/tracing/vercel-ai/utils.d.ts +2 -2
- package/build/types-ts3.8/types-hoist/attributes.d.ts +19 -0
- package/build/types-ts3.8/types-hoist/envelope.d.ts +22 -2
- package/build/types-ts3.8/types-hoist/integration.d.ts +7 -0
- package/build/types-ts3.8/types-hoist/link.d.ts +2 -2
- package/build/types-ts3.8/types-hoist/options.d.ts +18 -2
- package/build/types-ts3.8/types-hoist/span.d.ts +27 -0
- package/build/types-ts3.8/utils/beforeSendSpan.d.ts +22 -0
- package/build/types-ts3.8/utils/envToBool.d.ts +13 -0
- package/build/types-ts3.8/utils/hasSpanStreamingEnabled.d.ts +9 -0
- package/build/types-ts3.8/utils/should-ignore-span.d.ts +3 -3
- package/build/types-ts3.8/utils/spanUtils.d.ts +22 -2
- package/build/types-ts3.8/utils/timer.d.ts +11 -0
- package/build/types-ts3.8/utils/tracePropagationTargets.d.ts +9 -0
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';
|
|
9
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE = 'sentry.span.source';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Attributes that holds the sample rate that was locally applied to a span.
|
|
@@ -66,7 +67,9 @@ const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = 'cache.item_size';
|
|
|
66
67
|
|
|
67
68
|
/** TODO: Remove these once we update to latest semantic conventions */
|
|
68
69
|
const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = 'http.request.method';
|
|
70
|
+
const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_TIME_TO_FIRST_BYTE = 'http.request.time_to_first_byte';
|
|
69
71
|
const SEMANTIC_ATTRIBUTE_URL_FULL = 'url.full';
|
|
72
|
+
const SEMANTIC_ATTRIBUTE_URL_QUERY = 'url.query';
|
|
70
73
|
|
|
71
74
|
/**
|
|
72
75
|
* A span link attribute to mark the link as a special span link.
|
|
@@ -95,22 +98,103 @@ const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = 'sentry.link.type';
|
|
|
95
98
|
*/
|
|
96
99
|
const GEN_AI_CONVERSATION_ID_ATTRIBUTE = 'gen_ai.conversation.id';
|
|
97
100
|
|
|
101
|
+
// some attributes for span streaming, put onto every v2 span:
|
|
102
|
+
// @see https://develop.sentry.dev/sdk/telemetry/spans/span-protocol/#common-attribute-keys
|
|
103
|
+
|
|
104
|
+
/** The release version of the application */
|
|
105
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = 'sentry.release';
|
|
106
|
+
/** The environment name (e.g., "production", "staging", "development") */
|
|
107
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = 'sentry.environment';
|
|
108
|
+
/** The segment name (e.g., "GET /users") */
|
|
109
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = 'sentry.segment.name';
|
|
110
|
+
/** The id of the segment that this span belongs to. */
|
|
111
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = 'sentry.segment.id';
|
|
112
|
+
/** The user ID (gated by sendDefaultPii) */
|
|
113
|
+
const SEMANTIC_ATTRIBUTE_USER_ID = 'user.id';
|
|
114
|
+
/** The user email (gated by sendDefaultPii) */
|
|
115
|
+
const SEMANTIC_ATTRIBUTE_USER_EMAIL = 'user.email';
|
|
116
|
+
/** The user IP address (gated by sendDefaultPii) */
|
|
117
|
+
const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = 'user.ip_address';
|
|
118
|
+
/** The user username (gated by sendDefaultPii) */
|
|
119
|
+
const SEMANTIC_ATTRIBUTE_USER_USERNAME = 'user.name';
|
|
120
|
+
/** The name of the Sentry SDK (e.g., "sentry.php", "sentry.javascript") */
|
|
121
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = 'sentry.sdk.name';
|
|
122
|
+
/** The version of the Sentry SDK */
|
|
123
|
+
const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = 'sentry.sdk.version';
|
|
124
|
+
|
|
125
|
+
// Web vital attributes
|
|
126
|
+
|
|
127
|
+
// LCP
|
|
128
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_VALUE = 'browser.web_vital.lcp.value';
|
|
129
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_ELEMENT = 'browser.web_vital.lcp.element';
|
|
130
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_ID = 'browser.web_vital.lcp.id';
|
|
131
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_URL = 'browser.web_vital.lcp.url';
|
|
132
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_LOAD_TIME = 'browser.web_vital.lcp.load_time';
|
|
133
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_RENDER_TIME = 'browser.web_vital.lcp.render_time';
|
|
134
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_SIZE = 'browser.web_vital.lcp.size';
|
|
135
|
+
|
|
136
|
+
// CLS
|
|
137
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_CLS_VALUE = 'browser.web_vital.cls.value';
|
|
138
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_CLS_SOURCES = 'browser.web_vital.cls.source';
|
|
139
|
+
|
|
140
|
+
// INP
|
|
141
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_INP_VALUE = 'browser.web_vital.inp.value';
|
|
142
|
+
|
|
143
|
+
// TTFB
|
|
144
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_TTFB_VALUE = 'browser.web_vital.ttfb.value';
|
|
145
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_TTFB_REQUEST_TIME = 'browser.web_vital.ttfb.request_time';
|
|
146
|
+
|
|
147
|
+
// FP/FCP
|
|
148
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_FP_VALUE = 'browser.web_vital.fp.value';
|
|
149
|
+
const SEMANTIC_ATTRIBUTE_WEB_VITAL_FCP_VALUE = 'browser.web_vital.fcp.value';
|
|
150
|
+
|
|
151
|
+
// Browser connection information
|
|
152
|
+
const SEMANTIC_ATTRIBUTE_BROWSER_CONNECTION_RTT = 'browser.connection.rtt';
|
|
153
|
+
|
|
98
154
|
exports.GEN_AI_CONVERSATION_ID_ATTRIBUTE = GEN_AI_CONVERSATION_ID_ATTRIBUTE;
|
|
155
|
+
exports.SEMANTIC_ATTRIBUTE_BROWSER_CONNECTION_RTT = SEMANTIC_ATTRIBUTE_BROWSER_CONNECTION_RTT;
|
|
99
156
|
exports.SEMANTIC_ATTRIBUTE_CACHE_HIT = SEMANTIC_ATTRIBUTE_CACHE_HIT;
|
|
100
157
|
exports.SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE;
|
|
101
158
|
exports.SEMANTIC_ATTRIBUTE_CACHE_KEY = SEMANTIC_ATTRIBUTE_CACHE_KEY;
|
|
102
159
|
exports.SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME;
|
|
103
160
|
exports.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD;
|
|
161
|
+
exports.SEMANTIC_ATTRIBUTE_HTTP_REQUEST_TIME_TO_FIRST_BYTE = SEMANTIC_ATTRIBUTE_HTTP_REQUEST_TIME_TO_FIRST_BYTE;
|
|
104
162
|
exports.SEMANTIC_ATTRIBUTE_PROFILE_ID = SEMANTIC_ATTRIBUTE_PROFILE_ID;
|
|
105
163
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME;
|
|
164
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT;
|
|
106
165
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON;
|
|
107
166
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT;
|
|
108
167
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE;
|
|
109
168
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = SEMANTIC_ATTRIBUTE_SENTRY_OP;
|
|
110
169
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN;
|
|
111
170
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE;
|
|
171
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = SEMANTIC_ATTRIBUTE_SENTRY_RELEASE;
|
|
112
172
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE;
|
|
173
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME;
|
|
174
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION;
|
|
175
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID;
|
|
176
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME;
|
|
113
177
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = SEMANTIC_ATTRIBUTE_SENTRY_SOURCE;
|
|
178
|
+
exports.SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE = SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE;
|
|
114
179
|
exports.SEMANTIC_ATTRIBUTE_URL_FULL = SEMANTIC_ATTRIBUTE_URL_FULL;
|
|
180
|
+
exports.SEMANTIC_ATTRIBUTE_URL_QUERY = SEMANTIC_ATTRIBUTE_URL_QUERY;
|
|
181
|
+
exports.SEMANTIC_ATTRIBUTE_USER_EMAIL = SEMANTIC_ATTRIBUTE_USER_EMAIL;
|
|
182
|
+
exports.SEMANTIC_ATTRIBUTE_USER_ID = SEMANTIC_ATTRIBUTE_USER_ID;
|
|
183
|
+
exports.SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS;
|
|
184
|
+
exports.SEMANTIC_ATTRIBUTE_USER_USERNAME = SEMANTIC_ATTRIBUTE_USER_USERNAME;
|
|
185
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_CLS_SOURCES = SEMANTIC_ATTRIBUTE_WEB_VITAL_CLS_SOURCES;
|
|
186
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_CLS_VALUE = SEMANTIC_ATTRIBUTE_WEB_VITAL_CLS_VALUE;
|
|
187
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_FCP_VALUE = SEMANTIC_ATTRIBUTE_WEB_VITAL_FCP_VALUE;
|
|
188
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_FP_VALUE = SEMANTIC_ATTRIBUTE_WEB_VITAL_FP_VALUE;
|
|
189
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_INP_VALUE = SEMANTIC_ATTRIBUTE_WEB_VITAL_INP_VALUE;
|
|
190
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_ELEMENT = SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_ELEMENT;
|
|
191
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_ID = SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_ID;
|
|
192
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_LOAD_TIME = SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_LOAD_TIME;
|
|
193
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_RENDER_TIME = SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_RENDER_TIME;
|
|
194
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_SIZE = SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_SIZE;
|
|
195
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_URL = SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_URL;
|
|
196
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_VALUE = SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_VALUE;
|
|
197
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_TTFB_REQUEST_TIME = SEMANTIC_ATTRIBUTE_WEB_VITAL_TTFB_REQUEST_TIME;
|
|
198
|
+
exports.SEMANTIC_ATTRIBUTE_WEB_VITAL_TTFB_VALUE = SEMANTIC_ATTRIBUTE_WEB_VITAL_TTFB_VALUE;
|
|
115
199
|
exports.SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE;
|
|
116
200
|
//# sourceMappingURL=semanticAttributes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semanticAttributes.js","sources":["../../src/semanticAttributes.ts"],"sourcesContent":["/**\n * Use this attribute to represent the source of a span.\n * Should be one of: custom, url, route, view, component, task, unknown\n *\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';\n\n/**\n * Attributes that holds the sample rate that was locally applied to a span.\n * If this attribute is not defined, it means that the span inherited a sampling decision.\n *\n * NOTE: Is only defined on root spans.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = 'sentry.sample_rate';\n\n/**\n * Attribute holding the sample rate of the previous trace.\n * This is used to sample consistently across subsequent traces in the browser SDK.\n *\n * Note: Only defined on root spans, if opted into consistent sampling\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = 'sentry.previous_trace_sample_rate';\n\n/**\n * Use this attribute to represent the operation of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_OP = 'sentry.op';\n\n/**\n * Use this attribute to represent the origin of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin';\n\n/** The reason why an idle span finished. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = 'sentry.idle_span_finish_reason';\n\n/** The unit of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = 'sentry.measurement_unit';\n\n/** The value of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = 'sentry.measurement_value';\n\n/**\n * A custom span name set by users guaranteed to be taken over any automatically\n * inferred name. This attribute is removed before the span is sent.\n *\n * @internal only meant for internal SDK usage\n * @hidden\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = 'sentry.custom_span_name';\n\n/**\n * The id of the profile that this span occurred in.\n */\nexport const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'sentry.profile_id';\n\nexport const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = 'sentry.exclusive_time';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_HIT = 'cache.hit';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = 'cache.item_size';\n\n/** TODO: Remove these once we update to latest semantic conventions */\nexport const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = 'http.request.method';\nexport const SEMANTIC_ATTRIBUTE_URL_FULL = 'url.full';\n\n/**\n * A span link attribute to mark the link as a special span link.\n *\n * Known values:\n * - `previous_trace`: The span links to the frontend root span of the previous trace.\n * - `next_trace`: The span links to the frontend root span of the next trace. (Not set by the SDK)\n *\n * Other values may be set as appropriate.\n * @see https://develop.sentry.dev/sdk/telemetry/traces/span-links/#link-types\n */\nexport const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = 'sentry.link.type';\n\n/**\n * =============================================================================\n * GEN AI ATTRIBUTES\n * Based on OpenTelemetry Semantic Conventions for Generative AI\n * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/\n * =============================================================================\n */\n\n/**\n * The conversation ID for linking messages across API calls.\n * For OpenAI Assistants API: thread_id\n * For LangGraph: configurable.thread_id\n */\nexport const GEN_AI_CONVERSATION_ID_ATTRIBUTE = 'gen_ai.conversation.id';\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACO,MAAM,gCAAA,GAAmC;;
|
|
1
|
+
{"version":3,"file":"semanticAttributes.js","sources":["../../src/semanticAttributes.ts"],"sourcesContent":["/**\n * Use this attribute to represent the source of a span.\n * Should be one of: custom, url, route, view, component, task, unknown\n *\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE = 'sentry.span.source';\n\n/**\n * Attributes that holds the sample rate that was locally applied to a span.\n * If this attribute is not defined, it means that the span inherited a sampling decision.\n *\n * NOTE: Is only defined on root spans.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = 'sentry.sample_rate';\n\n/**\n * Attribute holding the sample rate of the previous trace.\n * This is used to sample consistently across subsequent traces in the browser SDK.\n *\n * Note: Only defined on root spans, if opted into consistent sampling\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = 'sentry.previous_trace_sample_rate';\n\n/**\n * Use this attribute to represent the operation of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_OP = 'sentry.op';\n\n/**\n * Use this attribute to represent the origin of a span.\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin';\n\n/** The reason why an idle span finished. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = 'sentry.idle_span_finish_reason';\n\n/** The unit of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = 'sentry.measurement_unit';\n\n/** The value of a measurement, which may be stored as a TimedEvent. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = 'sentry.measurement_value';\n\n/**\n * A custom span name set by users guaranteed to be taken over any automatically\n * inferred name. This attribute is removed before the span is sent.\n *\n * @internal only meant for internal SDK usage\n * @hidden\n */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME = 'sentry.custom_span_name';\n\n/**\n * The id of the profile that this span occurred in.\n */\nexport const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'sentry.profile_id';\n\nexport const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = 'sentry.exclusive_time';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_HIT = 'cache.hit';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key';\n\nexport const SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE = 'cache.item_size';\n\n/** TODO: Remove these once we update to latest semantic conventions */\nexport const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD = 'http.request.method';\nexport const SEMANTIC_ATTRIBUTE_HTTP_REQUEST_TIME_TO_FIRST_BYTE = 'http.request.time_to_first_byte';\nexport const SEMANTIC_ATTRIBUTE_URL_FULL = 'url.full';\nexport const SEMANTIC_ATTRIBUTE_URL_QUERY = 'url.query';\n\n/**\n * A span link attribute to mark the link as a special span link.\n *\n * Known values:\n * - `previous_trace`: The span links to the frontend root span of the previous trace.\n * - `next_trace`: The span links to the frontend root span of the next trace. (Not set by the SDK)\n *\n * Other values may be set as appropriate.\n * @see https://develop.sentry.dev/sdk/telemetry/traces/span-links/#link-types\n */\nexport const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = 'sentry.link.type';\n\n/**\n * =============================================================================\n * GEN AI ATTRIBUTES\n * Based on OpenTelemetry Semantic Conventions for Generative AI\n * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/\n * =============================================================================\n */\n\n/**\n * The conversation ID for linking messages across API calls.\n * For OpenAI Assistants API: thread_id\n * For LangGraph: configurable.thread_id\n */\nexport const GEN_AI_CONVERSATION_ID_ATTRIBUTE = 'gen_ai.conversation.id';\n\n// some attributes for span streaming, put onto every v2 span:\n// @see https://develop.sentry.dev/sdk/telemetry/spans/span-protocol/#common-attribute-keys\n\n/** The release version of the application */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = 'sentry.release';\n/** The environment name (e.g., \"production\", \"staging\", \"development\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = 'sentry.environment';\n/** The segment name (e.g., \"GET /users\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = 'sentry.segment.name';\n/** The id of the segment that this span belongs to. */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = 'sentry.segment.id';\n/** The user ID (gated by sendDefaultPii) */\nexport const SEMANTIC_ATTRIBUTE_USER_ID = 'user.id';\n/** The user email (gated by sendDefaultPii) */\nexport const SEMANTIC_ATTRIBUTE_USER_EMAIL = 'user.email';\n/** The user IP address (gated by sendDefaultPii) */\nexport const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = 'user.ip_address';\n/** The user username (gated by sendDefaultPii) */\nexport const SEMANTIC_ATTRIBUTE_USER_USERNAME = 'user.name';\n/** The name of the Sentry SDK (e.g., \"sentry.php\", \"sentry.javascript\") */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = 'sentry.sdk.name';\n/** The version of the Sentry SDK */\nexport const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = 'sentry.sdk.version';\n\n// Web vital attributes\n\n// LCP\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_VALUE = 'browser.web_vital.lcp.value';\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_ELEMENT = 'browser.web_vital.lcp.element';\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_ID = 'browser.web_vital.lcp.id';\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_URL = 'browser.web_vital.lcp.url';\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_LOAD_TIME = 'browser.web_vital.lcp.load_time';\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_RENDER_TIME = 'browser.web_vital.lcp.render_time';\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_LCP_SIZE = 'browser.web_vital.lcp.size';\n\n// CLS\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_CLS_VALUE = 'browser.web_vital.cls.value';\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_CLS_SOURCES = 'browser.web_vital.cls.source';\n\n// INP\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_INP_VALUE = 'browser.web_vital.inp.value';\n\n// TTFB\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_TTFB_VALUE = 'browser.web_vital.ttfb.value';\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_TTFB_REQUEST_TIME = 'browser.web_vital.ttfb.request_time';\n\n// FP/FCP\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_FP_VALUE = 'browser.web_vital.fp.value';\nexport const SEMANTIC_ATTRIBUTE_WEB_VITAL_FCP_VALUE = 'browser.web_vital.fcp.value';\n\n// Browser connection information\nexport const SEMANTIC_ATTRIBUTE_BROWSER_CONNECTION_RTT = 'browser.connection.rtt';\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACO,MAAM,gCAAA,GAAmC;AACzC,MAAM,qCAAA,GAAwC;;AAErD;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,qCAAA,GAAwC;;AAErD;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,oDAAA,GAAuD;;AAEpE;AACA;AACA;AACO,MAAM,4BAAA,GAA+B;;AAE5C;AACA;AACA;AACO,MAAM,gCAAA,GAAmC;;AAEhD;AACO,MAAM,iDAAA,GAAoD;;AAEjE;AACO,MAAM,0CAAA,GAA6C;;AAE1D;AACO,MAAM,2CAAA,GAA8C;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,0CAAA,GAA6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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const currentScopes = require('../currentScopes.js');
|
|
4
|
+
const debugBuild = require('../debug-build.js');
|
|
5
|
+
const semanticAttributes = require('../semanticAttributes.js');
|
|
6
|
+
const utils = require('../tracing/utils.js');
|
|
7
|
+
const beforeSendSpan = require('../utils/beforeSendSpan.js');
|
|
8
|
+
const debugLogger = require('../utils/debug-logger.js');
|
|
9
|
+
const scopeData = require('../utils/scopeData.js');
|
|
10
|
+
const spanUtils = require('../utils/spanUtils.js');
|
|
11
|
+
const spanFirstUtils = require('./spanFirstUtils.js');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Captures a span and returns a JSON representation to be enqueued for sending.
|
|
15
|
+
*
|
|
16
|
+
* IMPORTANT: This function converts the span to JSON immediately to avoid writing
|
|
17
|
+
* to an already-ended OTel span instance (which is blocked by the OTel Span class).
|
|
18
|
+
*/
|
|
19
|
+
function captureSpan(span, client = currentScopes.getClient()) {
|
|
20
|
+
if (!client) {
|
|
21
|
+
debugBuild.DEBUG_BUILD && debugLogger.debug.warn('No client available to capture span.');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Convert to JSON FIRST - we cannot write to an already-ended span
|
|
26
|
+
const spanJSON = spanUtils.spanToV2JSON(span);
|
|
27
|
+
|
|
28
|
+
const segmentSpan = spanUtils.INTERNAL_getSegmentSpan(span);
|
|
29
|
+
const serializedSegmentSpan = spanUtils.spanToV2JSON(segmentSpan);
|
|
30
|
+
|
|
31
|
+
const { isolationScope: spanIsolationScope, scope: spanScope } = utils.getCapturedScopesOnSpan(span);
|
|
32
|
+
|
|
33
|
+
const finalScopeData = scopeData.getCombinedScopeData(spanIsolationScope, spanScope);
|
|
34
|
+
|
|
35
|
+
applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);
|
|
36
|
+
|
|
37
|
+
if (span === segmentSpan) {
|
|
38
|
+
applyScopeToSegmentSpan(spanJSON, finalScopeData);
|
|
39
|
+
client.emit('processSegmentSpan', spanJSON, { scopeData: finalScopeData });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Allow integrations to add additional data to the span JSON
|
|
43
|
+
client.emit('processSpan', spanJSON, { readOnlySpan: span });
|
|
44
|
+
|
|
45
|
+
const beforeSendSpan$1 = client.getOptions().beforeSendSpan;
|
|
46
|
+
const processedSpan = beforeSendSpan.isV2BeforeSendSpanCallback(beforeSendSpan$1)
|
|
47
|
+
? spanFirstUtils.applyBeforeSendSpanCallback(spanJSON, beforeSendSpan$1)
|
|
48
|
+
: spanJSON;
|
|
49
|
+
|
|
50
|
+
// Backfill sentry.span.source from sentry.source for the PoC
|
|
51
|
+
// TODO(v11): Stop sending `sentry.source` attribute and only send `sentry.span.source`
|
|
52
|
+
// probably easiest done by just renaming SEMANTIC_ATTRIBUTE_SENTRY_SOURCE
|
|
53
|
+
if (processedSpan.attributes?.[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]) {
|
|
54
|
+
spanFirstUtils.safeSetSpanJSONAttributes(processedSpan, {
|
|
55
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE]: processedSpan.attributes?.[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]?.value,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const spanWithRef = {
|
|
60
|
+
...processedSpan,
|
|
61
|
+
_segmentSpan: segmentSpan,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
client.emit('enqueueSpan', spanWithRef);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function applyScopeToSegmentSpan(segmentSpanJSON, scopeData) {
|
|
68
|
+
// TODO: Apply all scope and request data from auto instrumentation (contexts, request) to segment span
|
|
69
|
+
const { contexts } = scopeData;
|
|
70
|
+
|
|
71
|
+
spanFirstUtils.safeSetSpanJSONAttributes(segmentSpanJSON, spanFirstUtils.contextsToAttributes(contexts));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function applyCommonSpanAttributes(
|
|
75
|
+
spanJSON,
|
|
76
|
+
serializedSegmentSpan,
|
|
77
|
+
client,
|
|
78
|
+
scopeData,
|
|
79
|
+
) {
|
|
80
|
+
const sdk = client.getSdkMetadata();
|
|
81
|
+
const { release, environment, sendDefaultPii } = client.getOptions();
|
|
82
|
+
|
|
83
|
+
// avoid overwriting any previously set attributes (from users or potentially our SDK instrumentation)
|
|
84
|
+
spanFirstUtils.safeSetSpanJSONAttributes(spanJSON, {
|
|
85
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,
|
|
86
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment,
|
|
87
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME]: serializedSegmentSpan.name,
|
|
88
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: serializedSegmentSpan.span_id,
|
|
89
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: sdk?.sdk?.name,
|
|
90
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: sdk?.sdk?.version,
|
|
91
|
+
...(sendDefaultPii
|
|
92
|
+
? {
|
|
93
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,
|
|
94
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_USER_EMAIL]: scopeData.user?.email,
|
|
95
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: scopeData.user?.ip_address,
|
|
96
|
+
[semanticAttributes.SEMANTIC_ATTRIBUTE_USER_USERNAME]: scopeData.user?.username,
|
|
97
|
+
}
|
|
98
|
+
: {}),
|
|
99
|
+
...scopeData.attributes,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
exports.captureSpan = captureSpan;
|
|
104
|
+
//# sourceMappingURL=captureSpan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"captureSpan.js","sources":["../../../src/spans/captureSpan.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { ScopeData } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT,\n SEMANTIC_ATTRIBUTE_SENTRY_RELEASE,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE,\n SEMANTIC_ATTRIBUTE_USER_EMAIL,\n SEMANTIC_ATTRIBUTE_USER_ID,\n SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,\n SEMANTIC_ATTRIBUTE_USER_USERNAME,\n} from '../semanticAttributes';\nimport { getCapturedScopesOnSpan } from '../tracing/utils';\nimport type { Span, SpanV2JSON } from '../types-hoist/span';\nimport { isV2BeforeSendSpanCallback } from '../utils/beforeSendSpan';\nimport { debug } from '../utils/debug-logger';\nimport { getCombinedScopeData } from '../utils/scopeData';\nimport { INTERNAL_getSegmentSpan, spanToV2JSON } from '../utils/spanUtils';\nimport { applyBeforeSendSpanCallback, contextsToAttributes, safeSetSpanJSONAttributes } from './spanFirstUtils';\n/**\n * Captures a span and returns a JSON representation to be enqueued for sending.\n *\n * IMPORTANT: This function converts the span to JSON immediately to avoid writing\n * to an already-ended OTel span instance (which is blocked by the OTel Span class).\n */\nexport function captureSpan(span: Span, client = getClient()): void {\n if (!client) {\n DEBUG_BUILD && debug.warn('No client available to capture span.');\n return;\n }\n\n // Convert to JSON FIRST - we cannot write to an already-ended span\n const spanJSON = spanToV2JSON(span);\n\n const segmentSpan = INTERNAL_getSegmentSpan(span);\n const serializedSegmentSpan = spanToV2JSON(segmentSpan);\n\n const { isolationScope: spanIsolationScope, scope: spanScope } = getCapturedScopesOnSpan(span);\n\n const finalScopeData = getCombinedScopeData(spanIsolationScope, spanScope);\n\n applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);\n\n if (span === segmentSpan) {\n applyScopeToSegmentSpan(spanJSON, finalScopeData);\n client.emit('processSegmentSpan', spanJSON, { scopeData: finalScopeData });\n }\n\n // Allow integrations to add additional data to the span JSON\n client.emit('processSpan', spanJSON, { readOnlySpan: span });\n\n const beforeSendSpan = client.getOptions().beforeSendSpan;\n const processedSpan = isV2BeforeSendSpanCallback(beforeSendSpan)\n ? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)\n : spanJSON;\n\n // Backfill sentry.span.source from sentry.source for the PoC\n // TODO(v11): Stop sending `sentry.source` attribute and only send `sentry.span.source`\n // probably easiest done by just renaming SEMANTIC_ATTRIBUTE_SENTRY_SOURCE\n if (processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]) {\n safeSetSpanJSONAttributes(processedSpan, {\n [SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE]: processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]?.value,\n });\n }\n\n const spanWithRef = {\n ...processedSpan,\n _segmentSpan: segmentSpan,\n };\n\n client.emit('enqueueSpan', spanWithRef);\n}\n\nfunction applyScopeToSegmentSpan(segmentSpanJSON: SpanV2JSON, scopeData: ScopeData): void {\n // TODO: Apply all scope and request data from auto instrumentation (contexts, request) to segment span\n const { contexts } = scopeData;\n\n safeSetSpanJSONAttributes(segmentSpanJSON, contextsToAttributes(contexts));\n}\n\nfunction applyCommonSpanAttributes(\n spanJSON: SpanV2JSON,\n serializedSegmentSpan: SpanV2JSON,\n client: Client,\n scopeData: ScopeData,\n): void {\n const sdk = client.getSdkMetadata();\n const { release, environment, sendDefaultPii } = client.getOptions();\n\n // avoid overwriting any previously set attributes (from users or potentially our SDK instrumentation)\n safeSetSpanJSONAttributes(spanJSON, {\n [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,\n [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME]: serializedSegmentSpan.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: serializedSegmentSpan.span_id,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: sdk?.sdk?.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: sdk?.sdk?.version,\n ...(sendDefaultPii\n ? {\n [SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,\n [SEMANTIC_ATTRIBUTE_USER_EMAIL]: scopeData.user?.email,\n [SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: scopeData.user?.ip_address,\n [SEMANTIC_ATTRIBUTE_USER_USERNAME]: scopeData.user?.username,\n }\n : {}),\n ...scopeData.attributes,\n });\n}\n"],"names":["getClient","DEBUG_BUILD","debug","spanToV2JSON","INTERNAL_getSegmentSpan","getCapturedScopesOnSpan","getCombinedScopeData","beforeSendSpan","isV2BeforeSendSpanCallback","applyBeforeSendSpanCallback","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","safeSetSpanJSONAttributes","SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE","contextsToAttributes","SEMANTIC_ATTRIBUTE_SENTRY_RELEASE","SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT","SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME","SEMANTIC_AT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oC,GAAG,qBAAqB,CAAC,OAAO;AACzE,IAAI,CAACC,qDAAkC,GAAG,GAAG,EAAE,GAAG,EAAE,IAAI;AACxD,IAAI,CAACC,wDAAqC,GAAG,GAAG,EAAE,GAAG,EAAE,OAAO;AAC9D,IAAI,IAAI;AACR,QAAQ;AACR,UAAU,CAACC,6CAA0B,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE;AAC1D,UAAU,CAACC,gDAA6B,GAAG,SAAS,CAAC,IAAI,EAAE,KAAK;AAChE,UAAU,CAACC,qDAAkC,GAAG,SAAS,CAAC,IAAI,EAAE,UAAU;AAC1E,UAAU,CAACC,mDAAgC,GAAG,SAAS,CAAC,IAAI,EAAE,QAAQ;AACtE;AACA,QAAQ,EAAE,CAAC;AACX,IAAI,GAAG,SAAS,CAAC,UAAU;AAC3B,GAAG,CAAC;AACJ;;;;"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const debugBuild = require('../debug-build.js');
|
|
4
|
+
const envelope = require('../envelope.js');
|
|
5
|
+
const dynamicSamplingContext = require('../tracing/dynamicSamplingContext.js');
|
|
6
|
+
const debugLogger = require('../utils/debug-logger.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A buffer for span JSON objects that flushes them to Sentry in Span v2 envelopes.
|
|
10
|
+
* Handles interval-based flushing, size thresholds, and graceful shutdown.
|
|
11
|
+
*/
|
|
12
|
+
class SpanBuffer {
|
|
13
|
+
|
|
14
|
+
constructor(client, options) {
|
|
15
|
+
this._spanTreeMap = new Map();
|
|
16
|
+
this._client = client;
|
|
17
|
+
|
|
18
|
+
const { maxSpanLimit, flushInterval } = options ?? {};
|
|
19
|
+
|
|
20
|
+
this._maxSpanLimit = maxSpanLimit && maxSpanLimit > 0 && maxSpanLimit <= 1000 ? maxSpanLimit : 1000;
|
|
21
|
+
this._flushInterval = flushInterval && flushInterval > 0 ? flushInterval : 5000;
|
|
22
|
+
|
|
23
|
+
this._flushIntervalId = setInterval(() => {
|
|
24
|
+
this.flush();
|
|
25
|
+
}, this._flushInterval);
|
|
26
|
+
|
|
27
|
+
this._client.on('flush', () => {
|
|
28
|
+
this.flush();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Add a span to the buffer.
|
|
34
|
+
*/
|
|
35
|
+
addSpan(spanJSON) {
|
|
36
|
+
const traceId = spanJSON.trace_id;
|
|
37
|
+
let traceBucket = this._spanTreeMap.get(traceId);
|
|
38
|
+
if (traceBucket) {
|
|
39
|
+
traceBucket.add(spanJSON);
|
|
40
|
+
} else {
|
|
41
|
+
traceBucket = new Set([spanJSON]);
|
|
42
|
+
this._spanTreeMap.set(traceId, traceBucket);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (traceBucket.size >= this._maxSpanLimit) {
|
|
46
|
+
this.flushTrace(traceId);
|
|
47
|
+
this._debounceFlushInterval();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Flush all buffered traces.
|
|
53
|
+
*/
|
|
54
|
+
flush() {
|
|
55
|
+
if (!this._spanTreeMap.size) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
debugBuild.DEBUG_BUILD && debugLogger.debug.log(`Flushing span tree map with ${this._spanTreeMap.size} traces`);
|
|
60
|
+
|
|
61
|
+
this._spanTreeMap.forEach((_, traceId) => {
|
|
62
|
+
this.flushTrace(traceId);
|
|
63
|
+
});
|
|
64
|
+
this._debounceFlushInterval();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Flush spans of a specific trace.
|
|
69
|
+
* In contrast to {@link SpanBuffer.flush}, this method does not flush all traces, but only the one with the given traceId.
|
|
70
|
+
*/
|
|
71
|
+
flushTrace(traceId) {
|
|
72
|
+
const traceBucket = this._spanTreeMap.get(traceId);
|
|
73
|
+
if (!traceBucket) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!traceBucket.size) {
|
|
78
|
+
this._spanTreeMap.delete(traceId);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const firstSpanJSON = traceBucket.values().next().value;
|
|
83
|
+
|
|
84
|
+
const segmentSpan = firstSpanJSON?._segmentSpan;
|
|
85
|
+
if (!segmentSpan) {
|
|
86
|
+
debugBuild.DEBUG_BUILD && debugLogger.debug.warn('No segment span reference found on span JSON, cannot compute DSC');
|
|
87
|
+
this._spanTreeMap.delete(traceId);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const dsc = dynamicSamplingContext.getDynamicSamplingContextFromSpan(segmentSpan);
|
|
92
|
+
|
|
93
|
+
const cleanedSpans = Array.from(traceBucket).map(spanJSON => {
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
95
|
+
const { _segmentSpan, ...cleanSpanJSON } = spanJSON;
|
|
96
|
+
return cleanSpanJSON;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const envelope$1 = envelope.createSpanV2Envelope(cleanedSpans, dsc, this._client);
|
|
100
|
+
|
|
101
|
+
debugBuild.DEBUG_BUILD && debugLogger.debug.log(`Sending span envelope for trace ${traceId} with ${cleanedSpans.length} spans`);
|
|
102
|
+
|
|
103
|
+
this._client.sendEnvelope(envelope$1).then(null, reason => {
|
|
104
|
+
debugBuild.DEBUG_BUILD && debugLogger.debug.error('Error while sending span stream envelope:', reason);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
this._spanTreeMap.delete(traceId);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_debounceFlushInterval() {
|
|
111
|
+
if (this._flushIntervalId) {
|
|
112
|
+
clearInterval(this._flushIntervalId);
|
|
113
|
+
}
|
|
114
|
+
this._flushIntervalId = setInterval(() => {
|
|
115
|
+
this.flush();
|
|
116
|
+
}, this._flushInterval);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
exports.SpanBuffer = SpanBuffer;
|
|
121
|
+
//# sourceMappingURL=spanBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spanBuffer.js","sources":["../../../src/spans/spanBuffer.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { createSpanV2Envelope } from '../envelope';\nimport { getDynamicSamplingContextFromSpan } from '../tracing/dynamicSamplingContext';\nimport type { SpanV2JSON, SpanV2JSONWithSegmentRef } from '../types-hoist/span';\nimport { debug } from '../utils/debug-logger';\n\nexport interface SpanBufferOptions {\n /** Max spans per trace before auto-flush (default: 1000) */\n maxSpanLimit?: number;\n /** Flush interval in ms (default: 5000) */\n flushInterval?: number;\n}\n\n/**\n * A buffer for span JSON objects that flushes them to Sentry in Span v2 envelopes.\n * Handles interval-based flushing, size thresholds, and graceful shutdown.\n */\nexport class SpanBuffer {\n private _spanTreeMap: Map<string, Set<SpanV2JSONWithSegmentRef>>;\n private _flushIntervalId: ReturnType<typeof setInterval> | null;\n private _client: Client;\n private _maxSpanLimit: number;\n private _flushInterval: number;\n\n public constructor(client: Client, options?: SpanBufferOptions) {\n this._spanTreeMap = new Map();\n this._client = client;\n\n const { maxSpanLimit, flushInterval } = options ?? {};\n\n this._maxSpanLimit = maxSpanLimit && maxSpanLimit > 0 && maxSpanLimit <= 1000 ? maxSpanLimit : 1000;\n this._flushInterval = flushInterval && flushInterval > 0 ? flushInterval : 5_000;\n\n this._flushIntervalId = setInterval(() => {\n this.flush();\n }, this._flushInterval);\n\n this._client.on('flush', () => {\n this.flush();\n });\n }\n\n /**\n * Add a span to the buffer.\n */\n public addSpan(spanJSON: SpanV2JSONWithSegmentRef): void {\n const traceId = spanJSON.trace_id;\n let traceBucket = this._spanTreeMap.get(traceId);\n if (traceBucket) {\n traceBucket.add(spanJSON);\n } else {\n traceBucket = new Set([spanJSON]);\n this._spanTreeMap.set(traceId, traceBucket);\n }\n\n if (traceBucket.size >= this._maxSpanLimit) {\n this.flushTrace(traceId);\n this._debounceFlushInterval();\n }\n }\n\n /**\n * Flush all buffered traces.\n */\n public flush(): void {\n if (!this._spanTreeMap.size) {\n return;\n }\n\n DEBUG_BUILD && debug.log(`Flushing span tree map with ${this._spanTreeMap.size} traces`);\n\n this._spanTreeMap.forEach((_, traceId) => {\n this.flushTrace(traceId);\n });\n this._debounceFlushInterval();\n }\n\n /**\n * Flush spans of a specific trace.\n * In contrast to {@link SpanBuffer.flush}, this method does not flush all traces, but only the one with the given traceId.\n */\n public flushTrace(traceId: string): void {\n const traceBucket = this._spanTreeMap.get(traceId);\n if (!traceBucket) {\n return;\n }\n\n if (!traceBucket.size) {\n this._spanTreeMap.delete(traceId);\n return;\n }\n\n const firstSpanJSON = traceBucket.values().next().value;\n\n const segmentSpan = firstSpanJSON?._segmentSpan;\n if (!segmentSpan) {\n DEBUG_BUILD && debug.warn('No segment span reference found on span JSON, cannot compute DSC');\n this._spanTreeMap.delete(traceId);\n return;\n }\n\n const dsc = getDynamicSamplingContextFromSpan(segmentSpan);\n\n const cleanedSpans: SpanV2JSON[] = Array.from(traceBucket).map(spanJSON => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { _segmentSpan, ...cleanSpanJSON } = spanJSON;\n return cleanSpanJSON;\n });\n\n const envelope = createSpanV2Envelope(cleanedSpans, dsc, this._client);\n\n DEBUG_BUILD && debug.log(`Sending span envelope for trace ${traceId} with ${cleanedSpans.length} spans`);\n\n this._client.sendEnvelope(envelope).then(null, reason => {\n DEBUG_BUILD && debug.error('Error while sending span stream envelope:', reason);\n });\n\n this._spanTreeMap.delete(traceId);\n }\n\n private _debounceFlushInterval(): void {\n if (this._flushIntervalId) {\n clearInterval(this._flushIntervalId);\n }\n this._flushIntervalId = setInterval(() => {\n this.flush();\n }, this._flushInterval);\n }\n}\n"],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Tag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const attributes = require('../attributes.js');
|
|
4
|
+
const is = require('../utils/is.js');
|
|
5
|
+
const spanUtils = require('../utils/spanUtils.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Only set a span JSON attribute if it is not already set.
|
|
9
|
+
* This is used to safely set attributes on JSON objects without mutating already-ended span instances.
|
|
10
|
+
*/
|
|
11
|
+
function safeSetSpanJSONAttributes(
|
|
12
|
+
spanJSON,
|
|
13
|
+
newAttributes,
|
|
14
|
+
) {
|
|
15
|
+
if (!spanJSON.attributes) {
|
|
16
|
+
spanJSON.attributes = {};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const originalAttributes = spanJSON.attributes;
|
|
20
|
+
|
|
21
|
+
Object.keys(newAttributes).forEach(key => {
|
|
22
|
+
if (!originalAttributes?.[key]) {
|
|
23
|
+
setAttributeOnSpanJSONWithMaybeUnit(
|
|
24
|
+
// type-casting here because we ensured above that the attributes object exists
|
|
25
|
+
spanJSON ,
|
|
26
|
+
key,
|
|
27
|
+
newAttributes[key],
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Apply a user-provided beforeSendSpan callback to a span JSON.
|
|
35
|
+
*/
|
|
36
|
+
function applyBeforeSendSpanCallback(
|
|
37
|
+
span,
|
|
38
|
+
beforeSendSpan,
|
|
39
|
+
) {
|
|
40
|
+
const modifedSpan = beforeSendSpan(span);
|
|
41
|
+
if (!modifedSpan) {
|
|
42
|
+
spanUtils.showSpanDropWarning();
|
|
43
|
+
return span;
|
|
44
|
+
}
|
|
45
|
+
return modifedSpan;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function setAttributeOnSpanJSONWithMaybeUnit(
|
|
49
|
+
spanJSON,
|
|
50
|
+
attributeKey,
|
|
51
|
+
attributeValue,
|
|
52
|
+
) {
|
|
53
|
+
const { value, unit } = attributes.isAttributeObject(attributeValue)
|
|
54
|
+
? attributeValue
|
|
55
|
+
: { value: attributeValue, unit: undefined };
|
|
56
|
+
const typedAttributeValue = attributes.attributeValueToTypedAttributeValue(value);
|
|
57
|
+
|
|
58
|
+
if (typedAttributeValue && isSupportedSerializableType(value)) {
|
|
59
|
+
spanJSON.attributes[attributeKey] = typedAttributeValue;
|
|
60
|
+
if (unit) {
|
|
61
|
+
spanJSON.attributes[attributeKey].unit = unit;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function isSupportedSerializableType(value) {
|
|
67
|
+
return ['string', 'number', 'boolean'].includes(typeof value) || Array.isArray(value);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// map of attributes->context keys for those attributes that don't correspond 1:1 to the context key
|
|
71
|
+
const explicitAttributeToContextMapping = {
|
|
72
|
+
'os.build_id': 'os.build',
|
|
73
|
+
'app.name': 'app.app_name',
|
|
74
|
+
'app.identifier': 'app.app_identifier',
|
|
75
|
+
'app.version': 'app.app_version',
|
|
76
|
+
'app.memory': 'app.app_memory',
|
|
77
|
+
'app.start_time': 'app.app_start_time',
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const knownContexts = [
|
|
81
|
+
// set by `nodeContextIntegration`
|
|
82
|
+
'app',
|
|
83
|
+
'os',
|
|
84
|
+
'device',
|
|
85
|
+
'culture',
|
|
86
|
+
'cloud_resource',
|
|
87
|
+
'runtime',
|
|
88
|
+
|
|
89
|
+
// TODO: These need more thorough checking if they're all setting expected attributes
|
|
90
|
+
|
|
91
|
+
// set by the `instrumentPostgresJs`
|
|
92
|
+
'postgresjsConnection',
|
|
93
|
+
// set by `ensureIsWrapped`
|
|
94
|
+
'missing_instrumentation',
|
|
95
|
+
// set by `nodeProfilingIntegration`
|
|
96
|
+
'profile',
|
|
97
|
+
// set by angular `init`
|
|
98
|
+
'angular',
|
|
99
|
+
// set by AWS Lambda SDK
|
|
100
|
+
'aws.lambda',
|
|
101
|
+
'aws.cloudwatch.logs',
|
|
102
|
+
// set by `instrumentBunServe`
|
|
103
|
+
'response',
|
|
104
|
+
// set by `trpcMiddleware`
|
|
105
|
+
'trpc',
|
|
106
|
+
// set by `instrumentSupabaseClient`
|
|
107
|
+
'supabase',
|
|
108
|
+
// set by `gcp.function.context`
|
|
109
|
+
'gcp.function.context',
|
|
110
|
+
// set by nextjs SDK
|
|
111
|
+
'nextjs',
|
|
112
|
+
// set by react SDK `captureReactException`, `init`
|
|
113
|
+
'react',
|
|
114
|
+
// set by react SDK `createReduxEnhancer`
|
|
115
|
+
'state',
|
|
116
|
+
// set by `replayIntegration`
|
|
117
|
+
'Replays',
|
|
118
|
+
// Other information:
|
|
119
|
+
// - no need to handler feature flags `flags` context because it's already added to the active span
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Converts a context object to a set of attributes.
|
|
124
|
+
* Only includes attributes that are primitives (for now).
|
|
125
|
+
* @param contexts - The context object to convert.
|
|
126
|
+
* @returns The attributes object.
|
|
127
|
+
*/
|
|
128
|
+
function contextsToAttributes(contexts) {
|
|
129
|
+
function contextToAttribute(context) {
|
|
130
|
+
return Object.keys(context).reduce(
|
|
131
|
+
(acc, key) => {
|
|
132
|
+
if (!is.isPrimitive(context[key])) {
|
|
133
|
+
return acc;
|
|
134
|
+
}
|
|
135
|
+
acc[key] = context[key];
|
|
136
|
+
return acc;
|
|
137
|
+
},
|
|
138
|
+
{} ,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const contextsWithPrimitiveValues = Object.keys(contexts).reduce((acc, key) => {
|
|
143
|
+
if (!knownContexts.includes(key)) {
|
|
144
|
+
return acc;
|
|
145
|
+
}
|
|
146
|
+
const context = contexts[key];
|
|
147
|
+
if (context) {
|
|
148
|
+
acc[key] = contextToAttribute(context);
|
|
149
|
+
}
|
|
150
|
+
return acc;
|
|
151
|
+
}, {} );
|
|
152
|
+
|
|
153
|
+
const explicitlyMappedAttributes = Object.entries(explicitAttributeToContextMapping).reduce(
|
|
154
|
+
(acc, [attributeKey, contextKey]) => {
|
|
155
|
+
const [contextName, contextValueKey] = contextKey.split('.');
|
|
156
|
+
if (contextName && contextValueKey && contextsWithPrimitiveValues[contextName]?.[contextValueKey]) {
|
|
157
|
+
acc[attributeKey] = contextsWithPrimitiveValues[contextName]?.[contextValueKey];
|
|
158
|
+
// now we delete this key from `contextsWithPrimitiveValues` so we don't include it in the next step
|
|
159
|
+
delete contextsWithPrimitiveValues[contextName]?.[contextValueKey];
|
|
160
|
+
}
|
|
161
|
+
return acc;
|
|
162
|
+
},
|
|
163
|
+
{} ,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
...explicitlyMappedAttributes,
|
|
168
|
+
...Object.entries(contextsWithPrimitiveValues).reduce(
|
|
169
|
+
(acc, [contextName, contextObj]) => {
|
|
170
|
+
contextObj &&
|
|
171
|
+
Object.entries(contextObj).forEach(([key, value]) => {
|
|
172
|
+
if (value) {
|
|
173
|
+
acc[`${contextName}.${key}`] = value;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
return acc;
|
|
177
|
+
},
|
|
178
|
+
{} ,
|
|
179
|
+
),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
exports.applyBeforeSendSpanCallback = applyBeforeSendSpanCallback;
|
|
184
|
+
exports.contextsToAttributes = contextsToAttributes;
|
|
185
|
+
exports.safeSetSpanJSONAttributes = safeSetSpanJSONAttributes;
|
|
186
|
+
//# sourceMappingURL=spanFirstUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spanFirstUtils.js","sources":["../../../src/spans/spanFirstUtils.ts"],"sourcesContent":["import type { RawAttributes } from '../attributes';\nimport { attributeValueToTypedAttributeValue, isAttributeObject } from '../attributes';\nimport type { Context, Contexts } from '../types-hoist/context';\nimport type { SpanV2JSON } from '../types-hoist/span';\nimport { isPrimitive } from '../utils/is';\nimport { showSpanDropWarning } from '../utils/spanUtils';\n\n/**\n * Only set a span JSON attribute if it is not already set.\n * This is used to safely set attributes on JSON objects without mutating already-ended span instances.\n */\nexport function safeSetSpanJSONAttributes(\n spanJSON: SpanV2JSON,\n newAttributes: RawAttributes<Record<string, unknown>>,\n): void {\n if (!spanJSON.attributes) {\n spanJSON.attributes = {};\n }\n\n const originalAttributes = spanJSON.attributes;\n\n Object.keys(newAttributes).forEach(key => {\n if (!originalAttributes?.[key]) {\n setAttributeOnSpanJSONWithMaybeUnit(\n // type-casting here because we ensured above that the attributes object exists\n spanJSON as SpanV2JSON & Required<Pick<SpanV2JSON, 'attributes'>>,\n key,\n newAttributes[key],\n );\n }\n });\n}\n\n/**\n * Apply a user-provided beforeSendSpan callback to a span JSON.\n */\nexport function applyBeforeSendSpanCallback(\n span: SpanV2JSON,\n beforeSendSpan: (span: SpanV2JSON) => SpanV2JSON,\n): SpanV2JSON {\n const modifedSpan = beforeSendSpan(span);\n if (!modifedSpan) {\n showSpanDropWarning();\n return span;\n }\n return modifedSpan;\n}\n\nfunction setAttributeOnSpanJSONWithMaybeUnit(\n spanJSON: SpanV2JSON & Required<Pick<SpanV2JSON, 'attributes'>>,\n attributeKey: string,\n attributeValue: unknown,\n): void {\n const { value, unit } = isAttributeObject(attributeValue)\n ? attributeValue\n : { value: attributeValue, unit: undefined };\n const typedAttributeValue = attributeValueToTypedAttributeValue(value);\n\n if (typedAttributeValue && isSupportedSerializableType(value)) {\n spanJSON.attributes[attributeKey] = typedAttributeValue;\n if (unit) {\n spanJSON.attributes[attributeKey].unit = unit;\n }\n }\n}\n\nfunction isSupportedSerializableType(value: unknown): boolean {\n return ['string', 'number', 'boolean'].includes(typeof value) || Array.isArray(value);\n}\n\n// map of attributes->context keys for those attributes that don't correspond 1:1 to the context key\nconst explicitAttributeToContextMapping = {\n 'os.build_id': 'os.build',\n 'app.name': 'app.app_name',\n 'app.identifier': 'app.app_identifier',\n 'app.version': 'app.app_version',\n 'app.memory': 'app.app_memory',\n 'app.start_time': 'app.app_start_time',\n};\n\nconst knownContexts = [\n // set by `nodeContextIntegration`\n 'app',\n 'os',\n 'device',\n 'culture',\n 'cloud_resource',\n 'runtime',\n\n // TODO: These need more thorough checking if they're all setting expected attributes\n\n // set by the `instrumentPostgresJs`\n 'postgresjsConnection',\n // set by `ensureIsWrapped`\n 'missing_instrumentation',\n // set by `nodeProfilingIntegration`\n 'profile',\n // set by angular `init`\n 'angular',\n // set by AWS Lambda SDK\n 'aws.lambda',\n 'aws.cloudwatch.logs',\n // set by `instrumentBunServe`\n 'response',\n // set by `trpcMiddleware`\n 'trpc',\n // set by `instrumentSupabaseClient`\n 'supabase',\n // set by `gcp.function.context`\n 'gcp.function.context',\n // set by nextjs SDK\n 'nextjs',\n // set by react SDK `captureReactException`, `init`\n 'react',\n // set by react SDK `createReduxEnhancer`\n 'state',\n // set by `replayIntegration`\n 'Replays',\n // Other information:\n // - no need to handler feature flags `flags` context because it's already added to the active span\n];\n\n/**\n * Converts a context object to a set of attributes.\n * Only includes attributes that are primitives (for now).\n * @param contexts - The context object to convert.\n * @returns The attributes object.\n */\nexport function contextsToAttributes(contexts: Contexts): RawAttributes<Record<string, unknown>> {\n function contextToAttribute(context: Context): Context {\n return Object.keys(context).reduce(\n (acc, key) => {\n if (!isPrimitive(context[key])) {\n return acc;\n }\n acc[key] = context[key];\n return acc;\n },\n {} as Record<string, unknown>,\n );\n }\n\n const contextsWithPrimitiveValues = Object.keys(contexts).reduce((acc, key) => {\n if (!knownContexts.includes(key)) {\n return acc;\n }\n const context = contexts[key];\n if (context) {\n acc[key] = contextToAttribute(context);\n }\n return acc;\n }, {} as Contexts);\n\n const explicitlyMappedAttributes = Object.entries(explicitAttributeToContextMapping).reduce(\n (acc, [attributeKey, contextKey]) => {\n const [contextName, contextValueKey] = contextKey.split('.');\n if (contextName && contextValueKey && contextsWithPrimitiveValues[contextName]?.[contextValueKey]) {\n acc[attributeKey] = contextsWithPrimitiveValues[contextName]?.[contextValueKey];\n // now we delete this key from `contextsWithPrimitiveValues` so we don't include it in the next step\n delete contextsWithPrimitiveValues[contextName]?.[contextValueKey];\n }\n return acc;\n },\n {} as Record<string, unknown>,\n );\n\n return {\n ...explicitlyMappedAttributes,\n ...Object.entries(contextsWithPrimitiveValues).reduce(\n (acc, [contextName, contextObj]) => {\n contextObj &&\n Object.entries(contextObj).forEach(([key, value]) => {\n if (value) {\n acc[`${contextName}.${key}`] = value;\n }\n });\n return acc;\n },\n {} as Record<string, unknown>,\n ),\n };\n}\n"],"names":["showSpanDropWarning","isAttributeObject","attributeValueToTypedAttributeValue","isPrimitive"],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACO,SAAS,yBAAyB;AACzC,EAAE,QAAQ;AACV,EAAE,aAAa;AACf,EAAQ;AACR,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;AAC5B,IAAI,QAAQ,CAAC,UAAA,GAAa,EAAE;AAC5B,EAAE;;AAEF,EAAE,MAAM,kBAAA,GAAqB,QAAQ,CAAC,UAAU;;AAEhD,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,GAAA,IAAO;AAC5C,IAAI,IAAI,CAAC,kBAAkB,GAAG,GAAG,CAAC,EAAE;AACpC,MAAM,mCAAmC;AACzC;AACA,QAAQ,QAAA;AACR,QAAQ,GAAG;AACX,QAAQ,aAAa,CAAC,GAAG,CAAC;AAC1B,OAAO;AACP,IAAI;AACJ,EAAE,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACO,SAAS,2BAA2B;AAC3C,EAAE,IAAI;AACN,EAAE,cAAc;AAChB,EAAc;AACd,EAAE,MAAM,WAAA,GAAc,cAAc,CAAC,IAAI,CAAC;AAC1C,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAIA,6BAAmB,EAAE;AACzB,IAAI,OAAO,IAAI;AACf,EAAE;AACF,EAAE,OAAO,WAAW;AACpB;;A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many';
|
|
233
233
|
|
|
234
|
+
/**
|
|
235
|
+
* The span operation name for reranking
|
|
236
|
+
*/
|
|
237
|
+
const GEN_AI_RERANK_DO_RERANK_OPERATION_ATTRIBUTE = 'gen_ai.rerank';
|
|
238
|
+
|
|
234
239
|
/**
|
|
235
240
|
* The span operation name for executing a tool
|
|
236
241
|
*/
|
|
@@ -338,6 +343,7 @@ exports.GEN_AI_REQUEST_STREAM_ATTRIBUTE = GEN_AI_REQUEST_STREAM_ATTRIBUTE;
|
|
|
338
343
|
exports.GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE = GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE;
|
|
339
344
|
exports.GEN_AI_REQUEST_TOP_K_ATTRIBUTE = GEN_AI_REQUEST_TOP_K_ATTRIBUTE;
|
|
340
345
|
exports.GEN_AI_REQUEST_TOP_P_ATTRIBUTE = GEN_AI_REQUEST_TOP_P_ATTRIBUTE;
|
|
346
|
+
exports.GEN_AI_RERANK_DO_RERANK_OPERATION_ATTRIBUTE = GEN_AI_RERANK_DO_RERANK_OPERATION_ATTRIBUTE;
|
|
341
347
|
exports.GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE = GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE;
|
|
342
348
|
exports.GEN_AI_RESPONSE_ID_ATTRIBUTE = GEN_AI_RESPONSE_ID_ATTRIBUTE;
|
|
343
349
|
exports.GEN_AI_RESPONSE_MODEL_ATTRIBUTE = GEN_AI_RESPONSE_MODEL_ATTRIBUTE;
|