@sentry/core 10.47.0 → 10.48.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 (316) hide show
  1. package/build/cjs/attributes.js +43 -0
  2. package/build/cjs/attributes.js.map +1 -1
  3. package/build/cjs/client.js +13 -6
  4. package/build/cjs/client.js.map +1 -1
  5. package/build/cjs/envelope.js +4 -3
  6. package/build/cjs/envelope.js.map +1 -1
  7. package/build/cjs/index.js +44 -13
  8. package/build/cjs/index.js.map +1 -1
  9. package/build/cjs/integration.js +6 -0
  10. package/build/cjs/integration.js.map +1 -1
  11. package/build/cjs/integrations/express/index.js +206 -0
  12. package/build/cjs/integrations/express/index.js.map +1 -0
  13. package/build/cjs/integrations/express/patch-layer.js +251 -0
  14. package/build/cjs/integrations/express/patch-layer.js.map +1 -0
  15. package/build/cjs/integrations/express/request-layer-store.js +25 -0
  16. package/build/cjs/integrations/express/request-layer-store.js.map +1 -0
  17. package/build/cjs/integrations/express/set-sdk-processing-metadata.js +17 -0
  18. package/build/cjs/integrations/express/set-sdk-processing-metadata.js.map +1 -0
  19. package/build/cjs/integrations/express/types.js +17 -0
  20. package/build/cjs/integrations/express/types.js.map +1 -0
  21. package/build/cjs/integrations/express/utils.js +238 -0
  22. package/build/cjs/integrations/express/utils.js.map +1 -0
  23. package/build/cjs/integrations/mcp-server/correlation.js +5 -1
  24. package/build/cjs/integrations/mcp-server/correlation.js.map +1 -1
  25. package/build/cjs/integrations/mcp-server/handlers.js +18 -10
  26. package/build/cjs/integrations/mcp-server/handlers.js.map +1 -1
  27. package/build/cjs/integrations/mcp-server/index.js +2 -1
  28. package/build/cjs/integrations/mcp-server/index.js.map +1 -1
  29. package/build/cjs/integrations/mcp-server/transport.js +1 -1
  30. package/build/cjs/integrations/mcp-server/transport.js.map +1 -1
  31. package/build/cjs/integrations/mcp-server/validation.js +7 -5
  32. package/build/cjs/integrations/mcp-server/validation.js.map +1 -1
  33. package/build/cjs/integrations/spanStreaming.js +48 -0
  34. package/build/cjs/integrations/spanStreaming.js.map +1 -0
  35. package/build/cjs/semanticAttributes.js +35 -3
  36. package/build/cjs/semanticAttributes.js.map +1 -1
  37. package/build/cjs/tracing/ai/gen-ai-attributes.js +9 -65
  38. package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
  39. package/build/cjs/tracing/ai/utils.js +50 -0
  40. package/build/cjs/tracing/ai/utils.js.map +1 -1
  41. package/build/cjs/tracing/anthropic-ai/index.js +1 -12
  42. package/build/cjs/tracing/anthropic-ai/index.js.map +1 -1
  43. package/build/cjs/tracing/anthropic-ai/streaming.js +2 -100
  44. package/build/cjs/tracing/anthropic-ai/streaming.js.map +1 -1
  45. package/build/cjs/tracing/dynamicSamplingContext.js +2 -1
  46. package/build/cjs/tracing/dynamicSamplingContext.js.map +1 -1
  47. package/build/cjs/tracing/google-genai/constants.js +1 -6
  48. package/build/cjs/tracing/google-genai/constants.js.map +1 -1
  49. package/build/cjs/tracing/google-genai/index.js +24 -30
  50. package/build/cjs/tracing/google-genai/index.js.map +1 -1
  51. package/build/cjs/tracing/google-genai/streaming.js +2 -23
  52. package/build/cjs/tracing/google-genai/streaming.js.map +1 -1
  53. package/build/cjs/tracing/langchain/embeddings.js +132 -0
  54. package/build/cjs/tracing/langchain/embeddings.js.map +1 -0
  55. package/build/cjs/tracing/langchain/index.js.map +1 -1
  56. package/build/cjs/tracing/openai/index.js +2 -29
  57. package/build/cjs/tracing/openai/index.js.map +1 -1
  58. package/build/cjs/tracing/openai/streaming.js +3 -34
  59. package/build/cjs/tracing/openai/streaming.js.map +1 -1
  60. package/build/cjs/tracing/openai/utils.js +78 -204
  61. package/build/cjs/tracing/openai/utils.js.map +1 -1
  62. package/build/cjs/tracing/sentryNonRecordingSpan.js +7 -0
  63. package/build/cjs/tracing/sentryNonRecordingSpan.js.map +1 -1
  64. package/build/cjs/tracing/sentrySpan.js +39 -0
  65. package/build/cjs/tracing/sentrySpan.js.map +1 -1
  66. package/build/cjs/tracing/spans/beforeSendSpan.js +43 -0
  67. package/build/cjs/tracing/spans/beforeSendSpan.js.map +1 -0
  68. package/build/cjs/tracing/spans/captureSpan.js +126 -0
  69. package/build/cjs/tracing/spans/captureSpan.js.map +1 -0
  70. package/build/cjs/tracing/spans/envelope.js +38 -0
  71. package/build/cjs/tracing/spans/envelope.js.map +1 -0
  72. package/build/cjs/tracing/spans/estimateSize.js +41 -0
  73. package/build/cjs/tracing/spans/estimateSize.js.map +1 -0
  74. package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js +11 -0
  75. package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
  76. package/build/cjs/tracing/spans/spanBuffer.js +158 -0
  77. package/build/cjs/tracing/spans/spanBuffer.js.map +1 -0
  78. package/build/cjs/tracing/trace.js +83 -13
  79. package/build/cjs/tracing/trace.js.map +1 -1
  80. package/build/cjs/tracing/vercel-ai/utils.js +1 -4
  81. package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
  82. package/build/cjs/utils/featureFlags.js +6 -0
  83. package/build/cjs/utils/featureFlags.js.map +1 -1
  84. package/build/cjs/utils/object.js +33 -0
  85. package/build/cjs/utils/object.js.map +1 -1
  86. package/build/cjs/utils/spanUtils.js +116 -13
  87. package/build/cjs/utils/spanUtils.js.map +1 -1
  88. package/build/cjs/utils/stacktrace.js +3 -1
  89. package/build/cjs/utils/stacktrace.js.map +1 -1
  90. package/build/cjs/utils/string.js +3 -0
  91. package/build/cjs/utils/string.js.map +1 -1
  92. package/build/cjs/utils/version.js +1 -1
  93. package/build/esm/attributes.js +43 -1
  94. package/build/esm/attributes.js.map +1 -1
  95. package/build/esm/client.js +8 -1
  96. package/build/esm/client.js.map +1 -1
  97. package/build/esm/envelope.js +2 -1
  98. package/build/esm/envelope.js.map +1 -1
  99. package/build/esm/index.js +10 -2
  100. package/build/esm/index.js.map +1 -1
  101. package/build/esm/integration.js +6 -0
  102. package/build/esm/integration.js.map +1 -1
  103. package/build/esm/integrations/express/index.js +202 -0
  104. package/build/esm/integrations/express/index.js.map +1 -0
  105. package/build/esm/integrations/express/patch-layer.js +249 -0
  106. package/build/esm/integrations/express/patch-layer.js.map +1 -0
  107. package/build/esm/integrations/express/request-layer-store.js +22 -0
  108. package/build/esm/integrations/express/request-layer-store.js.map +1 -0
  109. package/build/esm/integrations/express/set-sdk-processing-metadata.js +15 -0
  110. package/build/esm/integrations/express/set-sdk-processing-metadata.js.map +1 -0
  111. package/build/esm/integrations/express/types.js +10 -0
  112. package/build/esm/integrations/express/types.js.map +1 -0
  113. package/build/esm/integrations/express/utils.js +225 -0
  114. package/build/esm/integrations/express/utils.js.map +1 -0
  115. package/build/esm/integrations/mcp-server/correlation.js +5 -1
  116. package/build/esm/integrations/mcp-server/correlation.js.map +1 -1
  117. package/build/esm/integrations/mcp-server/handlers.js +18 -10
  118. package/build/esm/integrations/mcp-server/handlers.js.map +1 -1
  119. package/build/esm/integrations/mcp-server/index.js +2 -1
  120. package/build/esm/integrations/mcp-server/index.js.map +1 -1
  121. package/build/esm/integrations/mcp-server/transport.js +1 -1
  122. package/build/esm/integrations/mcp-server/transport.js.map +1 -1
  123. package/build/esm/integrations/mcp-server/validation.js +7 -5
  124. package/build/esm/integrations/mcp-server/validation.js.map +1 -1
  125. package/build/esm/integrations/spanStreaming.js +46 -0
  126. package/build/esm/integrations/spanStreaming.js.map +1 -0
  127. package/build/esm/package.json +1 -1
  128. package/build/esm/semanticAttributes.js +26 -4
  129. package/build/esm/semanticAttributes.js.map +1 -1
  130. package/build/esm/tracing/ai/gen-ai-attributes.js +8 -56
  131. package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
  132. package/build/esm/tracing/ai/utils.js +51 -2
  133. package/build/esm/tracing/ai/utils.js.map +1 -1
  134. package/build/esm/tracing/anthropic-ai/index.js +2 -13
  135. package/build/esm/tracing/anthropic-ai/index.js.map +1 -1
  136. package/build/esm/tracing/anthropic-ai/streaming.js +3 -101
  137. package/build/esm/tracing/anthropic-ai/streaming.js.map +1 -1
  138. package/build/esm/tracing/dynamicSamplingContext.js +2 -1
  139. package/build/esm/tracing/dynamicSamplingContext.js.map +1 -1
  140. package/build/esm/tracing/google-genai/constants.js +2 -5
  141. package/build/esm/tracing/google-genai/constants.js.map +1 -1
  142. package/build/esm/tracing/google-genai/index.js +25 -31
  143. package/build/esm/tracing/google-genai/index.js.map +1 -1
  144. package/build/esm/tracing/google-genai/streaming.js +2 -23
  145. package/build/esm/tracing/google-genai/streaming.js.map +1 -1
  146. package/build/esm/tracing/langchain/embeddings.js +129 -0
  147. package/build/esm/tracing/langchain/embeddings.js.map +1 -0
  148. package/build/esm/tracing/langchain/index.js.map +1 -1
  149. package/build/esm/tracing/openai/index.js +3 -30
  150. package/build/esm/tracing/openai/index.js.map +1 -1
  151. package/build/esm/tracing/openai/streaming.js +4 -35
  152. package/build/esm/tracing/openai/streaming.js.map +1 -1
  153. package/build/esm/tracing/openai/utils.js +79 -196
  154. package/build/esm/tracing/openai/utils.js.map +1 -1
  155. package/build/esm/tracing/sentryNonRecordingSpan.js +7 -0
  156. package/build/esm/tracing/sentryNonRecordingSpan.js.map +1 -1
  157. package/build/esm/tracing/sentrySpan.js +40 -1
  158. package/build/esm/tracing/sentrySpan.js.map +1 -1
  159. package/build/esm/tracing/spans/beforeSendSpan.js +40 -0
  160. package/build/esm/tracing/spans/beforeSendSpan.js.map +1 -0
  161. package/build/esm/tracing/spans/captureSpan.js +122 -0
  162. package/build/esm/tracing/spans/captureSpan.js.map +1 -0
  163. package/build/esm/tracing/spans/envelope.js +36 -0
  164. package/build/esm/tracing/spans/envelope.js.map +1 -0
  165. package/build/esm/tracing/spans/estimateSize.js +39 -0
  166. package/build/esm/tracing/spans/estimateSize.js.map +1 -0
  167. package/build/esm/tracing/spans/hasSpanStreamingEnabled.js +9 -0
  168. package/build/esm/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
  169. package/build/esm/tracing/spans/spanBuffer.js +156 -0
  170. package/build/esm/tracing/spans/spanBuffer.js.map +1 -0
  171. package/build/esm/tracing/trace.js +84 -14
  172. package/build/esm/tracing/trace.js.map +1 -1
  173. package/build/esm/tracing/vercel-ai/utils.js +2 -5
  174. package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
  175. package/build/esm/utils/featureFlags.js +6 -0
  176. package/build/esm/utils/featureFlags.js.map +1 -1
  177. package/build/esm/utils/object.js +33 -1
  178. package/build/esm/utils/object.js.map +1 -1
  179. package/build/esm/utils/spanUtils.js +112 -14
  180. package/build/esm/utils/spanUtils.js.map +1 -1
  181. package/build/esm/utils/stacktrace.js +3 -1
  182. package/build/esm/utils/stacktrace.js.map +1 -1
  183. package/build/esm/utils/string.js +3 -0
  184. package/build/esm/utils/string.js.map +1 -1
  185. package/build/esm/utils/version.js +1 -1
  186. package/build/types/attributes.d.ts +5 -0
  187. package/build/types/attributes.d.ts.map +1 -1
  188. package/build/types/client.d.ts +35 -1
  189. package/build/types/client.d.ts.map +1 -1
  190. package/build/types/envelope.d.ts.map +1 -1
  191. package/build/types/index.d.ts +12 -4
  192. package/build/types/index.d.ts.map +1 -1
  193. package/build/types/integration.d.ts.map +1 -1
  194. package/build/types/integrations/express/index.d.ts +75 -0
  195. package/build/types/integrations/express/index.d.ts.map +1 -0
  196. package/build/types/integrations/express/patch-layer.d.ts +32 -0
  197. package/build/types/integrations/express/patch-layer.d.ts.map +1 -0
  198. package/build/types/integrations/express/request-layer-store.d.ts +32 -0
  199. package/build/types/integrations/express/request-layer-store.d.ts.map +1 -0
  200. package/build/types/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
  201. package/build/types/integrations/express/set-sdk-processing-metadata.d.ts.map +1 -0
  202. package/build/types/integrations/express/types.d.ts +154 -0
  203. package/build/types/integrations/express/types.d.ts.map +1 -0
  204. package/build/types/integrations/express/utils.d.ts +93 -0
  205. package/build/types/integrations/express/utils.d.ts.map +1 -0
  206. package/build/types/integrations/mcp-server/correlation.d.ts +2 -1
  207. package/build/types/integrations/mcp-server/correlation.d.ts.map +1 -1
  208. package/build/types/integrations/mcp-server/handlers.d.ts +9 -4
  209. package/build/types/integrations/mcp-server/handlers.d.ts.map +1 -1
  210. package/build/types/integrations/mcp-server/index.d.ts +2 -1
  211. package/build/types/integrations/mcp-server/index.d.ts.map +1 -1
  212. package/build/types/integrations/mcp-server/types.d.ts +40 -7
  213. package/build/types/integrations/mcp-server/types.d.ts.map +1 -1
  214. package/build/types/integrations/mcp-server/validation.d.ts +4 -1
  215. package/build/types/integrations/mcp-server/validation.d.ts.map +1 -1
  216. package/build/types/integrations/spanStreaming.d.ts +2 -0
  217. package/build/types/integrations/spanStreaming.d.ts.map +1 -0
  218. package/build/types/semanticAttributes.d.ts +23 -3
  219. package/build/types/semanticAttributes.d.ts.map +1 -1
  220. package/build/types/tracing/ai/gen-ai-attributes.d.ts +6 -38
  221. package/build/types/tracing/ai/gen-ai-attributes.d.ts.map +1 -1
  222. package/build/types/tracing/ai/utils.d.ts +21 -2
  223. package/build/types/tracing/ai/utils.d.ts.map +1 -1
  224. package/build/types/tracing/anthropic-ai/index.d.ts.map +1 -1
  225. package/build/types/tracing/anthropic-ai/streaming.d.ts.map +1 -1
  226. package/build/types/tracing/dynamicSamplingContext.d.ts.map +1 -1
  227. package/build/types/tracing/google-genai/constants.d.ts +1 -3
  228. package/build/types/tracing/google-genai/constants.d.ts.map +1 -1
  229. package/build/types/tracing/google-genai/index.d.ts.map +1 -1
  230. package/build/types/tracing/google-genai/streaming.d.ts.map +1 -1
  231. package/build/types/tracing/index.d.ts +1 -0
  232. package/build/types/tracing/index.d.ts.map +1 -1
  233. package/build/types/tracing/langchain/embeddings.d.ts +27 -0
  234. package/build/types/tracing/langchain/embeddings.d.ts.map +1 -0
  235. package/build/types/tracing/langchain/index.d.ts +1 -0
  236. package/build/types/tracing/langchain/index.d.ts.map +1 -1
  237. package/build/types/tracing/openai/index.d.ts.map +1 -1
  238. package/build/types/tracing/openai/streaming.d.ts.map +1 -1
  239. package/build/types/tracing/openai/utils.d.ts +4 -49
  240. package/build/types/tracing/openai/utils.d.ts.map +1 -1
  241. package/build/types/tracing/sentryNonRecordingSpan.d.ts +12 -1
  242. package/build/types/tracing/sentryNonRecordingSpan.d.ts.map +1 -1
  243. package/build/types/tracing/sentrySpan.d.ts +10 -1
  244. package/build/types/tracing/sentrySpan.d.ts.map +1 -1
  245. package/build/types/tracing/spans/beforeSendSpan.d.ts +35 -0
  246. package/build/types/tracing/spans/beforeSendSpan.d.ts.map +1 -0
  247. package/build/types/tracing/spans/captureSpan.d.ts +26 -0
  248. package/build/types/tracing/spans/captureSpan.d.ts.map +1 -0
  249. package/build/types/tracing/spans/envelope.d.ts +8 -0
  250. package/build/types/tracing/spans/envelope.d.ts.map +1 -0
  251. package/build/types/tracing/spans/estimateSize.d.ts +12 -0
  252. package/build/types/tracing/spans/estimateSize.d.ts.map +1 -0
  253. package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
  254. package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts.map +1 -0
  255. package/build/types/tracing/spans/spanBuffer.d.ts +60 -0
  256. package/build/types/tracing/spans/spanBuffer.d.ts.map +1 -0
  257. package/build/types/tracing/trace.d.ts.map +1 -1
  258. package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
  259. package/build/types/types-hoist/envelope.d.ts +22 -2
  260. package/build/types/types-hoist/envelope.d.ts.map +1 -1
  261. package/build/types/types-hoist/integration.d.ts +8 -0
  262. package/build/types/types-hoist/integration.d.ts.map +1 -1
  263. package/build/types/types-hoist/link.d.ts +2 -2
  264. package/build/types/types-hoist/link.d.ts.map +1 -1
  265. package/build/types/types-hoist/options.d.ts +26 -2
  266. package/build/types/types-hoist/options.d.ts.map +1 -1
  267. package/build/types/types-hoist/span.d.ts +35 -0
  268. package/build/types/types-hoist/span.d.ts.map +1 -1
  269. package/build/types/utils/featureFlags.d.ts.map +1 -1
  270. package/build/types/utils/object.d.ts +10 -0
  271. package/build/types/utils/object.d.ts.map +1 -1
  272. package/build/types/utils/spanUtils.d.ts +27 -2
  273. package/build/types/utils/spanUtils.d.ts.map +1 -1
  274. package/build/types/utils/stacktrace.d.ts.map +1 -1
  275. package/build/types/utils/string.d.ts +2 -2
  276. package/build/types/utils/string.d.ts.map +1 -1
  277. package/build/types-ts3.8/attributes.d.ts +5 -0
  278. package/build/types-ts3.8/client.d.ts +35 -1
  279. package/build/types-ts3.8/index.d.ts +12 -4
  280. package/build/types-ts3.8/integrations/express/index.d.ts +75 -0
  281. package/build/types-ts3.8/integrations/express/patch-layer.d.ts +32 -0
  282. package/build/types-ts3.8/integrations/express/request-layer-store.d.ts +32 -0
  283. package/build/types-ts3.8/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
  284. package/build/types-ts3.8/integrations/express/types.d.ts +154 -0
  285. package/build/types-ts3.8/integrations/express/utils.d.ts +96 -0
  286. package/build/types-ts3.8/integrations/mcp-server/correlation.d.ts +2 -1
  287. package/build/types-ts3.8/integrations/mcp-server/handlers.d.ts +9 -4
  288. package/build/types-ts3.8/integrations/mcp-server/index.d.ts +2 -1
  289. package/build/types-ts3.8/integrations/mcp-server/types.d.ts +40 -7
  290. package/build/types-ts3.8/integrations/mcp-server/validation.d.ts +4 -1
  291. package/build/types-ts3.8/integrations/spanStreaming.d.ts +2 -0
  292. package/build/types-ts3.8/semanticAttributes.d.ts +23 -3
  293. package/build/types-ts3.8/tracing/ai/gen-ai-attributes.d.ts +6 -38
  294. package/build/types-ts3.8/tracing/ai/utils.d.ts +21 -2
  295. package/build/types-ts3.8/tracing/google-genai/constants.d.ts +1 -3
  296. package/build/types-ts3.8/tracing/index.d.ts +1 -0
  297. package/build/types-ts3.8/tracing/langchain/embeddings.d.ts +27 -0
  298. package/build/types-ts3.8/tracing/langchain/index.d.ts +1 -0
  299. package/build/types-ts3.8/tracing/openai/utils.d.ts +4 -49
  300. package/build/types-ts3.8/tracing/sentryNonRecordingSpan.d.ts +12 -1
  301. package/build/types-ts3.8/tracing/sentrySpan.d.ts +10 -1
  302. package/build/types-ts3.8/tracing/spans/beforeSendSpan.d.ts +35 -0
  303. package/build/types-ts3.8/tracing/spans/captureSpan.d.ts +26 -0
  304. package/build/types-ts3.8/tracing/spans/envelope.d.ts +8 -0
  305. package/build/types-ts3.8/tracing/spans/estimateSize.d.ts +12 -0
  306. package/build/types-ts3.8/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
  307. package/build/types-ts3.8/tracing/spans/spanBuffer.d.ts +60 -0
  308. package/build/types-ts3.8/types-hoist/envelope.d.ts +22 -2
  309. package/build/types-ts3.8/types-hoist/integration.d.ts +8 -0
  310. package/build/types-ts3.8/types-hoist/link.d.ts +2 -2
  311. package/build/types-ts3.8/types-hoist/options.d.ts +26 -2
  312. package/build/types-ts3.8/types-hoist/span.d.ts +35 -0
  313. package/build/types-ts3.8/utils/object.d.ts +10 -0
  314. package/build/types-ts3.8/utils/spanUtils.d.ts +27 -2
  315. package/build/types-ts3.8/utils/string.d.ts +2 -2
  316. package/package.json +1 -1
@@ -74,15 +74,48 @@ export interface MCPTransport {
74
74
  export type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse;
75
75
  /**
76
76
  * MCP server instance interface
77
- * @description MCP server methods for registering handlers
77
+ * @description MCP server methods for registering handlers.
78
+ * Supports both the legacy API (`tool`, `resource`, `prompt`) used in SDK 1.x
79
+ * and the newer API (`registerTool`, `registerResource`, `registerPrompt`) introduced in SDK 1.x
80
+ * and made the only option in SDK 2.x.
78
81
  */
79
82
  export interface MCPServerInstance {
80
- /** Register a resource handler */
81
- resource: (name: string, ...args: unknown[]) => void;
82
- /** Register a tool handler */
83
- tool: (name: string, ...args: unknown[]) => void;
84
- /** Register a prompt handler */
85
- prompt: (name: string, ...args: unknown[]) => void;
83
+ /**
84
+ * Register a resource handler.
85
+ * Supported in `@modelcontextprotocol/sdk` v1.x alongside `registerResource`.
86
+ * @deprecated Removed in `@modelcontextprotocol/sdk` v2.0.0 — use `registerResource` instead.
87
+ */
88
+ resource?: (name: string, ...args: unknown[]) => void;
89
+ /**
90
+ * Register a tool handler.
91
+ * Supported in `@modelcontextprotocol/sdk` v1.x alongside `registerTool`.
92
+ * @deprecated Removed in `@modelcontextprotocol/sdk` v2.0.0 — use `registerTool` instead.
93
+ */
94
+ tool?: (name: string, ...args: unknown[]) => void;
95
+ /**
96
+ * Register a prompt handler.
97
+ * Supported in `@modelcontextprotocol/sdk` v1.x alongside `registerPrompt`.
98
+ * @deprecated Removed in `@modelcontextprotocol/sdk` v2.0.0 — use `registerPrompt` instead.
99
+ */
100
+ prompt?: (name: string, ...args: unknown[]) => void;
101
+ /**
102
+ * Register a resource handler.
103
+ * Available in `@modelcontextprotocol/sdk` v1.x (alongside the legacy `resource` method)
104
+ * and the only supported form in v2.0.0+.
105
+ */
106
+ registerResource?: (name: string, ...args: unknown[]) => void;
107
+ /**
108
+ * Register a tool handler.
109
+ * Available in `@modelcontextprotocol/sdk` v1.x (alongside the legacy `tool` method)
110
+ * and the only supported form in v2.0.0+.
111
+ */
112
+ registerTool?: (name: string, ...args: unknown[]) => void;
113
+ /**
114
+ * Register a prompt handler.
115
+ * Available in `@modelcontextprotocol/sdk` v1.x (alongside the legacy `prompt` method)
116
+ * and the only supported form in v2.0.0+.
117
+ */
118
+ registerPrompt?: (name: string, ...args: unknown[]) => void;
86
119
  /** Connect the server to a transport */
87
120
  connect(transport: MCPTransport): Promise<void>;
88
121
  }
@@ -23,7 +23,10 @@ export declare function isJsonRpcNotification(message: unknown): message is Json
23
23
  */
24
24
  export declare function isJsonRpcResponse(message: unknown): message is JsonRpcResponse;
25
25
  /**
26
- * Validates MCP server instance with type checking
26
+ * Validates MCP server instance with type checking.
27
+ * Accepts both the legacy API (`tool`, `resource`, `prompt`) used in SDK 1.x
28
+ * and the newer API (`registerTool`, `registerResource`, `registerPrompt`) introduced
29
+ * alongside the legacy API in SDK 1.x and made the only option in SDK 2.x.
27
30
  * @param instance - Object to validate as MCP server instance
28
31
  * @returns True if instance has required MCP server methods
29
32
  */
@@ -0,0 +1,2 @@
1
+ export declare const spanStreamingIntegration: () => import("../types-hoist/integration").Integration;
2
+ //# sourceMappingURL=spanStreaming.d.ts.map
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Use this attribute to represent the source of a span.
3
- * Should be one of: custom, url, route, view, component, task, unknown
4
- *
2
+ * Use this attribute to represent the source of a span name.
3
+ * Must be one of: custom, url, route, view, component, task
4
+ * TODO(v11): rename this to sentry.span.source'
5
5
  */
6
6
  export declare const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = "sentry.source";
7
7
  /**
@@ -32,6 +32,26 @@ export declare const SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON = "sentry
32
32
  export declare const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT = "sentry.measurement_unit";
33
33
  /** The value of a measurement, which may be stored as a TimedEvent. */
34
34
  export declare const SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE = "sentry.measurement_value";
35
+ /** The release version of the application */
36
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_RELEASE = "sentry.release";
37
+ /** The environment name (e.g., "production", "staging", "development") */
38
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT = "sentry.environment";
39
+ /** The segment name (e.g., "GET /users") */
40
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME = "sentry.segment.name";
41
+ /** The id of the segment that this span belongs to. */
42
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID = "sentry.segment.id";
43
+ /** The name of the Sentry SDK (e.g., "sentry.php", "sentry.javascript") */
44
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME = "sentry.sdk.name";
45
+ /** The version of the Sentry SDK */
46
+ export declare const SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION = "sentry.sdk.version";
47
+ /** The user ID (gated by sendDefaultPii) */
48
+ export declare const SEMANTIC_ATTRIBUTE_USER_ID = "user.id";
49
+ /** The user email (gated by sendDefaultPii) */
50
+ export declare const SEMANTIC_ATTRIBUTE_USER_EMAIL = "user.email";
51
+ /** The user IP address (gated by sendDefaultPii) */
52
+ export declare const SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS = "user.ip_address";
53
+ /** The user username (gated by sendDefaultPii) */
54
+ export declare const SEMANTIC_ATTRIBUTE_USER_USERNAME = "user.name";
35
55
  /**
36
56
  * A custom span name set by users guaranteed to be taken over any automatically
37
57
  * inferred name. This attribute is removed before the span is sent.
@@ -165,26 +165,18 @@ export declare const GEN_AI_USAGE_INPUT_TOKENS_CACHED_ATTRIBUTE = "gen_ai.usage.
165
165
  */
166
166
  export declare const GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE = "gen_ai.invoke_agent";
167
167
  /**
168
- * The span operation name for generating text
168
+ * The span operation name for generating content
169
169
  */
170
- export declare const GEN_AI_GENERATE_TEXT_DO_GENERATE_OPERATION_ATTRIBUTE = "gen_ai.generate_text";
171
- /**
172
- * The span operation name for streaming text
173
- */
174
- export declare const GEN_AI_STREAM_TEXT_DO_STREAM_OPERATION_ATTRIBUTE = "gen_ai.stream_text";
175
- /**
176
- * The span operation name for generating object
177
- */
178
- export declare const GEN_AI_GENERATE_OBJECT_DO_GENERATE_OPERATION_ATTRIBUTE = "gen_ai.generate_object";
179
- /**
180
- * The span operation name for streaming object
181
- */
182
- export declare const GEN_AI_STREAM_OBJECT_DO_STREAM_OPERATION_ATTRIBUTE = "gen_ai.stream_object";
170
+ export declare const GEN_AI_GENERATE_CONTENT_OPERATION_ATTRIBUTE = "gen_ai.generate_content";
183
171
  /**
184
172
  * The embeddings input
185
173
  * Only recorded when recordInputs is enabled
186
174
  */
187
175
  export declare const GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE = "gen_ai.embeddings.input";
176
+ /**
177
+ * The span operation for embeddings
178
+ */
179
+ export declare const GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE = "gen_ai.embeddings";
188
180
  /**
189
181
  * The span operation name for embedding
190
182
  */
@@ -226,28 +218,4 @@ export declare const GEN_AI_TOOL_OUTPUT_ATTRIBUTE = "gen_ai.tool.output";
226
218
  * @see https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-tool-description
227
219
  */
228
220
  export declare const GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE = "gen_ai.tool.description";
229
- /**
230
- * The response ID from OpenAI
231
- */
232
- export declare const OPENAI_RESPONSE_ID_ATTRIBUTE = "openai.response.id";
233
- /**
234
- * The response model from OpenAI
235
- */
236
- export declare const OPENAI_RESPONSE_MODEL_ATTRIBUTE = "openai.response.model";
237
- /**
238
- * The response timestamp from OpenAI (ISO string)
239
- */
240
- export declare const OPENAI_RESPONSE_TIMESTAMP_ATTRIBUTE = "openai.response.timestamp";
241
- /**
242
- * The number of completion tokens used
243
- */
244
- export declare const OPENAI_USAGE_COMPLETION_TOKENS_ATTRIBUTE = "openai.usage.completion_tokens";
245
- /**
246
- * The number of prompt tokens used
247
- */
248
- export declare const OPENAI_USAGE_PROMPT_TOKENS_ATTRIBUTE = "openai.usage.prompt_tokens";
249
- /**
250
- * The response timestamp from Anthropic AI (ISO string)
251
- */
252
- export declare const ANTHROPIC_AI_RESPONSE_TIMESTAMP_ATTRIBUTE = "anthropic.response.timestamp";
253
221
  //# sourceMappingURL=gen-ai-attributes.d.ts.map
@@ -8,10 +8,12 @@ export interface AIRecordingOptions {
8
8
  * which gen_ai operation it maps to and whether it is intrinsically streaming.
9
9
  */
10
10
  export interface InstrumentedMethodEntry {
11
- /** Operation name (e.g. 'chat', 'embeddings', 'generate_content') */
12
- operation: string;
11
+ /** Operation name (e.g. 'chat', 'embeddings', 'generate_content'). Omit for factory methods that only need result proxying. */
12
+ operation?: string;
13
13
  /** True if the method itself is always streaming (not param-based) */
14
14
  streaming?: boolean;
15
+ /** When set, the method's return value is re-proxied with this as the base path */
16
+ proxyResultPath?: string;
15
17
  }
16
18
  /**
17
19
  * Maps method paths to their registry entries.
@@ -37,6 +39,23 @@ export declare function buildMethodPath(currentPath: string, prop: string): stri
37
39
  * @param cachedOutputTokens - The number of cached output tokens
38
40
  */
39
41
  export declare function setTokenUsageAttributes(span: Span, promptTokens?: number, completionTokens?: number, cachedInputTokens?: number, cachedOutputTokens?: number): void;
42
+ export interface StreamResponseState {
43
+ responseId?: string;
44
+ responseModel?: string;
45
+ finishReasons: string[];
46
+ responseTexts: string[];
47
+ toolCalls: unknown[];
48
+ promptTokens?: number;
49
+ completionTokens?: number;
50
+ totalTokens?: number;
51
+ cacheCreationInputTokens?: number;
52
+ cacheReadInputTokens?: number;
53
+ }
54
+ /**
55
+ * Ends a streaming span by setting all accumulated response attributes and ending the span.
56
+ * Shared across OpenAI, Anthropic, and Google GenAI streaming implementations.
57
+ */
58
+ export declare function endStreamSpan(span: Span, state: StreamResponseState, recordOutputs: boolean): void;
40
59
  /**
41
60
  * Get the truncated JSON string for a string or array of strings.
42
61
  *
@@ -11,7 +11,7 @@ export declare const GOOGLE_GENAI_METHOD_REGISTRY: {
11
11
  readonly operation: "embeddings";
12
12
  };
13
13
  readonly 'chats.create': {
14
- readonly operation: "chat";
14
+ readonly proxyResultPath: "chat";
15
15
  };
16
16
  readonly 'chat.sendMessage': {
17
17
  readonly operation: "chat";
@@ -22,6 +22,4 @@ export declare const GOOGLE_GENAI_METHOD_REGISTRY: {
22
22
  };
23
23
  };
24
24
  export declare const GOOGLE_GENAI_SYSTEM_NAME = "google_genai";
25
- export declare const CHATS_CREATE_METHOD = "chats.create";
26
- export declare const CHAT_PATH = "chat";
27
25
  //# sourceMappingURL=constants.d.ts.map
@@ -10,4 +10,5 @@ export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan,
10
10
  export { setMeasurement, timedEventsToMeasurements } from './measurement';
11
11
  export { sampleSpan } from './sampling';
12
12
  export { logSpanEnd, logSpanStart } from './logSpans';
13
+ export { captureSpan } from './spans/captureSpan';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { LangChainOptions } from './types';
2
+ /**
3
+ * Wraps a LangChain embedding method (embedQuery or embedDocuments) to create Sentry spans.
4
+ *
5
+ * Used internally by the Node.js auto-instrumentation to patch embedding class prototypes.
6
+ */
7
+ export declare function instrumentEmbeddingMethod(originalMethod: (...args: unknown[]) => Promise<unknown>, options?: LangChainOptions): (...args: unknown[]) => Promise<unknown>;
8
+ /**
9
+ * Wraps a LangChain embeddings instance to create Sentry spans for `embedQuery` and `embedDocuments` calls.
10
+ *
11
+ * Use this in non-Node runtimes (Cloudflare, browser, etc.) where auto-instrumentation is not available.
12
+ *
13
+ * @example
14
+ * ```javascript
15
+ * import * as Sentry from '@sentry/cloudflare';
16
+ * import { OpenAIEmbeddings } from '@langchain/openai';
17
+ *
18
+ * const embeddings = Sentry.instrumentLangChainEmbeddings(
19
+ * new OpenAIEmbeddings({ model: 'text-embedding-3-small' })
20
+ * );
21
+ *
22
+ * await embeddings.embedQuery('Hello world');
23
+ * await embeddings.embedDocuments(['doc1', 'doc2']);
24
+ * ```
25
+ */
26
+ export declare function instrumentLangChainEmbeddings<T extends object>(instance: T, options?: LangChainOptions): T;
27
+ //# sourceMappingURL=embeddings.d.ts.map
@@ -6,4 +6,5 @@ import { LangChainCallbackHandler, LangChainOptions } from './types';
6
6
  * This is a stateful handler that tracks spans across multiple LangChain executions.
7
7
  */
8
8
  export declare function createLangChainCallbackHandler(options?: LangChainOptions): LangChainCallbackHandler;
9
+ export { instrumentLangChainEmbeddings } from './embeddings';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1,22 +1,5 @@
1
1
  import { Span } from '../../types-hoist/span';
2
- import { ChatCompletionChunk, OpenAiChatCompletionObject, OpenAIConversationObject, OpenAICreateEmbeddingsObject, OpenAIResponseObject, ResponseStreamingEvent } from './types';
3
- /**
4
- * Check if response is a Chat Completion object
5
- */
6
- export declare function isChatCompletionResponse(response: unknown): response is OpenAiChatCompletionObject;
7
- /**
8
- * Check if response is a Responses API object
9
- */
10
- export declare function isResponsesApiResponse(response: unknown): response is OpenAIResponseObject;
11
- /**
12
- * Check if response is an Embeddings API object
13
- */
14
- export declare function isEmbeddingsResponse(response: unknown): response is OpenAICreateEmbeddingsObject;
15
- /**
16
- * Check if response is a Conversations API object
17
- * @see https://platform.openai.com/docs/api-reference/conversations
18
- */
19
- export declare function isConversationResponse(response: unknown): response is OpenAIConversationObject;
2
+ import { ChatCompletionChunk, ResponseStreamingEvent } from './types';
20
3
  /**
21
4
  * Check if streaming event is from the Responses API
22
5
  */
@@ -26,38 +9,10 @@ export declare function isResponsesApiStreamEvent(event: unknown): event is Resp
26
9
  */
27
10
  export declare function isChatCompletionChunk(event: unknown): event is ChatCompletionChunk;
28
11
  /**
29
- * Add attributes for Chat Completion responses
30
- */
31
- export declare function addChatCompletionAttributes(span: Span, response: OpenAiChatCompletionObject, recordOutputs?: boolean): void;
32
- /**
33
- * Add attributes for Responses API responses
34
- */
35
- export declare function addResponsesApiAttributes(span: Span, response: OpenAIResponseObject, recordOutputs?: boolean): void;
36
- /**
37
- * Add attributes for Embeddings API responses
38
- */
39
- export declare function addEmbeddingsAttributes(span: Span, response: OpenAICreateEmbeddingsObject): void;
40
- /**
41
- * Add attributes for Conversations API responses
42
- * @see https://platform.openai.com/docs/api-reference/conversations
43
- */
44
- export declare function addConversationAttributes(span: Span, response: OpenAIConversationObject): void;
45
- /**
46
- * Set token usage attributes
47
- * @param span - The span to add attributes to
48
- * @param promptTokens - The number of prompt tokens
49
- * @param completionTokens - The number of completion tokens
50
- * @param totalTokens - The number of total tokens
51
- */
52
- export declare function setTokenUsageAttributes(span: Span, promptTokens?: number, completionTokens?: number, totalTokens?: number): void;
53
- /**
54
- * Set common response attributes
55
- * @param span - The span to add attributes to
56
- * @param id - The response id
57
- * @param model - The response model
58
- * @param timestamp - The response timestamp
12
+ * Add response attributes to a span using duck-typing.
13
+ * Works for Chat Completions, Responses API, Embeddings, and Conversations API responses.
59
14
  */
60
- export declare function setCommonResponseAttributes(span: Span, id: string, model: string, timestamp: number): void;
15
+ export declare function addResponseAttributes(span: Span, result: unknown, recordOutputs?: boolean): void;
61
16
  /**
62
17
  * Extract request parameters including model settings and conversation context
63
18
  */
@@ -1,12 +1,22 @@
1
+ import { EventDropReason } from '../types-hoist/clientreport';
1
2
  import { SentrySpanArguments, Span, SpanAttributes, SpanAttributeValue, SpanContextData, SpanTimeInput } from '../types-hoist/span';
2
3
  import { SpanStatus } from '../types-hoist/spanStatus';
4
+ interface SentryNonRecordingSpanArguments extends SentrySpanArguments {
5
+ dropReason?: EventDropReason;
6
+ }
3
7
  /**
4
8
  * A Sentry Span that is non-recording, meaning it will not be sent to Sentry.
5
9
  */
6
10
  export declare class SentryNonRecordingSpan implements Span {
7
11
  private _traceId;
8
12
  private _spanId;
9
- constructor(spanContext?: SentrySpanArguments);
13
+ /**
14
+ * Reason why this span was dropped, if applicable ('ignored' or 'sample_rate').
15
+ * Used to propagate the correct client report outcome to descendant spans
16
+ * when span streaming is enabled.
17
+ */
18
+ dropReason?: EventDropReason;
19
+ constructor(spanContext?: SentryNonRecordingSpanArguments);
10
20
  /** @inheritdoc */
11
21
  spanContext(): SpanContextData;
12
22
  /** @inheritdoc */
@@ -36,4 +46,5 @@ export declare class SentryNonRecordingSpan implements Span {
36
46
  */
37
47
  recordException(_exception: unknown, _time?: number | undefined): void;
38
48
  }
49
+ export {};
39
50
  //# sourceMappingURL=sentryNonRecordingSpan.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { SpanLink } from '../types-hoist/link';
2
- import { SentrySpanArguments, Span, SpanAttributes, SpanAttributeValue, SpanContextData, SpanJSON, SpanTimeInput } from '../types-hoist/span';
2
+ import { SentrySpanArguments, Span, SpanAttributes, SpanAttributeValue, SpanContextData, SpanJSON, SpanTimeInput, StreamedSpanJSON } from '../types-hoist/span';
3
3
  import { SpanStatus } from '../types-hoist/spanStatus';
4
4
  import { TimedEvent } from '../types-hoist/timedEvent';
5
5
  /**
@@ -77,6 +77,15 @@ export declare class SentrySpan implements Span {
77
77
  * use `spanToJSON(span)` instead.
78
78
  */
79
79
  getSpanJSON(): SpanJSON;
80
+ /**
81
+ * Get {@link StreamedSpanJSON} representation of this span.
82
+ *
83
+ * @hidden
84
+ * @internal This method is purely for internal purposes and should not be used outside
85
+ * of SDK code. If you need to get a JSON representation of a span,
86
+ * use `spanToStreamedSpanJSON(span)` instead.
87
+ */
88
+ getStreamedSpanJSON(): StreamedSpanJSON;
80
89
  /** @inheritdoc */
81
90
  isRecording(): boolean;
82
91
  /**
@@ -0,0 +1,35 @@
1
+ import { CoreOptions } from '../../types-hoist/options';
2
+ import { BeforeSendStreamedSpanCallback } from '../../types-hoist/options';
3
+ import { StreamedSpanJSON } from '../../types-hoist/span';
4
+ type StaticBeforeSendSpanCallback = CoreOptions['beforeSendSpan'];
5
+ /**
6
+ * A wrapper to use the new span format in your `beforeSendSpan` callback.
7
+ *
8
+ * When using `traceLifecycle: 'stream'`, wrap your callback with this function
9
+ * to receive and return {@link StreamedSpanJSON} instead of the standard {@link SpanJSON}.
10
+ *
11
+ * @example
12
+ *
13
+ * Sentry.init({
14
+ * traceLifecycle: 'stream',
15
+ * beforeSendSpan: withStreamedSpan((span) => {
16
+ * // span is of type StreamedSpanJSON
17
+ * return span;
18
+ * }),
19
+ * });
20
+ *
21
+ * @param callback - The callback function that receives and returns a {@link StreamedSpanJSON}.
22
+ * @returns A callback that is compatible with the `beforeSendSpan` option when using `traceLifecycle: 'stream'`.
23
+ */
24
+ export declare function withStreamedSpan(callback: (span: StreamedSpanJSON) => StreamedSpanJSON): StaticBeforeSendSpanCallback & {
25
+ _streamed: true;
26
+ };
27
+ /**
28
+ * Typesafe check to identify if a `beforeSendSpan` callback expects the streamed span JSON format.
29
+ *
30
+ * @param callback - The `beforeSendSpan` callback to check.
31
+ * @returns `true` if the callback was wrapped with {@link withStreamedSpan}.
32
+ */
33
+ export declare function isStreamedBeforeSendSpanCallback(callback: unknown): callback is BeforeSendStreamedSpanCallback;
34
+ export {};
35
+ //# sourceMappingURL=beforeSendSpan.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { RawAttributes } from '../../attributes';
2
+ import { Client } from '../../client';
3
+ import { SerializedStreamedSpan, Span, StreamedSpanJSON } from '../../types-hoist/span';
4
+ export type SerializedStreamedSpanWithSegmentSpan = SerializedStreamedSpan & {
5
+ _segmentSpan: Span;
6
+ };
7
+ /**
8
+ * Captures a span and returns a JSON representation to be enqueued for sending.
9
+ *
10
+ * IMPORTANT: This function converts the span to JSON immediately to avoid writing
11
+ * to an already-ended OTel span instance (which is blocked by the OTel Span class).
12
+ *
13
+ * @returns the final serialized span with a reference to its segment span. This reference
14
+ * is needed later on to compute the DSC for the span envelope.
15
+ */
16
+ export declare function captureSpan(span: Span, client: Client): SerializedStreamedSpanWithSegmentSpan;
17
+ /**
18
+ * Apply a user-provided beforeSendSpan callback to a span JSON.
19
+ */
20
+ export declare function applyBeforeSendSpanCallback(span: StreamedSpanJSON, beforeSendSpan: (span: StreamedSpanJSON) => StreamedSpanJSON): StreamedSpanJSON;
21
+ /**
22
+ * Safely set attributes on a span JSON.
23
+ * If an attribute already exists, it will not be overwritten.
24
+ */
25
+ export declare function safeSetSpanJSONAttributes(spanJSON: StreamedSpanJSON, newAttributes: RawAttributes<Record<string, unknown>>): void;
26
+ //# sourceMappingURL=captureSpan.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { Client } from '../../client';
2
+ import { DynamicSamplingContext, StreamedSpanEnvelope } from '../../types-hoist/envelope';
3
+ import { SerializedStreamedSpan } from '../../types-hoist/span';
4
+ /**
5
+ * Creates a span v2 span streaming envelope
6
+ */
7
+ export declare function createStreamedSpanEnvelope(serializedSpans: Array<SerializedStreamedSpan>, dsc: Partial<DynamicSamplingContext>, client: Client): StreamedSpanEnvelope;
8
+ //# sourceMappingURL=envelope.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { SerializedStreamedSpan } from '../../types-hoist/span';
2
+ /**
3
+ * Estimates the serialized byte size of a {@link SerializedStreamedSpan}.
4
+ *
5
+ * Uses 2 bytes per character as a UTF-16 approximation, and 8 bytes per number.
6
+ * The estimate is intentionally conservative and may be slightly lower than the
7
+ * actual byte size on the wire.
8
+ * We compensate for this by setting the span buffers internal limit well below the limit
9
+ * of how large an actual span v2 envelope may be.
10
+ */
11
+ export declare function estimateSerializedSpanSizeInBytes(span: SerializedStreamedSpan): number;
12
+ //# sourceMappingURL=estimateSize.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { Client } from '../../client';
2
+ /**
3
+ * Determines if span streaming is enabled for the given client
4
+ */
5
+ export declare function hasSpanStreamingEnabled(client: Client): boolean;
6
+ //# sourceMappingURL=hasSpanStreamingEnabled.d.ts.map
@@ -0,0 +1,60 @@
1
+ import { Client } from '../../client';
2
+ import { SerializedStreamedSpanWithSegmentSpan } from './captureSpan';
3
+ export interface SpanBufferOptions {
4
+ /**
5
+ * Max spans per trace before auto-flush
6
+ * Must not exceed 1000.
7
+ *
8
+ * @default 1_000
9
+ */
10
+ maxSpanLimit?: number;
11
+ /**
12
+ * Per-trace flush timeout in ms. A timeout is started when a trace bucket is first created
13
+ * and fires flush() for that specific trace when it expires.
14
+ * Must be greater than 0.
15
+ *
16
+ * @default 5_000
17
+ */
18
+ flushInterval?: number;
19
+ /**
20
+ * Max accumulated byte weight of spans per trace before auto-flush.
21
+ * Size is estimated, not exact. Uses 2 bytes per character for strings (UTF-16).
22
+ *
23
+ * @default 5_000_000 (5 MB)
24
+ */
25
+ maxTraceWeightInBytes?: number;
26
+ }
27
+ /**
28
+ * A buffer for serialized streamed span JSON objects that flushes them to Sentry in Span v2 envelopes.
29
+ * Handles per-trace timeout-based flushing, size thresholds, and graceful shutdown.
30
+ * Also handles computation of the Dynamic Sampling Context (DSC) for the trace, if it wasn't yet
31
+ * frozen onto the segment span.
32
+ *
33
+ * For this, we need the reference to the segment span instance, from
34
+ * which we compute the DSC. Doing this in the buffer ensures that we compute the DSC as late as possible,
35
+ * allowing span name and data updates up to this point. Worth noting here that the segment span is likely
36
+ * still active and modifyable when child spans are added to the buffer.
37
+ */
38
+ export declare class SpanBuffer {
39
+ private _traceBuckets;
40
+ private _client;
41
+ private _maxSpanLimit;
42
+ private _flushInterval;
43
+ private _maxTraceWeight;
44
+ constructor(client: Client, options?: SpanBufferOptions);
45
+ /**
46
+ * Add a span to the buffer.
47
+ */
48
+ add(spanJSON: SerializedStreamedSpanWithSegmentSpan): void;
49
+ /**
50
+ * Drain and flush all buffered traces.
51
+ */
52
+ drain(): void;
53
+ /**
54
+ * Flush spans of a specific trace.
55
+ * In contrast to {@link SpanBuffer.drain}, this method does not flush all traces, but only the one with the given traceId.
56
+ */
57
+ flush(traceId: string): void;
58
+ private _removeTrace;
59
+ }
60
+ //# sourceMappingURL=spanBuffer.d.ts.map
@@ -11,7 +11,7 @@ import { Profile, ProfileChunk } from './profiling';
11
11
  import { ReplayEvent, ReplayRecordingData } from './replay';
12
12
  import { SdkInfo } from './sdkinfo';
13
13
  import { SerializedSession, SessionAggregates } from './session';
14
- import { SpanJSON } from './span';
14
+ import { SerializedStreamedSpanContainer, SpanJSON } from './span';
15
15
  export type DynamicSamplingContext = {
16
16
  trace_id: string;
17
17
  public_key: DsnComponents['publicKey'];
@@ -87,6 +87,21 @@ type ProfileChunkItemHeaders = {
87
87
  type SpanItemHeaders = {
88
88
  type: 'span';
89
89
  };
90
+ type SpanContainerItemHeaders = {
91
+ /**
92
+ * Same as v1 span item type but this envelope is distinguished by {@link SpanContainerItemHeaders.content_type}.
93
+ */
94
+ type: 'span';
95
+ /**
96
+ * The number of span items in the container. This must be the same as the number of span items in the payload.
97
+ */
98
+ item_count: number;
99
+ /**
100
+ * The content type of the span items. This must be `application/vnd.sentry.items.span.v2+json`.
101
+ * (the presence of this field also distinguishes the span item from the v1 span item)
102
+ */
103
+ content_type: 'application/vnd.sentry.items.span.v2+json';
104
+ };
90
105
  type LogContainerItemHeaders = {
91
106
  type: 'log';
92
107
  /**
@@ -120,6 +135,7 @@ export type FeedbackItem = BaseEnvelopeItem<FeedbackItemHeaders, FeedbackEvent>;
120
135
  export type ProfileItem = BaseEnvelopeItem<ProfileItemHeaders, Profile>;
121
136
  export type ProfileChunkItem = BaseEnvelopeItem<ProfileChunkItemHeaders, ProfileChunk>;
122
137
  export type SpanItem = BaseEnvelopeItem<SpanItemHeaders, Partial<SpanJSON>>;
138
+ export type SpanContainerItem = BaseEnvelopeItem<SpanContainerItemHeaders, SerializedStreamedSpanContainer>;
123
139
  export type LogContainerItem = BaseEnvelopeItem<LogContainerItemHeaders, SerializedLogContainer>;
124
140
  export type MetricContainerItem = BaseEnvelopeItem<MetricContainerItemHeaders, SerializedMetricContainer>;
125
141
  export type RawSecurityItem = BaseEnvelopeItem<RawSecurityHeaders, LegacyCSPReport>;
@@ -139,6 +155,9 @@ type ReplayEnvelopeHeaders = BaseEnvelopeHeaders;
139
155
  type SpanEnvelopeHeaders = BaseEnvelopeHeaders & {
140
156
  trace?: DynamicSamplingContext;
141
157
  };
158
+ type StreamedSpanEnvelopeHeaders = BaseEnvelopeHeaders & {
159
+ trace?: DynamicSamplingContext;
160
+ };
142
161
  type LogEnvelopeHeaders = BaseEnvelopeHeaders;
143
162
  type MetricEnvelopeHeaders = BaseEnvelopeHeaders;
144
163
  export type EventEnvelope = BaseEnvelope<EventEnvelopeHeaders, EventItem | AttachmentItem | UserFeedbackItem | FeedbackItem | ProfileItem>;
@@ -153,11 +172,12 @@ export type ReplayEnvelope = [
153
172
  ];
154
173
  export type CheckInEnvelope = BaseEnvelope<CheckInEnvelopeHeaders, CheckInItem>;
155
174
  export type SpanEnvelope = BaseEnvelope<SpanEnvelopeHeaders, SpanItem>;
175
+ export type StreamedSpanEnvelope = BaseEnvelope<StreamedSpanEnvelopeHeaders, SpanContainerItem>;
156
176
  export type ProfileChunkEnvelope = BaseEnvelope<BaseEnvelopeHeaders, ProfileChunkItem>;
157
177
  export type RawSecurityEnvelope = BaseEnvelope<BaseEnvelopeHeaders, RawSecurityItem>;
158
178
  export type LogEnvelope = BaseEnvelope<LogEnvelopeHeaders, LogContainerItem>;
159
179
  export type MetricEnvelope = BaseEnvelope<MetricEnvelopeHeaders, MetricContainerItem>;
160
- export type Envelope = EventEnvelope | SessionEnvelope | ClientReportEnvelope | ProfileChunkEnvelope | ReplayEnvelope | CheckInEnvelope | SpanEnvelope | RawSecurityEnvelope | LogEnvelope | MetricEnvelope;
180
+ export type Envelope = EventEnvelope | SessionEnvelope | ClientReportEnvelope | ProfileChunkEnvelope | ReplayEnvelope | CheckInEnvelope | SpanEnvelope | StreamedSpanEnvelope | RawSecurityEnvelope | LogEnvelope | MetricEnvelope;
161
181
  export type EnvelopeItem = Envelope[1][number];
162
182
  export {};
163
183
  //# sourceMappingURL=envelope.d.ts.map
@@ -11,6 +11,14 @@ export interface Integration {
11
11
  * It does not receives any arguments, and should only use for e.g. global monkey patching and similar things.
12
12
  */
13
13
  setupOnce?(): void;
14
+ /**
15
+ * Called before the `setup` hook of any integration is called.
16
+ * This is useful if an integration needs to e.g. modify client options prior to other integrations
17
+ * reading client options.
18
+ *
19
+ * @param client
20
+ */
21
+ beforeSetup?(client: Client): void;
14
22
  /**
15
23
  * Set up an integration for the given client.
16
24
  * Receives the client as argument.
@@ -19,11 +19,11 @@ export interface SpanLink {
19
19
  * Link interface for the event envelope item. It's a flattened representation of `SpanLink`.
20
20
  * Can include additional fields defined by OTel.
21
21
  */
22
- export interface SpanLinkJSON extends Record<string, unknown> {
22
+ export interface SpanLinkJSON<TAttributes = SpanLinkAttributes> extends Record<string, unknown> {
23
23
  span_id: string;
24
24
  trace_id: string;
25
25
  sampled?: boolean;
26
- attributes?: SpanLinkAttributes;
26
+ attributes?: TAttributes;
27
27
  }
28
28
  export {};
29
29
  //# sourceMappingURL=link.d.ts.map