@sentry/core 10.46.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 (381) hide show
  1. package/build/cjs/api.js +1 -0
  2. package/build/cjs/api.js.map +1 -1
  3. package/build/cjs/attributes.js +43 -0
  4. package/build/cjs/attributes.js.map +1 -1
  5. package/build/cjs/client.js +13 -6
  6. package/build/cjs/client.js.map +1 -1
  7. package/build/cjs/currentScopes.js +33 -0
  8. package/build/cjs/currentScopes.js.map +1 -1
  9. package/build/cjs/envelope.js +4 -3
  10. package/build/cjs/envelope.js.map +1 -1
  11. package/build/cjs/index.js +50 -13
  12. package/build/cjs/index.js.map +1 -1
  13. package/build/cjs/integration.js +6 -0
  14. package/build/cjs/integration.js.map +1 -1
  15. package/build/cjs/integrations/express/index.js +206 -0
  16. package/build/cjs/integrations/express/index.js.map +1 -0
  17. package/build/cjs/integrations/express/patch-layer.js +251 -0
  18. package/build/cjs/integrations/express/patch-layer.js.map +1 -0
  19. package/build/cjs/integrations/express/request-layer-store.js +25 -0
  20. package/build/cjs/integrations/express/request-layer-store.js.map +1 -0
  21. package/build/cjs/integrations/express/set-sdk-processing-metadata.js +17 -0
  22. package/build/cjs/integrations/express/set-sdk-processing-metadata.js.map +1 -0
  23. package/build/cjs/integrations/express/types.js +17 -0
  24. package/build/cjs/integrations/express/types.js.map +1 -0
  25. package/build/cjs/integrations/express/utils.js +238 -0
  26. package/build/cjs/integrations/express/utils.js.map +1 -0
  27. package/build/cjs/integrations/mcp-server/correlation.js +5 -1
  28. package/build/cjs/integrations/mcp-server/correlation.js.map +1 -1
  29. package/build/cjs/integrations/mcp-server/handlers.js +18 -10
  30. package/build/cjs/integrations/mcp-server/handlers.js.map +1 -1
  31. package/build/cjs/integrations/mcp-server/index.js +2 -1
  32. package/build/cjs/integrations/mcp-server/index.js.map +1 -1
  33. package/build/cjs/integrations/mcp-server/transport.js +1 -1
  34. package/build/cjs/integrations/mcp-server/transport.js.map +1 -1
  35. package/build/cjs/integrations/mcp-server/validation.js +7 -5
  36. package/build/cjs/integrations/mcp-server/validation.js.map +1 -1
  37. package/build/cjs/integrations/spanStreaming.js +48 -0
  38. package/build/cjs/integrations/spanStreaming.js.map +1 -0
  39. package/build/cjs/integrations/supabase.js +1 -1
  40. package/build/cjs/integrations/supabase.js.map +1 -1
  41. package/build/cjs/semanticAttributes.js +35 -3
  42. package/build/cjs/semanticAttributes.js.map +1 -1
  43. package/build/cjs/tracing/ai/gen-ai-attributes.js +9 -79
  44. package/build/cjs/tracing/ai/gen-ai-attributes.js.map +1 -1
  45. package/build/cjs/tracing/ai/utils.js +50 -35
  46. package/build/cjs/tracing/ai/utils.js.map +1 -1
  47. package/build/cjs/tracing/anthropic-ai/constants.js +10 -10
  48. package/build/cjs/tracing/anthropic-ai/constants.js.map +1 -1
  49. package/build/cjs/tracing/anthropic-ai/index.js +18 -20
  50. package/build/cjs/tracing/anthropic-ai/index.js.map +1 -1
  51. package/build/cjs/tracing/anthropic-ai/streaming.js +2 -100
  52. package/build/cjs/tracing/anthropic-ai/streaming.js.map +1 -1
  53. package/build/cjs/tracing/anthropic-ai/utils.js +0 -9
  54. package/build/cjs/tracing/anthropic-ai/utils.js.map +1 -1
  55. package/build/cjs/tracing/dynamicSamplingContext.js +2 -1
  56. package/build/cjs/tracing/dynamicSamplingContext.js.map +1 -1
  57. package/build/cjs/tracing/google-genai/constants.js +9 -12
  58. package/build/cjs/tracing/google-genai/constants.js.map +1 -1
  59. package/build/cjs/tracing/google-genai/index.js +49 -27
  60. package/build/cjs/tracing/google-genai/index.js.map +1 -1
  61. package/build/cjs/tracing/google-genai/streaming.js +2 -23
  62. package/build/cjs/tracing/google-genai/streaming.js.map +1 -1
  63. package/build/cjs/tracing/google-genai/utils.js +0 -25
  64. package/build/cjs/tracing/google-genai/utils.js.map +1 -1
  65. package/build/cjs/tracing/langchain/embeddings.js +132 -0
  66. package/build/cjs/tracing/langchain/embeddings.js.map +1 -0
  67. package/build/cjs/tracing/langchain/index.js.map +1 -1
  68. package/build/cjs/tracing/openai/constants.js +7 -7
  69. package/build/cjs/tracing/openai/constants.js.map +1 -1
  70. package/build/cjs/tracing/openai/index.js +19 -37
  71. package/build/cjs/tracing/openai/index.js.map +1 -1
  72. package/build/cjs/tracing/openai/streaming.js +3 -34
  73. package/build/cjs/tracing/openai/streaming.js.map +1 -1
  74. package/build/cjs/tracing/openai/utils.js +78 -243
  75. package/build/cjs/tracing/openai/utils.js.map +1 -1
  76. package/build/cjs/tracing/sentryNonRecordingSpan.js +7 -0
  77. package/build/cjs/tracing/sentryNonRecordingSpan.js.map +1 -1
  78. package/build/cjs/tracing/sentrySpan.js +39 -0
  79. package/build/cjs/tracing/sentrySpan.js.map +1 -1
  80. package/build/cjs/tracing/spans/beforeSendSpan.js +43 -0
  81. package/build/cjs/tracing/spans/beforeSendSpan.js.map +1 -0
  82. package/build/cjs/tracing/spans/captureSpan.js +126 -0
  83. package/build/cjs/tracing/spans/captureSpan.js.map +1 -0
  84. package/build/cjs/tracing/spans/envelope.js +38 -0
  85. package/build/cjs/tracing/spans/envelope.js.map +1 -0
  86. package/build/cjs/tracing/spans/estimateSize.js +41 -0
  87. package/build/cjs/tracing/spans/estimateSize.js.map +1 -0
  88. package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js +11 -0
  89. package/build/cjs/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
  90. package/build/cjs/tracing/spans/spanBuffer.js +158 -0
  91. package/build/cjs/tracing/spans/spanBuffer.js.map +1 -0
  92. package/build/cjs/tracing/trace.js +88 -13
  93. package/build/cjs/tracing/trace.js.map +1 -1
  94. package/build/cjs/tracing/vercel-ai/utils.js +1 -4
  95. package/build/cjs/tracing/vercel-ai/utils.js.map +1 -1
  96. package/build/cjs/utils/featureFlags.js +6 -0
  97. package/build/cjs/utils/featureFlags.js.map +1 -1
  98. package/build/cjs/utils/object.js +33 -0
  99. package/build/cjs/utils/object.js.map +1 -1
  100. package/build/cjs/utils/spanUtils.js +116 -13
  101. package/build/cjs/utils/spanUtils.js.map +1 -1
  102. package/build/cjs/utils/stacktrace.js +3 -1
  103. package/build/cjs/utils/stacktrace.js.map +1 -1
  104. package/build/cjs/utils/string.js +3 -0
  105. package/build/cjs/utils/string.js.map +1 -1
  106. package/build/cjs/utils/traceData.js +11 -0
  107. package/build/cjs/utils/traceData.js.map +1 -1
  108. package/build/cjs/utils/version.js +1 -1
  109. package/build/esm/api.js +1 -1
  110. package/build/esm/api.js.map +1 -1
  111. package/build/esm/attributes.js +43 -1
  112. package/build/esm/attributes.js.map +1 -1
  113. package/build/esm/client.js +8 -1
  114. package/build/esm/client.js.map +1 -1
  115. package/build/esm/currentScopes.js +31 -1
  116. package/build/esm/currentScopes.js.map +1 -1
  117. package/build/esm/envelope.js +2 -1
  118. package/build/esm/envelope.js.map +1 -1
  119. package/build/esm/index.js +13 -4
  120. package/build/esm/index.js.map +1 -1
  121. package/build/esm/integration.js +6 -0
  122. package/build/esm/integration.js.map +1 -1
  123. package/build/esm/integrations/express/index.js +202 -0
  124. package/build/esm/integrations/express/index.js.map +1 -0
  125. package/build/esm/integrations/express/patch-layer.js +249 -0
  126. package/build/esm/integrations/express/patch-layer.js.map +1 -0
  127. package/build/esm/integrations/express/request-layer-store.js +22 -0
  128. package/build/esm/integrations/express/request-layer-store.js.map +1 -0
  129. package/build/esm/integrations/express/set-sdk-processing-metadata.js +15 -0
  130. package/build/esm/integrations/express/set-sdk-processing-metadata.js.map +1 -0
  131. package/build/esm/integrations/express/types.js +10 -0
  132. package/build/esm/integrations/express/types.js.map +1 -0
  133. package/build/esm/integrations/express/utils.js +225 -0
  134. package/build/esm/integrations/express/utils.js.map +1 -0
  135. package/build/esm/integrations/mcp-server/correlation.js +5 -1
  136. package/build/esm/integrations/mcp-server/correlation.js.map +1 -1
  137. package/build/esm/integrations/mcp-server/handlers.js +18 -10
  138. package/build/esm/integrations/mcp-server/handlers.js.map +1 -1
  139. package/build/esm/integrations/mcp-server/index.js +2 -1
  140. package/build/esm/integrations/mcp-server/index.js.map +1 -1
  141. package/build/esm/integrations/mcp-server/transport.js +1 -1
  142. package/build/esm/integrations/mcp-server/transport.js.map +1 -1
  143. package/build/esm/integrations/mcp-server/validation.js +7 -5
  144. package/build/esm/integrations/mcp-server/validation.js.map +1 -1
  145. package/build/esm/integrations/spanStreaming.js +46 -0
  146. package/build/esm/integrations/spanStreaming.js.map +1 -0
  147. package/build/esm/integrations/supabase.js +1 -1
  148. package/build/esm/integrations/supabase.js.map +1 -1
  149. package/build/esm/package.json +1 -1
  150. package/build/esm/semanticAttributes.js +26 -4
  151. package/build/esm/semanticAttributes.js.map +1 -1
  152. package/build/esm/tracing/ai/gen-ai-attributes.js +8 -69
  153. package/build/esm/tracing/ai/gen-ai-attributes.js.map +1 -1
  154. package/build/esm/tracing/ai/utils.js +51 -35
  155. package/build/esm/tracing/ai/utils.js.map +1 -1
  156. package/build/esm/tracing/anthropic-ai/constants.js +10 -10
  157. package/build/esm/tracing/anthropic-ai/constants.js.map +1 -1
  158. package/build/esm/tracing/anthropic-ai/index.js +21 -23
  159. package/build/esm/tracing/anthropic-ai/index.js.map +1 -1
  160. package/build/esm/tracing/anthropic-ai/streaming.js +3 -101
  161. package/build/esm/tracing/anthropic-ai/streaming.js.map +1 -1
  162. package/build/esm/tracing/anthropic-ai/utils.js +1 -9
  163. package/build/esm/tracing/anthropic-ai/utils.js.map +1 -1
  164. package/build/esm/tracing/dynamicSamplingContext.js +2 -1
  165. package/build/esm/tracing/dynamicSamplingContext.js.map +1 -1
  166. package/build/esm/tracing/google-genai/constants.js +9 -10
  167. package/build/esm/tracing/google-genai/constants.js.map +1 -1
  168. package/build/esm/tracing/google-genai/index.js +53 -31
  169. package/build/esm/tracing/google-genai/index.js.map +1 -1
  170. package/build/esm/tracing/google-genai/streaming.js +2 -23
  171. package/build/esm/tracing/google-genai/streaming.js.map +1 -1
  172. package/build/esm/tracing/google-genai/utils.js +1 -24
  173. package/build/esm/tracing/google-genai/utils.js.map +1 -1
  174. package/build/esm/tracing/langchain/embeddings.js +129 -0
  175. package/build/esm/tracing/langchain/embeddings.js.map +1 -0
  176. package/build/esm/tracing/langchain/index.js.map +1 -1
  177. package/build/esm/tracing/openai/constants.js +7 -7
  178. package/build/esm/tracing/openai/constants.js.map +1 -1
  179. package/build/esm/tracing/openai/index.js +21 -39
  180. package/build/esm/tracing/openai/index.js.map +1 -1
  181. package/build/esm/tracing/openai/streaming.js +4 -35
  182. package/build/esm/tracing/openai/streaming.js.map +1 -1
  183. package/build/esm/tracing/openai/utils.js +79 -232
  184. package/build/esm/tracing/openai/utils.js.map +1 -1
  185. package/build/esm/tracing/sentryNonRecordingSpan.js +7 -0
  186. package/build/esm/tracing/sentryNonRecordingSpan.js.map +1 -1
  187. package/build/esm/tracing/sentrySpan.js +40 -1
  188. package/build/esm/tracing/sentrySpan.js.map +1 -1
  189. package/build/esm/tracing/spans/beforeSendSpan.js +40 -0
  190. package/build/esm/tracing/spans/beforeSendSpan.js.map +1 -0
  191. package/build/esm/tracing/spans/captureSpan.js +122 -0
  192. package/build/esm/tracing/spans/captureSpan.js.map +1 -0
  193. package/build/esm/tracing/spans/envelope.js +36 -0
  194. package/build/esm/tracing/spans/envelope.js.map +1 -0
  195. package/build/esm/tracing/spans/estimateSize.js +39 -0
  196. package/build/esm/tracing/spans/estimateSize.js.map +1 -0
  197. package/build/esm/tracing/spans/hasSpanStreamingEnabled.js +9 -0
  198. package/build/esm/tracing/spans/hasSpanStreamingEnabled.js.map +1 -0
  199. package/build/esm/tracing/spans/spanBuffer.js +156 -0
  200. package/build/esm/tracing/spans/spanBuffer.js.map +1 -0
  201. package/build/esm/tracing/trace.js +89 -14
  202. package/build/esm/tracing/trace.js.map +1 -1
  203. package/build/esm/tracing/vercel-ai/utils.js +2 -5
  204. package/build/esm/tracing/vercel-ai/utils.js.map +1 -1
  205. package/build/esm/utils/featureFlags.js +6 -0
  206. package/build/esm/utils/featureFlags.js.map +1 -1
  207. package/build/esm/utils/object.js +33 -1
  208. package/build/esm/utils/object.js.map +1 -1
  209. package/build/esm/utils/spanUtils.js +112 -14
  210. package/build/esm/utils/spanUtils.js.map +1 -1
  211. package/build/esm/utils/stacktrace.js +3 -1
  212. package/build/esm/utils/stacktrace.js.map +1 -1
  213. package/build/esm/utils/string.js +3 -0
  214. package/build/esm/utils/string.js.map +1 -1
  215. package/build/esm/utils/traceData.js +12 -1
  216. package/build/esm/utils/traceData.js.map +1 -1
  217. package/build/esm/utils/version.js +1 -1
  218. package/build/types/api.d.ts +1 -0
  219. package/build/types/api.d.ts.map +1 -1
  220. package/build/types/asyncContext/types.d.ts +3 -1
  221. package/build/types/asyncContext/types.d.ts.map +1 -1
  222. package/build/types/attributes.d.ts +5 -0
  223. package/build/types/attributes.d.ts.map +1 -1
  224. package/build/types/client.d.ts +35 -1
  225. package/build/types/client.d.ts.map +1 -1
  226. package/build/types/currentScopes.d.ts +20 -0
  227. package/build/types/currentScopes.d.ts.map +1 -1
  228. package/build/types/envelope.d.ts.map +1 -1
  229. package/build/types/index.d.ts +15 -6
  230. package/build/types/index.d.ts.map +1 -1
  231. package/build/types/integration.d.ts.map +1 -1
  232. package/build/types/integrations/express/index.d.ts +75 -0
  233. package/build/types/integrations/express/index.d.ts.map +1 -0
  234. package/build/types/integrations/express/patch-layer.d.ts +32 -0
  235. package/build/types/integrations/express/patch-layer.d.ts.map +1 -0
  236. package/build/types/integrations/express/request-layer-store.d.ts +32 -0
  237. package/build/types/integrations/express/request-layer-store.d.ts.map +1 -0
  238. package/build/types/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
  239. package/build/types/integrations/express/set-sdk-processing-metadata.d.ts.map +1 -0
  240. package/build/types/integrations/express/types.d.ts +154 -0
  241. package/build/types/integrations/express/types.d.ts.map +1 -0
  242. package/build/types/integrations/express/utils.d.ts +93 -0
  243. package/build/types/integrations/express/utils.d.ts.map +1 -0
  244. package/build/types/integrations/mcp-server/correlation.d.ts +2 -1
  245. package/build/types/integrations/mcp-server/correlation.d.ts.map +1 -1
  246. package/build/types/integrations/mcp-server/handlers.d.ts +9 -4
  247. package/build/types/integrations/mcp-server/handlers.d.ts.map +1 -1
  248. package/build/types/integrations/mcp-server/index.d.ts +2 -1
  249. package/build/types/integrations/mcp-server/index.d.ts.map +1 -1
  250. package/build/types/integrations/mcp-server/types.d.ts +40 -7
  251. package/build/types/integrations/mcp-server/types.d.ts.map +1 -1
  252. package/build/types/integrations/mcp-server/validation.d.ts +4 -1
  253. package/build/types/integrations/mcp-server/validation.d.ts.map +1 -1
  254. package/build/types/integrations/spanStreaming.d.ts +2 -0
  255. package/build/types/integrations/spanStreaming.d.ts.map +1 -0
  256. package/build/types/semanticAttributes.d.ts +23 -3
  257. package/build/types/semanticAttributes.d.ts.map +1 -1
  258. package/build/types/tracing/ai/gen-ai-attributes.d.ts +6 -46
  259. package/build/types/tracing/ai/gen-ai-attributes.d.ts.map +1 -1
  260. package/build/types/tracing/ai/utils.d.ts +34 -9
  261. package/build/types/tracing/ai/utils.d.ts.map +1 -1
  262. package/build/types/tracing/anthropic-ai/constants.d.ts +24 -1
  263. package/build/types/tracing/anthropic-ai/constants.d.ts.map +1 -1
  264. package/build/types/tracing/anthropic-ai/index.d.ts.map +1 -1
  265. package/build/types/tracing/anthropic-ai/streaming.d.ts.map +1 -1
  266. package/build/types/tracing/anthropic-ai/types.d.ts +5 -2
  267. package/build/types/tracing/anthropic-ai/types.d.ts.map +1 -1
  268. package/build/types/tracing/anthropic-ai/utils.d.ts +1 -5
  269. package/build/types/tracing/anthropic-ai/utils.d.ts.map +1 -1
  270. package/build/types/tracing/dynamicSamplingContext.d.ts.map +1 -1
  271. package/build/types/tracing/google-genai/constants.d.ts +22 -3
  272. package/build/types/tracing/google-genai/constants.d.ts.map +1 -1
  273. package/build/types/tracing/google-genai/index.d.ts.map +1 -1
  274. package/build/types/tracing/google-genai/streaming.d.ts.map +1 -1
  275. package/build/types/tracing/google-genai/types.d.ts +6 -2
  276. package/build/types/tracing/google-genai/types.d.ts.map +1 -1
  277. package/build/types/tracing/google-genai/utils.d.ts +0 -9
  278. package/build/types/tracing/google-genai/utils.d.ts.map +1 -1
  279. package/build/types/tracing/index.d.ts +1 -0
  280. package/build/types/tracing/index.d.ts.map +1 -1
  281. package/build/types/tracing/langchain/embeddings.d.ts +27 -0
  282. package/build/types/tracing/langchain/embeddings.d.ts.map +1 -0
  283. package/build/types/tracing/langchain/index.d.ts +1 -0
  284. package/build/types/tracing/langchain/index.d.ts.map +1 -1
  285. package/build/types/tracing/openai/constants.d.ts +14 -1
  286. package/build/types/tracing/openai/constants.d.ts.map +1 -1
  287. package/build/types/tracing/openai/index.d.ts.map +1 -1
  288. package/build/types/tracing/openai/streaming.d.ts.map +1 -1
  289. package/build/types/tracing/openai/types.d.ts +5 -2
  290. package/build/types/tracing/openai/types.d.ts.map +1 -1
  291. package/build/types/tracing/openai/utils.d.ts +4 -63
  292. package/build/types/tracing/openai/utils.d.ts.map +1 -1
  293. package/build/types/tracing/sentryNonRecordingSpan.d.ts +12 -1
  294. package/build/types/tracing/sentryNonRecordingSpan.d.ts.map +1 -1
  295. package/build/types/tracing/sentrySpan.d.ts +10 -1
  296. package/build/types/tracing/sentrySpan.d.ts.map +1 -1
  297. package/build/types/tracing/spans/beforeSendSpan.d.ts +35 -0
  298. package/build/types/tracing/spans/beforeSendSpan.d.ts.map +1 -0
  299. package/build/types/tracing/spans/captureSpan.d.ts +26 -0
  300. package/build/types/tracing/spans/captureSpan.d.ts.map +1 -0
  301. package/build/types/tracing/spans/envelope.d.ts +8 -0
  302. package/build/types/tracing/spans/envelope.d.ts.map +1 -0
  303. package/build/types/tracing/spans/estimateSize.d.ts +12 -0
  304. package/build/types/tracing/spans/estimateSize.d.ts.map +1 -0
  305. package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
  306. package/build/types/tracing/spans/hasSpanStreamingEnabled.d.ts.map +1 -0
  307. package/build/types/tracing/spans/spanBuffer.d.ts +60 -0
  308. package/build/types/tracing/spans/spanBuffer.d.ts.map +1 -0
  309. package/build/types/tracing/trace.d.ts.map +1 -1
  310. package/build/types/tracing/vercel-ai/utils.d.ts.map +1 -1
  311. package/build/types/types-hoist/envelope.d.ts +22 -2
  312. package/build/types/types-hoist/envelope.d.ts.map +1 -1
  313. package/build/types/types-hoist/integration.d.ts +8 -0
  314. package/build/types/types-hoist/integration.d.ts.map +1 -1
  315. package/build/types/types-hoist/link.d.ts +2 -2
  316. package/build/types/types-hoist/link.d.ts.map +1 -1
  317. package/build/types/types-hoist/options.d.ts +26 -2
  318. package/build/types/types-hoist/options.d.ts.map +1 -1
  319. package/build/types/types-hoist/span.d.ts +35 -0
  320. package/build/types/types-hoist/span.d.ts.map +1 -1
  321. package/build/types/utils/featureFlags.d.ts.map +1 -1
  322. package/build/types/utils/object.d.ts +10 -0
  323. package/build/types/utils/object.d.ts.map +1 -1
  324. package/build/types/utils/spanUtils.d.ts +27 -2
  325. package/build/types/utils/spanUtils.d.ts.map +1 -1
  326. package/build/types/utils/stacktrace.d.ts.map +1 -1
  327. package/build/types/utils/string.d.ts +2 -2
  328. package/build/types/utils/string.d.ts.map +1 -1
  329. package/build/types/utils/traceData.d.ts +4 -0
  330. package/build/types/utils/traceData.d.ts.map +1 -1
  331. package/build/types-ts3.8/api.d.ts +1 -0
  332. package/build/types-ts3.8/asyncContext/types.d.ts +3 -1
  333. package/build/types-ts3.8/attributes.d.ts +5 -0
  334. package/build/types-ts3.8/client.d.ts +35 -1
  335. package/build/types-ts3.8/currentScopes.d.ts +20 -0
  336. package/build/types-ts3.8/index.d.ts +15 -6
  337. package/build/types-ts3.8/integrations/express/index.d.ts +75 -0
  338. package/build/types-ts3.8/integrations/express/patch-layer.d.ts +32 -0
  339. package/build/types-ts3.8/integrations/express/request-layer-store.d.ts +32 -0
  340. package/build/types-ts3.8/integrations/express/set-sdk-processing-metadata.d.ts +35 -0
  341. package/build/types-ts3.8/integrations/express/types.d.ts +154 -0
  342. package/build/types-ts3.8/integrations/express/utils.d.ts +96 -0
  343. package/build/types-ts3.8/integrations/mcp-server/correlation.d.ts +2 -1
  344. package/build/types-ts3.8/integrations/mcp-server/handlers.d.ts +9 -4
  345. package/build/types-ts3.8/integrations/mcp-server/index.d.ts +2 -1
  346. package/build/types-ts3.8/integrations/mcp-server/types.d.ts +40 -7
  347. package/build/types-ts3.8/integrations/mcp-server/validation.d.ts +4 -1
  348. package/build/types-ts3.8/integrations/spanStreaming.d.ts +2 -0
  349. package/build/types-ts3.8/semanticAttributes.d.ts +23 -3
  350. package/build/types-ts3.8/tracing/ai/gen-ai-attributes.d.ts +6 -46
  351. package/build/types-ts3.8/tracing/ai/utils.d.ts +34 -9
  352. package/build/types-ts3.8/tracing/anthropic-ai/constants.d.ts +24 -9
  353. package/build/types-ts3.8/tracing/anthropic-ai/types.d.ts +5 -2
  354. package/build/types-ts3.8/tracing/anthropic-ai/utils.d.ts +1 -5
  355. package/build/types-ts3.8/tracing/google-genai/constants.d.ts +22 -9
  356. package/build/types-ts3.8/tracing/google-genai/types.d.ts +6 -2
  357. package/build/types-ts3.8/tracing/google-genai/utils.d.ts +0 -9
  358. package/build/types-ts3.8/tracing/index.d.ts +1 -0
  359. package/build/types-ts3.8/tracing/langchain/embeddings.d.ts +27 -0
  360. package/build/types-ts3.8/tracing/langchain/index.d.ts +1 -0
  361. package/build/types-ts3.8/tracing/openai/constants.d.ts +14 -6
  362. package/build/types-ts3.8/tracing/openai/types.d.ts +5 -2
  363. package/build/types-ts3.8/tracing/openai/utils.d.ts +4 -63
  364. package/build/types-ts3.8/tracing/sentryNonRecordingSpan.d.ts +12 -1
  365. package/build/types-ts3.8/tracing/sentrySpan.d.ts +10 -1
  366. package/build/types-ts3.8/tracing/spans/beforeSendSpan.d.ts +35 -0
  367. package/build/types-ts3.8/tracing/spans/captureSpan.d.ts +26 -0
  368. package/build/types-ts3.8/tracing/spans/envelope.d.ts +8 -0
  369. package/build/types-ts3.8/tracing/spans/estimateSize.d.ts +12 -0
  370. package/build/types-ts3.8/tracing/spans/hasSpanStreamingEnabled.d.ts +6 -0
  371. package/build/types-ts3.8/tracing/spans/spanBuffer.d.ts +60 -0
  372. package/build/types-ts3.8/types-hoist/envelope.d.ts +22 -2
  373. package/build/types-ts3.8/types-hoist/integration.d.ts +8 -0
  374. package/build/types-ts3.8/types-hoist/link.d.ts +2 -2
  375. package/build/types-ts3.8/types-hoist/options.d.ts +26 -2
  376. package/build/types-ts3.8/types-hoist/span.d.ts +35 -0
  377. package/build/types-ts3.8/utils/object.d.ts +10 -0
  378. package/build/types-ts3.8/utils/spanUtils.d.ts +27 -2
  379. package/build/types-ts3.8/utils/string.d.ts +2 -2
  380. package/build/types-ts3.8/utils/traceData.d.ts +4 -0
  381. package/package.json +1 -1
@@ -0,0 +1,249 @@
1
+ import { DEBUG_BUILD } from '../../debug-build.js';
2
+ import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes.js';
3
+ import { debug } from '../../utils/debug-logger.js';
4
+ import { getActiveSpan } from '../../utils/spanUtils.js';
5
+ import { SPAN_STATUS_ERROR } from '../../tracing/spanstatus.js';
6
+ import { getOriginalFunction, markFunctionWrapped } from '../../utils/object.js';
7
+ import { getIsolationScope } from '../../currentScopes.js';
8
+ import { startSpanManual, withActiveSpan } from '../../tracing/trace.js';
9
+ import { storeLayer, getStoredLayers } from './request-layer-store.js';
10
+ import { ATTR_EXPRESS_NAME, ATTR_EXPRESS_TYPE, ATTR_HTTP_ROUTE, ExpressLayerType_ROUTER } from './types.js';
11
+ import { getConstructedRoute, getActualMatchedRoute, getLayerMetadata, isLayerIgnored, asErrorAndMessage } from './utils.js';
12
+ import { getDefaultIsolationScope } from '../../defaultScopes.js';
13
+ import { setSDKProcessingMetadata } from './set-sdk-processing-metadata.js';
14
+
15
+ /**
16
+ * Platform-portable Express tracing integration.
17
+ *
18
+ * @module
19
+ *
20
+ * This Sentry integration is a derivative work based on the OpenTelemetry
21
+ * Express instrumentation.
22
+ *
23
+ * <https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-express>
24
+ *
25
+ * Extended under the terms of the Apache 2.0 license linked below:
26
+ *
27
+ * ----
28
+ *
29
+ * Copyright The OpenTelemetry Authors
30
+ *
31
+ * Licensed under the Apache License, Version 2.0 (the "License");
32
+ * you may not use this file except in compliance with the License.
33
+ * You may obtain a copy of the License at
34
+ *
35
+ * https://www.apache.org/licenses/LICENSE-2.0
36
+ *
37
+ * Unless required by applicable law or agreed to in writing, software
38
+ * distributed under the License is distributed on an "AS IS" BASIS,
39
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40
+ * See the License for the specific language governing permissions and
41
+ * limitations under the License.
42
+ */
43
+
44
+
45
+ function patchLayer(options, maybeLayer, layerPath) {
46
+ if (!maybeLayer?.handle) {
47
+ return;
48
+ }
49
+ const layer = maybeLayer;
50
+
51
+ const layerHandleOriginal = layer.handle;
52
+
53
+ // avoid patching multiple times the same layer
54
+ if (getOriginalFunction(layerHandleOriginal)) {
55
+ return;
56
+ }
57
+
58
+ if (layerHandleOriginal.length === 4) {
59
+ // todo: instrument error handlers
60
+ return;
61
+ }
62
+
63
+ function layerHandlePatched(
64
+
65
+ req,
66
+ res,
67
+ //oxlint-disable-next-line no-explicit-any
68
+ ...otherArgs
69
+ ) {
70
+ // Set normalizedRequest here because expressRequestHandler middleware
71
+ // (registered via setupExpressErrorHandler) is added after routes and
72
+ // therefore never runs for successful requests — route handlers typically
73
+ // send a response without calling next(). It would be safe to set this
74
+ // multiple times, since the data is identical, but more performant not to.
75
+ setSDKProcessingMetadata(req);
76
+
77
+ // Only create spans when there's an active parent span
78
+ // Without a parent span, this request is being ignored, so skip it
79
+ const parentSpan = getActiveSpan();
80
+ if (!parentSpan) {
81
+ return layerHandleOriginal.apply(this, [req, res, ...otherArgs]);
82
+ }
83
+
84
+ if (layerPath) {
85
+ storeLayer(req, layerPath);
86
+ }
87
+ const storedLayers = getStoredLayers(req);
88
+ const isLayerPathStored = !!layerPath;
89
+
90
+ const constructedRoute = getConstructedRoute(req);
91
+ const actualMatchedRoute = getActualMatchedRoute(req, constructedRoute);
92
+
93
+ options.onRouteResolved?.(actualMatchedRoute);
94
+
95
+ const metadata = getLayerMetadata(constructedRoute, layer, layerPath);
96
+ const name = metadata.attributes[ATTR_EXPRESS_NAME];
97
+ const type = metadata.attributes[ATTR_EXPRESS_TYPE];
98
+ const attributes = Object.assign(metadata.attributes, {
99
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.express',
100
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.express`,
101
+ });
102
+ if (actualMatchedRoute) {
103
+ attributes[ATTR_HTTP_ROUTE] = actualMatchedRoute;
104
+ }
105
+
106
+ // verify against the config if the layer should be ignored
107
+ if (isLayerIgnored(metadata.attributes[ATTR_EXPRESS_NAME], type, options)) {
108
+ // XXX: the isLayerPathStored guard here is *not* present in the
109
+ // original @opentelemetry/instrumentation-express impl, but was
110
+ // suggested by the Sentry code review bot. It appears to correctly
111
+ // prevent improper layer calculation in the case where there's a
112
+ // middleware without a layerPath argument. It's unclear whether
113
+ // that's possible, or if any existing code depends on that "bug".
114
+ if (isLayerPathStored) {
115
+ storedLayers.pop();
116
+ }
117
+ return layerHandleOriginal.apply(this, [req, res, ...otherArgs]);
118
+ }
119
+
120
+ const currentScope = getIsolationScope();
121
+ if (currentScope !== getDefaultIsolationScope()) {
122
+ if (type === 'request_handler') {
123
+ // type cast b/c Otel unfortunately types info.request as any :(
124
+ const method = req.method ? req.method.toUpperCase() : 'GET';
125
+ currentScope.setTransactionName(`${method} ${constructedRoute}`);
126
+ }
127
+ } else {
128
+ DEBUG_BUILD && debug.warn('Isolation scope is still default isolation scope - skipping setting transactionName');
129
+ }
130
+
131
+ return startSpanManual({ name, attributes }, span => {
132
+ let spanHasEnded = false;
133
+ // TODO: Fix router spans (getRouterPath does not work properly) to
134
+ // have useful names before removing this branch
135
+ if (metadata.attributes[ATTR_EXPRESS_TYPE] === ExpressLayerType_ROUTER) {
136
+ span.end();
137
+ spanHasEnded = true;
138
+ }
139
+ // listener for response.on('finish')
140
+ const onResponseFinish = () => {
141
+ if (!spanHasEnded) {
142
+ spanHasEnded = true;
143
+ span.end();
144
+ }
145
+ };
146
+
147
+ // verify we have a callback
148
+ for (let i = 0; i < otherArgs.length; i++) {
149
+ const callback = otherArgs[i] ;
150
+ if (typeof callback !== 'function') {
151
+ continue;
152
+ }
153
+
154
+ //oxlint-disable-next-line no-explicit-any
155
+ otherArgs[i] = function (...args) {
156
+ // express considers anything but an empty value, "route" or "router"
157
+ // passed to its callback to be an error
158
+ const maybeError = args[0];
159
+ const isError = !!maybeError && maybeError !== 'route' && maybeError !== 'router';
160
+ if (!spanHasEnded && isError) {
161
+ const [_, message] = asErrorAndMessage(maybeError);
162
+ // intentionally do not record the exception here, because
163
+ // the error handler we assign does that, provided the user
164
+ // correctly calls setupExpressErrorHandler.
165
+ // TODO: A future enhancement can automatically attach
166
+ // the error handler if we detect that it has not been added.
167
+ span.setStatus({
168
+ code: SPAN_STATUS_ERROR,
169
+ message,
170
+ });
171
+ }
172
+
173
+ if (!spanHasEnded) {
174
+ spanHasEnded = true;
175
+ res.removeListener('finish', onResponseFinish);
176
+ span.end();
177
+ }
178
+ if (!(req.route && isError) && isLayerPathStored) {
179
+ storedLayers.pop();
180
+ }
181
+ // execute the callback back in the parent's scope, so that
182
+ // we bubble up each level as next() is called.
183
+ return withActiveSpan(parentSpan, () => callback.apply(this, args));
184
+ };
185
+ break;
186
+ }
187
+
188
+ try {
189
+ return layerHandleOriginal.apply(this, [req, res, ...otherArgs]);
190
+ } catch (anyError) {
191
+ const [_, message] = asErrorAndMessage(anyError);
192
+ // intentionally do not record the exception here, because
193
+ // the error handler we assign does that, provided the user
194
+ // correctly calls setupExpressErrorHandler.
195
+ // TODO: A future enhancement can automatically attach
196
+ // the error handler if we detect that it has not been added.
197
+ span.setStatus({
198
+ code: SPAN_STATUS_ERROR,
199
+ message,
200
+ });
201
+ throw anyError;
202
+ /* v8 ignore next - it sees the block end at the throw */
203
+ } finally {
204
+ // At this point if the callback wasn't called, that means
205
+ // either the layer is asynchronous (so it will call the
206
+ // callback later on) or that the layer directly ends the
207
+ // http response, so we'll hook into the "finish" event to
208
+ // handle the later case.
209
+ if (!spanHasEnded) {
210
+ res.once('finish', onResponseFinish);
211
+ }
212
+ }
213
+ });
214
+ }
215
+
216
+ // `handle` isn't just a regular function in some cases. It also contains
217
+ // some properties holding metadata and state so we need to proxy them
218
+ // through through patched function. Use a for-in to also pick up properties
219
+ // that other libraries might add to the prototype before we instrument.
220
+ // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1950
221
+ // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2271
222
+ // oxlint-disable-next-line guard-for-in
223
+ for (const key in layerHandleOriginal ) {
224
+ // skip standard function prototype fields that both have
225
+ if (key in layerHandlePatched) {
226
+ continue;
227
+ }
228
+ Object.defineProperty(layerHandlePatched, key, {
229
+ get() {
230
+ return layerHandleOriginal[key];
231
+ },
232
+ set(value) {
233
+ layerHandleOriginal[key] = value;
234
+ },
235
+ });
236
+ }
237
+
238
+ markFunctionWrapped(layerHandlePatched, layerHandleOriginal);
239
+
240
+ Object.defineProperty(layer, 'handle', {
241
+ enumerable: true,
242
+ configurable: true,
243
+ writable: true,
244
+ value: layerHandlePatched,
245
+ });
246
+ }
247
+
248
+ export { patchLayer };
249
+ //# sourceMappingURL=patch-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch-layer.js","sources":["../../../../src/integrations/express/patch-layer.ts"],"sourcesContent":["/**\n * Platform-portable Express tracing integration.\n *\n * @module\n *\n * This Sentry integration is a derivative work based on the OpenTelemetry\n * Express instrumentation.\n *\n * <https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-express>\n *\n * Extended under the terms of the Apache 2.0 license linked below:\n *\n * ----\n *\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';\nimport { SPAN_STATUS_ERROR, startSpanManual, withActiveSpan } from '../../tracing';\nimport { debug } from '../../utils/debug-logger';\nimport type { SpanAttributes } from '../../types-hoist/span';\nimport { getActiveSpan } from '../../utils/spanUtils';\nimport { getStoredLayers, storeLayer } from './request-layer-store';\nimport {\n type ExpressRequest,\n type ExpressResponse,\n type ExpressIntegrationOptions,\n type ExpressLayer,\n ATTR_HTTP_ROUTE,\n ATTR_EXPRESS_TYPE,\n ATTR_EXPRESS_NAME,\n ExpressLayerType_ROUTER,\n} from './types';\nimport {\n asErrorAndMessage,\n getActualMatchedRoute,\n getConstructedRoute,\n getLayerMetadata,\n isLayerIgnored,\n} from './utils';\nimport { getIsolationScope } from '../../currentScopes';\nimport { getDefaultIsolationScope } from '../../defaultScopes';\nimport { getOriginalFunction, markFunctionWrapped } from '../../utils/object';\nimport { setSDKProcessingMetadata } from './set-sdk-processing-metadata';\n\nexport type ExpressPatchLayerOptions = Pick<\n ExpressIntegrationOptions,\n 'onRouteResolved' | 'ignoreLayers' | 'ignoreLayersType'\n>;\n\nexport function patchLayer(options: ExpressPatchLayerOptions, maybeLayer?: ExpressLayer, layerPath?: string): void {\n if (!maybeLayer?.handle) {\n return;\n }\n const layer = maybeLayer;\n\n const layerHandleOriginal = layer.handle;\n\n // avoid patching multiple times the same layer\n if (getOriginalFunction(layerHandleOriginal)) {\n return;\n }\n\n if (layerHandleOriginal.length === 4) {\n // todo: instrument error handlers\n return;\n }\n\n function layerHandlePatched(\n this: ExpressLayer,\n req: ExpressRequest,\n res: ExpressResponse,\n //oxlint-disable-next-line no-explicit-any\n ...otherArgs: any[]\n ) {\n // Set normalizedRequest here because expressRequestHandler middleware\n // (registered via setupExpressErrorHandler) is added after routes and\n // therefore never runs for successful requests — route handlers typically\n // send a response without calling next(). It would be safe to set this\n // multiple times, since the data is identical, but more performant not to.\n setSDKProcessingMetadata(req);\n\n // Only create spans when there's an active parent span\n // Without a parent span, this request is being ignored, so skip it\n const parentSpan = getActiveSpan();\n if (!parentSpan) {\n return layerHandleOriginal.apply(this, [req, res, ...otherArgs]);\n }\n\n if (layerPath) {\n storeLayer(req, layerPath);\n }\n const storedLayers = getStoredLayers(req);\n const isLayerPathStored = !!layerPath;\n\n const constructedRoute = getConstructedRoute(req);\n const actualMatchedRoute = getActualMatchedRoute(req, constructedRoute);\n\n options.onRouteResolved?.(actualMatchedRoute);\n\n const metadata = getLayerMetadata(constructedRoute, layer, layerPath);\n const name = metadata.attributes[ATTR_EXPRESS_NAME];\n const type = metadata.attributes[ATTR_EXPRESS_TYPE];\n const attributes: SpanAttributes = Object.assign(metadata.attributes, {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.express',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.express`,\n });\n if (actualMatchedRoute) {\n attributes[ATTR_HTTP_ROUTE] = actualMatchedRoute;\n }\n\n // verify against the config if the layer should be ignored\n if (isLayerIgnored(metadata.attributes[ATTR_EXPRESS_NAME], type, options)) {\n // XXX: the isLayerPathStored guard here is *not* present in the\n // original @opentelemetry/instrumentation-express impl, but was\n // suggested by the Sentry code review bot. It appears to correctly\n // prevent improper layer calculation in the case where there's a\n // middleware without a layerPath argument. It's unclear whether\n // that's possible, or if any existing code depends on that \"bug\".\n if (isLayerPathStored) {\n storedLayers.pop();\n }\n return layerHandleOriginal.apply(this, [req, res, ...otherArgs]);\n }\n\n const currentScope = getIsolationScope();\n if (currentScope !== getDefaultIsolationScope()) {\n if (type === 'request_handler') {\n // type cast b/c Otel unfortunately types info.request as any :(\n const method = req.method ? req.method.toUpperCase() : 'GET';\n currentScope.setTransactionName(`${method} ${constructedRoute}`);\n }\n } else {\n DEBUG_BUILD && debug.warn('Isolation scope is still default isolation scope - skipping setting transactionName');\n }\n\n return startSpanManual({ name, attributes }, span => {\n let spanHasEnded = false;\n // TODO: Fix router spans (getRouterPath does not work properly) to\n // have useful names before removing this branch\n if (metadata.attributes[ATTR_EXPRESS_TYPE] === ExpressLayerType_ROUTER) {\n span.end();\n spanHasEnded = true;\n }\n // listener for response.on('finish')\n const onResponseFinish = () => {\n if (!spanHasEnded) {\n spanHasEnded = true;\n span.end();\n }\n };\n\n // verify we have a callback\n for (let i = 0; i < otherArgs.length; i++) {\n const callback = otherArgs[i] as Function;\n if (typeof callback !== 'function') {\n continue;\n }\n\n //oxlint-disable-next-line no-explicit-any\n otherArgs[i] = function (...args: any[]) {\n // express considers anything but an empty value, \"route\" or \"router\"\n // passed to its callback to be an error\n const maybeError = args[0];\n const isError = !!maybeError && maybeError !== 'route' && maybeError !== 'router';\n if (!spanHasEnded && isError) {\n const [_, message] = asErrorAndMessage(maybeError);\n // intentionally do not record the exception here, because\n // the error handler we assign does that, provided the user\n // correctly calls setupExpressErrorHandler.\n // TODO: A future enhancement can automatically attach\n // the error handler if we detect that it has not been added.\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message,\n });\n }\n\n if (!spanHasEnded) {\n spanHasEnded = true;\n res.removeListener('finish', onResponseFinish);\n span.end();\n }\n if (!(req.route && isError) && isLayerPathStored) {\n storedLayers.pop();\n }\n // execute the callback back in the parent's scope, so that\n // we bubble up each level as next() is called.\n return withActiveSpan(parentSpan, () => callback.apply(this, args));\n };\n break;\n }\n\n try {\n return layerHandleOriginal.apply(this, [req, res, ...otherArgs]);\n } catch (anyError) {\n const [_, message] = asErrorAndMessage(anyError);\n // intentionally do not record the exception here, because\n // the error handler we assign does that, provided the user\n // correctly calls setupExpressErrorHandler.\n // TODO: A future enhancement can automatically attach\n // the error handler if we detect that it has not been added.\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message,\n });\n throw anyError;\n /* v8 ignore next - it sees the block end at the throw */\n } finally {\n // At this point if the callback wasn't called, that means\n // either the layer is asynchronous (so it will call the\n // callback later on) or that the layer directly ends the\n // http response, so we'll hook into the \"finish\" event to\n // handle the later case.\n if (!spanHasEnded) {\n res.once('finish', onResponseFinish);\n }\n }\n });\n }\n\n // `handle` isn't just a regular function in some cases. It also contains\n // some properties holding metadata and state so we need to proxy them\n // through through patched function. Use a for-in to also pick up properties\n // that other libraries might add to the prototype before we instrument.\n // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1950\n // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2271\n // oxlint-disable-next-line guard-for-in\n for (const key in layerHandleOriginal as Function & Record<string, unknown>) {\n // skip standard function prototype fields that both have\n if (key in layerHandlePatched) {\n continue;\n }\n Object.defineProperty(layerHandlePatched, key, {\n get() {\n return layerHandleOriginal[key];\n },\n set(value) {\n layerHandleOriginal[key] = value;\n },\n });\n }\n\n markFunctionWrapped(layerHandlePatched, layerHandleOriginal);\n\n Object.defineProperty(layer, 'handle', {\n enumerable: true,\n configurable: true,\n writable: true,\n value: layerHandlePatched,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAoCO,SAAS,UAAU,CAAC,OAAO,EAA4B,UAAU,EAAiB,SAAS,EAAiB;AACnH,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE;AAC3B,IAA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EAAA;;AAEA,EAAA,mBAAA,CAAA,kBAAA,EAAA,mBAAA,CAAA;;AAEA,EAAA,MAAA,CAAA,cAAA,CAAA,KAAA,EAAA,QAAA,EAAA;AACA,IAAA,UAAA,EAAA,IAAA;AACA,IAAA,YAAA,EAAA,IAAA;AACA,IAAA,QAAA,EAAA,IAAA;AACA,IAAA,KAAA,EAAA,kBAAA;AACA,GAAA,CAAA;AACA;;;;"}
@@ -0,0 +1,22 @@
1
+ // map of patched request objects to stored layers
2
+ const requestLayerStore = new WeakMap();
3
+ const storeLayer = (req, layer) => {
4
+ const store = requestLayerStore.get(req);
5
+ if (!store) {
6
+ requestLayerStore.set(req, [layer]);
7
+ } else {
8
+ store.push(layer);
9
+ }
10
+ };
11
+
12
+ const getStoredLayers = (req) => {
13
+ let store = requestLayerStore.get(req);
14
+ if (!store) {
15
+ store = [];
16
+ requestLayerStore.set(req, store);
17
+ }
18
+ return store;
19
+ };
20
+
21
+ export { getStoredLayers, storeLayer };
22
+ //# sourceMappingURL=request-layer-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-layer-store.js","sources":["../../../../src/integrations/express/request-layer-store.ts"],"sourcesContent":["/**\n * Platform-portable Express tracing integration.\n *\n * @module\n *\n * This Sentry integration is a derivative work based on the OpenTelemetry\n * Express instrumentation.\n *\n * <https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-express>\n *\n * Extended under the terms of the Apache 2.0 license linked below:\n *\n * ----\n *\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ExpressRequest } from './types';\n\n// map of patched request objects to stored layers\nconst requestLayerStore = new WeakMap<ExpressRequest, string[]>();\nexport const storeLayer = (req: ExpressRequest, layer: string) => {\n const store = requestLayerStore.get(req);\n if (!store) {\n requestLayerStore.set(req, [layer]);\n } else {\n store.push(layer);\n }\n};\n\nexport const getStoredLayers = (req: ExpressRequest) => {\n let store = requestLayerStore.get(req);\n if (!store) {\n store = [];\n requestLayerStore.set(req, store);\n }\n return store;\n};\n"],"names":[],"mappings":"AA+BA;AACA,MAAM,iBAAA,GAAoB,IAAI,OAAO,EAA4B;AAC1D,MAAM,aAAa,CAAC,GAAG,EAAkB,KAAK,KAAa;AAClE,EAAE,MAAM,QAAQ,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC;AAC1C,EAAE,IAAI,CAAC,KAAK,EAAE;AACd,IAAI,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AACvC,EAAE,OAAO;AACT,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;AACrB,EAAE;AACF;;MAEa,eAAA,GAAkB,CAAC,GAAG,KAAqB;AACxD,EAAE,IAAI,QAAQ,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC;AACxC,EAAE,IAAI,CAAC,KAAK,EAAE;AACd,IAAI,KAAA,GAAQ,EAAE;AACd,IAAI,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;AACrC,EAAE;AACF,EAAE,OAAO,KAAK;AACd;;;;"}
@@ -0,0 +1,15 @@
1
+ import { getIsolationScope } from '../../currentScopes.js';
2
+ import { httpRequestToRequestData } from '../../utils/request.js';
3
+
4
+ // TODO: consider moving this into a core util, eg
5
+ // setSDKProcessingMetadataFromRequest(..), if other integrations need it.
6
+ function setSDKProcessingMetadata(request) {
7
+ const sdkProcMeta = getIsolationScope()?.getScopeData()?.sdkProcessingMetadata;
8
+ if (!sdkProcMeta?.normalizedRequest) {
9
+ const normalizedRequest = httpRequestToRequestData(request);
10
+ getIsolationScope().setSDKProcessingMetadata({ normalizedRequest });
11
+ }
12
+ }
13
+
14
+ export { setSDKProcessingMetadata };
15
+ //# sourceMappingURL=set-sdk-processing-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-sdk-processing-metadata.js","sources":["../../../../src/integrations/express/set-sdk-processing-metadata.ts"],"sourcesContent":["/**\n * Platform-portable Express tracing integration.\n *\n * @module\n *\n * This Sentry integration is a derivative work based on the OpenTelemetry\n * Express instrumentation.\n *\n * <https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-express>\n *\n * Extended under the terms of the Apache 2.0 license linked below:\n *\n * ----\n *\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Abstract this out because we call it in multiple places, and it's cheaper to\n * only do one time for any given request.\n */\n\nimport type { ExpressRequest } from './types';\nimport { getIsolationScope } from '../../currentScopes';\nimport { httpRequestToRequestData } from '../../utils/request';\n\n// TODO: consider moving this into a core util, eg\n// setSDKProcessingMetadataFromRequest(..), if other integrations need it.\nexport function setSDKProcessingMetadata(request: ExpressRequest) {\n const sdkProcMeta = getIsolationScope()?.getScopeData()?.sdkProcessingMetadata;\n if (!sdkProcMeta?.normalizedRequest) {\n const normalizedRequest = httpRequestToRequestData(request);\n getIsolationScope().setSDKProcessingMetadata({ normalizedRequest });\n }\n}\n"],"names":[],"mappings":";;;AAsCA;AACA;AACO,SAAS,wBAAwB,CAAC,OAAO,EAAkB;AAClE,EAAE,MAAM,WAAA,GAAc,iBAAiB,EAAE,EAAE,YAAY,EAAE,EAAE,qBAAqB;AAChF,EAAE,IAAI,CAAC,WAAW,EAAE,iBAAiB,EAAE;AACvC,IAAI,MAAM,iBAAA,GAAoB,wBAAwB,CAAC,OAAO,CAAC;AAC/D,IAAI,iBAAiB,EAAE,CAAC,wBAAwB,CAAC,EAAE,iBAAA,EAAmB,CAAC;AACvE,EAAE;AACF;;;;"}
@@ -0,0 +1,10 @@
1
+ const ATTR_EXPRESS_NAME = 'express.name';
2
+ const ATTR_HTTP_ROUTE = 'http.route';
3
+ const ATTR_EXPRESS_TYPE = 'express.type';
4
+
5
+ const ExpressLayerType_ROUTER = 'router';
6
+ const ExpressLayerType_MIDDLEWARE = 'middleware';
7
+ const ExpressLayerType_REQUEST_HANDLER = 'request_handler';
8
+
9
+ export { ATTR_EXPRESS_NAME, ATTR_EXPRESS_TYPE, ATTR_HTTP_ROUTE, ExpressLayerType_MIDDLEWARE, ExpressLayerType_REQUEST_HANDLER, ExpressLayerType_ROUTER };
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../../src/integrations/express/types.ts"],"sourcesContent":["/**\n * Platform-portable Express tracing integration.\n *\n * @module\n *\n * This Sentry integration is a derivative work based on the OpenTelemetry\n * Express instrumentation.\n *\n * <https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-express>\n *\n * Extended under the terms of the Apache 2.0 license linked below:\n *\n * ----\n *\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RequestEventData } from '../../types-hoist/request';\nimport type { SpanAttributes } from '../../types-hoist/span';\n\nexport const ATTR_EXPRESS_NAME = 'express.name';\nexport const ATTR_HTTP_ROUTE = 'http.route';\nexport const ATTR_EXPRESS_TYPE = 'express.type';\n\nexport type ExpressExport = {\n Router: ExpressRouterv5 | ExpressRouterv4;\n application: ExpressApplication;\n};\n\nexport type ExpressExportv5 = ExpressExport & {\n Router: ExpressRouterv5;\n};\n\nexport type ExpressExportv4 = ExpressExport & {\n Router: ExpressRouterv4;\n};\n\nexport type ExpressModuleExport = ExpressExport | { default: ExpressExport };\n\nexport interface ExpressRequest extends RequestEventData {\n originalUrl: string;\n route: unknown;\n // Note: req.res is typed as optional (only present after middleware init).\n // mark optional to preserve compat with express v4 types.\n res?: ExpressResponse;\n}\n\n// just a minimum type def for what we need, since this also needs to\n// work in environments lacking node:http\nexport interface ExpressResponse {\n once(ev: string, listener: Function): this;\n removeListener(ev: string, listener?: Function): this;\n emit(ev: string, ...data: unknown[]): this;\n}\n\nexport interface NextFunction {\n (err?: unknown): void;\n /**\n * \"Break-out\" of a router by calling {next('router')};\n * @see {https://expressjs.com/en/guide/using-middleware.html#middleware.router}\n */\n (deferToNext: 'router'): void;\n /**\n * \"Break-out\" of a route by calling {next('route')};\n * @see {https://expressjs.com/en/guide/using-middleware.html#middleware.application}\n */\n (deferToNext: 'route'): void;\n}\n\n// Need to mark this as `any` so they don't conflict with the actual express\n//oxlint-disable-next-line no-explicit-any\nexport type ExpressApplicationRequestHandler = (...handlers: any[]) => any;\n\nexport type ExpressRequestInfo<T = unknown> = {\n /** An express request object */\n request: T;\n route: string;\n layerType: ExpressLayerType;\n};\n\nexport type ExpressLayerType = 'router' | 'middleware' | 'request_handler';\nexport const ExpressLayerType_ROUTER = 'router';\nexport const ExpressLayerType_MIDDLEWARE = 'middleware';\nexport const ExpressLayerType_REQUEST_HANDLER = 'request_handler';\n\nexport type PathParams = string | RegExp | Array<string | RegExp>;\nexport type LayerPathSegment = string | RegExp | number;\n\nexport interface ExpressRoute {\n path: string;\n stack: ExpressLayer[];\n}\n\nexport type ExpressRouterv4 = ExpressRouter;\n\nexport interface ExpressRouterv5 {\n prototype: ExpressRouter;\n}\n\n// https://github.com/expressjs/express/blob/main/lib/router/layer.js#L33\nexport type ExpressLayer = {\n handle: Function &\n Record<string, unknown> & {\n stack?: ExpressLayer[];\n };\n name: string;\n params: { [key: string]: string };\n path?: string;\n regexp: RegExp;\n route?: ExpressLayer;\n};\n\nexport type ExpressRouter = {\n params: { [key: string]: string };\n _params: string[];\n caseSensitive: boolean;\n mergeParams: boolean;\n strict: boolean;\n stack: ExpressLayer[];\n route(prefix: PathParams): ExpressRoute;\n use(...handlers: unknown[]): unknown;\n};\n\nexport type IgnoreMatcher = string | RegExp | ((name: string) => boolean);\n\nexport type ExpressIntegrationOptions = {\n express: ExpressModuleExport; //Express\n /** Ignore specific based on their name */\n ignoreLayers?: IgnoreMatcher[];\n /** Ignore specific layers based on their type */\n ignoreLayersType?: ExpressLayerType[];\n /**\n * Optional callback invoked each time a layer resolves the matched HTTP route.\n * Platform-specific integrations (e.g. Node.js) use this to propagate the\n * resolved route to the underlying transport layer (e.g. OTel RPCMetadata).\n */\n onRouteResolved?: (route: string | undefined) => void;\n};\n\nexport type LayerMetadata = {\n attributes: SpanAttributes;\n name: string;\n};\n\nexport interface ExpressApplication {\n stack: ExpressLayer[];\n use: ExpressApplicationRequestHandler;\n}\n\nexport interface MiddlewareError extends Error {\n status?: number | string;\n statusCode?: number | string;\n status_code?: number | string;\n output?: {\n statusCode?: number | string;\n };\n}\n\nexport type ExpressMiddleware = (req: ExpressRequest, res: ExpressResponse, next: () => void) => void;\n\nexport type ExpressErrorMiddleware = (\n error: MiddlewareError,\n req: ExpressRequest,\n res: ExpressResponse,\n next: (error: MiddlewareError) => void,\n) => void;\n\nexport interface ExpressHandlerOptions {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n * @param error Captured middleware error\n */\n shouldHandleError?(this: void, error: MiddlewareError): boolean;\n}\n"],"names":[],"mappings":"AAgCO,MAAM,iBAAA,GAAoB;AAC1B,MAAM,eAAA,GAAkB;AACxB,MAAM,iBAAA,GAAoB;;AA2D1B,MAAM,uBAAA,GAA0B;AAChC,MAAM,2BAAA,GAA8B;AACpC,MAAM,gCAAA,GAAmC;;;;"}
@@ -0,0 +1,225 @@
1
+ import { getStoredLayers } from './request-layer-store.js';
2
+ import { ExpressLayerType_ROUTER, ATTR_EXPRESS_TYPE, ATTR_EXPRESS_NAME, ExpressLayerType_REQUEST_HANDLER, ExpressLayerType_MIDDLEWARE } from './types.js';
3
+ import { stringMatchesSomePattern } from '../../utils/string.js';
4
+
5
+ /**
6
+ * Converts a user-provided error value into an error and error message pair
7
+ *
8
+ * @param error - User-provided error value
9
+ * @returns Both an Error or string representation of the value and an error message
10
+ */
11
+ const asErrorAndMessage = (error) =>
12
+ error instanceof Error ? [error, error.message] : [String(error), String(error)];
13
+
14
+ /**
15
+ * Checks if a route contains parameter patterns (e.g., :id, :userId)
16
+ * which are valid even if they don't exactly match the original URL
17
+ */
18
+ function isRoutePattern(route) {
19
+ return route.includes(':') || route.includes('*');
20
+ }
21
+
22
+ /**
23
+ * Parse express layer context to retrieve a name and attributes.
24
+ * @param route The route of the layer
25
+ * @param layer Express layer
26
+ * @param [layerPath] if present, the path on which the layer has been mounted
27
+ */
28
+ const getLayerMetadata = (
29
+ route,
30
+ layer,
31
+ layerPath,
32
+
33
+ ) => {
34
+ if (layer.name === 'router') {
35
+ const maybeRouterPath = getRouterPath('', layer);
36
+ const extractedRouterPath = maybeRouterPath ? maybeRouterPath : layerPath || route || '/';
37
+
38
+ return {
39
+ attributes: {
40
+ [ATTR_EXPRESS_NAME]: extractedRouterPath,
41
+ [ATTR_EXPRESS_TYPE]: ExpressLayerType_ROUTER,
42
+ },
43
+ name: `router - ${extractedRouterPath}`,
44
+ };
45
+ } else if (layer.name === 'bound dispatch' || layer.name === 'handle') {
46
+ return {
47
+ attributes: {
48
+ [ATTR_EXPRESS_NAME]: (route || layerPath) ?? 'request handler',
49
+ [ATTR_EXPRESS_TYPE]: ExpressLayerType_REQUEST_HANDLER,
50
+ },
51
+ name: `request handler${layer.path ? ` - ${route || layerPath}` : ''}`,
52
+ };
53
+ } else {
54
+ return {
55
+ attributes: {
56
+ [ATTR_EXPRESS_NAME]: layer.name,
57
+ [ATTR_EXPRESS_TYPE]: ExpressLayerType_MIDDLEWARE,
58
+ },
59
+ name: `middleware - ${layer.name}`,
60
+ };
61
+ }
62
+ };
63
+
64
+ /**
65
+ * Recursively search the router path from layer stack
66
+ * @param path The path to reconstruct
67
+ * @param layer The layer to reconstruct from
68
+ * @returns The reconstructed path
69
+ */
70
+ const getRouterPath = (path, layer) => {
71
+ const stackLayer = Array.isArray(layer.handle?.stack) ? layer.handle?.stack?.[0] : undefined;
72
+
73
+ if (stackLayer?.route?.path) {
74
+ return `${path}${stackLayer.route.path}`;
75
+ }
76
+
77
+ if (stackLayer && Array.isArray(stackLayer?.handle?.stack)) {
78
+ return getRouterPath(path, stackLayer);
79
+ }
80
+
81
+ return path;
82
+ };
83
+
84
+ /**
85
+ * Check whether the given request is ignored by configuration
86
+ * It will not re-throw exceptions from `list` provided by the client
87
+ * @param constant e.g URL of request
88
+ * @param [list] List of ignore patterns
89
+ * @param [onException] callback for doing something when an exception has
90
+ * occurred
91
+ */
92
+
93
+ const isLayerIgnored = (
94
+ name,
95
+ type,
96
+ config,
97
+ ) => {
98
+ if (Array.isArray(config?.ignoreLayersType) && config?.ignoreLayersType?.includes(type)) {
99
+ return true;
100
+ }
101
+ if (!Array.isArray(config?.ignoreLayers)) {
102
+ return false;
103
+ }
104
+ try {
105
+ return stringMatchesSomePattern(name, config.ignoreLayers, true);
106
+ } catch {}
107
+
108
+ return false;
109
+ };
110
+
111
+ /**
112
+ * Extracts the actual matched route from Express request for OpenTelemetry instrumentation.
113
+ * Returns the route that should be used as the http.route attribute.
114
+ *
115
+ * @param req - The Express request object with layers store
116
+ * @param constructedRoute - The constructed route from `getConstructedRoute`
117
+ * @returns The matched route string or undefined if no valid route is found
118
+ */
119
+ function getActualMatchedRoute(req, constructedRoute) {
120
+ const layersStore = getStoredLayers(req);
121
+
122
+ // If no layers are stored, no route can be determined
123
+ if (layersStore.length === 0) {
124
+ return undefined;
125
+ }
126
+
127
+ // Handle root path case - if all paths are root, only return root if originalUrl is also root
128
+ // The layer store also includes root paths in case a non-existing url was requested
129
+ if (layersStore.every(path => path === '/')) {
130
+ return req.originalUrl === '/' ? '/' : undefined;
131
+ }
132
+
133
+ if (constructedRoute === '*') {
134
+ return constructedRoute;
135
+ }
136
+
137
+ // For RegExp routes or route arrays, return the constructed route
138
+ // This handles the case where the route is defined using RegExp or an array
139
+ if (
140
+ constructedRoute.includes('/') &&
141
+ (constructedRoute.includes(',') ||
142
+ constructedRoute.includes('\\') ||
143
+ constructedRoute.includes('*') ||
144
+ constructedRoute.includes('['))
145
+ ) {
146
+ return constructedRoute;
147
+ }
148
+
149
+ // Ensure route starts with '/' if it doesn't already
150
+ const normalizedRoute = constructedRoute.startsWith('/') ? constructedRoute : `/${constructedRoute}`;
151
+
152
+ // Validate that this appears to be a matched route
153
+ // A route is considered matched if:
154
+ // 1. We have a constructed route
155
+ // 2. The original URL matches or starts with our route pattern
156
+ const isValidRoute =
157
+ normalizedRoute.length > 0 &&
158
+ (req.originalUrl === normalizedRoute ||
159
+ req.originalUrl.startsWith(normalizedRoute) ||
160
+ isRoutePattern(normalizedRoute));
161
+
162
+ return isValidRoute ? normalizedRoute : undefined;
163
+ }
164
+
165
+ function getConstructedRoute(req) {
166
+ const layersStore = getStoredLayers(req);
167
+
168
+ let constructedRoute = '';
169
+ for (const path of layersStore) {
170
+ if (path === '/' || path === '/*') {
171
+ continue;
172
+ }
173
+ constructedRoute += !constructedRoute || constructedRoute.endsWith('/') ? path : `/${path}`;
174
+ }
175
+
176
+ return constructedRoute.replace(/\/{2,}/g, '/');
177
+ }
178
+
179
+ const getLayerPath = (args) => {
180
+ const firstArg = args[0];
181
+
182
+ if (Array.isArray(firstArg)) {
183
+ return firstArg.map(arg => extractLayerPathSegment(arg) || '').join(',');
184
+ }
185
+
186
+ return extractLayerPathSegment(firstArg );
187
+ };
188
+
189
+ const extractLayerPathSegment = (arg) =>
190
+ typeof arg === 'string' ? arg : arg instanceof RegExp || typeof arg === 'number' ? String(arg) : undefined;
191
+
192
+ // v5 we instrument Router.prototype
193
+ // v4 we instrument Router itself
194
+ const isExpressWithRouterPrototype = (express) =>
195
+ isExpressRouterPrototype((express )?.Router?.prototype);
196
+
197
+ // In Express v4, Router is a function (not a plain object), so we need to accept both
198
+ const isExpressRouterPrototype = (routerProto) =>
199
+ (typeof routerProto === 'object' || typeof routerProto === 'function') &&
200
+ !!routerProto &&
201
+ 'route' in routerProto &&
202
+ typeof (routerProto ).route === 'function';
203
+
204
+ const isExpressWithoutRouterPrototype = (express) =>
205
+ isExpressRouterPrototype((express ).Router) && !isExpressWithRouterPrototype(express);
206
+
207
+ // dynamic puts the default on .default, require or normal import are fine
208
+ const hasDefaultProp = (
209
+ express,
210
+
211
+ ) => !!express && typeof express === 'object' && 'default' in express && typeof express.default === 'function';
212
+
213
+ function getStatusCodeFromResponse(error) {
214
+ const statusCode = error.status || error.statusCode || error.status_code || error.output?.statusCode;
215
+ return statusCode ? parseInt(statusCode , 10) : 500;
216
+ }
217
+
218
+ /** Returns true if response code is internal server error */
219
+ function defaultShouldHandleError(error) {
220
+ const status = getStatusCodeFromResponse(error);
221
+ return status >= 500;
222
+ }
223
+
224
+ export { asErrorAndMessage, defaultShouldHandleError, getActualMatchedRoute, getConstructedRoute, getLayerMetadata, getLayerPath, getRouterPath, hasDefaultProp, isExpressWithRouterPrototype, isExpressWithoutRouterPrototype, isLayerIgnored, isRoutePattern };
225
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/integrations/express/utils.ts"],"sourcesContent":["/**\n * Platform-portable Express tracing integration.\n *\n * @module\n *\n * This Sentry integration is a derivative work based on the OpenTelemetry\n * Express instrumentation.\n *\n * <https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-express>\n *\n * Extended under the terms of the Apache 2.0 license linked below:\n *\n * ----\n *\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SpanAttributes } from '../../types-hoist/span';\nimport { getStoredLayers } from './request-layer-store';\nimport type {\n ExpressExport,\n ExpressIntegrationOptions,\n ExpressLayer,\n ExpressLayerType,\n ExpressRequest,\n LayerPathSegment,\n MiddlewareError,\n ExpressRouterv4,\n ExpressExportv5,\n ExpressExportv4,\n} from './types';\nimport {\n ATTR_EXPRESS_NAME,\n ATTR_EXPRESS_TYPE,\n ExpressLayerType_MIDDLEWARE,\n ExpressLayerType_REQUEST_HANDLER,\n ExpressLayerType_ROUTER,\n} from './types';\nimport { stringMatchesSomePattern } from '../../utils/string';\n\n/**\n * Converts a user-provided error value into an error and error message pair\n *\n * @param error - User-provided error value\n * @returns Both an Error or string representation of the value and an error message\n */\nexport const asErrorAndMessage = (error: unknown): [string | Error, string] =>\n error instanceof Error ? [error, error.message] : [String(error), String(error)];\n\n/**\n * Checks if a route contains parameter patterns (e.g., :id, :userId)\n * which are valid even if they don't exactly match the original URL\n */\nexport function isRoutePattern(route: string): boolean {\n return route.includes(':') || route.includes('*');\n}\n\n/**\n * Parse express layer context to retrieve a name and attributes.\n * @param route The route of the layer\n * @param layer Express layer\n * @param [layerPath] if present, the path on which the layer has been mounted\n */\nexport const getLayerMetadata = (\n route: string,\n layer: ExpressLayer,\n layerPath?: string,\n): {\n attributes: SpanAttributes & { [ATTR_EXPRESS_NAME]: string; [ATTR_EXPRESS_TYPE]: ExpressLayerType };\n name: string;\n} => {\n if (layer.name === 'router') {\n const maybeRouterPath = getRouterPath('', layer);\n const extractedRouterPath = maybeRouterPath ? maybeRouterPath : layerPath || route || '/';\n\n return {\n attributes: {\n [ATTR_EXPRESS_NAME]: extractedRouterPath,\n [ATTR_EXPRESS_TYPE]: ExpressLayerType_ROUTER,\n },\n name: `router - ${extractedRouterPath}`,\n };\n } else if (layer.name === 'bound dispatch' || layer.name === 'handle') {\n return {\n attributes: {\n [ATTR_EXPRESS_NAME]: (route || layerPath) ?? 'request handler',\n [ATTR_EXPRESS_TYPE]: ExpressLayerType_REQUEST_HANDLER,\n },\n name: `request handler${layer.path ? ` - ${route || layerPath}` : ''}`,\n };\n } else {\n return {\n attributes: {\n [ATTR_EXPRESS_NAME]: layer.name,\n [ATTR_EXPRESS_TYPE]: ExpressLayerType_MIDDLEWARE,\n },\n name: `middleware - ${layer.name}`,\n };\n }\n};\n\n/**\n * Recursively search the router path from layer stack\n * @param path The path to reconstruct\n * @param layer The layer to reconstruct from\n * @returns The reconstructed path\n */\nexport const getRouterPath = (path: string, layer: ExpressLayer): string => {\n const stackLayer = Array.isArray(layer.handle?.stack) ? layer.handle?.stack?.[0] : undefined;\n\n if (stackLayer?.route?.path) {\n return `${path}${stackLayer.route.path}`;\n }\n\n if (stackLayer && Array.isArray(stackLayer?.handle?.stack)) {\n return getRouterPath(path, stackLayer);\n }\n\n return path;\n};\n\n/**\n * Check whether the given request is ignored by configuration\n * It will not re-throw exceptions from `list` provided by the client\n * @param constant e.g URL of request\n * @param [list] List of ignore patterns\n * @param [onException] callback for doing something when an exception has\n * occurred\n */\nexport type ExpressIsLayerIgnoredOptions = Pick<ExpressIntegrationOptions, 'ignoreLayersType' | 'ignoreLayers'>;\nexport const isLayerIgnored = (\n name: string,\n type: ExpressLayerType,\n config?: ExpressIsLayerIgnoredOptions,\n): boolean => {\n if (Array.isArray(config?.ignoreLayersType) && config?.ignoreLayersType?.includes(type)) {\n return true;\n }\n if (!Array.isArray(config?.ignoreLayers)) {\n return false;\n }\n try {\n return stringMatchesSomePattern(name, config.ignoreLayers, true);\n } catch {}\n\n return false;\n};\n\n/**\n * Extracts the actual matched route from Express request for OpenTelemetry instrumentation.\n * Returns the route that should be used as the http.route attribute.\n *\n * @param req - The Express request object with layers store\n * @param constructedRoute - The constructed route from `getConstructedRoute`\n * @returns The matched route string or undefined if no valid route is found\n */\nexport function getActualMatchedRoute(req: ExpressRequest, constructedRoute: string): string | undefined {\n const layersStore = getStoredLayers(req);\n\n // If no layers are stored, no route can be determined\n if (layersStore.length === 0) {\n return undefined;\n }\n\n // Handle root path case - if all paths are root, only return root if originalUrl is also root\n // The layer store also includes root paths in case a non-existing url was requested\n if (layersStore.every(path => path === '/')) {\n return req.originalUrl === '/' ? '/' : undefined;\n }\n\n if (constructedRoute === '*') {\n return constructedRoute;\n }\n\n // For RegExp routes or route arrays, return the constructed route\n // This handles the case where the route is defined using RegExp or an array\n if (\n constructedRoute.includes('/') &&\n (constructedRoute.includes(',') ||\n constructedRoute.includes('\\\\') ||\n constructedRoute.includes('*') ||\n constructedRoute.includes('['))\n ) {\n return constructedRoute;\n }\n\n // Ensure route starts with '/' if it doesn't already\n const normalizedRoute = constructedRoute.startsWith('/') ? constructedRoute : `/${constructedRoute}`;\n\n // Validate that this appears to be a matched route\n // A route is considered matched if:\n // 1. We have a constructed route\n // 2. The original URL matches or starts with our route pattern\n const isValidRoute =\n normalizedRoute.length > 0 &&\n (req.originalUrl === normalizedRoute ||\n req.originalUrl.startsWith(normalizedRoute) ||\n isRoutePattern(normalizedRoute));\n\n return isValidRoute ? normalizedRoute : undefined;\n}\n\nexport function getConstructedRoute(req: ExpressRequest) {\n const layersStore: string[] = getStoredLayers(req);\n\n let constructedRoute: string = '';\n for (const path of layersStore) {\n if (path === '/' || path === '/*') {\n continue;\n }\n constructedRoute += !constructedRoute || constructedRoute.endsWith('/') ? path : `/${path}`;\n }\n\n return constructedRoute.replace(/\\/{2,}/g, '/');\n}\n\nexport const getLayerPath = (args: unknown[]): string | undefined => {\n const firstArg = args[0];\n\n if (Array.isArray(firstArg)) {\n return firstArg.map(arg => extractLayerPathSegment(arg) || '').join(',');\n }\n\n return extractLayerPathSegment(firstArg as LayerPathSegment);\n};\n\nconst extractLayerPathSegment = (arg: LayerPathSegment): string | undefined =>\n typeof arg === 'string' ? arg : arg instanceof RegExp || typeof arg === 'number' ? String(arg) : undefined;\n\n// v5 we instrument Router.prototype\n// v4 we instrument Router itself\nexport const isExpressWithRouterPrototype = (express: unknown): express is ExpressExportv5 =>\n isExpressRouterPrototype((express as ExpressExportv5)?.Router?.prototype);\n\n// In Express v4, Router is a function (not a plain object), so we need to accept both\nconst isExpressRouterPrototype = (routerProto?: unknown): routerProto is ExpressRouterv4 =>\n (typeof routerProto === 'object' || typeof routerProto === 'function') &&\n !!routerProto &&\n 'route' in routerProto &&\n typeof (routerProto as ExpressRouterv4).route === 'function';\n\nexport const isExpressWithoutRouterPrototype = (express: unknown): express is ExpressExportv4 =>\n isExpressRouterPrototype((express as ExpressExportv4).Router) && !isExpressWithRouterPrototype(express);\n\n// dynamic puts the default on .default, require or normal import are fine\nexport const hasDefaultProp = (\n express: unknown,\n): express is {\n [k: string]: unknown;\n default: ExpressExport;\n} => !!express && typeof express === 'object' && 'default' in express && typeof express.default === 'function';\n\nfunction getStatusCodeFromResponse(error: MiddlewareError): number {\n const statusCode = error.status || error.statusCode || error.status_code || error.output?.statusCode;\n return statusCode ? parseInt(statusCode as string, 10) : 500;\n}\n\n/** Returns true if response code is internal server error */\nexport function defaultShouldHandleError(error: MiddlewareError): boolean {\n const status = getStatusCodeFromResponse(error);\n return status >= 500;\n}\n"],"names":[],"mappings":";;;;AAoDA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,iBAAA,GAAoB,CAAC,KAAK;AACvC,EAAE,KAAA,YAAiB,KAAA,GAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAA,GAAI,CAAC,MAAM,CAAC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AA,CAAA,OAAA,WAAA,KAAA,QAAA,IAAA,OAAA,WAAA,KAAA,UAAA;AACA,EAAA,CAAA,CAAA,WAAA;AACA,EAAA,OAAA,IAAA,WAAA;AACA,EAAA,OAAA,CAAA,WAAA,GAAA,KAAA,KAAA,UAAA;;AAEA,MAAA,+BAAA,GAAA,CAAA,OAAA;AACA,EAAA,wBAAA,CAAA,CAAA,OAAA,GAAA,MAAA,CAAA,IAAA,CAAA,4BAAA,CAAA,OAAA;;AAEA;AACA,MAAA,cAAA,GAAA;AACA,EAAA,OAAA;;AAIA,KAAA,CAAA,CAAA,OAAA,IAAA,OAAA,OAAA,KAAA,QAAA,IAAA,SAAA,IAAA,OAAA,IAAA,OAAA,OAAA,CAAA,OAAA,KAAA;;AAEA,SAAA,yBAAA,CAAA,KAAA,EAAA;AACA,EAAA,MAAA,UAAA,GAAA,KAAA,CAAA,MAAA,IAAA,KAAA,CAAA,UAAA,IAAA,KAAA,CAAA,WAAA,IAAA,KAAA,CAAA,MAAA,EAAA,UAAA;AACA,EAAA,OAAA,UAAA,GAAA,QAAA,CAAA,UAAA,GAAA,EAAA,CAAA,GAAA,GAAA;AACA;;AAEA;AACA,SAAA,wBAAA,CAAA,KAAA,EAAA;AACA,EAAA,MAAA,MAAA,GAAA,yBAAA,CAAA,KAAA,CAAA;AACA,EAAA,OAAA,MAAA,IAAA,GAAA;AACA;;;;"}
@@ -80,19 +80,23 @@ function storeSpanForRequest(transport, requestId, span, method) {
80
80
  * @param requestId - Request identifier
81
81
  * @param result - Execution result for attribute extraction
82
82
  * @param options - Resolved MCP options
83
+ * @param hasError - Whether the JSON-RPC response contained an error
83
84
  */
84
85
  function completeSpanWithResults(
85
86
  transport,
86
87
  requestId,
87
88
  result,
88
89
  options,
90
+ hasError = false,
89
91
  ) {
90
92
  const spanMap = getOrCreateSpanMap(transport);
91
93
  const spanData = spanMap.get(requestId);
92
94
  if (spanData) {
93
95
  const { span, method } = spanData;
94
96
 
95
- if (method === 'initialize') {
97
+ if (hasError) {
98
+ span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
99
+ } else if (method === 'initialize') {
96
100
  const sessionData = extractSessionDataFromInitializeResponse(result);
97
101
  const serverAttributes = buildServerAttributesFromInfo(sessionData.serverInfo);
98
102