@sentry/core 10.48.0 → 10.50.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.
Files changed (220) hide show
  1. package/build/cjs/client.js +9 -0
  2. package/build/cjs/client.js.map +1 -1
  3. package/build/cjs/fetch.js +41 -19
  4. package/build/cjs/fetch.js.map +1 -1
  5. package/build/cjs/index.js +9 -5
  6. package/build/cjs/index.js.map +1 -1
  7. package/build/cjs/integration.js +9 -0
  8. package/build/cjs/integration.js.map +1 -1
  9. package/build/cjs/integrations/conversationId.js +11 -0
  10. package/build/cjs/integrations/conversationId.js.map +1 -1
  11. package/build/cjs/integrations/express/index.js +44 -7
  12. package/build/cjs/integrations/express/index.js.map +1 -1
  13. package/build/cjs/integrations/express/patch-layer.js +7 -1
  14. package/build/cjs/integrations/express/patch-layer.js.map +1 -1
  15. package/build/cjs/integrations/express/types.js.map +1 -1
  16. package/build/cjs/integrations/mcp-server/transport.js +9 -9
  17. package/build/cjs/integrations/mcp-server/transport.js.map +1 -1
  18. package/build/cjs/tracing/ai/gen-ai-attributes.js +0 -30
  19. package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
  20. package/build/cjs/tracing/ai/utils.js +24 -0
  21. package/build/cjs/tracing/ai/utils.js.map +1 -1
  22. package/build/cjs/tracing/anthropic-ai/index.js +5 -5
  23. package/build/cjs/tracing/anthropic-ai/index.js.map +1 -1
  24. package/build/cjs/tracing/anthropic-ai/utils.js +4 -2
  25. package/build/cjs/tracing/anthropic-ai/utils.js.map +1 -1
  26. package/build/cjs/tracing/google-genai/index.js +16 -5
  27. package/build/cjs/tracing/google-genai/index.js.map +1 -1
  28. package/build/cjs/tracing/langchain/index.js +3 -0
  29. package/build/cjs/tracing/langchain/index.js.map +1 -1
  30. package/build/cjs/tracing/langchain/utils.js +12 -4
  31. package/build/cjs/tracing/langchain/utils.js.map +1 -1
  32. package/build/cjs/tracing/langgraph/index.js +4 -3
  33. package/build/cjs/tracing/langgraph/index.js.map +1 -1
  34. package/build/cjs/tracing/openai/index.js +12 -5
  35. package/build/cjs/tracing/openai/index.js.map +1 -1
  36. package/build/cjs/tracing/sentrySpan.js +5 -0
  37. package/build/cjs/tracing/sentrySpan.js.map +1 -1
  38. package/build/cjs/tracing/spans/captureSpan.js +3 -1
  39. package/build/cjs/tracing/spans/captureSpan.js.map +1 -1
  40. package/build/cjs/tracing/spans/extractGenAiSpans.js +50 -0
  41. package/build/cjs/tracing/spans/extractGenAiSpans.js.map +1 -0
  42. package/build/cjs/tracing/spans/spanJsonToStreamedSpan.js +26 -0
  43. package/build/cjs/tracing/spans/spanJsonToStreamedSpan.js.map +1 -0
  44. package/build/cjs/tracing/trace.js +17 -6
  45. package/build/cjs/tracing/trace.js.map +1 -1
  46. package/build/cjs/tracing/utils.js +3 -37
  47. package/build/cjs/tracing/utils.js.map +1 -1
  48. package/build/cjs/tracing/vercel-ai/constants.js +15 -23
  49. package/build/cjs/tracing/vercel-ai/constants.js.map +1 -1
  50. package/build/cjs/tracing/vercel-ai/index.js +41 -45
  51. package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
  52. package/build/cjs/tracing/vercel-ai/utils.js +11 -39
  53. package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
  54. package/build/cjs/tracing/vercel-ai/vercel-ai-attributes.js +4 -1
  55. package/build/cjs/tracing/vercel-ai/vercel-ai-attributes.js.map +1 -1
  56. package/build/cjs/utils/browser.js +2 -3
  57. package/build/cjs/utils/browser.js.map +1 -1
  58. package/build/cjs/utils/version.js +1 -1
  59. package/build/cjs/utils/version.js.map +1 -1
  60. package/build/cjs/utils/weakRef.js +62 -0
  61. package/build/cjs/utils/weakRef.js.map +1 -0
  62. package/build/esm/client.js +9 -0
  63. package/build/esm/client.js.map +1 -1
  64. package/build/esm/fetch.js +41 -19
  65. package/build/esm/fetch.js.map +1 -1
  66. package/build/esm/index.js +2 -1
  67. package/build/esm/index.js.map +1 -1
  68. package/build/esm/integration.js +9 -0
  69. package/build/esm/integration.js.map +1 -1
  70. package/build/esm/integrations/conversationId.js +11 -0
  71. package/build/esm/integrations/conversationId.js.map +1 -1
  72. package/build/esm/integrations/express/index.js +44 -7
  73. package/build/esm/integrations/express/index.js.map +1 -1
  74. package/build/esm/integrations/express/patch-layer.js +7 -1
  75. package/build/esm/integrations/express/patch-layer.js.map +1 -1
  76. package/build/esm/integrations/express/types.js.map +1 -1
  77. package/build/esm/integrations/mcp-server/transport.js +9 -9
  78. package/build/esm/integrations/mcp-server/transport.js.map +1 -1
  79. package/build/esm/package.json +1 -1
  80. package/build/esm/tracing/ai/gen-ai-attributes.js +1 -26
  81. package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
  82. package/build/esm/tracing/ai/utils.js +23 -1
  83. package/build/esm/tracing/ai/utils.js.map +1 -1
  84. package/build/esm/tracing/anthropic-ai/index.js +6 -6
  85. package/build/esm/tracing/anthropic-ai/index.js.map +1 -1
  86. package/build/esm/tracing/anthropic-ai/utils.js +5 -3
  87. package/build/esm/tracing/anthropic-ai/utils.js.map +1 -1
  88. package/build/esm/tracing/google-genai/index.js +17 -6
  89. package/build/esm/tracing/google-genai/index.js.map +1 -1
  90. package/build/esm/tracing/langchain/index.js +4 -1
  91. package/build/esm/tracing/langchain/index.js.map +1 -1
  92. package/build/esm/tracing/langchain/utils.js +13 -5
  93. package/build/esm/tracing/langchain/utils.js.map +1 -1
  94. package/build/esm/tracing/langgraph/index.js +5 -4
  95. package/build/esm/tracing/langgraph/index.js.map +1 -1
  96. package/build/esm/tracing/openai/index.js +13 -6
  97. package/build/esm/tracing/openai/index.js.map +1 -1
  98. package/build/esm/tracing/sentrySpan.js +5 -0
  99. package/build/esm/tracing/sentrySpan.js.map +1 -1
  100. package/build/esm/tracing/spans/captureSpan.js +3 -1
  101. package/build/esm/tracing/spans/captureSpan.js.map +1 -1
  102. package/build/esm/tracing/spans/extractGenAiSpans.js +48 -0
  103. package/build/esm/tracing/spans/extractGenAiSpans.js.map +1 -0
  104. package/build/esm/tracing/spans/spanJsonToStreamedSpan.js +24 -0
  105. package/build/esm/tracing/spans/spanJsonToStreamedSpan.js.map +1 -0
  106. package/build/esm/tracing/trace.js +17 -6
  107. package/build/esm/tracing/trace.js.map +1 -1
  108. package/build/esm/tracing/utils.js +3 -37
  109. package/build/esm/tracing/utils.js.map +1 -1
  110. package/build/esm/tracing/vercel-ai/constants.js +15 -19
  111. package/build/esm/tracing/vercel-ai/constants.js.map +1 -1
  112. package/build/esm/tracing/vercel-ai/index.js +38 -42
  113. package/build/esm/tracing/vercel-ai/index.js.map +1 -1
  114. package/build/esm/tracing/vercel-ai/utils.js +14 -41
  115. package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
  116. package/build/esm/tracing/vercel-ai/vercel-ai-attributes.js +4 -1
  117. package/build/esm/tracing/vercel-ai/vercel-ai-attributes.js.map +1 -1
  118. package/build/esm/utils/browser.js +2 -3
  119. package/build/esm/utils/browser.js.map +1 -1
  120. package/build/esm/utils/version.js +1 -1
  121. package/build/esm/utils/version.js.map +1 -1
  122. package/build/esm/utils/weakRef.js +59 -0
  123. package/build/esm/utils/weakRef.js.map +1 -0
  124. package/build/types/build-time-plugins/buildTimeOptionsBase.d.ts +13 -0
  125. package/build/types/build-time-plugins/buildTimeOptionsBase.d.ts.map +1 -1
  126. package/build/types/client.d.ts +20 -0
  127. package/build/types/client.d.ts.map +1 -1
  128. package/build/types/fetch.d.ts +12 -8
  129. package/build/types/fetch.d.ts.map +1 -1
  130. package/build/types/index.d.ts +5 -2
  131. package/build/types/index.d.ts.map +1 -1
  132. package/build/types/integration.d.ts.map +1 -1
  133. package/build/types/integrations/conversationId.d.ts.map +1 -1
  134. package/build/types/integrations/express/index.d.ts +10 -3
  135. package/build/types/integrations/express/index.d.ts.map +1 -1
  136. package/build/types/integrations/express/patch-layer.d.ts +1 -1
  137. package/build/types/integrations/express/patch-layer.d.ts.map +1 -1
  138. package/build/types/integrations/express/types.d.ts +5 -1
  139. package/build/types/integrations/express/types.d.ts.map +1 -1
  140. package/build/types/tracing/ai/gen-ai-attributes.d.ts +0 -8
  141. package/build/types/tracing/ai/gen-ai-attributes.d.ts.map +1 -1
  142. package/build/types/tracing/ai/utils.d.ts +13 -0
  143. package/build/types/tracing/ai/utils.d.ts.map +1 -1
  144. package/build/types/tracing/anthropic-ai/index.d.ts.map +1 -1
  145. package/build/types/tracing/anthropic-ai/types.d.ts +5 -0
  146. package/build/types/tracing/anthropic-ai/types.d.ts.map +1 -1
  147. package/build/types/tracing/anthropic-ai/utils.d.ts +1 -1
  148. package/build/types/tracing/anthropic-ai/utils.d.ts.map +1 -1
  149. package/build/types/tracing/google-genai/index.d.ts.map +1 -1
  150. package/build/types/tracing/google-genai/types.d.ts +5 -0
  151. package/build/types/tracing/google-genai/types.d.ts.map +1 -1
  152. package/build/types/tracing/langchain/index.d.ts.map +1 -1
  153. package/build/types/tracing/langchain/types.d.ts +5 -0
  154. package/build/types/tracing/langchain/types.d.ts.map +1 -1
  155. package/build/types/tracing/langchain/utils.d.ts +2 -2
  156. package/build/types/tracing/langchain/utils.d.ts.map +1 -1
  157. package/build/types/tracing/langgraph/index.d.ts.map +1 -1
  158. package/build/types/tracing/langgraph/types.d.ts +5 -0
  159. package/build/types/tracing/langgraph/types.d.ts.map +1 -1
  160. package/build/types/tracing/openai/index.d.ts.map +1 -1
  161. package/build/types/tracing/openai/types.d.ts +5 -0
  162. package/build/types/tracing/openai/types.d.ts.map +1 -1
  163. package/build/types/tracing/sentrySpan.d.ts.map +1 -1
  164. package/build/types/tracing/spans/captureSpan.d.ts.map +1 -1
  165. package/build/types/tracing/spans/extractGenAiSpans.d.ts +15 -0
  166. package/build/types/tracing/spans/extractGenAiSpans.d.ts.map +1 -0
  167. package/build/types/tracing/spans/spanJsonToStreamedSpan.d.ts +6 -0
  168. package/build/types/tracing/spans/spanJsonToStreamedSpan.d.ts.map +1 -0
  169. package/build/types/tracing/trace.d.ts.map +1 -1
  170. package/build/types/tracing/utils.d.ts.map +1 -1
  171. package/build/types/tracing/vercel-ai/constants.d.ts +2 -5
  172. package/build/types/tracing/vercel-ai/constants.d.ts.map +1 -1
  173. package/build/types/tracing/vercel-ai/index.d.ts.map +1 -1
  174. package/build/types/tracing/vercel-ai/utils.d.ts +1 -5
  175. package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
  176. package/build/types/tracing/vercel-ai/vercel-ai-attributes.d.ts +0 -480
  177. package/build/types/tracing/vercel-ai/vercel-ai-attributes.d.ts.map +1 -1
  178. package/build/types/types-hoist/clientreport.d.ts +1 -1
  179. package/build/types/types-hoist/clientreport.d.ts.map +1 -1
  180. package/build/types/types-hoist/envelope.d.ts +1 -1
  181. package/build/types/types-hoist/envelope.d.ts.map +1 -1
  182. package/build/types/types-hoist/integration.d.ts +13 -0
  183. package/build/types/types-hoist/integration.d.ts.map +1 -1
  184. package/build/types/types-hoist/replay.d.ts +25 -0
  185. package/build/types/types-hoist/replay.d.ts.map +1 -1
  186. package/build/types/types-hoist/view-hierarchy.d.ts +1 -0
  187. package/build/types/types-hoist/view-hierarchy.d.ts.map +1 -1
  188. package/build/types/utils/browser.d.ts +1 -1
  189. package/build/types/utils/browser.d.ts.map +1 -1
  190. package/build/types/utils/weakRef.d.ts +34 -0
  191. package/build/types/utils/weakRef.d.ts.map +1 -0
  192. package/build/types-ts3.8/build-time-plugins/buildTimeOptionsBase.d.ts +13 -0
  193. package/build/types-ts3.8/client.d.ts +20 -0
  194. package/build/types-ts3.8/fetch.d.ts +14 -10
  195. package/build/types-ts3.8/index.d.ts +5 -2
  196. package/build/types-ts3.8/integrations/express/index.d.ts +10 -3
  197. package/build/types-ts3.8/integrations/express/patch-layer.d.ts +1 -1
  198. package/build/types-ts3.8/integrations/express/types.d.ts +5 -1
  199. package/build/types-ts3.8/tracing/ai/gen-ai-attributes.d.ts +0 -8
  200. package/build/types-ts3.8/tracing/ai/utils.d.ts +13 -0
  201. package/build/types-ts3.8/tracing/anthropic-ai/types.d.ts +5 -0
  202. package/build/types-ts3.8/tracing/anthropic-ai/utils.d.ts +1 -1
  203. package/build/types-ts3.8/tracing/google-genai/types.d.ts +5 -0
  204. package/build/types-ts3.8/tracing/langchain/types.d.ts +5 -0
  205. package/build/types-ts3.8/tracing/langchain/utils.d.ts +2 -2
  206. package/build/types-ts3.8/tracing/langgraph/types.d.ts +5 -0
  207. package/build/types-ts3.8/tracing/openai/types.d.ts +5 -0
  208. package/build/types-ts3.8/tracing/spans/extractGenAiSpans.d.ts +15 -0
  209. package/build/types-ts3.8/tracing/spans/spanJsonToStreamedSpan.d.ts +6 -0
  210. package/build/types-ts3.8/tracing/vercel-ai/constants.d.ts +2 -5
  211. package/build/types-ts3.8/tracing/vercel-ai/utils.d.ts +1 -5
  212. package/build/types-ts3.8/tracing/vercel-ai/vercel-ai-attributes.d.ts +0 -480
  213. package/build/types-ts3.8/types-hoist/clientreport.d.ts +1 -1
  214. package/build/types-ts3.8/types-hoist/envelope.d.ts +1 -1
  215. package/build/types-ts3.8/types-hoist/integration.d.ts +13 -0
  216. package/build/types-ts3.8/types-hoist/replay.d.ts +25 -0
  217. package/build/types-ts3.8/types-hoist/view-hierarchy.d.ts +1 -0
  218. package/build/types-ts3.8/utils/browser.d.ts +1 -1
  219. package/build/types-ts3.8/utils/weakRef.d.ts +34 -0
  220. package/package.json +1 -1
@@ -0,0 +1,48 @@
1
+ import { hasSpanStreamingEnabled } from './hasSpanStreamingEnabled.js';
2
+ import { spanJsonToSerializedStreamedSpan } from './spanJsonToStreamedSpan.js';
3
+
4
+ /**
5
+ * Extracts gen_ai spans from a transaction event, converts them to span v2 format,
6
+ * and returns them as a SpanContainerItem.
7
+ *
8
+ * Only applies to static mode (non-streaming) transactions.
9
+ *
10
+ * WARNING: This function mutates `event.spans` by removing the extracted gen_ai spans
11
+ * from the array. Call this before creating the event envelope so the transaction
12
+ * item does not include the extracted spans.
13
+ */
14
+ function extractGenAiSpansFromEvent(event, client) {
15
+ if (
16
+ event.type !== 'transaction' ||
17
+ !event.spans?.length ||
18
+ !event.sdkProcessingMetadata?.hasGenAiSpans ||
19
+ hasSpanStreamingEnabled(client)
20
+ ) {
21
+ return undefined;
22
+ }
23
+
24
+ const genAiSpans = [];
25
+ const remainingSpans = [];
26
+
27
+ for (const span of event.spans) {
28
+ if (span.op?.startsWith('gen_ai.')) {
29
+ genAiSpans.push(spanJsonToSerializedStreamedSpan(span));
30
+ } else {
31
+ remainingSpans.push(span);
32
+ }
33
+ }
34
+
35
+ if (genAiSpans.length === 0) {
36
+ return undefined;
37
+ }
38
+
39
+ event.spans = remainingSpans;
40
+
41
+ return [
42
+ { type: 'span', item_count: genAiSpans.length, content_type: 'application/vnd.sentry.items.span.v2+json' },
43
+ { items: genAiSpans },
44
+ ];
45
+ }
46
+
47
+ export { extractGenAiSpansFromEvent };
48
+ //# sourceMappingURL=extractGenAiSpans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractGenAiSpans.js","sources":["../../../../src/tracing/spans/extractGenAiSpans.ts"],"sourcesContent":["import type { Client } from '../../client';\nimport type { SpanContainerItem } from '../../types-hoist/envelope';\nimport type { Event } from '../../types-hoist/event';\nimport { hasSpanStreamingEnabled } from './hasSpanStreamingEnabled';\nimport { spanJsonToSerializedStreamedSpan } from './spanJsonToStreamedSpan';\n\n/**\n * Extracts gen_ai spans from a transaction event, converts them to span v2 format,\n * and returns them as a SpanContainerItem.\n *\n * Only applies to static mode (non-streaming) transactions.\n *\n * WARNING: This function mutates `event.spans` by removing the extracted gen_ai spans\n * from the array. Call this before creating the event envelope so the transaction\n * item does not include the extracted spans.\n */\nexport function extractGenAiSpansFromEvent(event: Event, client: Client): SpanContainerItem | undefined {\n if (\n event.type !== 'transaction' ||\n !event.spans?.length ||\n !event.sdkProcessingMetadata?.hasGenAiSpans ||\n hasSpanStreamingEnabled(client)\n ) {\n return undefined;\n }\n\n const genAiSpans = [];\n const remainingSpans = [];\n\n for (const span of event.spans) {\n if (span.op?.startsWith('gen_ai.')) {\n genAiSpans.push(spanJsonToSerializedStreamedSpan(span));\n } else {\n remainingSpans.push(span);\n }\n }\n\n if (genAiSpans.length === 0) {\n return undefined;\n }\n\n event.spans = remainingSpans;\n\n return [\n { type: 'span', item_count: genAiSpans.length, content_type: 'application/vnd.sentry.items.span.v2+json' },\n { items: genAiSpans },\n ];\n}\n"],"names":[],"mappings":";;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,0BAA0B,CAAC,KAAK,EAAS,MAAM,EAAyC;AACxG,EAAE;AACF,IAAI,KAAK,CAAC,IAAA,KAAS,aAAA;AACnB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,MAAA;AAClB,IAAI,CAAC,KAAK,CAAC,qBAAqB,EAAE,aAAA;AAClC,IAAI,uBAAuB,CAAC,MAAM;AAClC,IAAI;AACJ,IAAI,OAAO,SAAS;AACpB,EAAE;;AAEF,EAAE,MAAM,UAAA,GAAa,EAAE;AACvB,EAAE,MAAM,cAAA,GAAiB,EAAE;;AAE3B,EAAE,KAAK,MAAM,IAAA,IAAQ,KAAK,CAAC,KAAK,EAAE;AAClC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE;AACxC,MAAM,UAAU,CAAC,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC;AAC7D,IAAI,OAAO;AACX,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/B,IAAI;AACJ,EAAE;;AAEF,EAAE,IAAI,UAAU,CAAC,MAAA,KAAW,CAAC,EAAE;AAC/B,IAAI,OAAO,SAAS;AACpB,EAAE;;AAEF,EAAE,KAAK,CAAC,KAAA,GAAQ,cAAc;;AAE9B,EAAE,OAAO;AACT,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,6CAA6C;AAC9G,IAAI,EAAE,KAAK,EAAE,UAAA,EAAY;AACzB,GAAG;AACH;;;;"}
@@ -0,0 +1,24 @@
1
+ import { streamedSpanJsonToSerializedSpan } from '../../utils/spanUtils.js';
2
+
3
+ /**
4
+ * Converts a v1 SpanJSON (from a legacy transaction) to a serialized v2 StreamedSpan.
5
+ */
6
+ function spanJsonToSerializedStreamedSpan(span) {
7
+ const streamedSpan = {
8
+ trace_id: span.trace_id,
9
+ span_id: span.span_id,
10
+ parent_span_id: span.parent_span_id,
11
+ name: span.description || '',
12
+ start_timestamp: span.start_timestamp,
13
+ end_timestamp: span.timestamp || span.start_timestamp,
14
+ status: !span.status || span.status === 'ok' || span.status === 'cancelled' ? 'ok' : 'error',
15
+ is_segment: false,
16
+ attributes: { ...(span.data ) },
17
+ links: span.links,
18
+ };
19
+
20
+ return streamedSpanJsonToSerializedSpan(streamedSpan);
21
+ }
22
+
23
+ export { spanJsonToSerializedStreamedSpan };
24
+ //# sourceMappingURL=spanJsonToStreamedSpan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spanJsonToStreamedSpan.js","sources":["../../../../src/tracing/spans/spanJsonToStreamedSpan.ts"],"sourcesContent":["import type { RawAttributes } from '../../attributes';\nimport type { SerializedStreamedSpan, SpanJSON, StreamedSpanJSON } from '../../types-hoist/span';\nimport { streamedSpanJsonToSerializedSpan } from '../../utils/spanUtils';\n\n/**\n * Converts a v1 SpanJSON (from a legacy transaction) to a serialized v2 StreamedSpan.\n */\nexport function spanJsonToSerializedStreamedSpan(span: SpanJSON): SerializedStreamedSpan {\n const streamedSpan: StreamedSpanJSON = {\n trace_id: span.trace_id,\n span_id: span.span_id,\n parent_span_id: span.parent_span_id,\n name: span.description || '',\n start_timestamp: span.start_timestamp,\n end_timestamp: span.timestamp || span.start_timestamp,\n status: !span.status || span.status === 'ok' || span.status === 'cancelled' ? 'ok' : 'error',\n is_segment: false,\n attributes: { ...(span.data as RawAttributes<Record<string, unknown>>) },\n links: span.links,\n };\n\n return streamedSpanJsonToSerializedSpan(streamedSpan);\n}\n"],"names":[],"mappings":";;AAIA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,IAAI,EAAoC;AACzF,EAAE,MAAM,YAAY,GAAqB;AACzC,IAAI,QAAQ,EAAE,IAAI,CAAC,QAAQ;AAC3B,IAAI,OAAO,EAAE,IAAI,CAAC,OAAO;AACzB,IAAI,cAAc,EAAE,IAAI,CAAC,cAAc;AACvC,IAAI,IAAI,EAAE,IAAI,CAAC,WAAA,IAAe,EAAE;AAChC,IAAI,eAAe,EAAE,IAAI,CAAC,eAAe;AACzC,IAAI,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,CAAC,eAAe;AACzD,IAAI,MAAM,EAAE,CAAC,IAAI,CAAC,MAAA,IAAU,IAAI,CAAC,MAAA,KAAW,IAAA,IAAQ,IAAI,CAAC,MAAA,KAAW,WAAA,GAAc,IAAA,GAAO,OAAO;AAChG,IAAI,UAAU,EAAE,KAAK;AACrB,IAAI,UAAU,EAAE,EAAE,IAAI,IAAI,CAAC,IAAA,EAAK,EAA4C;AAC5E,IAAI,KAAK,EAAE,IAAI,CAAC,KAAK;AACrB,GAAG;;AAEH,EAAE,OAAO,gCAAgC,CAAC,YAAY,CAAC;AACvD;;;;"}
@@ -58,9 +58,10 @@ function startSpan(options, callback) {
58
58
  return wrapper(() => {
59
59
  const scope = getCurrentScope();
60
60
  const parentSpan = getParentSpan(scope, customParentSpan);
61
+ const client = getClient();
61
62
 
62
- const shouldSkipSpan = options.onlyIfParent && !parentSpan;
63
- const activeSpan = shouldSkipSpan
63
+ const missingRequiredParent = options.onlyIfParent && !parentSpan;
64
+ const activeSpan = missingRequiredParent
64
65
  ? new SentryNonRecordingSpan()
65
66
  : createChildOrRootSpan({
66
67
  parentSpan,
@@ -69,6 +70,10 @@ function startSpan(options, callback) {
69
70
  scope,
70
71
  });
71
72
 
73
+ if (missingRequiredParent) {
74
+ client?.recordDroppedEvent('no_parent_span', 'span');
75
+ }
76
+
72
77
  // Ignored root spans still need to be set on scope so that `getActiveSpan()` returns them
73
78
  // and descendants are also non-recording. Ignored child spans don't need this because
74
79
  // the parent span is already on scope.
@@ -122,8 +127,8 @@ function startSpanManual(options, callback) {
122
127
  const scope = getCurrentScope();
123
128
  const parentSpan = getParentSpan(scope, customParentSpan);
124
129
 
125
- const shouldSkipSpan = options.onlyIfParent && !parentSpan;
126
- const activeSpan = shouldSkipSpan
130
+ const missingRequiredParent = options.onlyIfParent && !parentSpan;
131
+ const activeSpan = missingRequiredParent
127
132
  ? new SentryNonRecordingSpan()
128
133
  : createChildOrRootSpan({
129
134
  parentSpan,
@@ -132,6 +137,10 @@ function startSpanManual(options, callback) {
132
137
  scope,
133
138
  });
134
139
 
140
+ if (missingRequiredParent) {
141
+ getClient()?.recordDroppedEvent('no_parent_span', 'span');
142
+ }
143
+
135
144
  // We don't set ignored child spans onto the scope because there likely is an active,
136
145
  // unignored span on the scope already.
137
146
  if (!_isIgnoredSpan(activeSpan) || !parentSpan) {
@@ -185,10 +194,12 @@ function startInactiveSpan(options) {
185
194
  return wrapper(() => {
186
195
  const scope = getCurrentScope();
187
196
  const parentSpan = getParentSpan(scope, customParentSpan);
197
+ const client = getClient();
188
198
 
189
- const shouldSkipSpan = options.onlyIfParent && !parentSpan;
199
+ const missingRequiredParent = options.onlyIfParent && !parentSpan;
190
200
 
191
- if (shouldSkipSpan) {
201
+ if (missingRequiredParent) {
202
+ client?.recordDroppedEvent('no_parent_span', 'span');
192
203
  return new SentryNonRecordingSpan();
193
204
  }
194
205
 
@@ -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 {\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":[],"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,M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,yBAAA,CAAA,MAAA,EAAA,aAAA,EAAA;AACA,EAAA,MAAA,WAAA,GAAA,MAAA,EAAA,UAAA,EAAA,CAAA,WAAA;;AAEA,EAAA,IAAA,CAAA,MAAA,IAAA,CAAA,uBAAA,CAAA,MAAA,CAAA,IAAA,CAAA,WAAA,EAAA,MAAA,EAAA;AACA,IAAA,OAAA,KAAA;AACA,EAAA;;AAEA,EAAA,OAAA,gBAAA;AACA,IAAA;AACA,MAAA,WAAA,EAAA,aAAA,CAAA,IAAA,IAAA,EAAA;AACA,MAAA,EAAA,EAAA,aAAA,CAAA,UAAA,GAAA,4BAAA,CAAA,IAAA,aAAA,CAAA,EAAA;AACA,KAAA;AACA,IAAA,WAAA;AACA,GAAA;AACA;;AAEA,SAAA,cAAA,CAAA,IAAA,EAAA;AACA,EAAA,OAAA,IAAA,YAAA,sBAAA,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
+ {"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 const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n if (missingRequiredParent) {\n client?.recordDroppedEvent('no_parent_span', 'span');\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 missingRequiredParent = options.onlyIfParent && !parentSpan;\n const activeSpan = missingRequiredParent\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n if (missingRequiredParent) {\n getClient()?.recordDroppedEvent('no_parent_span', 'span');\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 const client = getClient();\n\n const missingRequiredParent = options.onlyIfParent && !parentSpan;\n\n if (missingRequiredParent) {\n client?.recordDroppedEvent('no_parent_span', 'span');\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":[],"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,OAA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0BAAA,EAAA;AACA,IAAA,OAAA,WAAA,CAAA,IAAA,CAAA;AACA,EAAA;;AAEA,EAAA,OAAA,IAAA;AACA;;AAEA,SAAA,oBAAA,CAAA,UAAA,EAAA;AACA,EAAA,OAAA,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;;AAEA;AACA,SAAA,yBAAA,CAAA,MAAA,EAAA,aAAA,EAAA;AACA,EAAA,MAAA,WAAA,GAAA,MAAA,EAAA,UAAA,EAAA,CAAA,WAAA;;AAEA,EAAA,IAAA,CAAA,MAAA,IAAA,CAAA,uBAAA,CAAA,MAAA,CAAA,IAAA,CAAA,WAAA,EAAA,MAAA,EAAA;AACA,IAAA,OAAA,KAAA;AACA,EAAA;;AAEA,EAAA,OAAA,gBAAA;AACA,IAAA;AACA,MAAA,WAAA,EAAA,aAAA,CAAA,IAAA,IAAA,EAAA;AACA,MAAA,EAAA,EAAA,aAAA,CAAA,UAAA,GAAA,4BAAA,CAAA,IAAA,aAAA,CAAA,EAAA;AACA,KAAA;AACA,IAAA,WAAA;AACA,GAAA;AACA;;AAEA,SAAA,cAAA,CAAA,IAAA,EAAA;AACA,EAAA,OAAA,IAAA,YAAA,sBAAA,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,47 +1,13 @@
1
1
  import { addNonEnumerableProperty } from '../utils/object.js';
2
- import { GLOBAL_OBJ } from '../utils/worldwide.js';
2
+ import { derefWeakRef, makeWeakRef } from '../utils/weakRef.js';
3
3
 
4
4
  const SCOPE_ON_START_SPAN_FIELD = '_sentryScope';
5
5
  const ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';
6
6
 
7
- /** Wrap a scope with a WeakRef if available, falling back to a direct scope. */
8
- function wrapScopeWithWeakRef(scope) {
9
- try {
10
- // @ts-expect-error - WeakRef is not available in all environments
11
- const WeakRefClass = GLOBAL_OBJ.WeakRef;
12
- if (typeof WeakRefClass === 'function') {
13
- return new WeakRefClass(scope);
14
- }
15
- } catch {
16
- // WeakRef not available or failed to create
17
- // We'll fall back to a direct scope
18
- }
19
-
20
- return scope;
21
- }
22
-
23
- /** Try to unwrap a scope from a potential WeakRef wrapper. */
24
- function unwrapScopeFromWeakRef(scopeRef) {
25
- if (!scopeRef) {
26
- return undefined;
27
- }
28
-
29
- if (typeof scopeRef === 'object' && 'deref' in scopeRef && typeof scopeRef.deref === 'function') {
30
- try {
31
- return scopeRef.deref();
32
- } catch {
33
- return undefined;
34
- }
35
- }
36
-
37
- // Fallback to a direct scope
38
- return scopeRef ;
39
- }
40
-
41
7
  /** Store the scope & isolation scope for a span, which can the be used when it is finished. */
42
8
  function setCapturedScopesOnSpan(span, scope, isolationScope) {
43
9
  if (span) {
44
- addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, wrapScopeWithWeakRef(isolationScope));
10
+ addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, makeWeakRef(isolationScope));
45
11
  // We don't wrap the scope with a WeakRef here because webkit aggressively garbage collects
46
12
  // and scopes are not held in memory for long periods of time.
47
13
  addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);
@@ -57,7 +23,7 @@ function getCapturedScopesOnSpan(span) {
57
23
 
58
24
  return {
59
25
  scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],
60
- isolationScope: unwrapScopeFromWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),
26
+ isolationScope: derefWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),
61
27
  };
62
28
  }
63
29
 
@@ -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 { GLOBAL_OBJ } from '../utils/worldwide';\n\nconst SCOPE_ON_START_SPAN_FIELD = '_sentryScope';\nconst ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';\n\ntype ScopeWeakRef = { deref(): Scope | undefined } | Scope;\n\ntype SpanWithScopes = Span & {\n [SCOPE_ON_START_SPAN_FIELD]?: Scope;\n [ISOLATION_SCOPE_ON_START_SPAN_FIELD]?: ScopeWeakRef;\n};\n\n/** Wrap a scope with a WeakRef if available, falling back to a direct scope. */\nfunction wrapScopeWithWeakRef(scope: Scope): ScopeWeakRef {\n try {\n // @ts-expect-error - WeakRef is not available in all environments\n const WeakRefClass = GLOBAL_OBJ.WeakRef;\n if (typeof WeakRefClass === 'function') {\n return new WeakRefClass(scope);\n }\n } catch {\n // WeakRef not available or failed to create\n // We'll fall back to a direct scope\n }\n\n return scope;\n}\n\n/** Try to unwrap a scope from a potential WeakRef wrapper. */\nfunction unwrapScopeFromWeakRef(scopeRef: ScopeWeakRef | undefined): Scope | undefined {\n if (!scopeRef) {\n return undefined;\n }\n\n if (typeof scopeRef === 'object' && 'deref' in scopeRef && typeof scopeRef.deref === 'function') {\n try {\n return scopeRef.deref();\n } catch {\n return undefined;\n }\n }\n\n // Fallback to a direct scope\n return scopeRef as 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, wrapScopeWithWeakRef(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: unwrapScopeFromWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),\n };\n}\n"],"names":[],"mappings":";;;AAKA,MAAM,yBAAA,GAA4B,cAAc;AAChD,MAAM,mCAAA,GAAsC,uBAAuB;;AASnE;AACA,SAAS,oBAAoB,CAAC,KAAK,EAAuB;AAC1D,EAAE,IAAI;AACN;AACA,IAAI,MAAM,YAAA,GAAe,UAAU,CAAC,OAAO;AAC3C,IAAI,IAAI,OAAO,YAAA,KAAiB,UAAU,EAAE;AAC5C,MAAM,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC;AACpC,IAAI;AACJ,EAAE,EAAE,MAAM;AACV;AACA;AACA,EAAE;;AAEF,EAAE,OAAO,KAAK;AACd;;AAEA;AACA,SAAS,sBAAsB,CAAC,QAAQ,EAA+C;AACvF,EAAE,IAAI,CAAC,QAAQ,EAAE;AACjB,IAAI,OAAO,SAAS;AACpB,EAAE;;AAEF,EAAE,IAAI,OAAO,QAAA,KAAa,YAAY,OAAA,IAAW,QAAA,IAAY,OAAO,QAAQ,CAAC,KAAA,KAAU,UAAU,EAAE;AACnG,IAAI,IAAI;AACR,MAAM,OAAO,QAAQ,CAAC,KAAK,EAAE;AAC7B,IAAI,EAAE,MAAM;AACZ,MAAM,OAAO,SAAS;AACtB,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,OAAO,QAAA;AACT;;AAEA;AACO,SAAS,uBAAuB,CAAC,IAAI,EAAoB,KAAK,EAAS,cAAc,EAAe;AAC3G,EAAE,IAAI,IAAI,EAAE;AACZ,IAAI,wBAAwB,CAAC,IAAI,EAAE,mCAAmC,EAAE,oBAAoB,CAAC,cAAc,CAAC,CAAC;AAC7G;AACA;AACA,IAAI,wBAAwB,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,EAAE,sBAAsB,CAAC,cAAc,CAAC,mCAAmC,CAAC,CAAC;AAC/F,GAAG;AACH;;;;"}
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":[],"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,IAAI,wBAAwB,CAAC,IAAI,EAAE,mCAAmC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;AACpG;AACA;AACA,IAAI,wBAAwB,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,EAAE,YAAY,CAAC,cAAc,CAAC,mCAAmC,CAAC,CAAC;AACrF,GAAG;AACH;;;;"}
@@ -3,25 +3,21 @@
3
3
  // without keeping full Span objects (and their potentially large attributes) alive.
4
4
  const toolCallSpanContextMap = new Map();
5
5
 
6
- // Operation sets for efficient mapping to OpenTelemetry semantic convention values
7
- const INVOKE_AGENT_OPS = new Set(['ai.generateText', 'ai.streamText', 'ai.generateObject', 'ai.streamObject']);
8
-
9
- const GENERATE_CONTENT_OPS = new Set([
10
- 'ai.generateText.doGenerate',
11
- 'ai.streamText.doStream',
12
- 'ai.generateObject.doGenerate',
13
- 'ai.streamObject.doStream',
6
+ /** Maps Vercel AI span names to standardized OpenTelemetry operation names. */
7
+ const SPAN_TO_OPERATION_NAME = new Map([
8
+ ['ai.generateText', 'invoke_agent'],
9
+ ['ai.streamText', 'invoke_agent'],
10
+ ['ai.generateObject', 'invoke_agent'],
11
+ ['ai.streamObject', 'invoke_agent'],
12
+ ['ai.generateText.doGenerate', 'generate_content'],
13
+ ['ai.streamText.doStream', 'generate_content'],
14
+ ['ai.generateObject.doGenerate', 'generate_content'],
15
+ ['ai.streamObject.doStream', 'generate_content'],
16
+ ['ai.embed.doEmbed', 'embeddings'],
17
+ ['ai.embedMany.doEmbed', 'embeddings'],
18
+ ['ai.rerank.doRerank', 'rerank'],
19
+ ['ai.toolCall', 'execute_tool'],
14
20
  ]);
15
21
 
16
- const EMBEDDINGS_OPS = new Set(['ai.embed.doEmbed', 'ai.embedMany.doEmbed']);
17
-
18
- const RERANK_OPS = new Set(['ai.rerank.doRerank']);
19
-
20
- const DO_SPAN_NAME_PREFIX = {
21
- 'ai.embed.doEmbed': 'embeddings',
22
- 'ai.embedMany.doEmbed': 'embeddings',
23
- 'ai.rerank.doRerank': 'rerank',
24
- };
25
-
26
- export { DO_SPAN_NAME_PREFIX, EMBEDDINGS_OPS, GENERATE_CONTENT_OPS, INVOKE_AGENT_OPS, RERANK_OPS, toolCallSpanContextMap };
22
+ export { SPAN_TO_OPERATION_NAME, toolCallSpanContextMap };
27
23
  //# 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// Operation sets for efficient mapping to OpenTelemetry semantic convention values\nexport const INVOKE_AGENT_OPS = new Set(['ai.generateText', 'ai.streamText', 'ai.generateObject', 'ai.streamObject']);\n\nexport const GENERATE_CONTENT_OPS = new Set([\n 'ai.generateText.doGenerate',\n 'ai.streamText.doStream',\n 'ai.generateObject.doGenerate',\n 'ai.streamObject.doStream',\n]);\n\nexport const EMBEDDINGS_OPS = new Set(['ai.embed.doEmbed', 'ai.embedMany.doEmbed']);\n\nexport const RERANK_OPS = new Set(['ai.rerank.doRerank']);\n\nexport const DO_SPAN_NAME_PREFIX: Record<string, string> = {\n 'ai.embed.doEmbed': 'embeddings',\n 'ai.embedMany.doEmbed': 'embeddings',\n 'ai.rerank.doRerank': 'rerank',\n};\n"],"names":[],"mappings":"AAEA;AACA;AACA;MACa,sBAAA,GAAyB,IAAI,GAAG;;AAE7C;AACO,MAAM,gBAAA,GAAmB,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,CAAC;;AAE7G,MAAM,oBAAA,GAAuB,IAAI,GAAG,CAAC;AAC5C,EAAE,4BAA4B;AAC9B,EAAE,wBAAwB;AAC1B,EAAE,8BAA8B;AAChC,EAAE,0BAA0B;AAC5B,CAAC;;AAEM,MAAM,cAAA,GAAiB,IAAI,GAAG,CAAC,CAAC,kBAAkB,EAAE,sBAAsB,CAAC;;AAE3E,MAAM,aAAa,IAAI,GAAG,CAAC,CAAC,oBAAoB,CAAC;;AAEjD,MAAM,mBAAmB,GAA2B;AAC3D,EAAE,kBAAkB,EAAE,YAAY;AAClC,EAAE,sBAAsB,EAAE,YAAY;AACtC,EAAE,oBAAoB,EAAE,QAAQ;AAChC;;;;"}
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,36 +1,12 @@
1
+ import { getClient } from '../../currentScopes.js';
1
2
  import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '../../semanticAttributes.js';
3
+ import { shouldEnableTruncation } from '../ai/utils.js';
2
4
  import { spanToJSON } from '../../utils/spanUtils.js';
3
5
  import { GEN_AI_OPERATION_NAME_ATTRIBUTE, GEN_AI_TOOL_CALL_ID_ATTRIBUTE, GEN_AI_TOOL_TYPE_ATTRIBUTE, GEN_AI_TOOL_NAME_ATTRIBUTE, GEN_AI_RESPONSE_MODEL_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE, GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE, GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE, GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE, GEN_AI_OUTPUT_MESSAGES_ATTRIBUTE, GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE_ATTRIBUTE, GEN_AI_INPUT_MESSAGES_ATTRIBUTE, GEN_AI_TOOL_INPUT_ATTRIBUTE, GEN_AI_TOOL_OUTPUT_ATTRIBUTE, GEN_AI_REQUEST_MODEL_ATTRIBUTE } from '../ai/gen-ai-attributes.js';
4
- import { toolCallSpanContextMap, INVOKE_AGENT_OPS, GENERATE_CONTENT_OPS, DO_SPAN_NAME_PREFIX, EMBEDDINGS_OPS, RERANK_OPS } from './constants.js';
5
- import { accumulateTokensForParent, applyToolDescriptionsAndTokens, applyAccumulatedTokens, requestMessagesFromPrompt, getSpanOpFromName, convertAvailableToolsToJsonString } from './utils.js';
6
+ import { toolCallSpanContextMap, SPAN_TO_OPERATION_NAME } from './constants.js';
7
+ import { accumulateTokensForParent, applyToolDescriptionsAndTokens, applyAccumulatedTokens, requestMessagesFromPrompt, convertAvailableToolsToJsonString } from './utils.js';
6
8
  import { AI_TOOL_CALL_NAME_ATTRIBUTE, AI_TOOL_CALL_ID_ATTRIBUTE, AI_OPERATION_ID_ATTRIBUTE, AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE, AI_MODEL_ID_ATTRIBUTE, AI_PROMPT_TOOLS_ATTRIBUTE, OPERATION_NAME_ATTRIBUTE, AI_VALUES_ATTRIBUTE, AI_RESPONSE_TEXT_ATTRIBUTE, AI_RESPONSE_TOOL_CALLS_ATTRIBUTE, AI_RESPONSE_FINISH_REASON_ATTRIBUTE, AI_RESPONSE_PROVIDER_METADATA_ATTRIBUTE, AI_USAGE_COMPLETION_TOKENS_ATTRIBUTE, AI_USAGE_PROMPT_TOKENS_ATTRIBUTE, AI_USAGE_CACHED_INPUT_TOKENS_ATTRIBUTE, AI_USAGE_TOKENS_ATTRIBUTE, AI_PROMPT_MESSAGES_ATTRIBUTE, AI_RESPONSE_OBJECT_ATTRIBUTE, AI_TOOL_CALL_ARGS_ATTRIBUTE, AI_TOOL_CALL_RESULT_ATTRIBUTE, AI_SCHEMA_ATTRIBUTE } from './vercel-ai-attributes.js';
7
9
 
8
- /**
9
- * Maps Vercel AI SDK operation names to OpenTelemetry semantic convention values
10
- * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/#llm-request-spans
11
- */
12
- function mapVercelAiOperationName(operationName) {
13
- // Top-level pipeline operations map to invoke_agent
14
- if (INVOKE_AGENT_OPS.has(operationName)) {
15
- return 'invoke_agent';
16
- }
17
- // .do* operations are the actual LLM calls
18
- if (GENERATE_CONTENT_OPS.has(operationName)) {
19
- return 'generate_content';
20
- }
21
- if (EMBEDDINGS_OPS.has(operationName)) {
22
- return 'embeddings';
23
- }
24
- if (RERANK_OPS.has(operationName)) {
25
- return 'rerank';
26
- }
27
- if (operationName === 'ai.toolCall') {
28
- return 'execute_tool';
29
- }
30
- // Return the original value for unknown operations
31
- return operationName;
32
- }
33
-
34
10
  /**
35
11
  * Post-process spans emitted by the Vercel AI SDK.
36
12
  * This is supposed to be used in `client.on('spanStart', ...)
@@ -55,7 +31,13 @@ function onVercelAiSpanStart(span) {
55
31
  return;
56
32
  }
57
33
 
58
- processGenerateSpan(span, name, attributes);
34
+ const client = getClient();
35
+ const integration = client?.getIntegrationByName('VercelAI')
36
+
37
+ ;
38
+ const enableTruncation = shouldEnableTruncation(integration?.options?.enableTruncation);
39
+
40
+ processGenerateSpan(span, name, attributes, enableTruncation);
59
41
  }
60
42
 
61
43
  function vercelAiEventProcessor(event) {
@@ -249,7 +231,13 @@ function processEndedVercelAiSpan(span) {
249
231
  // Rename AI SDK attributes to standardized gen_ai attributes
250
232
  // Map operation.name to OpenTelemetry semantic convention values
251
233
  if (attributes[OPERATION_NAME_ATTRIBUTE]) {
252
- const operationName = mapVercelAiOperationName(attributes[OPERATION_NAME_ATTRIBUTE] );
234
+ // V6+ sets ai.operationId to the bare operation (e.g. "ai.streamText") while
235
+ // operation.name appends functionId (e.g. "ai.streamText myAgent").
236
+ // When ai.operationId is present, use it for correct mapping.
237
+ const rawOperationName = attributes[AI_OPERATION_ID_ATTRIBUTE]
238
+ ? (attributes[AI_OPERATION_ID_ATTRIBUTE] )
239
+ : (attributes[OPERATION_NAME_ATTRIBUTE] );
240
+ const operationName = SPAN_TO_OPERATION_NAME.get(rawOperationName) ?? rawOperationName;
253
241
  attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE] = operationName;
254
242
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
255
243
  delete attributes[OPERATION_NAME_ATTRIBUTE];
@@ -291,6 +279,15 @@ function processEndedVercelAiSpan(span) {
291
279
  renameAttributeKey(attributes, key, `vercel.${key}`);
292
280
  }
293
281
  }
282
+
283
+ // JSON-stringify any array-valued attributes so they survive v2 span serialization.
284
+ // The v2 serializer currently drops array values. Can be removed once span streaming
285
+ // supports arrays natively.
286
+ for (const [key, value] of Object.entries(attributes)) {
287
+ if (Array.isArray(value)) {
288
+ attributes[key] = JSON.stringify(value);
289
+ }
290
+ }
294
291
  }
295
292
 
296
293
  /**
@@ -331,7 +328,7 @@ function processToolCallSpan(span, attributes) {
331
328
  }
332
329
  }
333
330
 
334
- function processGenerateSpan(span, name, attributes) {
331
+ function processGenerateSpan(span, name, attributes, enableTruncation) {
335
332
  span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.vercelai.otel');
336
333
 
337
334
  const nameWthoutAi = name.replace('ai.', '');
@@ -343,22 +340,24 @@ function processGenerateSpan(span, name, attributes) {
343
340
  span.setAttribute('gen_ai.function_id', functionId);
344
341
  }
345
342
 
346
- requestMessagesFromPrompt(span, attributes);
343
+ requestMessagesFromPrompt(span, attributes, enableTruncation);
347
344
 
348
345
  if (attributes[AI_MODEL_ID_ATTRIBUTE] && !attributes[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]) {
349
346
  span.setAttribute(GEN_AI_RESPONSE_MODEL_ATTRIBUTE, attributes[AI_MODEL_ID_ATTRIBUTE]);
350
347
  }
351
348
  span.setAttribute('ai.streaming', name.includes('stream'));
352
349
 
353
- // Set the op based on the span name
354
- const op = getSpanOpFromName(name);
355
- if (op) {
356
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, op);
350
+ // Set the op based on the operation name registry
351
+ const operationName = SPAN_TO_OPERATION_NAME.get(name);
352
+ if (operationName) {
353
+ span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `gen_ai.${operationName}`);
354
+ } else if (name.startsWith('ai.stream')) {
355
+ span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'ai.run');
357
356
  }
358
357
 
359
358
  // For invoke_agent pipeline spans, use 'invoke_agent' as the description
360
359
  // to be consistent with other AI integrations (e.g. LangGraph)
361
- if (INVOKE_AGENT_OPS.has(name)) {
360
+ if (operationName === 'invoke_agent') {
362
361
  if (functionId && typeof functionId === 'string') {
363
362
  span.updateName(`invoke_agent ${functionId}`);
364
363
  } else {
@@ -368,11 +367,8 @@ function processGenerateSpan(span, name, attributes) {
368
367
  }
369
368
 
370
369
  const modelId = attributes[AI_MODEL_ID_ATTRIBUTE];
371
- if (modelId) {
372
- const doSpanPrefix = GENERATE_CONTENT_OPS.has(name) ? 'generate_content' : DO_SPAN_NAME_PREFIX[name];
373
- if (doSpanPrefix) {
374
- span.updateName(`${doSpanPrefix} ${modelId}`);
375
- }
370
+ if (modelId && operationName) {
371
+ span.updateName(`${operationName} ${modelId}`);
376
372
  }
377
373
  }
378
374