@sentry/server-utils 11.14.0 → 11.15.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 (277) hide show
  1. package/build/cjs/chunks/exports.js +526 -217
  2. package/build/cjs/chunks/exports.js.map +1 -1
  3. package/build/cjs/index.js +1028 -120
  4. package/build/cjs/index.js.map +1 -1
  5. package/build/esm/ai/anthropic-ai/index.js +32 -56
  6. package/build/esm/ai/anthropic-ai/index.js.map +1 -1
  7. package/build/esm/ai/anthropic-ai/streaming.js +10 -6
  8. package/build/esm/ai/anthropic-ai/streaming.js.map +1 -1
  9. package/build/esm/ai/anthropic-ai/tool-runner.js +18 -3
  10. package/build/esm/ai/anthropic-ai/tool-runner.js.map +1 -1
  11. package/build/esm/ai/anthropic-ai/utils.js +41 -3
  12. package/build/esm/ai/anthropic-ai/utils.js.map +1 -1
  13. package/build/esm/ai/core/span-hooks.js +23 -0
  14. package/build/esm/ai/core/span-hooks.js.map +1 -0
  15. package/build/esm/ai/core/time-to-first-chunk.js +14 -0
  16. package/build/esm/ai/core/time-to-first-chunk.js.map +1 -0
  17. package/build/esm/ai/core/utils.js +29 -3
  18. package/build/esm/ai/core/utils.js.map +1 -1
  19. package/build/esm/ai/flue/index.js +15 -12
  20. package/build/esm/ai/flue/index.js.map +1 -1
  21. package/build/esm/ai/flue/utils.js +24 -17
  22. package/build/esm/ai/flue/utils.js.map +1 -1
  23. package/build/esm/ai/google-genai/index.js +21 -8
  24. package/build/esm/ai/google-genai/index.js.map +1 -1
  25. package/build/esm/ai/google-genai/streaming.js +6 -2
  26. package/build/esm/ai/google-genai/streaming.js.map +1 -1
  27. package/build/esm/ai/langchain/embeddings.js +5 -2
  28. package/build/esm/ai/langchain/embeddings.js.map +1 -1
  29. package/build/esm/ai/langchain/index.js +82 -24
  30. package/build/esm/ai/langchain/index.js.map +1 -1
  31. package/build/esm/ai/langchain/utils.js +9 -1
  32. package/build/esm/ai/langchain/utils.js.map +1 -1
  33. package/build/esm/ai/langgraph/agent-span.js +13 -5
  34. package/build/esm/ai/langgraph/agent-span.js.map +1 -1
  35. package/build/esm/ai/langgraph/index.js +13 -15
  36. package/build/esm/ai/langgraph/index.js.map +1 -1
  37. package/build/esm/ai/langgraph/stream.js +4 -3
  38. package/build/esm/ai/langgraph/stream.js.map +1 -1
  39. package/build/esm/ai/langgraph/utils.js +17 -8
  40. package/build/esm/ai/langgraph/utils.js.map +1 -1
  41. package/build/esm/ai/mastra/classifier-evaluation.js.map +1 -1
  42. package/build/esm/ai/mastra/index.js +33 -16
  43. package/build/esm/ai/mastra/index.js.map +1 -1
  44. package/build/esm/ai/mastra/utils.js +3 -5
  45. package/build/esm/ai/mastra/utils.js.map +1 -1
  46. package/build/esm/ai/mistral/index.js +21 -7
  47. package/build/esm/ai/mistral/index.js.map +1 -1
  48. package/build/esm/ai/mistral/streaming.js +4 -2
  49. package/build/esm/ai/mistral/streaming.js.map +1 -1
  50. package/build/esm/ai/openai/index.js +19 -8
  51. package/build/esm/ai/openai/index.js.map +1 -1
  52. package/build/esm/ai/openai/streaming.js +7 -2
  53. package/build/esm/ai/openai/streaming.js.map +1 -1
  54. package/build/esm/ai/pi-ai/chat.js +18 -1
  55. package/build/esm/ai/pi-ai/chat.js.map +1 -1
  56. package/build/esm/ai/pi-ai/recording.js +34 -15
  57. package/build/esm/ai/pi-ai/recording.js.map +1 -1
  58. package/build/esm/ai/pi-durable/index.js +7 -2
  59. package/build/esm/ai/pi-durable/index.js.map +1 -1
  60. package/build/esm/ai/pi-durable/runs.js.map +1 -1
  61. package/build/esm/ai/pi-durable/tools.js +18 -3
  62. package/build/esm/ai/pi-durable/tools.js.map +1 -1
  63. package/build/esm/ai/typesafe/index.js +14 -6
  64. package/build/esm/ai/typesafe/index.js.map +1 -1
  65. package/build/esm/ai/workers-ai/index.js +26 -9
  66. package/build/esm/ai/workers-ai/index.js.map +1 -1
  67. package/build/esm/ai/workers-ai/streaming.js +6 -4
  68. package/build/esm/ai/workers-ai/streaming.js.map +1 -1
  69. package/build/esm/cron/common.js +16 -0
  70. package/build/esm/cron/common.js.map +1 -0
  71. package/build/esm/cron/cron.js +82 -0
  72. package/build/esm/cron/cron.js.map +1 -0
  73. package/build/esm/cron/index.js +13 -0
  74. package/build/esm/cron/index.js.map +1 -0
  75. package/build/esm/cron/node-cron.js +66 -0
  76. package/build/esm/cron/node-cron.js.map +1 -0
  77. package/build/esm/cron/node-schedule.js +43 -0
  78. package/build/esm/cron/node-schedule.js.map +1 -0
  79. package/build/esm/index.js +6 -2
  80. package/build/esm/index.js.map +1 -1
  81. package/build/esm/integrations/anthropic.js +25 -16
  82. package/build/esm/integrations/anthropic.js.map +1 -1
  83. package/build/esm/integrations/aws-sdk/index.js +1 -0
  84. package/build/esm/integrations/aws-sdk/index.js.map +1 -1
  85. package/build/esm/integrations/aws-sdk/services/ServicesExtensions.js +3 -0
  86. package/build/esm/integrations/aws-sdk/services/ServicesExtensions.js.map +1 -1
  87. package/build/esm/integrations/aws-sdk/services/bedrock-runtime.js +45 -12
  88. package/build/esm/integrations/aws-sdk/services/bedrock-runtime.js.map +1 -1
  89. package/build/esm/integrations/bullmq/contextManager.js +45 -0
  90. package/build/esm/integrations/bullmq/contextManager.js.map +1 -0
  91. package/build/esm/integrations/bullmq/index.js +44 -0
  92. package/build/esm/integrations/bullmq/index.js.map +1 -0
  93. package/build/esm/integrations/bullmq/meter.js +86 -0
  94. package/build/esm/integrations/bullmq/meter.js.map +1 -0
  95. package/build/esm/integrations/bullmq/span.js +114 -0
  96. package/build/esm/integrations/bullmq/span.js.map +1 -0
  97. package/build/esm/integrations/bullmq/tracer.js +62 -0
  98. package/build/esm/integrations/bullmq/tracer.js.map +1 -0
  99. package/build/esm/integrations/express/instrumentation.js +10 -1
  100. package/build/esm/integrations/express/instrumentation.js.map +1 -1
  101. package/build/esm/integrations/google-genai.js +17 -9
  102. package/build/esm/integrations/google-genai.js.map +1 -1
  103. package/build/esm/integrations/langgraph.js +5 -7
  104. package/build/esm/integrations/langgraph.js.map +1 -1
  105. package/build/esm/integrations/mastra-classifier.js +1 -1
  106. package/build/esm/integrations/mastra-classifier.js.map +1 -1
  107. package/build/esm/integrations/mistral.js +13 -4
  108. package/build/esm/integrations/mistral.js.map +1 -1
  109. package/build/esm/integrations/openai-compatible.js +16 -8
  110. package/build/esm/integrations/openai-compatible.js.map +1 -1
  111. package/build/esm/integrations/openai.js +16 -8
  112. package/build/esm/integrations/openai.js.map +1 -1
  113. package/build/esm/integrations/pi-ai.js +39 -18
  114. package/build/esm/integrations/pi-ai.js.map +1 -1
  115. package/build/esm/integrations/pino.js +131 -0
  116. package/build/esm/integrations/pino.js.map +1 -0
  117. package/build/esm/integrations/typesafe.js +17 -3
  118. package/build/esm/integrations/typesafe.js.map +1 -1
  119. package/build/esm/integrations/vercel-ai/index.js.map +1 -1
  120. package/build/esm/integrations/vercel-ai/util.js +3 -2
  121. package/build/esm/integrations/vercel-ai/util.js.map +1 -1
  122. package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js +44 -17
  123. package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  124. package/build/esm/integrations/vercel-ai/vercel-ai-orchestrion-subscriber.js +22 -16
  125. package/build/esm/integrations/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -1
  126. package/build/esm/integrations/winston.js +90 -0
  127. package/build/esm/integrations/winston.js.map +1 -0
  128. package/build/esm/orchestrion/detect.js +1 -1
  129. package/build/esm/orchestrion/detect.js.map +1 -1
  130. package/build/esm/package.json +1 -1
  131. package/build/types/ai/anthropic-ai/index.d.ts +1 -5
  132. package/build/types/ai/anthropic-ai/index.d.ts.map +1 -1
  133. package/build/types/ai/anthropic-ai/streaming.d.ts +3 -2
  134. package/build/types/ai/anthropic-ai/streaming.d.ts.map +1 -1
  135. package/build/types/ai/anthropic-ai/tool-runner.d.ts.map +1 -1
  136. package/build/types/ai/anthropic-ai/types.d.ts +24 -3
  137. package/build/types/ai/anthropic-ai/types.d.ts.map +1 -1
  138. package/build/types/ai/anthropic-ai/utils.d.ts +2 -3
  139. package/build/types/ai/anthropic-ai/utils.d.ts.map +1 -1
  140. package/build/types/ai/core/span-hooks.d.ts +31 -0
  141. package/build/types/ai/core/span-hooks.d.ts.map +1 -0
  142. package/build/types/ai/core/time-to-first-chunk.d.ts +7 -0
  143. package/build/types/ai/core/time-to-first-chunk.d.ts.map +1 -0
  144. package/build/types/ai/core/utils.d.ts +30 -1
  145. package/build/types/ai/core/utils.d.ts.map +1 -1
  146. package/build/types/ai/flue/index.d.ts +13 -5
  147. package/build/types/ai/flue/index.d.ts.map +1 -1
  148. package/build/types/ai/flue/types.d.ts +20 -2
  149. package/build/types/ai/flue/types.d.ts.map +1 -1
  150. package/build/types/ai/flue/utils.d.ts +5 -9
  151. package/build/types/ai/flue/utils.d.ts.map +1 -1
  152. package/build/types/ai/google-genai/index.d.ts.map +1 -1
  153. package/build/types/ai/google-genai/streaming.d.ts +2 -1
  154. package/build/types/ai/google-genai/streaming.d.ts.map +1 -1
  155. package/build/types/ai/google-genai/types.d.ts +17 -3
  156. package/build/types/ai/google-genai/types.d.ts.map +1 -1
  157. package/build/types/ai/langchain/index.d.ts.map +1 -1
  158. package/build/types/ai/langchain/types.d.ts +49 -3
  159. package/build/types/ai/langchain/types.d.ts.map +1 -1
  160. package/build/types/ai/langchain/utils.d.ts +6 -0
  161. package/build/types/ai/langchain/utils.d.ts.map +1 -1
  162. package/build/types/ai/langgraph/agent-span.d.ts +4 -1
  163. package/build/types/ai/langgraph/agent-span.d.ts.map +1 -1
  164. package/build/types/ai/langgraph/index.d.ts +1 -1
  165. package/build/types/ai/langgraph/index.d.ts.map +1 -1
  166. package/build/types/ai/langgraph/stream.d.ts.map +1 -1
  167. package/build/types/ai/langgraph/types.d.ts +14 -3
  168. package/build/types/ai/langgraph/types.d.ts.map +1 -1
  169. package/build/types/ai/langgraph/utils.d.ts +3 -0
  170. package/build/types/ai/langgraph/utils.d.ts.map +1 -1
  171. package/build/types/ai/mastra/classifier-evaluation.d.ts +3 -3
  172. package/build/types/ai/mastra/classifier-evaluation.d.ts.map +1 -1
  173. package/build/types/ai/mastra/index.d.ts +17 -3
  174. package/build/types/ai/mastra/index.d.ts.map +1 -1
  175. package/build/types/ai/mastra/types.d.ts +2 -0
  176. package/build/types/ai/mastra/types.d.ts.map +1 -1
  177. package/build/types/ai/mastra/utils.d.ts.map +1 -1
  178. package/build/types/ai/mistral/index.d.ts.map +1 -1
  179. package/build/types/ai/mistral/streaming.d.ts +2 -1
  180. package/build/types/ai/mistral/streaming.d.ts.map +1 -1
  181. package/build/types/ai/mistral/types.d.ts +14 -3
  182. package/build/types/ai/mistral/types.d.ts.map +1 -1
  183. package/build/types/ai/openai/index.d.ts.map +1 -1
  184. package/build/types/ai/openai/streaming.d.ts +3 -1
  185. package/build/types/ai/openai/streaming.d.ts.map +1 -1
  186. package/build/types/ai/openai/types.d.ts +14 -3
  187. package/build/types/ai/openai/types.d.ts.map +1 -1
  188. package/build/types/ai/pi-ai/chat.d.ts +7 -1
  189. package/build/types/ai/pi-ai/chat.d.ts.map +1 -1
  190. package/build/types/ai/pi-ai/recording.d.ts +21 -9
  191. package/build/types/ai/pi-ai/recording.d.ts.map +1 -1
  192. package/build/types/ai/pi-ai/types.d.ts +16 -0
  193. package/build/types/ai/pi-ai/types.d.ts.map +1 -1
  194. package/build/types/ai/pi-durable/index.d.ts +12 -3
  195. package/build/types/ai/pi-durable/index.d.ts.map +1 -1
  196. package/build/types/ai/pi-durable/runs.d.ts +2 -0
  197. package/build/types/ai/pi-durable/runs.d.ts.map +1 -1
  198. package/build/types/ai/pi-durable/tools.d.ts +4 -3
  199. package/build/types/ai/pi-durable/tools.d.ts.map +1 -1
  200. package/build/types/ai/pi-durable/types.d.ts +15 -0
  201. package/build/types/ai/pi-durable/types.d.ts.map +1 -1
  202. package/build/types/ai/typesafe/index.d.ts +10 -2
  203. package/build/types/ai/typesafe/index.d.ts.map +1 -1
  204. package/build/types/ai/workers-ai/index.d.ts.map +1 -1
  205. package/build/types/ai/workers-ai/streaming.d.ts +2 -1
  206. package/build/types/ai/workers-ai/streaming.d.ts.map +1 -1
  207. package/build/types/ai/workers-ai/types.d.ts +18 -3
  208. package/build/types/ai/workers-ai/types.d.ts.map +1 -1
  209. package/build/types/cron/common.d.ts +8 -0
  210. package/build/types/cron/common.d.ts.map +1 -0
  211. package/build/types/cron/cron.d.ts +45 -0
  212. package/build/types/cron/cron.d.ts.map +1 -0
  213. package/build/types/cron/index.d.ts +10 -0
  214. package/build/types/cron/index.d.ts.map +1 -0
  215. package/build/types/cron/node-cron.d.ts +33 -0
  216. package/build/types/cron/node-cron.d.ts.map +1 -0
  217. package/build/types/cron/node-schedule.d.ts +19 -0
  218. package/build/types/cron/node-schedule.d.ts.map +1 -0
  219. package/build/types/index.d.ts +5 -2
  220. package/build/types/index.d.ts.map +1 -1
  221. package/build/types/integrations/anthropic.d.ts +2 -1
  222. package/build/types/integrations/anthropic.d.ts.map +1 -1
  223. package/build/types/integrations/aws-sdk/index.d.ts +3 -3
  224. package/build/types/integrations/aws-sdk/index.d.ts.map +1 -1
  225. package/build/types/integrations/aws-sdk/services/ServiceExtension.d.ts +1 -0
  226. package/build/types/integrations/aws-sdk/services/ServiceExtension.d.ts.map +1 -1
  227. package/build/types/integrations/aws-sdk/services/ServicesExtensions.d.ts +3 -2
  228. package/build/types/integrations/aws-sdk/services/ServicesExtensions.d.ts.map +1 -1
  229. package/build/types/integrations/aws-sdk/services/bedrock-runtime.d.ts +25 -4
  230. package/build/types/integrations/aws-sdk/services/bedrock-runtime.d.ts.map +1 -1
  231. package/build/types/integrations/bullmq/contextManager.d.ts +13 -0
  232. package/build/types/integrations/bullmq/contextManager.d.ts.map +1 -0
  233. package/build/types/integrations/bullmq/index.d.ts +43 -0
  234. package/build/types/integrations/bullmq/index.d.ts.map +1 -0
  235. package/build/types/integrations/bullmq/meter.d.ts +7 -0
  236. package/build/types/integrations/bullmq/meter.d.ts.map +1 -0
  237. package/build/types/integrations/bullmq/span.d.ts +35 -0
  238. package/build/types/integrations/bullmq/span.d.ts.map +1 -0
  239. package/build/types/integrations/bullmq/tracer.d.ts +5 -0
  240. package/build/types/integrations/bullmq/tracer.d.ts.map +1 -0
  241. package/build/types/integrations/bullmq/types.d.ts +72 -0
  242. package/build/types/integrations/bullmq/types.d.ts.map +1 -0
  243. package/build/types/integrations/express/types.d.ts +1 -0
  244. package/build/types/integrations/express/types.d.ts.map +1 -1
  245. package/build/types/integrations/flue.d.ts +2 -1
  246. package/build/types/integrations/flue.d.ts.map +1 -1
  247. package/build/types/integrations/google-genai.d.ts +2 -1
  248. package/build/types/integrations/google-genai.d.ts.map +1 -1
  249. package/build/types/integrations/groq.d.ts +1 -1
  250. package/build/types/integrations/langchain.d.ts +2 -1
  251. package/build/types/integrations/langchain.d.ts.map +1 -1
  252. package/build/types/integrations/langgraph.d.ts +2 -1
  253. package/build/types/integrations/langgraph.d.ts.map +1 -1
  254. package/build/types/integrations/mistral.d.ts +2 -1
  255. package/build/types/integrations/mistral.d.ts.map +1 -1
  256. package/build/types/integrations/openai-compatible.d.ts.map +1 -1
  257. package/build/types/integrations/openai.d.ts +2 -1
  258. package/build/types/integrations/openai.d.ts.map +1 -1
  259. package/build/types/integrations/pi-ai.d.ts +6 -3
  260. package/build/types/integrations/pi-ai.d.ts.map +1 -1
  261. package/build/types/integrations/pi-durable.d.ts +2 -1
  262. package/build/types/integrations/pi-durable.d.ts.map +1 -1
  263. package/build/types/integrations/pino.d.ts +61 -0
  264. package/build/types/integrations/pino.d.ts.map +1 -0
  265. package/build/types/integrations/together-ai.d.ts +1 -1
  266. package/build/types/integrations/typesafe.d.ts +2 -2
  267. package/build/types/integrations/typesafe.d.ts.map +1 -1
  268. package/build/types/integrations/vercel-ai/index.d.ts +3 -3
  269. package/build/types/integrations/vercel-ai/index.d.ts.map +1 -1
  270. package/build/types/integrations/vercel-ai/util.d.ts +2 -1
  271. package/build/types/integrations/vercel-ai/util.d.ts.map +1 -1
  272. package/build/types/integrations/vercel-ai/vercel-ai-dc-subscriber.d.ts +20 -4
  273. package/build/types/integrations/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
  274. package/build/types/integrations/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts.map +1 -1
  275. package/build/types/integrations/winston.d.ts +55 -0
  276. package/build/types/integrations/winston.d.ts.map +1 -0
  277. package/package.json +3 -3
@@ -0,0 +1,82 @@
1
+ import { getCronMonitorConfig } from "./common.js";
2
+ import { addNonEnumerableProperty, captureException, withMonitor } from "@sentry/core";
3
+ // src/cron/cron.ts
4
+ const MONITORED = Symbol.for("sentry.cron.monitored");
5
+ const ERROR_TEXT = "Automatic instrumentation of CronJob only supports crontab string";
6
+ /**
7
+ * Instruments the `cron` library to send a check-in event to Sentry for each job execution.
8
+ *
9
+ * ```ts
10
+ * import * as Sentry from '@sentry/node';
11
+ * import { CronJob } from 'cron';
12
+ *
13
+ * const CronJobWithCheckIn = Sentry.cron.instrumentCron(CronJob, 'my-cron-job');
14
+ *
15
+ * // use the constructor
16
+ * const job = new CronJobWithCheckIn('* * * * *', () => {
17
+ * console.log('You will see this message every minute');
18
+ * });
19
+ *
20
+ * // or from
21
+ * const job = CronJobWithCheckIn.from({ cronTime: '* * * * *', onTick: () => {
22
+ * console.log('You will see this message every minute');
23
+ * });
24
+ * ```
25
+ *
26
+ * @deprecated Use `cronJobIntegration` instead.
27
+ */
28
+ function instrumentCron(lib, monitorSlug) {
29
+ let jobScheduled = false;
30
+ return new Proxy(lib, {
31
+ construct(target, args) {
32
+ const [cronTime, onTick, onComplete, start, timeZone, ...rest] = args;
33
+ if (typeof cronTime !== "string") throw new Error(ERROR_TEXT);
34
+ if (jobScheduled) throw new Error(`A job named '${monitorSlug}' has already been scheduled`);
35
+ jobScheduled = true;
36
+ const monitorConfig = args[7] == null ? getCronMonitorConfig(cronTime, timeZone, "cron") : void 0;
37
+ async function monitoredTick(context, onComplete) {
38
+ return withMonitor(monitorSlug, async () => {
39
+ try {
40
+ await onTick(context, onComplete);
41
+ } catch (e) {
42
+ captureException(e, { mechanism: {
43
+ handled: false,
44
+ type: "auto.function.cron.instrumentCron"
45
+ } });
46
+ throw e;
47
+ }
48
+ }, monitorConfig);
49
+ }
50
+ addNonEnumerableProperty(monitoredTick, MONITORED, true);
51
+ return new target(cronTime, monitoredTick, onComplete, start, timeZone, ...rest);
52
+ },
53
+ get(target, prop) {
54
+ if (prop === "from") return (param) => {
55
+ const { cronTime, onTick, timeZone, utcOffset } = param;
56
+ if (typeof cronTime !== "string") throw new Error(ERROR_TEXT);
57
+ if (jobScheduled) throw new Error(`A job named '${monitorSlug}' has already been scheduled`);
58
+ jobScheduled = true;
59
+ const monitorConfig = utcOffset == null ? getCronMonitorConfig(cronTime, timeZone, "cron") : void 0;
60
+ param.onTick = async (context, onComplete) => {
61
+ return withMonitor(monitorSlug, async () => {
62
+ try {
63
+ await onTick(context, onComplete);
64
+ } catch (e) {
65
+ captureException(e, { mechanism: {
66
+ handled: false,
67
+ type: "auto.function.cron.instrumentCron"
68
+ } });
69
+ throw e;
70
+ }
71
+ }, monitorConfig);
72
+ };
73
+ addNonEnumerableProperty(param.onTick, MONITORED, true);
74
+ return target.from(param);
75
+ };
76
+ else return target[prop];
77
+ }
78
+ });
79
+ }
80
+ export { instrumentCron };
81
+
82
+ //# sourceMappingURL=cron.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron.js","names":[],"sources":["../../../src/cron/cron.ts"],"sourcesContent":["import { addNonEnumerableProperty, captureException, withMonitor } from '@sentry/core';\nimport { getCronMonitorConfig } from './common';\n\nexport type CronJobParams = {\n cronTime: string | Date;\n onTick: (context: unknown, onComplete?: unknown) => void | Promise<void>;\n onComplete?: () => void | Promise<void>;\n start?: boolean | null;\n context?: unknown;\n runOnInit?: boolean | null;\n unrefTimeout?: boolean | null;\n} & (\n | {\n timeZone?: string | null;\n utcOffset?: never;\n }\n | {\n timeZone?: never;\n utcOffset?: number | null;\n }\n);\n\nexport type CronJob = {\n //\n};\n\nexport type CronJobConstructor = {\n from: (param: CronJobParams) => CronJob;\n\n new (\n cronTime: CronJobParams['cronTime'],\n onTick: CronJobParams['onTick'],\n onComplete?: CronJobParams['onComplete'],\n start?: CronJobParams['start'],\n timeZone?: CronJobParams['timeZone'],\n context?: CronJobParams['context'],\n runOnInit?: CronJobParams['runOnInit'],\n utcOffset?: null,\n unrefTimeout?: CronJobParams['unrefTimeout'],\n ): CronJob;\n new (\n cronTime: CronJobParams['cronTime'],\n onTick: CronJobParams['onTick'],\n onComplete?: CronJobParams['onComplete'],\n start?: CronJobParams['start'],\n timeZone?: null,\n context?: CronJobParams['context'],\n runOnInit?: CronJobParams['runOnInit'],\n utcOffset?: CronJobParams['utcOffset'],\n unrefTimeout?: CronJobParams['unrefTimeout'],\n ): CronJob;\n};\n\nconst MONITORED = Symbol.for('sentry.cron.monitored');\n\nconst ERROR_TEXT = 'Automatic instrumentation of CronJob only supports crontab string';\n\n/**\n * Instruments the `cron` library to send a check-in event to Sentry for each job execution.\n *\n * ```ts\n * import * as Sentry from '@sentry/node';\n * import { CronJob } from 'cron';\n *\n * const CronJobWithCheckIn = Sentry.cron.instrumentCron(CronJob, 'my-cron-job');\n *\n * // use the constructor\n * const job = new CronJobWithCheckIn('* * * * *', () => {\n * console.log('You will see this message every minute');\n * });\n *\n * // or from\n * const job = CronJobWithCheckIn.from({ cronTime: '* * * * *', onTick: () => {\n * console.log('You will see this message every minute');\n * });\n * ```\n *\n * @deprecated Use `cronJobIntegration` instead.\n */\nexport function instrumentCron<T>(lib: T & CronJobConstructor, monitorSlug: string): T {\n let jobScheduled = false;\n\n return new Proxy(lib, {\n construct(target, args: ConstructorParameters<CronJobConstructor>) {\n const [cronTime, onTick, onComplete, start, timeZone, ...rest] = args;\n\n if (typeof cronTime !== 'string') {\n throw new Error(ERROR_TEXT);\n }\n\n if (jobScheduled) {\n throw new Error(`A job named '${monitorSlug}' has already been scheduled`);\n }\n\n jobScheduled = true;\n\n const utcOffset = args[7];\n const monitorConfig = utcOffset == null ? getCronMonitorConfig(cronTime, timeZone, 'cron') : undefined;\n\n async function monitoredTick(context: unknown, onComplete?: unknown): Promise<void> {\n return withMonitor(\n monitorSlug,\n async () => {\n try {\n await onTick(context, onComplete);\n } catch (e) {\n captureException(e, {\n mechanism: {\n handled: false,\n type: 'auto.function.cron.instrumentCron',\n },\n });\n throw e;\n }\n },\n monitorConfig,\n );\n }\n\n // Tells `cronJobIntegration` that this job is already monitored.\n addNonEnumerableProperty(monitoredTick, MONITORED, true);\n\n return new target(cronTime, monitoredTick, onComplete, start, timeZone, ...rest);\n },\n get(target, prop: keyof CronJobConstructor) {\n if (prop === 'from') {\n return (param: CronJobParams) => {\n const { cronTime, onTick, timeZone, utcOffset } = param;\n\n if (typeof cronTime !== 'string') {\n throw new Error(ERROR_TEXT);\n }\n\n if (jobScheduled) {\n throw new Error(`A job named '${monitorSlug}' has already been scheduled`);\n }\n\n jobScheduled = true;\n\n const monitorConfig = utcOffset == null ? getCronMonitorConfig(cronTime, timeZone, 'cron') : undefined;\n\n param.onTick = async (context: unknown, onComplete?: unknown) => {\n return withMonitor(\n monitorSlug,\n async () => {\n try {\n await onTick(context, onComplete);\n } catch (e) {\n captureException(e, {\n mechanism: {\n handled: false,\n type: 'auto.function.cron.instrumentCron',\n },\n });\n throw e;\n }\n },\n monitorConfig,\n );\n };\n\n addNonEnumerableProperty(param.onTick, MONITORED, true);\n\n return target.from(param);\n };\n } else {\n return target[prop];\n }\n },\n });\n}\n"],"mappings":";;;AAqDA,MAAM,YAAY,OAAO,IAAI,uBAAuB;AAEpD,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;AAwBnB,SAAgB,eAAkB,KAA6B,aAAwB;CACrF,IAAI,eAAe;CAEnB,OAAO,IAAI,MAAM,KAAK;EACpB,UAAU,QAAQ,MAAiD;GACjE,MAAM,CAAC,UAAU,QAAQ,YAAY,OAAO,UAA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Cron } from "./cron.js";
2
+ import { instrumentNodeCron } from "./node-cron.js";
3
+ import { instrumentNodeSchedule } from "./node-schedule.js";
4
+ // src/cron/index.ts
5
+ /** Methods to instrument cron libraries for Sentry check-ins */
6
+ const cron = {
7
+ instrumentCron,
8
+ instrumentNodeCron,
9
+ instrumentNodeSchedule
10
+ };
11
+ export { cron };
12
+
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/cron/index.ts"],"sourcesContent":["import { instrumentCron } from './cron';\nimport { instrumentNodeCron } from './node-cron';\nimport { instrumentNodeSchedule } from './node-schedule';\n\n/** Methods to instrument cron libraries for Sentry check-ins */\nexport const cron = {\n // oxlint-disable-next-line typescript/no-deprecated\n instrumentCron,\n // oxlint-disable-next-line typescript/no-deprecated\n instrumentNodeCron,\n instrumentNodeSchedule,\n};\n"],"mappings":";;;;;AAKA,MAAa,OAAO;CAElB;CAEA;CACA;AACF"}
@@ -0,0 +1,66 @@
1
+ import { isReadAlikeByNodeCron3 } from "../integrations/node-cron.js";
2
+ import { getCronMonitorConfig } from "./common.js";
3
+ import { addNonEnumerableProperty, captureException, startNewTrace, withMonitor } from "@sentry/core";
4
+ // src/cron/node-cron.ts
5
+ /**
6
+ * Wraps the `node-cron` library with check-in monitoring.
7
+ *
8
+ * ```ts
9
+ * import * as Sentry from "@sentry/node";
10
+ * import * as cron from "node-cron";
11
+ *
12
+ * const cronWithCheckIn = Sentry.cron.instrumentNodeCron(cron);
13
+ *
14
+ * cronWithCheckIn.schedule(
15
+ * "* * * * *",
16
+ * () => {
17
+ * console.log("running a task every minute");
18
+ * },
19
+ * { name: "my-cron-job" },
20
+ * );
21
+ * ```
22
+ *
23
+ * On node-cron 4, steps on `*` in the day-of-month or month field (such as every second day) aren't sent as a
24
+ * schedule, because this wrapper can't tell the node-cron version. `nodeCronIntegration` can.
25
+ *
26
+ * @deprecated Use `nodeCronIntegration` instead.
27
+ */
28
+ function instrumentNodeCron(lib, monitorConfig = {}) {
29
+ return new Proxy(lib, { get(target, prop) {
30
+ if (prop === "schedule" && target.schedule) return new Proxy(target.schedule, { apply(target, thisArg, argArray) {
31
+ const [expression, callback, options] = argArray;
32
+ const name = options?.name;
33
+ const timezone = options?.timezone;
34
+ if (!name) throw new Error("Missing \"name\" for scheduled job. A name is required for Sentry check-in monitoring.");
35
+ const cronConfig = getCronMonitorConfig(expression, timezone, "node-cron", isReadAlikeByNodeCron3);
36
+ const upsertMonitorConfig = cronConfig && {
37
+ ...cronConfig,
38
+ ...monitorConfig
39
+ };
40
+ const monitoredCallback = async (...args) => {
41
+ const runWithMonitor = () => withMonitor(name, async () => {
42
+ try {
43
+ return await callback(...args);
44
+ } catch (e) {
45
+ captureException(e, { mechanism: {
46
+ handled: false,
47
+ type: "auto.function.node-cron.instrumentNodeCron"
48
+ } });
49
+ throw e;
50
+ }
51
+ }, upsertMonitorConfig);
52
+ return !upsertMonitorConfig && monitorConfig.isolateTrace ? startNewTrace(runWithMonitor) : runWithMonitor();
53
+ };
54
+ addNonEnumerableProperty(monitoredCallback, Symbol.for("sentry.cron.monitored"), true);
55
+ return target.apply(thisArg, [
56
+ expression,
57
+ monitoredCallback,
58
+ options
59
+ ]);
60
+ } });
61
+ else return target[prop];
62
+ } });
63
+ }
64
+ export { instrumentNodeCron };
65
+
66
+ //# sourceMappingURL=node-cron.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-cron.js","names":[],"sources":["../../../src/cron/node-cron.ts"],"sourcesContent":["import {\n addNonEnumerableProperty,\n captureException,\n type MonitorConfig,\n startNewTrace,\n withMonitor,\n} from '@sentry/core';\nimport { isReadAlikeByNodeCron3 } from '../integrations/node-cron';\nimport { getCronMonitorConfig } from './common';\n\nexport interface NodeCronOptions {\n name: string;\n timezone?: string;\n}\n\nexport interface NodeCron {\n schedule: (\n cronExpression: string,\n callback: (context?: unknown) => void,\n options: NodeCronOptions | undefined,\n ) => unknown;\n}\n\n/**\n * Wraps the `node-cron` library with check-in monitoring.\n *\n * ```ts\n * import * as Sentry from \"@sentry/node\";\n * import * as cron from \"node-cron\";\n *\n * const cronWithCheckIn = Sentry.cron.instrumentNodeCron(cron);\n *\n * cronWithCheckIn.schedule(\n * \"* * * * *\",\n * () => {\n * console.log(\"running a task every minute\");\n * },\n * { name: \"my-cron-job\" },\n * );\n * ```\n *\n * On node-cron 4, steps on `*` in the day-of-month or month field (such as every second day) aren't sent as a\n * schedule, because this wrapper can't tell the node-cron version. `nodeCronIntegration` can.\n *\n * @deprecated Use `nodeCronIntegration` instead.\n */\nexport function instrumentNodeCron<T>(\n lib: Partial<NodeCron> & T,\n monitorConfig: Pick<MonitorConfig, 'isolateTrace'> = {},\n): T {\n return new Proxy(lib, {\n get(target, prop) {\n if (prop === 'schedule' && target.schedule) {\n // When 'get' is called for schedule, return a proxied version of the schedule function\n return new Proxy(target.schedule, {\n apply(target, thisArg, argArray: Parameters<NodeCron['schedule']>) {\n const [expression, callback, options] = argArray;\n\n const name = options?.name;\n const timezone = options?.timezone;\n\n if (!name) {\n throw new Error('Missing \"name\" for scheduled job. A name is required for Sentry check-in monitoring.');\n }\n\n // The node-cron version is unknown here, so check for node-cron 3 quirks, which include those before 4.6.\n const cronConfig = getCronMonitorConfig(expression, timezone, 'node-cron', isReadAlikeByNodeCron3);\n const upsertMonitorConfig = cronConfig && { ...cronConfig, ...monitorConfig };\n\n const monitoredCallback = async (...args: Parameters<typeof callback>): Promise<void> => {\n const runWithMonitor = (): Promise<void> =>\n withMonitor(\n name,\n async () => {\n // We have to manually catch here and capture the exception because node-cron swallows errors\n // https://github.com/node-cron/node-cron/issues/399\n try {\n // oxlint-disable-next-line typescript/await-thenable, typescript/return-await -- callback may be async at runtime; awaiting inside the try lets us capture its rejection\n return await callback(...args);\n } catch (e) {\n captureException(e, {\n mechanism: {\n handled: false,\n type: 'auto.function.node-cron.instrumentNodeCron',\n },\n });\n throw e;\n }\n },\n upsertMonitorConfig,\n );\n // `withMonitor` reads `isolateTrace` from the monitor config, which is not sent without a schedule.\n return !upsertMonitorConfig && monitorConfig.isolateTrace\n ? startNewTrace(runWithMonitor)\n : runWithMonitor();\n };\n\n // Tells `nodeCronIntegration` that this task is already monitored.\n addNonEnumerableProperty(monitoredCallback, Symbol.for('sentry.cron.monitored'), true);\n\n return target.apply(thisArg, [expression, monitoredCallback, options]);\n },\n });\n } else {\n return target[prop as keyof T];\n }\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,mBACd,KACA,gBAAqD,CAAC,GACnD;CACH,OAAO,IAAI,MAAM,KAAK,EACpB,IAAI,QAAQ,MAAM;EAChB,IAAI,SAAS,cAAc,OAAO,UAEhC,OAAO,IAAI,MAAM,OAAO,UAAU,EAChC,MAAM,QAAQ,SAAS,UAA4C;GACjE,MAAM,CAAC,YAAY,UAAU,WAAW;GAExC,MAAM,OAAO,SAAS;GACtB,MAAM,WAAW,SAAS;GAE1B,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,wFAAsF;GAIxG,MAAM,aAAa,qBAAqB,YAAY,UAAU,aAAa,sBAAsB;GACjG,MAAM,sBAAsB,cAAc;IAAE,GAAG;IAAY,GAAG;GAAc;GAE5E,MAAM,oBAAoB,OAAO,GAAG,SAAqD;IACvF,MAAM,uBACJ,YACE,MACA,YAAY;KAGV,IAAI;MAEF,OAAO,MAAM,SAAS,GAAG,IAAI;KAC/B,SAAS,GAAG;MACV,iBAAiB,GAAG,EAClB,WAAW;OACT,SAAS;OACT,MAAM;MACR,EACF,CAAC;MACD,MAAM;KACR;IACF,GACA,mBACF;IAEF,OAAO,CAAC,uBAAuB,cAAc,eACzC,cAAc,cAAc,IAC5B,eAAe;GACrB;GAGA,yBAAyB,mBAAmB,OAAO,IAAI,uBAAuB,GAAG,IAAI;GAErF,OAAO,OAAO,MAAM,SAAS;IAAC;IAAY;IAAmB;GAAO,CAAC;EACvE,EACF,CAAC;OAED,OAAO,OAAO;CAElB,EACF,CAAC;AACH"}
@@ -0,0 +1,43 @@
1
+ import { getCronMonitorConfig } from "./common.js";
2
+ import { addNonEnumerableProperty, withMonitor } from "@sentry/core";
3
+ // src/cron/node-schedule.ts
4
+ /**
5
+ * Instruments the `node-schedule` library to send a check-in event to Sentry for each job execution.
6
+ *
7
+ * ```ts
8
+ * import * as Sentry from '@sentry/node';
9
+ * import * as schedule from 'node-schedule';
10
+ *
11
+ * const scheduleWithCheckIn = Sentry.cron.instrumentNodeSchedule(schedule);
12
+ *
13
+ * const job = scheduleWithCheckIn.scheduleJob('my-cron-job', '* * * * *', () => {
14
+ * console.log('You will see this message every minute');
15
+ * });
16
+ * ```
17
+ */
18
+ function instrumentNodeSchedule(lib) {
19
+ return new Proxy(lib, { get(target, prop) {
20
+ if (prop === "scheduleJob") return new Proxy(target.scheduleJob, { apply(target, thisArg, argArray) {
21
+ const [nameOrExpression, expressionOrCallback, callback] = argArray;
22
+ if (typeof nameOrExpression !== "string" || typeof expressionOrCallback !== "string" || typeof callback !== "function") throw new Error("Automatic instrumentation of 'node-schedule' requires the first parameter of 'scheduleJob' to be a job name string and the second parameter to be a crontab string");
23
+ const monitorSlug = nameOrExpression;
24
+ const expression = expressionOrCallback;
25
+ const monitorConfig = getCronMonitorConfig(expression, void 0, "cron-parser");
26
+ async function monitoredCallback() {
27
+ return withMonitor(monitorSlug, async () => {
28
+ await callback?.();
29
+ }, monitorConfig);
30
+ }
31
+ addNonEnumerableProperty(monitoredCallback, Symbol.for("sentry.cron.monitored"), true);
32
+ return target.apply(thisArg, [
33
+ monitorSlug,
34
+ expression,
35
+ monitoredCallback
36
+ ]);
37
+ } });
38
+ return target[prop];
39
+ } });
40
+ }
41
+ export { instrumentNodeSchedule };
42
+
43
+ //# sourceMappingURL=node-schedule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-schedule.js","names":[],"sources":["../../../src/cron/node-schedule.ts"],"sourcesContent":["import { addNonEnumerableProperty, withMonitor } from '@sentry/core';\nimport { getCronMonitorConfig } from './common';\n\nexport interface NodeSchedule {\n scheduleJob(\n nameOrExpression: string | Date | object,\n expressionOrCallback: string | Date | object | (() => void),\n callback?: () => void,\n ): unknown;\n}\n\n/**\n * Instruments the `node-schedule` library to send a check-in event to Sentry for each job execution.\n *\n * ```ts\n * import * as Sentry from '@sentry/node';\n * import * as schedule from 'node-schedule';\n *\n * const scheduleWithCheckIn = Sentry.cron.instrumentNodeSchedule(schedule);\n *\n * const job = scheduleWithCheckIn.scheduleJob('my-cron-job', '* * * * *', () => {\n * console.log('You will see this message every minute');\n * });\n * ```\n */\nexport function instrumentNodeSchedule<T>(lib: T & NodeSchedule): T {\n return new Proxy(lib, {\n get(target, prop: keyof NodeSchedule) {\n if (prop === 'scheduleJob') {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n return new Proxy(target.scheduleJob, {\n apply(target, thisArg, argArray: Parameters<NodeSchedule['scheduleJob']>) {\n const [nameOrExpression, expressionOrCallback, callback] = argArray;\n\n if (\n typeof nameOrExpression !== 'string' ||\n typeof expressionOrCallback !== 'string' ||\n typeof callback !== 'function'\n ) {\n throw new Error(\n \"Automatic instrumentation of 'node-schedule' requires the first parameter of 'scheduleJob' to be a job name string and the second parameter to be a crontab string\",\n );\n }\n\n const monitorSlug = nameOrExpression;\n const expression = expressionOrCallback;\n const monitorConfig = getCronMonitorConfig(expression, undefined, 'cron-parser');\n\n async function monitoredCallback(): Promise<void> {\n return withMonitor(\n monitorSlug,\n async () => {\n // oxlint-disable-next-line typescript/await-thenable -- callback may be async at runtime\n await callback?.();\n },\n monitorConfig,\n );\n }\n\n // Tells `nodeScheduleIntegration` that this job is already monitored.\n addNonEnumerableProperty(monitoredCallback, Symbol.for('sentry.cron.monitored'), true);\n\n return target.apply(thisArg, [monitorSlug, expression, monitoredCallback]);\n },\n });\n }\n\n return target[prop];\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,SAAgB,uBAA0B,KAA0B;CAClE,OAAO,IAAI,MAAM,KAAK,EACpB,IAAI,QAAQ,MAA0B;EACpC,IAAI,SAAS,eAEX,OAAO,IAAI,MAAM,OAAO,aAAa,EACnC,MAAM,QAAQ,SAAS,UAAmD;GACxE,MAAM,CAAC,kBAAkB,sBAAsB,YAAY;GAE3D,IACE,OAAO,qBAAqB,YAC5B,OAAO,yBAAyB,YAChC,OAAO,aAAa,YAEpB,MAAM,IAAI,MACR,oKACF;GAGF,MAAM,cAAc;GACpB,MAAM,aAAa;GACnB,MAAM,gBAAgB,qBAAqB,YAAY,KAAA,GAAW,aAAa;GAE/E,eAAe,oBAAmC;IAChD,OAAO,YACL,aACA,YAAY;KAEV,MAAM,WAAW;IACnB,GACA,aACF;GACF;GAGA,yBAAyB,mBAAmB,OAAO,IAAI,uBAAuB,GAAG,IAAI;GAErF,OAAO,OAAO,MAAM,SAAS;IAAC;IAAa;IAAY;GAAiB,CAAC;EAC3E,EACF,CAAC;EAGH,OAAO,OAAO;CAChB,EACF,CAAC;AACH"}
@@ -32,9 +32,11 @@ import { awsIntegration } from "./integrations/aws-sdk/index.js";
32
32
  import { dataloaderIntegration } from "./integrations/dataloader.js";
33
33
  import { genericPoolIntegration } from "./integrations/generic-pool.js";
34
34
  import { cronJobIntegration } from "./integrations/cron.js";
35
- import { isReadAlikeByNodeCron3, nodeCronIntegration } from "./integrations/node-cron.js";
35
+ import { nodeCronIntegration } from "./integrations/node-cron.js";
36
36
  import { nodeScheduleIntegration } from "./integrations/node-schedule.js";
37
37
  import { cronExpressionToMonitorConfig } from "./utils/cronMonitoring.js";
38
+ import { cron } from "./cron/index.js";
39
+ import { BullMQTelemetry } from "./integrations/bullmq/index.js";
38
40
  import { googleGenAIIntegration } from "./integrations/google-genai.js";
39
41
  import { graphqlIntegration } from "./integrations/graphql/index.js";
40
42
  import { hapiIntegration } from "./integrations/hapi/index.js";
@@ -64,6 +66,8 @@ import { togetherAIIntegration } from "./integrations/together-ai.js";
64
66
  import { typesafeIntegration } from "./integrations/typesafe.js";
65
67
  import { mysqlIntegration } from "./integrations/mysql.js";
66
68
  import { mysql2Integration } from "./integrations/mysql2/index.js";
69
+ import { pinoIntegration } from "./integrations/pino.js";
70
+ import { createSentryWinstonTransport } from "./integrations/winston.js";
67
71
  import { openAIIntegration } from "./integrations/openai.js";
68
72
  import { postgresIntegration } from "./integrations/pg.js";
69
73
  import { postgresJsIntegration } from "./integrations/postgresjs/index.js";
@@ -80,6 +84,6 @@ import { getErrorIntegrations, getTracingIntegrations } from "./integrations/ind
80
84
  * @deprecated This is a temporary export to avoid breaking changes. It will be removed in the next major version.
81
85
  */
82
86
  const attachHapiErrorHandler = attachHapiErrorHandler$1;
83
- export { SentryMastraExporter, cronExpressionToMonitorConfig as _INTERNAL_cronExpressionToMonitorConfig, instrumentTunnelServer as _INTERNAL_instrumentTunnelServer, instrumentTunnelServers as _INTERNAL_instrumentTunnelServers, isReadAlikeByNodeCron3 as _INTERNAL_isReadAlikeByNodeCron3, amqplibIntegration, anthropicAIIntegration, applyHonoPatches, attachHapiErrorHandler, attachKoaErrorHandler, awsIntegration, bindTracingChannelToSpan, createFlueInstrumentation, createHonoRequestMiddleware, createLangChainCallbackHandler, cronJobIntegration, dataloaderIntegration, detectOrchestrionSetup, tracingChannel as diagnosticsTracingChannel, earlyPatchHono, eveConversationHook, eveIntegration, eveTracePolicy, expressErrorHandler, expressIntegration, fastifyIntegration, firebaseIntegration, flueIntegration, genericPoolIntegration, getErrorIntegrations, getInstrumentedModuleNames, getOtlpTracesEndpoint, getSqlQueryAttributes, getSqlQuerySummary, getSqlSpanName, getTracingIntegrations, googleGenAIIntegration, graphqlIntegration, groqIntegration, hapiIntegration, honoIntegration, honoMiddleware, instrumentAnthropicAiClient, instrumentCreateReactAgent, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentMistralAiClient, instrumentOpenAiClient, instrumentPostgresJsSql, instrumentStateGraph, instrumentStateGraphCompile, instrumentTypeSafeClient, instrumentWorkersAiClient, isBun, isCloudflareWorkers, isDeno, kafkaIntegration, knexIntegration, koaIntegration, langChainIntegration, langGraphIntegration, lruMemoizerIntegration, makeServeTunnelIntegration, mastraIntegration, mcpServerIntegration, mistralAIIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, neonIntegration, nitroIntegration, nodeCronIntegration, nodeScheduleIntegration, openAIIntegration, openTelemetryIntegration, orchestrionModuleInjected, piAiIntegration, piDurableIntegration, postgresIntegration, postgresJsIntegration, prismaIntegration, redisIntegration, sanitizeSqlQuery, setAsyncLocalStorageAsyncContextStrategy, setHttpServerSpanRouteAttribute, setupExpressErrorHandler, setupFastifyErrorHandler, subscribe as subscribeDiagnosticsChannel, tediousIntegration, togetherAIIntegration, typesafeIntegration, vercelAIIntegration };
87
+ export { BullMQTelemetry, SentryMastraExporter, cronExpressionToMonitorConfig as _INTERNAL_cronExpressionToMonitorConfig, instrumentTunnelServer as _INTERNAL_instrumentTunnelServer, instrumentTunnelServers as _INTERNAL_instrumentTunnelServers, amqplibIntegration, anthropicAIIntegration, applyHonoPatches, attachHapiErrorHandler, attachKoaErrorHandler, awsIntegration, bindTracingChannelToSpan, createFlueInstrumentation, createHonoRequestMiddleware, createLangChainCallbackHandler, createSentryWinstonTransport, cron, cronJobIntegration, dataloaderIntegration, detectOrchestrionSetup, tracingChannel as diagnosticsTracingChannel, earlyPatchHono, eveConversationHook, eveIntegration, eveTracePolicy, expressErrorHandler, expressIntegration, fastifyIntegration, firebaseIntegration, flueIntegration, genericPoolIntegration, getErrorIntegrations, getInstrumentedModuleNames, getOtlpTracesEndpoint, getSqlQueryAttributes, getSqlQuerySummary, getSqlSpanName, getTracingIntegrations, googleGenAIIntegration, graphqlIntegration, groqIntegration, hapiIntegration, honoIntegration, honoMiddleware, instrumentAnthropicAiClient, instrumentCreateReactAgent, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentMistralAiClient, instrumentOpenAiClient, instrumentPostgresJsSql, instrumentStateGraph, instrumentStateGraphCompile, instrumentTypeSafeClient, instrumentWorkersAiClient, isBun, isCloudflareWorkers, isDeno, kafkaIntegration, knexIntegration, koaIntegration, langChainIntegration, langGraphIntegration, lruMemoizerIntegration, makeServeTunnelIntegration, mastraIntegration, mcpServerIntegration, mistralAIIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, neonIntegration, nitroIntegration, nodeCronIntegration, nodeScheduleIntegration, openAIIntegration, openTelemetryIntegration, orchestrionModuleInjected, piAiIntegration, piDurableIntegration, pinoIntegration, postgresIntegration, postgresJsIntegration, prismaIntegration, redisIntegration, sanitizeSqlQuery, setAsyncLocalStorageAsyncContextStrategy, setHttpServerSpanRouteAttribute, setupExpressErrorHandler, setupFastifyErrorHandler, subscribe as subscribeDiagnosticsChannel, tediousIntegration, togetherAIIntegration, typesafeIntegration, vercelAIIntegration };
84
88
 
85
89
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_attachHapiErrorHandler"],"sources":["../../src/index.ts"],"sourcesContent":["export * from './exports';\n\n// Exports using diagnostics channels\nexport { detectOrchestrionSetup } from './orchestrion/detect';\n// oxlint-disable-next-line typescript/no-deprecated -- re-exported so the deprecated `setupKoaErrorHandler` can delegate\nexport { attachKoaErrorHandler } from './integrations/koa/koa-error-handler';\nimport { attachHapiErrorHandler as _attachHapiErrorHandler } from './integrations/hapi/hapi-error-handler';\nexport { bindTracingChannelToSpan } from './tracing-channel';\nexport type { TracingChannelPayloadWithSpan } from './tracing-channel';\nexport type { InstrumentationConfig } from './orchestrion/apmTypes';\nexport type { OrchestrionChannelContext } from './orchestrion/types';\n// Runtime target of the bundler-injected module snippet. The snippet imports it\n// from this entry alongside the module's subscriber factory (see\n// `orchestrion/bundler/moduleInjectedTransform.ts`); it is a plain runtime\n// helper with no orchestrion build-time dependency.\nexport { orchestrionModuleInjected } from './utils/moduleInjected';\nexport {\n subscribe as subscribeDiagnosticsChannel,\n tracingChannel as diagnosticsTracingChannel,\n} from './utils/diagnosticsChannel';\nexport { eveConversationHook, eveIntegration, eveTracePolicy } from './eve';\nexport { getInstrumentedModuleNames } from './orchestrion/config';\nexport {\n fastifyIntegration,\n // oxlint-disable-next-line typescript/no-deprecated\n setupFastifyErrorHandler,\n} from './integrations/fastify';\n\n/**\n * @deprecated This is a temporary export to avoid breaking changes. It will be removed in the next major version.\n */\nexport const attachHapiErrorHandler = _attachHapiErrorHandler;\n\n// Integrations\nexport { prismaIntegration } from './integrations/prisma';\nexport { amqplibIntegration } from './integrations/amqplib';\nexport { anthropicAIIntegration } from './integrations/anthropic';\nexport { awsIntegration } from './integrations/aws-sdk';\nexport { dataloaderIntegration } from './integrations/dataloader';\nexport { genericPoolIntegration } from './integrations/generic-pool';\nexport { cronJobIntegration } from './integrations/cron';\nexport type { CronJobIntegrationOptions } from './integrations/cron';\nexport {\n isReadAlikeByNodeCron3 as _INTERNAL_isReadAlikeByNodeCron3,\n nodeCronIntegration,\n} from './integrations/node-cron';\nexport type { NodeCronIntegrationOptions } from './integrations/node-cron';\nexport { nodeScheduleIntegration } from './integrations/node-schedule';\nexport type { NodeScheduleIntegrationOptions } from './integrations/node-schedule';\nexport { cronExpressionToMonitorConfig as _INTERNAL_cronExpressionToMonitorConfig } from './utils/cronMonitoring';\nexport type { CronDialect as _INTERNAL_CronDialect } from './utils/cronMonitoring';\nexport { googleGenAIIntegration } from './integrations/google-genai';\nexport { graphqlIntegration } from './integrations/graphql';\nexport { hapiIntegration } from './integrations/hapi';\nexport { honoIntegration, honoMiddleware } from './integrations/hono';\nexport type { HonoIntegrationOptions } from './integrations/hono';\nexport { koaIntegration } from './integrations/koa';\nexport { redisIntegration } from './integrations/redis';\nexport { kafkaIntegration } from './integrations/kafkajs';\nexport { knexIntegration } from './integrations/knex';\nexport { langChainIntegration } from './integrations/langchain';\nexport { langGraphIntegration } from './integrations/langgraph';\nexport { createFlueInstrumentation } from './ai/flue';\nexport { flueIntegration } from './integrations/flue';\nexport { piAiIntegration } from './integrations/pi-ai';\nexport { piDurableIntegration } from './integrations/pi-durable';\nexport type { FlueOptions } from './ai/flue';\nexport { mastraIntegration } from './integrations/mastra';\nexport { mcpServerIntegration } from './integrations/mcp-server';\nexport {\n instrumentTunnelServers as _INTERNAL_instrumentTunnelServers,\n makeServeTunnelIntegration,\n} from './integrations/serveTunnel';\nexport { instrumentTunnelServer as _INTERNAL_instrumentTunnelServer } from './utils/tunnelServer';\nexport { SentryMastraExporter } from './ai/mastra';\nexport { lruMemoizerIntegration } from './integrations/lru-memoizer';\nexport { mongoIntegration } from './integrations/mongodb';\nexport { mongooseIntegration } from './integrations/mongoose';\nexport { mistralAIIntegration } from './integrations/mistral';\nexport { groqIntegration } from './integrations/groq';\nexport { togetherAIIntegration } from './integrations/together-ai';\nexport { typesafeIntegration } from './integrations/typesafe';\nexport { mysqlIntegration } from './integrations/mysql';\nexport { mysql2Integration } from './integrations/mysql2';\nexport { openAIIntegration } from './integrations/openai';\nexport { postgresIntegration } from './integrations/pg';\nexport { postgresJsIntegration } from './integrations/postgresjs';\nexport { neonIntegration } from './integrations/neon';\nexport { tediousIntegration } from './integrations/tedious';\nexport { vercelAIIntegration } from './integrations/vercel-ai';\nexport { expressIntegration } from './integrations/express';\nexport type { ExpressIntegrationOptions } from './integrations/express/types';\n/* oxlint-disable typescript/no-deprecated -- deprecated Express error-handler exports, kept until the next major */\nexport { expressErrorHandler, setupExpressErrorHandler } from './integrations/express/error-handler';\n/* oxlint-enable typescript/no-deprecated */\nexport { firebaseIntegration } from './integrations/firebase';\nexport { nitroIntegration } from './integrations/nitro';\nexport type { NitroIntegrationOptions } from './integrations/nitro';\n\nexport { getTracingIntegrations, getErrorIntegrations } from './integrations';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,yBAAyBA"}
1
+ {"version":3,"file":"index.js","names":["_attachHapiErrorHandler"],"sources":["../../src/index.ts"],"sourcesContent":["export * from './exports';\n\n// Exports using diagnostics channels\nexport { detectOrchestrionSetup } from './orchestrion/detect';\n// oxlint-disable-next-line typescript/no-deprecated -- re-exported so the deprecated `setupKoaErrorHandler` can delegate\nexport { attachKoaErrorHandler } from './integrations/koa/koa-error-handler';\nimport { attachHapiErrorHandler as _attachHapiErrorHandler } from './integrations/hapi/hapi-error-handler';\nexport { bindTracingChannelToSpan } from './tracing-channel';\nexport type { TracingChannelPayloadWithSpan } from './tracing-channel';\nexport type { InstrumentationConfig } from './orchestrion/apmTypes';\nexport type { OrchestrionChannelContext } from './orchestrion/types';\n// Runtime target of the bundler-injected module snippet. The snippet imports it\n// from this entry alongside the module's subscriber factory (see\n// `orchestrion/bundler/moduleInjectedTransform.ts`); it is a plain runtime\n// helper with no orchestrion build-time dependency.\nexport { orchestrionModuleInjected } from './utils/moduleInjected';\nexport {\n subscribe as subscribeDiagnosticsChannel,\n tracingChannel as diagnosticsTracingChannel,\n} from './utils/diagnosticsChannel';\nexport { eveConversationHook, eveIntegration, eveTracePolicy } from './eve';\nexport { getInstrumentedModuleNames } from './orchestrion/config';\nexport {\n fastifyIntegration,\n // oxlint-disable-next-line typescript/no-deprecated\n setupFastifyErrorHandler,\n} from './integrations/fastify';\n\n/**\n * @deprecated This is a temporary export to avoid breaking changes. It will be removed in the next major version.\n */\nexport const attachHapiErrorHandler = _attachHapiErrorHandler;\n\n// Integrations\nexport { prismaIntegration } from './integrations/prisma';\nexport { amqplibIntegration } from './integrations/amqplib';\nexport { anthropicAIIntegration } from './integrations/anthropic';\nexport { awsIntegration } from './integrations/aws-sdk';\nexport { dataloaderIntegration } from './integrations/dataloader';\nexport { genericPoolIntegration } from './integrations/generic-pool';\nexport { cronJobIntegration } from './integrations/cron';\nexport type { CronJobIntegrationOptions } from './integrations/cron';\nexport { nodeCronIntegration } from './integrations/node-cron';\nexport type { NodeCronIntegrationOptions } from './integrations/node-cron';\nexport { nodeScheduleIntegration } from './integrations/node-schedule';\nexport type { NodeScheduleIntegrationOptions } from './integrations/node-schedule';\nexport { cronExpressionToMonitorConfig as _INTERNAL_cronExpressionToMonitorConfig } from './utils/cronMonitoring';\nexport { cron } from './cron';\nexport { BullMQTelemetry } from './integrations/bullmq';\nexport { googleGenAIIntegration } from './integrations/google-genai';\nexport { graphqlIntegration } from './integrations/graphql';\nexport { hapiIntegration } from './integrations/hapi';\nexport { honoIntegration, honoMiddleware } from './integrations/hono';\nexport type { HonoIntegrationOptions } from './integrations/hono';\nexport { koaIntegration } from './integrations/koa';\nexport { redisIntegration } from './integrations/redis';\nexport { kafkaIntegration } from './integrations/kafkajs';\nexport { knexIntegration } from './integrations/knex';\nexport { langChainIntegration } from './integrations/langchain';\nexport { langGraphIntegration } from './integrations/langgraph';\nexport { createFlueInstrumentation } from './ai/flue';\nexport { flueIntegration } from './integrations/flue';\nexport { piAiIntegration } from './integrations/pi-ai';\nexport { piDurableIntegration } from './integrations/pi-durable';\nexport type { FlueOptions } from './ai/flue';\nexport { mastraIntegration } from './integrations/mastra';\nexport { mcpServerIntegration } from './integrations/mcp-server';\nexport {\n instrumentTunnelServers as _INTERNAL_instrumentTunnelServers,\n makeServeTunnelIntegration,\n} from './integrations/serveTunnel';\nexport { instrumentTunnelServer as _INTERNAL_instrumentTunnelServer } from './utils/tunnelServer';\nexport { SentryMastraExporter } from './ai/mastra';\nexport { lruMemoizerIntegration } from './integrations/lru-memoizer';\nexport { mongoIntegration } from './integrations/mongodb';\nexport { mongooseIntegration } from './integrations/mongoose';\nexport { mistralAIIntegration } from './integrations/mistral';\nexport { groqIntegration } from './integrations/groq';\nexport { togetherAIIntegration } from './integrations/together-ai';\nexport { typesafeIntegration } from './integrations/typesafe';\nexport { mysqlIntegration } from './integrations/mysql';\nexport { mysql2Integration } from './integrations/mysql2';\nexport { pinoIntegration } from './integrations/pino';\nexport { createSentryWinstonTransport } from './integrations/winston';\nexport { openAIIntegration } from './integrations/openai';\nexport { postgresIntegration } from './integrations/pg';\nexport { postgresJsIntegration } from './integrations/postgresjs';\nexport { neonIntegration } from './integrations/neon';\nexport { tediousIntegration } from './integrations/tedious';\nexport { vercelAIIntegration } from './integrations/vercel-ai';\nexport { expressIntegration } from './integrations/express';\nexport type { ExpressIntegrationOptions } from './integrations/express/types';\n/* oxlint-disable typescript/no-deprecated -- deprecated Express error-handler exports, kept until the next major */\nexport { expressErrorHandler, setupExpressErrorHandler } from './integrations/express/error-handler';\n/* oxlint-enable typescript/no-deprecated */\nexport { firebaseIntegration } from './integrations/firebase';\nexport { nitroIntegration } from './integrations/nitro';\nexport type { NitroIntegrationOptions } from './integrations/nitro';\n\nexport { getTracingIntegrations, getErrorIntegrations } from './integrations';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,yBAAyBA"}
@@ -1,9 +1,10 @@
1
1
  import { tracingChannel } from "../utils/diagnosticsChannel.js";
2
- import { getGenAiSpanOp, getRequestSignal, markCancelledIfAborted, resolveAIRecordingOptions } from "../ai/core/utils.js";
2
+ import { getGenAiSpanOp, getRequestSignal, markCancelledIfAborted, resolveGenAiCallRecording } from "../ai/core/utils.js";
3
3
  import { wrapApiPromiseResponse } from "../ai/core/apiPromise.js";
4
- import { addPrivateRequestAttributes, addResponseAttributes, extractRequestAttributes } from "../ai/anthropic-ai/index.js";
4
+ import { runGenAiSpanEnd, runGenAiSpanStart } from "../ai/core/span-hooks.js";
5
+ import { addPrivateRequestAttributes, extractRequestAttributes } from "../ai/anthropic-ai/index.js";
5
6
  import { ANTHROPIC_AI_ORIGIN } from "../ai/anthropic-ai/constants.js";
6
- import { getProviderName } from "../ai/anthropic-ai/utils.js";
7
+ import { addResponseAttributes, getProviderName } from "../ai/anthropic-ai/utils.js";
7
8
  import { instrumentAsyncIterableStream, instrumentMessageStream } from "../ai/anthropic-ai/streaming.js";
8
9
  import { instrumentSessionToolRunner, instrumentToolRunner } from "../ai/anthropic-ai/tool-runner.js";
9
10
  import { shouldSkipAiProviderSpan } from "../ai/pi-ai/providers.js";
@@ -43,12 +44,13 @@ function instrumentAnthropic(options) {
43
44
  for (const { channel, operation, stream } of INSTRUMENTED_CHANNELS) bindTracingChannelToSpan(tracingChannel(channel), (data) => createGenAiSpan(data, operation, options, stream), {
44
45
  beforeSpanEnd: (span, data) => {
45
46
  if ("error" in data) markCancelledIfAborted(span, getRequestSignal(data.arguments?.[1]));
46
- addResponseAttributes(span, data.result, resolveAIRecordingOptions(options).recordOutputs);
47
+ addResponseAttributes(span, data.result, !!data._sentryRecordOutputs);
48
+ data._sentryOnSpanEnd?.("error" in data ? { error: data.error } : { response: data.result });
47
49
  },
48
- deferSpanEnd: ({ span, data, end }) => wrapThreadStreamRequest(span, data, end, options) || wrapApiPromiseResponse(data.result, (response) => {
50
+ deferSpanEnd: ({ span, data, end }) => wrapThreadStreamRequest(span, data, end) || wrapApiPromiseResponse(data.result, (response) => {
49
51
  data.result = response;
50
- if (!wrapStreamResult(span, data, stream, options)) end();
51
- }, end) || wrapStreamResult(span, data, stream, options)
52
+ if (!wrapStreamResult(span, data, stream)) end();
53
+ }, end) || wrapStreamResult(span, data, stream)
52
54
  });
53
55
  tracingChannel(CHANNELS.ANTHROPIC_TOOL_RUNNER).end.subscribe((message) => {
54
56
  instrumentToolRunner(message.result, options);
@@ -75,7 +77,12 @@ function createGenAiSpan(data, operation, options, stream) {
75
77
  const requestOptions = args[1];
76
78
  if (isStreamHelperRequest(requestOptions?.headers) && isInsideStreamHelperSpan()) return;
77
79
  const params = typeof args[0] === "object" && args[0] !== null ? args[0] : void 0;
78
- const { recordInputs } = resolveAIRecordingOptions(options);
80
+ const call = {
81
+ operation,
82
+ request: params
83
+ };
84
+ const { recordInputs, recordOutputs } = resolveGenAiCallRecording(options, call);
85
+ data._sentryRecordOutputs = recordOutputs;
79
86
  const attributes = extractRequestAttributes(args, operation, recordInputs, getProviderName(data.self));
80
87
  const model = attributes[GEN_AI_REQUEST_MODEL] || "unknown";
81
88
  attributes[SENTRY_ORIGIN] = ANTHROPIC_AI_ORIGIN;
@@ -86,6 +93,8 @@ function createGenAiSpan(data, operation, options, stream) {
86
93
  attributes
87
94
  });
88
95
  if (recordInputs && params) addPrivateRequestAttributes(span, params);
96
+ runGenAiSpanStart(options, span, call);
97
+ data._sentryOnSpanEnd = (result) => runGenAiSpanEnd(options, span, call, result);
89
98
  if (stream === "message-stream") streamHelperSpans.add(span);
90
99
  return span;
91
100
  }
@@ -127,18 +136,18 @@ const threadStreams = /* @__PURE__ */ new WeakMap();
127
136
  * End the span of a thread stream's `create()` call from the stream once the response arrives. A thread may
128
137
  * retry a rejected call, so a failed call ends its own span and only the one that succeeds reads the stream.
129
138
  */
130
- function wrapThreadStreamRequest(span, data, end, options) {
139
+ function wrapThreadStreamRequest(span, data, end) {
131
140
  const signal = (data.arguments?.[1])?.signal;
132
141
  const threadStream = signal && threadStreams.get(signal);
133
142
  const request = data.result;
134
143
  if (!threadStream || threadStream.stream.ended || typeof request?._responseProps !== "function") return false;
135
144
  const { stream, callerSignal } = threadStream;
136
- const { recordOutputs } = resolveAIRecordingOptions(options);
145
+ const recordOutputs = !!data._sentryRecordOutputs;
137
146
  request._responseProps().then(() => {
138
147
  threadStreams.delete(signal);
139
- instrumentMessageStream(stream, span, recordOutputs, callerSignal);
148
+ instrumentMessageStream(stream, span, recordOutputs, callerSignal, data._sentryOnSpanEnd);
140
149
  }, (error) => {
141
- if (signal.aborted) instrumentMessageStream(stream, span, recordOutputs, callerSignal);
150
+ if (signal.aborted) instrumentMessageStream(stream, span, recordOutputs, callerSignal, data._sentryOnSpanEnd);
142
151
  else end(error);
143
152
  });
144
153
  return true;
@@ -151,17 +160,17 @@ function wrapThreadStreamRequest(span, data, end, options) {
151
160
  * the span when iteration finishes.
152
161
  * - `message-stream`: `instrumentMessageStream` attaches `'message'`/`'error'`/`'end'` listeners that end the span.
153
162
  */
154
- function wrapStreamResult(span, data, stream, options) {
155
- const { recordOutputs } = resolveAIRecordingOptions(options);
163
+ function wrapStreamResult(span, data, stream) {
164
+ const recordOutputs = !!data._sentryRecordOutputs;
156
165
  const result = data.result;
157
166
  if (stream === "async-iterable" && isAsyncIterable(result)) {
158
167
  const iterate = result[Symbol.asyncIterator].bind(result);
159
- const instrumented = instrumentAsyncIterableStream({ [Symbol.asyncIterator]: iterate }, span, recordOutputs);
168
+ const instrumented = instrumentAsyncIterableStream({ [Symbol.asyncIterator]: iterate }, span, recordOutputs, data._sentryOnSpanEnd);
160
169
  result[Symbol.asyncIterator] = () => instrumented;
161
170
  return true;
162
171
  }
163
172
  if (stream === "message-stream" && isMessageStream(result)) {
164
- instrumentMessageStream(result, span, recordOutputs, getRequestSignal(data.arguments?.[1]));
173
+ instrumentMessageStream(result, span, recordOutputs, getRequestSignal(data.arguments?.[1]), data._sentryOnSpanEnd);
165
174
  return true;
166
175
  }
167
176
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.js","names":["diagnosticsChannel.tracingChannel","diagnosticsChannel\n .tracingChannel"],"sources":["../../../src/integrations/anthropic.ts"],"sourcesContent":["import { GEN_AI_REQUEST_MODEL, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport * as diagnosticsChannel from '../utils/diagnosticsChannel';\nimport type { IntegrationFn, Span, SpanAttributeValue } from '@sentry/core';\nimport { defineIntegration, getActiveSpan, getClient, hasSpanStreamingEnabled, startInactiveSpan } from '@sentry/core';\nimport { getGenAiSpanOp, getRequestSignal, markCancelledIfAborted, resolveAIRecordingOptions } from '../ai/core/utils';\nimport { wrapApiPromiseResponse } from '../ai/core/apiPromise';\nimport { addPrivateRequestAttributes, addResponseAttributes, extractRequestAttributes } from '../ai/anthropic-ai';\nimport { ANTHROPIC_AI_ORIGIN } from '../ai/anthropic-ai/constants';\nimport { getProviderName } from '../ai/anthropic-ai/utils';\nimport { instrumentAsyncIterableStream, instrumentMessageStream } from '../ai/anthropic-ai/streaming';\nimport { instrumentSessionToolRunner, instrumentToolRunner } from '../ai/anthropic-ai/tool-runner';\nimport type { AnthropicAiOptions, AnthropicAiResponse } from '../ai/anthropic-ai/types';\nimport { shouldSkipAiProviderSpan } from '../ai/pi-ai/providers';\nimport type { OrchestrionChannelContext } from '../orchestrion/types';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../tracing-channel';\nimport { anthropicAiModuleNames } from '../orchestrion/config/anthropic-ai';\nimport { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';\n\n// Same name as the OTel integration by design, so the OTel 'Anthropic_AI'\n// integration is deduplicated out of the default set.\nconst INTEGRATION_NAME = 'Anthropic_AI' as const;\n\n// `stream` determines how the span is ended\nconst INSTRUMENTED_CHANNELS = [\n { channel: CHANNELS.ANTHROPIC_CHAT, operation: 'chat', stream: 'async-iterable' },\n {\n channel: CHANNELS.ANTHROPIC_MESSAGES_STREAM,\n operation: 'chat',\n stream: 'message-stream',\n },\n] as const;\n\ntype StreamMode = (typeof INSTRUMENTED_CHANNELS)[number]['stream'];\n\nconst _anthropicAIIntegration = ((options: AnthropicAiOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n invokeOrchestrionInstrumentation(client, anthropicAiModuleNames, instrumentAnthropic, [options]);\n },\n };\n}) satisfies IntegrationFn;\n\n// Since 0.134 `@anthropic-ai/sdk` traces itself through the global OTel tracer provider, which duplicates our\n// spans. Only turned off once our channels subscribe, so an app we do not instrument keeps the SDK's spans.\n// A value the user set wins.\nfunction disableNativeTracing(): void {\n try {\n process.env.ANTHROPIC_OPEN_TELEMETRY ??= 'false';\n } catch {\n // `process` is absent (edge runtimes) or env access is gated (Deno without `--allow-env`).\n }\n}\n\nfunction instrumentAnthropic(options: AnthropicAiOptions): void {\n disableNativeTracing();\n for (const { channel, operation, stream } of INSTRUMENTED_CHANNELS) {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<OrchestrionChannelContext>(channel),\n data => createGenAiSpan(data, operation, options, stream),\n {\n beforeSpanEnd: (span, data) => {\n if ('error' in data) {\n markCancelledIfAborted(span, getRequestSignal(data.arguments?.[1]));\n }\n addResponseAttributes(\n span,\n data.result as AnthropicAiResponse,\n resolveAIRecordingOptions(options).recordOutputs,\n );\n },\n deferSpanEnd: ({ span, data, end }) =>\n wrapThreadStreamRequest(span, data, end, options) ||\n wrapApiPromiseResponse(\n data.result,\n response => {\n data.result = response;\n if (!wrapStreamResult(span, data, stream, options)) {\n end();\n }\n },\n end,\n ) ||\n wrapStreamResult(span, data, stream, options),\n },\n );\n }\n\n diagnosticsChannel\n .tracingChannel<OrchestrionChannelContext>(CHANNELS.ANTHROPIC_TOOL_RUNNER)\n .end.subscribe(message => {\n instrumentToolRunner((message as OrchestrionChannelContext).result, options);\n });\n diagnosticsChannel\n .tracingChannel<OrchestrionChannelContext>(CHANNELS.ANTHROPIC_SESSION_TOOL_RUNNER)\n .end.subscribe(message => {\n instrumentSessionToolRunner((message as OrchestrionChannelContext).self, options);\n });\n // On `start`, because `_start()` sends the first request before it returns.\n diagnosticsChannel\n .tracingChannel<OrchestrionChannelContext>(CHANNELS.ANTHROPIC_THREAD_STREAM)\n .start.subscribe(message => {\n const data = message as OrchestrionChannelContext;\n const stream = data.self as ThreadStream | undefined;\n if (isMessageStream(stream) && stream.controller?.signal) {\n // `_start(create, params, options)`: each `create()` gets only the stream's own signal, which doesn't carry\n // the reason a caller's signal fired with.\n threadStreams.set(stream.controller.signal, { stream, callerSignal: getRequestSignal(data.arguments?.[2]) });\n }\n });\n}\n\n/**\n * Build the span for an instrumented call.\n * Returning `undefined` opts the payload out so no span is opened.\n */\nfunction createGenAiSpan(\n data: OrchestrionChannelContext,\n operation: string,\n options: AnthropicAiOptions,\n stream: StreamMode,\n): Span | undefined {\n const args = data.arguments ?? [];\n\n if (shouldSkipAiProviderSpan(INTEGRATION_NAME)) {\n return undefined;\n }\n\n // `messages.stream()` internally calls the instrumented `messages.create({ stream: true })` tagged with\n // a `stream` helper-method header. The messages-stream channel already covers it, so skip the nested\n // create to avoid a duplicate span. Only the non-beta helper is on that channel, though:\n // `beta.messages.stream()` and the streaming tool runner send the same header with no span covering\n // them, so the header alone is not enough. Skip only while a stream-helper span of ours is active.\n const requestOptions = args[1] as { headers?: unknown } | undefined;\n if (isStreamHelperRequest(requestOptions?.headers) && isInsideStreamHelperSpan()) {\n return undefined;\n }\n\n const params = typeof args[0] === 'object' && args[0] !== null ? (args[0] as Record<string, unknown>) : undefined;\n\n const { recordInputs } = resolveAIRecordingOptions(options);\n\n const attributes = extractRequestAttributes(args, operation, recordInputs, getProviderName(data.self));\n const model = (attributes[GEN_AI_REQUEST_MODEL] as string) || 'unknown';\n attributes[SENTRY_ORIGIN] = ANTHROPIC_AI_ORIGIN;\n const client = getClient();\n\n const span = startInactiveSpan({\n // With span streaming, omit the `'unknown'` model sentinel so the name stays low-cardinality.\n name: model !== 'unknown' || !(client && hasSpanStreamingEnabled(client)) ? `${operation} ${model}` : operation,\n op: getGenAiSpanOp(operation),\n attributes: attributes as Record<string, SpanAttributeValue>,\n });\n\n if (recordInputs && params) {\n addPrivateRequestAttributes(span, params);\n }\n\n if (stream === 'message-stream') {\n streamHelperSpans.add(span);\n }\n\n return span;\n}\n\nconst STREAM_HELPER_METHOD_HEADER = 'x-stainless-helper-method';\n\n/** The spans opened for the messages-stream channel, i.e. for `messages.stream()` calls. */\nconst streamHelperSpans = new WeakSet<Span>();\n\n/**\n * Whether the active span is one this integration opened for `messages.stream()`. The helper's\n * internal `create` runs inside that span, so this is what tells it apart from the beta helper and\n * the tool runner, which send the same header but are not on the messages-stream channel.\n */\nfunction isInsideStreamHelperSpan(): boolean {\n const activeSpan = getActiveSpan();\n return !!activeSpan && streamHelperSpans.has(activeSpan);\n}\n\n/**\n * Whether request options carry the header the SDK's `messages.stream()` helper puts on its internal\n * `create` call. The SDK sent it as `X-Stainless-Helper-Method` up to 0.105 and lowercase since 0.106, and\n * HTTP header names are case-insensitive either way, so match without regard to case. The headers\n * arrive as a plain object; a `Headers` instance is handled for completeness.\n */\nfunction isStreamHelperRequest(headers: unknown): boolean {\n if (!headers || typeof headers !== 'object') {\n return false;\n }\n\n if (typeof (headers as Headers).get === 'function') {\n return (headers as Headers).get(STREAM_HELPER_METHOD_HEADER) === 'stream';\n }\n\n return Object.entries(headers as Record<string, unknown>).some(\n ([name, value]) => name.toLowerCase() === STREAM_HELPER_METHOD_HEADER && value === 'stream',\n );\n}\n\ntype AsyncIterableStream = { [Symbol.asyncIterator]: () => AsyncIterator<unknown> };\ntype MessageStreamEmitter = { on: (...args: unknown[]) => void };\n\nfunction isAsyncIterable(value: unknown): value is AsyncIterableStream {\n return !!value && typeof (value as AsyncIterableStream)[Symbol.asyncIterator] === 'function';\n}\n\nfunction isMessageStream(value: unknown): value is MessageStreamEmitter {\n return !!value && typeof (value as MessageStreamEmitter).on === 'function';\n}\n\ntype ThreadStream = MessageStreamEmitter & { ended?: boolean; controller?: { signal?: AbortSignal } };\n\n/**\n * The streams of threads and tool runners on 1.2+, by the signal they send each `create()` call with. Such a\n * stream parses the response itself, so the `create()` result is never parsed and never ends its span.\n */\nconst threadStreams = new WeakMap<AbortSignal, { stream: ThreadStream; callerSignal: AbortSignal | undefined }>();\n\n/**\n * End the span of a thread stream's `create()` call from the stream once the response arrives. A thread may\n * retry a rejected call, so a failed call ends its own span and only the one that succeeds reads the stream.\n */\nfunction wrapThreadStreamRequest(\n span: Span,\n data: OrchestrionChannelContext,\n end: (error?: unknown) => void,\n options: AnthropicAiOptions,\n): boolean {\n const signal = (data.arguments?.[1] as { signal?: AbortSignal } | undefined)?.signal;\n const threadStream = signal && threadStreams.get(signal);\n const request = data.result as { _responseProps?: () => Promise<unknown> } | undefined;\n // A finished stream sends no more requests, so a later call with its signal is the caller's own.\n if (!threadStream || threadStream.stream.ended || typeof request?._responseProps !== 'function') {\n return false;\n }\n const { stream, callerSignal } = threadStream;\n\n const { recordOutputs } = resolveAIRecordingOptions(options);\n // Not `asResponse()`, which on 1.x also ends the SDK's own span when the user turned its tracing on.\n void request._responseProps().then(\n () => {\n // Only a rejected attempt is retried, so nothing else may claim this stream.\n threadStreams.delete(signal);\n instrumentMessageStream(stream, span, recordOutputs, callerSignal);\n },\n error => {\n // An abort is not a failed request. The stream still emits 'end', which sets the status from the caller's signal.\n if (signal.aborted) {\n instrumentMessageStream(stream, span, recordOutputs, callerSignal);\n } else {\n end(error);\n }\n },\n );\n return true;\n}\n\n/**\n * Hand span-ending ownership to a streamed result: returns `true` to skip the normal `beforeSpanEnd`,\n * `false` for non-streaming results (which end via `beforeSpanEnd`).\n *\n * - `async-iterable`: patch the `Stream`'s async iterator in place so `instrumentAsyncIterableStream` ends\n * the span when iteration finishes.\n * - `message-stream`: `instrumentMessageStream` attaches `'message'`/`'error'`/`'end'` listeners that end the span.\n */\nfunction wrapStreamResult(\n span: Span,\n data: OrchestrionChannelContext,\n stream: StreamMode,\n options: AnthropicAiOptions,\n): boolean {\n const { recordOutputs } = resolveAIRecordingOptions(options);\n const result = data.result;\n\n if (stream === 'async-iterable' && isAsyncIterable(result)) {\n const iterate = result[Symbol.asyncIterator].bind(result);\n const instrumented = instrumentAsyncIterableStream({ [Symbol.asyncIterator]: iterate }, span, recordOutputs);\n result[Symbol.asyncIterator] = () => instrumented;\n return true;\n }\n\n if (stream === 'message-stream' && isMessageStream(result)) {\n instrumentMessageStream(result, span, recordOutputs, getRequestSignal(data.arguments?.[1]));\n return true;\n }\n\n return false;\n}\n\n/**\n * Diagnostics-channel-based Anthropic integration. Subscribes to the `orchestrion:@anthropic-ai/sdk:*`\n * diagnostics_channels injected into the SDK's chat (`messages`/`completions`/beta `messages`) and\n * `messages.stream()` methods, so it requires the Sentry runtime hook or bundler plugin.\n */\nexport const anthropicAIIntegration = defineIntegration(_anthropicAIIntegration);\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,MAAM,mBAAmB;AAGzB,MAAM,wBAAwB,CAC5B;CAAE,SAAS,SAAS;CAAgB,WAAW;CAAQ,QAAQ;AAA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,iBAAiB,KAAK,YAAY,EAAE,CAAC;EAC1F,OAAO;CACT;CAEA,OAAO;AACT;;;;;;AAOA,MAAa,yBAAyB,kBAAkB,uBAAuB"}
1
+ {"version":3,"file":"anthropic.js","names":["diagnosticsChannel.tracingChannel","diagnosticsChannel\n .tracingChannel"],"sources":["../../../src/integrations/anthropic.ts"],"sourcesContent":["import { GEN_AI_REQUEST_MODEL, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport * as diagnosticsChannel from '../utils/diagnosticsChannel';\nimport type { IntegrationFn, Span, SpanAttributeValue } from '@sentry/core';\nimport { defineIntegration, getActiveSpan, getClient, hasSpanStreamingEnabled, startInactiveSpan } from '@sentry/core';\nimport { getGenAiSpanOp, getRequestSignal, markCancelledIfAborted, resolveGenAiCallRecording } from '../ai/core/utils';\nimport { wrapApiPromiseResponse } from '../ai/core/apiPromise';\nimport { type GenAiSpanResult, runGenAiSpanEnd, runGenAiSpanStart } from '../ai/core/span-hooks';\nimport { addPrivateRequestAttributes, extractRequestAttributes } from '../ai/anthropic-ai';\nimport { ANTHROPIC_AI_ORIGIN } from '../ai/anthropic-ai/constants';\nimport { addResponseAttributes, getProviderName } from '../ai/anthropic-ai/utils';\nimport { instrumentAsyncIterableStream, instrumentMessageStream } from '../ai/anthropic-ai/streaming';\nimport { instrumentSessionToolRunner, instrumentToolRunner } from '../ai/anthropic-ai/tool-runner';\nimport type { AnthropicAiCallInfo, AnthropicAiOptions, AnthropicAiResponse } from '../ai/anthropic-ai/types';\nimport { shouldSkipAiProviderSpan } from '../ai/pi-ai/providers';\nimport type { OrchestrionChannelContext } from '../orchestrion/types';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../tracing-channel';\nimport { anthropicAiModuleNames } from '../orchestrion/config/anthropic-ai';\nimport { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';\n\n// Same name as the OTel integration by design, so the OTel 'Anthropic_AI'\n// integration is deduplicated out of the default set.\nconst INTEGRATION_NAME = 'Anthropic_AI' as const;\n\n// The recording decision is made once, when the span starts, in the caller's async context.\ntype AnthropicChannelContext = OrchestrionChannelContext & {\n _sentryRecordOutputs?: boolean;\n _sentryOnSpanEnd?: (result: GenAiSpanResult<unknown>) => void;\n};\n\n// `stream` determines how the span is ended\nconst INSTRUMENTED_CHANNELS = [\n { channel: CHANNELS.ANTHROPIC_CHAT, operation: 'chat', stream: 'async-iterable' },\n {\n channel: CHANNELS.ANTHROPIC_MESSAGES_STREAM,\n operation: 'chat',\n stream: 'message-stream',\n },\n] as const;\n\ntype StreamMode = (typeof INSTRUMENTED_CHANNELS)[number]['stream'];\n\nconst _anthropicAIIntegration = ((options: AnthropicAiOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n invokeOrchestrionInstrumentation(client, anthropicAiModuleNames, instrumentAnthropic, [options]);\n },\n };\n}) satisfies IntegrationFn;\n\n// Since 0.134 `@anthropic-ai/sdk` traces itself through the global OTel tracer provider, which duplicates our\n// spans. Only turned off once our channels subscribe, so an app we do not instrument keeps the SDK's spans.\n// A value the user set wins.\nfunction disableNativeTracing(): void {\n try {\n process.env.ANTHROPIC_OPEN_TELEMETRY ??= 'false';\n } catch {\n // `process` is absent (edge runtimes) or env access is gated (Deno without `--allow-env`).\n }\n}\n\nfunction instrumentAnthropic(options: AnthropicAiOptions): void {\n disableNativeTracing();\n for (const { channel, operation, stream } of INSTRUMENTED_CHANNELS) {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<AnthropicChannelContext>(channel),\n data => createGenAiSpan(data, operation, options, stream),\n {\n beforeSpanEnd: (span, data) => {\n if ('error' in data) {\n markCancelledIfAborted(span, getRequestSignal(data.arguments?.[1]));\n }\n addResponseAttributes(span, data.result as AnthropicAiResponse, !!data._sentryRecordOutputs);\n data._sentryOnSpanEnd?.('error' in data ? { error: data.error } : { response: data.result });\n },\n deferSpanEnd: ({ span, data, end }) =>\n wrapThreadStreamRequest(span, data, end) ||\n wrapApiPromiseResponse(\n data.result,\n response => {\n data.result = response;\n if (!wrapStreamResult(span, data, stream)) {\n end();\n }\n },\n end,\n ) ||\n wrapStreamResult(span, data, stream),\n },\n );\n }\n\n diagnosticsChannel\n .tracingChannel<OrchestrionChannelContext>(CHANNELS.ANTHROPIC_TOOL_RUNNER)\n .end.subscribe(message => {\n instrumentToolRunner((message as OrchestrionChannelContext).result, options);\n });\n diagnosticsChannel\n .tracingChannel<OrchestrionChannelContext>(CHANNELS.ANTHROPIC_SESSION_TOOL_RUNNER)\n .end.subscribe(message => {\n instrumentSessionToolRunner((message as OrchestrionChannelContext).self, options);\n });\n // On `start`, because `_start()` sends the first request before it returns.\n diagnosticsChannel\n .tracingChannel<OrchestrionChannelContext>(CHANNELS.ANTHROPIC_THREAD_STREAM)\n .start.subscribe(message => {\n const data = message as OrchestrionChannelContext;\n const stream = data.self as ThreadStream | undefined;\n if (isMessageStream(stream) && stream.controller?.signal) {\n // `_start(create, params, options)`: each `create()` gets only the stream's own signal, which doesn't carry\n // the reason a caller's signal fired with.\n threadStreams.set(stream.controller.signal, { stream, callerSignal: getRequestSignal(data.arguments?.[2]) });\n }\n });\n}\n\n/**\n * Build the span for an instrumented call.\n * Returning `undefined` opts the payload out so no span is opened.\n */\nfunction createGenAiSpan(\n data: AnthropicChannelContext,\n operation: 'chat',\n options: AnthropicAiOptions,\n stream: StreamMode,\n): Span | undefined {\n const args = data.arguments ?? [];\n\n if (shouldSkipAiProviderSpan(INTEGRATION_NAME)) {\n return undefined;\n }\n\n // `messages.stream()` internally calls the instrumented `messages.create({ stream: true })` tagged with\n // a `stream` helper-method header. The messages-stream channel already covers it, so skip the nested\n // create to avoid a duplicate span. Only the non-beta helper is on that channel, though:\n // `beta.messages.stream()` and the streaming tool runner send the same header with no span covering\n // them, so the header alone is not enough. Skip only while a stream-helper span of ours is active.\n const requestOptions = args[1] as { headers?: unknown } | undefined;\n if (isStreamHelperRequest(requestOptions?.headers) && isInsideStreamHelperSpan()) {\n return undefined;\n }\n\n const params = typeof args[0] === 'object' && args[0] !== null ? (args[0] as Record<string, unknown>) : undefined;\n\n const call: AnthropicAiCallInfo = { operation, request: params };\n const { recordInputs, recordOutputs } = resolveGenAiCallRecording(options, call);\n data._sentryRecordOutputs = recordOutputs;\n\n const attributes = extractRequestAttributes(args, operation, recordInputs, getProviderName(data.self));\n const model = (attributes[GEN_AI_REQUEST_MODEL] as string) || 'unknown';\n attributes[SENTRY_ORIGIN] = ANTHROPIC_AI_ORIGIN;\n const client = getClient();\n\n const span = startInactiveSpan({\n // With span streaming, omit the `'unknown'` model sentinel so the name stays low-cardinality.\n name: model !== 'unknown' || !(client && hasSpanStreamingEnabled(client)) ? `${operation} ${model}` : operation,\n op: getGenAiSpanOp(operation),\n attributes: attributes as Record<string, SpanAttributeValue>,\n });\n\n if (recordInputs && params) {\n addPrivateRequestAttributes(span, params);\n }\n\n runGenAiSpanStart(options, span, call);\n data._sentryOnSpanEnd = result => runGenAiSpanEnd(options, span, call, result);\n\n if (stream === 'message-stream') {\n streamHelperSpans.add(span);\n }\n\n return span;\n}\n\nconst STREAM_HELPER_METHOD_HEADER = 'x-stainless-helper-method';\n\n/** The spans opened for the messages-stream channel, i.e. for `messages.stream()` calls. */\nconst streamHelperSpans = new WeakSet<Span>();\n\n/**\n * Whether the active span is one this integration opened for `messages.stream()`. The helper's\n * internal `create` runs inside that span, so this is what tells it apart from the beta helper and\n * the tool runner, which send the same header but are not on the messages-stream channel.\n */\nfunction isInsideStreamHelperSpan(): boolean {\n const activeSpan = getActiveSpan();\n return !!activeSpan && streamHelperSpans.has(activeSpan);\n}\n\n/**\n * Whether request options carry the header the SDK's `messages.stream()` helper puts on its internal\n * `create` call. The SDK sent it as `X-Stainless-Helper-Method` up to 0.105 and lowercase since 0.106, and\n * HTTP header names are case-insensitive either way, so match without regard to case. The headers\n * arrive as a plain object; a `Headers` instance is handled for completeness.\n */\nfunction isStreamHelperRequest(headers: unknown): boolean {\n if (!headers || typeof headers !== 'object') {\n return false;\n }\n\n if (typeof (headers as Headers).get === 'function') {\n return (headers as Headers).get(STREAM_HELPER_METHOD_HEADER) === 'stream';\n }\n\n return Object.entries(headers as Record<string, unknown>).some(\n ([name, value]) => name.toLowerCase() === STREAM_HELPER_METHOD_HEADER && value === 'stream',\n );\n}\n\ntype AsyncIterableStream = { [Symbol.asyncIterator]: () => AsyncIterator<unknown> };\ntype MessageStreamEmitter = { on: (...args: unknown[]) => void };\n\nfunction isAsyncIterable(value: unknown): value is AsyncIterableStream {\n return !!value && typeof (value as AsyncIterableStream)[Symbol.asyncIterator] === 'function';\n}\n\nfunction isMessageStream(value: unknown): value is MessageStreamEmitter {\n return !!value && typeof (value as MessageStreamEmitter).on === 'function';\n}\n\ntype ThreadStream = MessageStreamEmitter & { ended?: boolean; controller?: { signal?: AbortSignal } };\n\n/**\n * The streams of threads and tool runners on 1.2+, by the signal they send each `create()` call with. Such a\n * stream parses the response itself, so the `create()` result is never parsed and never ends its span.\n */\nconst threadStreams = new WeakMap<AbortSignal, { stream: ThreadStream; callerSignal: AbortSignal | undefined }>();\n\n/**\n * End the span of a thread stream's `create()` call from the stream once the response arrives. A thread may\n * retry a rejected call, so a failed call ends its own span and only the one that succeeds reads the stream.\n */\nfunction wrapThreadStreamRequest(span: Span, data: AnthropicChannelContext, end: (error?: unknown) => void): boolean {\n const signal = (data.arguments?.[1] as { signal?: AbortSignal } | undefined)?.signal;\n const threadStream = signal && threadStreams.get(signal);\n const request = data.result as { _responseProps?: () => Promise<unknown> } | undefined;\n // A finished stream sends no more requests, so a later call with its signal is the caller's own.\n if (!threadStream || threadStream.stream.ended || typeof request?._responseProps !== 'function') {\n return false;\n }\n const { stream, callerSignal } = threadStream;\n\n const recordOutputs = !!data._sentryRecordOutputs;\n // Not `asResponse()`, which on 1.x also ends the SDK's own span when the user turned its tracing on.\n void request._responseProps().then(\n () => {\n // Only a rejected attempt is retried, so nothing else may claim this stream.\n threadStreams.delete(signal);\n instrumentMessageStream(stream, span, recordOutputs, callerSignal, data._sentryOnSpanEnd);\n },\n error => {\n // An abort is not a failed request. The stream still emits 'end', which sets the status from the caller's signal.\n if (signal.aborted) {\n instrumentMessageStream(stream, span, recordOutputs, callerSignal, data._sentryOnSpanEnd);\n } else {\n end(error);\n }\n },\n );\n return true;\n}\n\n/**\n * Hand span-ending ownership to a streamed result: returns `true` to skip the normal `beforeSpanEnd`,\n * `false` for non-streaming results (which end via `beforeSpanEnd`).\n *\n * - `async-iterable`: patch the `Stream`'s async iterator in place so `instrumentAsyncIterableStream` ends\n * the span when iteration finishes.\n * - `message-stream`: `instrumentMessageStream` attaches `'message'`/`'error'`/`'end'` listeners that end the span.\n */\nfunction wrapStreamResult(span: Span, data: AnthropicChannelContext, stream: StreamMode): boolean {\n const recordOutputs = !!data._sentryRecordOutputs;\n const result = data.result;\n\n if (stream === 'async-iterable' && isAsyncIterable(result)) {\n const iterate = result[Symbol.asyncIterator].bind(result);\n const instrumented = instrumentAsyncIterableStream(\n { [Symbol.asyncIterator]: iterate },\n span,\n recordOutputs,\n data._sentryOnSpanEnd,\n );\n result[Symbol.asyncIterator] = () => instrumented;\n return true;\n }\n\n if (stream === 'message-stream' && isMessageStream(result)) {\n instrumentMessageStream(result, span, recordOutputs, getRequestSignal(data.arguments?.[1]), data._sentryOnSpanEnd);\n return true;\n }\n\n return false;\n}\n\n/**\n * Diagnostics-channel-based Anthropic integration. Subscribes to the `orchestrion:@anthropic-ai/sdk:*`\n * diagnostics_channels injected into the SDK's chat (`messages`/`completions`/beta `messages`) and\n * `messages.stream()` methods, so it requires the Sentry runtime hook or bundler plugin.\n */\nexport const anthropicAIIntegration = defineIntegration(_anthropicAIIntegration);\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,MAAM,mBAAmB;AASzB,MAAM,wBAAwB,CAC5B;CAAE,SAAS,SAAS;CAAgB,WAAW;CAAQ,QAAQ;AAAiB,GAChF;CACE,SAAS,SAAS;CAClB,WAAW;CACX,QAAQ;AACV,CACF;AAIA,MAAM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AK,MAAM;EACxD,MAAM,eAAe,8BACnB,GAAG,OAAO,gBAAgB,QAAQ,GAClC,MACA,eACA,KAAK,gBACP;EACA,OAAO,OAAO,uBAAuB;EACrC,OAAO;CACT;CAEA,IAAI,WAAW,oBAAoB,gBAAgB,MAAM,GAAG;EAC1D,wBAAwB,QAAQ,MAAM,eAAe,iBAAiB,KAAK,YAAY,EAAE,GAAG,KAAK,gBAAgB;EACjH,OAAO;CACT;CAEA,OAAO;AACT;;;;;;AAOA,MAAa,yBAAyB,kBAAkB,uBAAuB"}
@@ -88,6 +88,7 @@ function instrumentAwsSdk(servicesExtensions) {
88
88
  httpStatusCode: errMetadata?.httpStatusCode,
89
89
  extendedRequestId: err?.extendedRequestId ?? errMetadata?.extendedRequestId
90
90
  });
91
+ servicesExtensions.errorHook(normalizedRequest, data.error, span);
91
92
  return;
92
93
  }
93
94
  const output = data.result;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["AWS_REQUEST_ID","diagnosticsChannel.tracingChannel"],"sources":["../../../../src/integrations/aws-sdk/index.ts"],"sourcesContent":["import * as diagnosticsChannel from '../../utils/diagnosticsChannel';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport { defineIntegration, startInactiveSpan } from '@sentry/core';\nimport {\n _AWS_REQUEST_ID as AWS_REQUEST_ID,\n AWS_REQUEST_EXTENDED_ID,\n CLOUD_REGION,\n SENTRY_KIND,\n HTTP_RESPONSE_STATUS_CODE,\n SENTRY_ORIGIN,\n} from '@sentry/conventions/attributes';\nimport { RPC } from '@sentry/conventions/op';\nimport type { GenAiOptions } from '../../ai/core/utils';\nimport type { OrchestrionChannelContext } from '../../orchestrion/types';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { awsSdkModuleNames } from '../../orchestrion/config/aws-sdk';\nimport { invokeOrchestrionInstrumentation } from '../../orchestrion/instrumentation';\nimport type { TracingChannelLifeCycleOptions } from '../../tracing-channel';\nimport { bindTracingChannelToSpan, safeChannelCallback } from '../../tracing-channel';\nimport { AWS_SDK_ORIGIN_INTEGRATION_NAME } from './constants';\nimport { ServicesExtensions } from './services';\nimport type { NormalizedRequest, NormalizedResponse, RequestMetadata } from './types';\nimport { extractAttributesFromNormalizedRequest, normalizeV3Request, removeSuffixFromStringIfExists } from './utils';\n\n// Same name as the OTel `Aws` integration by design, so enabling injection swaps this in for it.\nconst INTEGRATION_NAME = 'Aws' as const;\n\n// The context orchestrion's transform attaches to the channel: `arguments` is the live args of the\n// wrapped `Client.prototype.send` call (`[command, ...]`), `self` the client, `result`/`error` the\n// settled value. The `_sentry*` fields are stashed by us across the call's lifecycle.\ninterface AwsSendChannelContext extends OrchestrionChannelContext {\n self?: { config?: AwsClientConfig; constructor?: { name?: string } };\n _sentryNormalizedRequest?: NormalizedRequest;\n _sentryRequestMetadata?: RequestMetadata;\n _sentryRegion?: { settled: boolean; promise: Promise<void> };\n}\n\ninterface AwsClientConfig {\n serviceId?: string;\n region?: () => string | Promise<string> | undefined;\n}\n\ninterface AwsV3Command {\n input?: Record<string, unknown>;\n constructor?: { name?: string };\n}\n\n// `metadata` is smithy's `ResponseMetadata`, read off the untyped channel result/error (`any` for the\n// same reason as `CommandInput`, see types.ts).\nfunction setMetadataAttributes(span: Span, metadata: Record<string, any> | undefined): void {\n if (!metadata) {\n return;\n }\n if (metadata.requestId) {\n // oxlint-disable-next-line typescript/no-deprecated\n span.setAttribute(AWS_REQUEST_ID, metadata.requestId);\n }\n if (metadata.httpStatusCode) {\n span.setAttribute(HTTP_RESPONSE_STATUS_CODE, metadata.httpStatusCode);\n }\n if (metadata.extendedRequestId) {\n // oxlint-disable-next-line typescript/no-deprecated\n span.setAttribute(AWS_REQUEST_EXTENDED_ID, metadata.extendedRequestId);\n }\n}\n\n// `recordInputs` and `recordOutputs` apply to Bedrock Runtime calls, the only AWS calls that carry prompts and responses.\nexport type AwsIntegrationOptions = GenAiOptions;\n\nconst _awsIntegration = ((options?: AwsIntegrationOptions) => {\n const servicesExtensions = new ServicesExtensions(options);\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n invokeOrchestrionInstrumentation(client, awsSdkModuleNames, instrumentAwsSdk, [servicesExtensions]);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction getSpanOrigin(op: string): string {\n const opCategory = op.split('.')[0];\n // AI integrations use `ai` as their origin category, although their ops are `gen_ai.*`.\n const category = opCategory === 'gen_ai' ? 'ai' : opCategory;\n return `auto.${category}.${AWS_SDK_ORIGIN_INTEGRATION_NAME}`;\n}\n\nfunction instrumentAwsSdk(servicesExtensions: ServicesExtensions): void {\n const getSpan = (data: AwsSendChannelContext): Span | undefined =>\n safeChannelCallback(() => {\n const command = data.arguments[0] as AwsV3Command | undefined;\n const commandName = command?.constructor?.name;\n if (!command || !commandName) {\n // Not a recognizable v3 command call; leave the active context untouched.\n return undefined;\n }\n\n const clientConfig = data.self?.config;\n const serviceName =\n clientConfig?.serviceId ??\n // `clientName` isn't available at the `send` boundary; fall back to the client's\n // constructor name (e.g. `S3Client` -> `S3`). `serviceId` is set for all AWS clients.\n removeSuffixFromStringIfExists(data.self?.constructor?.name || 'AWS', 'Client');\n\n // Commands with all-optional members can be constructed without an input (`new\n // ListBucketsCommand()`); the OTel path traces those too, so default rather than bail.\n // The default is assigned back onto the command (not kept detached) because service hooks\n // mutate `commandInput` (trace-propagation headers, `MessageAttributeNames`) and those\n // writes must reach the serialized request. Current smithy clients already default `input`\n // to `{}` in the command constructor; this only affects older clients in our range.\n if (!command.input) {\n command.input = {};\n }\n const normalizedRequest = normalizeV3Request(serviceName, commandName, command.input, undefined);\n normalizedRequest.abortSignal = (data.arguments[1] as { abortSignal?: AbortSignal } | undefined)?.abortSignal;\n const requestMetadata = servicesExtensions.requestPreSpanHook(normalizedRequest);\n\n // `rpc` matches what the exporter infers from `rpc.service` for the OTel aws-sdk spans;\n // service extensions override it where inference yields a different op (DynamoDB: `db`).\n const op = requestMetadata.spanOp || RPC;\n const span = startInactiveSpan({\n name: requestMetadata.spanName ?? `${normalizedRequest.serviceName}.${normalizedRequest.commandName}`,\n op,\n attributes: {\n [SENTRY_KIND]: 'client',\n [SENTRY_ORIGIN]: getSpanOrigin(op),\n ...extractAttributesFromNormalizedRequest(normalizedRequest),\n ...requestMetadata.spanAttributes,\n },\n });\n\n data._sentryNormalizedRequest = normalizedRequest;\n data._sentryRequestMetadata = requestMetadata;\n\n // `region` resolves asynchronously while `send` proceeds (a channel subscriber cannot delay\n // the traced call the way the OTel middleware does). Backfill it onto the span and the\n // normalized request once available; `deferSpanEnd` holds the span open until this settles\n // so `cloud.region` cannot be lost when `send` settles first (e.g. an early failure).\n //\n // The provider call is guarded separately: the span is already started, so a synchronous\n // throw bubbling into the enclosing `safeChannelCallback` would discard it without ending it (a leaked\n // open span).\n let regionResult: string | Promise<string> | undefined;\n try {\n regionResult = clientConfig?.region?.();\n } catch {\n // Nothing to do; continue without a region.\n }\n // The `.finally` self-reference is safe: the callback only runs after initialization.\n const regionHolder: { settled: boolean; promise: Promise<void> } = {\n settled: false,\n promise: Promise.resolve(regionResult)\n .then(region => {\n if (region) {\n normalizedRequest.region = region;\n span.setAttribute(CLOUD_REGION, region);\n }\n })\n .catch(() => {\n // Nothing to do; continue without a region.\n })\n .finally(() => {\n regionHolder.settled = true;\n }),\n };\n data._sentryRegion = regionHolder;\n\n // Inject trace-propagation headers into outgoing messages (SQS/SNS/Lambda). Runs before\n // `send` proceeds, so the mutated `commandInput` is used to build the request.\n safeChannelCallback(() => servicesExtensions.requestPostSpanHook(normalizedRequest, span));\n\n return span;\n });\n\n const opts: TracingChannelLifeCycleOptions<AwsSendChannelContext> = {\n deferSpanEnd({ span, data, end }) {\n const normalizedRequest = data._sentryNormalizedRequest;\n const requestMetadata = data._sentryRequestMetadata;\n if (!normalizedRequest) {\n return false;\n }\n\n const failed = 'error' in data;\n\n // The channel `result`/`error` are untyped; the `$metadata` casts below name smithy's\n // `ResponseMetadata` shape (`any`-valued, see `setMetadataAttributes`).\n safeChannelCallback(() => {\n if (failed) {\n const err = data.error as\n | { $metadata?: Record<string, any>; RequestId?: string; extendedRequestId?: string }\n | undefined;\n const errMetadata = err?.$metadata;\n // Like the OTel path, read RequestId/extendedRequestId off the error itself, with\n // `$metadata` (which smithy service errors also carry) as the fallback. A spread won't\n // do: `$metadata` includes these keys with `undefined` values, clobbering the fallback.\n setMetadataAttributes(span, {\n requestId: err?.RequestId ?? errMetadata?.requestId,\n httpStatusCode: errMetadata?.httpStatusCode,\n extendedRequestId: err?.extendedRequestId ?? errMetadata?.extendedRequestId,\n });\n return;\n }\n\n const output = data.result as { $metadata?: Record<string, any> } | undefined;\n setMetadataAttributes(span, output?.$metadata);\n\n const normalizedResponse: NormalizedResponse = {\n data: output,\n request: normalizedRequest,\n requestId: output?.$metadata?.requestId,\n };\n servicesExtensions.responseHook(normalizedResponse, span);\n });\n\n // Streaming responses end the span when their wrapped stream is consumed (see\n // bedrock-runtime); the helper must not end it on `send` settling. Errors always end here.\n if (requestMetadata?.isStream && !failed) {\n return true;\n }\n\n // Normally the region settles long before `send` does (the SDK awaits it internally to\n // build the endpoint), but when `send` settles first (e.g. an early failure) hold the span\n // open until the region backfill lands. The error status was already applied by the\n // helper's `error` subscriber, so a plain `end()` suffices.\n const region = data._sentryRegion;\n if (region && !region.settled) {\n void region.promise.then(() => end());\n return true;\n }\n\n return false;\n },\n };\n\n // The AWS SDK's `Client.prototype.send` lives in different smithy packages across versions; the\n // transform injects one channel per package. Only the package hosting the app's client fires, so\n // subscribing to all of them is safe and never double-instruments a single call.\n const awsSendChannels = [\n CHANNELS.AWS_SMITHY_CORE_SEND,\n CHANNELS.AWS_SMITHY_CLIENT_SEND,\n CHANNELS.AWS_SDK_SMITHY_CLIENT_SEND,\n ] as const;\n\n for (const channelName of awsSendChannels) {\n bindTracingChannelToSpan(diagnosticsChannel.tracingChannel<AwsSendChannelContext>(channelName), getSpan, opts);\n }\n}\n\n/**\n * Diagnostics-channel-based aws-sdk (v3) integration.\n *\n * Subscribes to the `orchestrion:@smithy/smithy-client:send` (and equivalent) diagnostics_channel\n * Sentry's code transform injects into the AWS SDK's smithy `Client.prototype.send`, emitting\n * spans identical to the OTel `@opentelemetry/instrumentation-aws-sdk` integration. Requires the\n * Sentry runtime hook or bundler plugin.\n */\nexport const awsIntegration = defineIntegration(_awsIntegration);\n"],"mappings":";;;;;;;;;;;;;AAyBA,MAAM,mBAAmB;AAwBzB,SAAS,sBAAsB,MAAY,UAAiD;CAC1F,IAAI,CAAC,UACH;CAEF,IAAI,SAAS,WAEX,KAAK,aAAaA,iBAAgB,SAAS,SAAS;CAEtD,IAAI,SAAS,gBACX,KAAK,aAAa,2BAA2B,SAAS,cAAc;CAEtE,IAAI,SAAS,mBAEX,KAAK,aAAa,yBAAyB,SAAS,iBAAiB;AAEzE;AAKA,MAAM,oBAAoB,YAAoC;CAC5D,MAAM,qBAAqB,IAAI,mBAAmB,OAAO;CAEzD,OAAO;EACL,MAAM;EACN,MAAM,QAAQ;GACZ,iCAAiC,QAAQ,mBAAmB,kBAAkB,CAAC,kBAAkB,CAAC;EACpG;CACF;AACF;AAEA,SAAS,cAAc,IAAoB;CACzC,MAAM,aAAa,GAAG,MAAM,GAAG,CAAC,CAAC;CAGjC,OAAO,QADU,eAAe,WAAW,OAAO,WAC1B,GAAG;AAC7B;AAEA,SAAS,iBAAiB,oBAA8C;CACtE,MAAM,WAAW,SACf,0BAA0B;EACxB,MAAM,UAAU,KAAK,UAAU;EAC/B,MAAM,cAAc,SAAS,aAAa;EAC1C,IAAI,CAAC,WAAW,CAAC,aAEf;EAGF,MAAM,eAAe,KAAK,MAAM;EAChC,MAAM,cACJ,cAAc,aAGd,+BAA+B,KAAK,MAAM,aAAa,QAAQ,OAAO,QAAQ;EAQhF,IAAI,CAAC,QAAQ,OACX,QAAQ,QAAQ,CAAC;EAEnB,MAAM,oBAAoB,mBAAmB,aAAa,aAAa,QAAQ,OAAO,KAAA,CAAS;EAC/F,kBAAkB,cAAe,KAAK,UAAU,EAAE,EAAgD;EAClG,MAAM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,WAAW;GAChC;GACA,mBAAmB,aAAa,oBAAoB,IAAI;EAC1D,CAAC;EAID,IAAI,iBAAiB,YAAY,CAAC,QAChC,OAAO;EAOT,MAAM,SAAS,KAAK;EACpB,IAAI,UAAU,CAAC,OAAO,SAAS;GACxB,OAAO,QAAQ,WAAW,IAAI,CAAC;GACpC,OAAO;EACT;EAEA,OAAO;CACT,EACF;CAKA,MAAM,kBAAkB;EACtB,SAAS;EACT,SAAS;EACT,SAAS;CACX;CAEA,KAAK,MAAM,eAAe,iBACxB,yBAAyBC,eAAyD,WAAW,GAAG,SAAS,IAAI;AAEjH;;;;;;;;;AAUA,MAAa,iBAAiB,kBAAkB,eAAe"}
1
+ {"version":3,"file":"index.js","names":["AWS_REQUEST_ID","diagnosticsChannel.tracingChannel"],"sources":["../../../../src/integrations/aws-sdk/index.ts"],"sourcesContent":["import * as diagnosticsChannel from '../../utils/diagnosticsChannel';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport { defineIntegration, startInactiveSpan } from '@sentry/core';\nimport {\n _AWS_REQUEST_ID as AWS_REQUEST_ID,\n AWS_REQUEST_EXTENDED_ID,\n CLOUD_REGION,\n SENTRY_KIND,\n HTTP_RESPONSE_STATUS_CODE,\n SENTRY_ORIGIN,\n} from '@sentry/conventions/attributes';\nimport { RPC } from '@sentry/conventions/op';\nimport type { OrchestrionChannelContext } from '../../orchestrion/types';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { awsSdkModuleNames } from '../../orchestrion/config/aws-sdk';\nimport { invokeOrchestrionInstrumentation } from '../../orchestrion/instrumentation';\nimport type { TracingChannelLifeCycleOptions } from '../../tracing-channel';\nimport { bindTracingChannelToSpan, safeChannelCallback } from '../../tracing-channel';\nimport { AWS_SDK_ORIGIN_INTEGRATION_NAME } from './constants';\nimport { ServicesExtensions } from './services';\nimport type { BedrockRuntimeOptions } from './services/bedrock-runtime';\nimport type { NormalizedRequest, NormalizedResponse, RequestMetadata } from './types';\nimport { extractAttributesFromNormalizedRequest, normalizeV3Request, removeSuffixFromStringIfExists } from './utils';\n\n// Same name as the OTel `Aws` integration by design, so enabling injection swaps this in for it.\nconst INTEGRATION_NAME = 'Aws' as const;\n\n// The context orchestrion's transform attaches to the channel: `arguments` is the live args of the\n// wrapped `Client.prototype.send` call (`[command, ...]`), `self` the client, `result`/`error` the\n// settled value. The `_sentry*` fields are stashed by us across the call's lifecycle.\ninterface AwsSendChannelContext extends OrchestrionChannelContext {\n self?: { config?: AwsClientConfig; constructor?: { name?: string } };\n _sentryNormalizedRequest?: NormalizedRequest;\n _sentryRequestMetadata?: RequestMetadata;\n _sentryRegion?: { settled: boolean; promise: Promise<void> };\n}\n\ninterface AwsClientConfig {\n serviceId?: string;\n region?: () => string | Promise<string> | undefined;\n}\n\ninterface AwsV3Command {\n input?: Record<string, unknown>;\n constructor?: { name?: string };\n}\n\n// `metadata` is smithy's `ResponseMetadata`, read off the untyped channel result/error (`any` for the\n// same reason as `CommandInput`, see types.ts).\nfunction setMetadataAttributes(span: Span, metadata: Record<string, any> | undefined): void {\n if (!metadata) {\n return;\n }\n if (metadata.requestId) {\n // oxlint-disable-next-line typescript/no-deprecated\n span.setAttribute(AWS_REQUEST_ID, metadata.requestId);\n }\n if (metadata.httpStatusCode) {\n span.setAttribute(HTTP_RESPONSE_STATUS_CODE, metadata.httpStatusCode);\n }\n if (metadata.extendedRequestId) {\n // oxlint-disable-next-line typescript/no-deprecated\n span.setAttribute(AWS_REQUEST_EXTENDED_ID, metadata.extendedRequestId);\n }\n}\n\n// `recordInputs` and `recordOutputs` apply to Bedrock Runtime calls, the only AWS calls that carry prompts and responses.\nexport type AwsIntegrationOptions = BedrockRuntimeOptions;\n\nconst _awsIntegration = ((options?: AwsIntegrationOptions) => {\n const servicesExtensions = new ServicesExtensions(options);\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n invokeOrchestrionInstrumentation(client, awsSdkModuleNames, instrumentAwsSdk, [servicesExtensions]);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction getSpanOrigin(op: string): string {\n const opCategory = op.split('.')[0];\n // AI integrations use `ai` as their origin category, although their ops are `gen_ai.*`.\n const category = opCategory === 'gen_ai' ? 'ai' : opCategory;\n return `auto.${category}.${AWS_SDK_ORIGIN_INTEGRATION_NAME}`;\n}\n\nfunction instrumentAwsSdk(servicesExtensions: ServicesExtensions): void {\n const getSpan = (data: AwsSendChannelContext): Span | undefined =>\n safeChannelCallback(() => {\n const command = data.arguments[0] as AwsV3Command | undefined;\n const commandName = command?.constructor?.name;\n if (!command || !commandName) {\n // Not a recognizable v3 command call; leave the active context untouched.\n return undefined;\n }\n\n const clientConfig = data.self?.config;\n const serviceName =\n clientConfig?.serviceId ??\n // `clientName` isn't available at the `send` boundary; fall back to the client's\n // constructor name (e.g. `S3Client` -> `S3`). `serviceId` is set for all AWS clients.\n removeSuffixFromStringIfExists(data.self?.constructor?.name || 'AWS', 'Client');\n\n // Commands with all-optional members can be constructed without an input (`new\n // ListBucketsCommand()`); the OTel path traces those too, so default rather than bail.\n // The default is assigned back onto the command (not kept detached) because service hooks\n // mutate `commandInput` (trace-propagation headers, `MessageAttributeNames`) and those\n // writes must reach the serialized request. Current smithy clients already default `input`\n // to `{}` in the command constructor; this only affects older clients in our range.\n if (!command.input) {\n command.input = {};\n }\n const normalizedRequest = normalizeV3Request(serviceName, commandName, command.input, undefined);\n normalizedRequest.abortSignal = (data.arguments[1] as { abortSignal?: AbortSignal } | undefined)?.abortSignal;\n const requestMetadata = servicesExtensions.requestPreSpanHook(normalizedRequest);\n\n // `rpc` matches what the exporter infers from `rpc.service` for the OTel aws-sdk spans;\n // service extensions override it where inference yields a different op (DynamoDB: `db`).\n const op = requestMetadata.spanOp || RPC;\n const span = startInactiveSpan({\n name: requestMetadata.spanName ?? `${normalizedRequest.serviceName}.${normalizedRequest.commandName}`,\n op,\n attributes: {\n [SENTRY_KIND]: 'client',\n [SENTRY_ORIGIN]: getSpanOrigin(op),\n ...extractAttributesFromNormalizedRequest(normalizedRequest),\n ...requestMetadata.spanAttributes,\n },\n });\n\n data._sentryNormalizedRequest = normalizedRequest;\n data._sentryRequestMetadata = requestMetadata;\n\n // `region` resolves asynchronously while `send` proceeds (a channel subscriber cannot delay\n // the traced call the way the OTel middleware does). Backfill it onto the span and the\n // normalized request once available; `deferSpanEnd` holds the span open until this settles\n // so `cloud.region` cannot be lost when `send` settles first (e.g. an early failure).\n //\n // The provider call is guarded separately: the span is already started, so a synchronous\n // throw bubbling into the enclosing `safeChannelCallback` would discard it without ending it (a leaked\n // open span).\n let regionResult: string | Promise<string> | undefined;\n try {\n regionResult = clientConfig?.region?.();\n } catch {\n // Nothing to do; continue without a region.\n }\n // The `.finally` self-reference is safe: the callback only runs after initialization.\n const regionHolder: { settled: boolean; promise: Promise<void> } = {\n settled: false,\n promise: Promise.resolve(regionResult)\n .then(region => {\n if (region) {\n normalizedRequest.region = region;\n span.setAttribute(CLOUD_REGION, region);\n }\n })\n .catch(() => {\n // Nothing to do; continue without a region.\n })\n .finally(() => {\n regionHolder.settled = true;\n }),\n };\n data._sentryRegion = regionHolder;\n\n // Inject trace-propagation headers into outgoing messages (SQS/SNS/Lambda). Runs before\n // `send` proceeds, so the mutated `commandInput` is used to build the request.\n safeChannelCallback(() => servicesExtensions.requestPostSpanHook(normalizedRequest, span));\n\n return span;\n });\n\n const opts: TracingChannelLifeCycleOptions<AwsSendChannelContext> = {\n deferSpanEnd({ span, data, end }) {\n const normalizedRequest = data._sentryNormalizedRequest;\n const requestMetadata = data._sentryRequestMetadata;\n if (!normalizedRequest) {\n return false;\n }\n\n const failed = 'error' in data;\n\n // The channel `result`/`error` are untyped; the `$metadata` casts below name smithy's\n // `ResponseMetadata` shape (`any`-valued, see `setMetadataAttributes`).\n safeChannelCallback(() => {\n if (failed) {\n const err = data.error as\n | { $metadata?: Record<string, any>; RequestId?: string; extendedRequestId?: string }\n | undefined;\n const errMetadata = err?.$metadata;\n // Like the OTel path, read RequestId/extendedRequestId off the error itself, with\n // `$metadata` (which smithy service errors also carry) as the fallback. A spread won't\n // do: `$metadata` includes these keys with `undefined` values, clobbering the fallback.\n setMetadataAttributes(span, {\n requestId: err?.RequestId ?? errMetadata?.requestId,\n httpStatusCode: errMetadata?.httpStatusCode,\n extendedRequestId: err?.extendedRequestId ?? errMetadata?.extendedRequestId,\n });\n servicesExtensions.errorHook(normalizedRequest, data.error, span);\n return;\n }\n\n const output = data.result as { $metadata?: Record<string, any> } | undefined;\n setMetadataAttributes(span, output?.$metadata);\n\n const normalizedResponse: NormalizedResponse = {\n data: output,\n request: normalizedRequest,\n requestId: output?.$metadata?.requestId,\n };\n servicesExtensions.responseHook(normalizedResponse, span);\n });\n\n // Streaming responses end the span when their wrapped stream is consumed (see\n // bedrock-runtime); the helper must not end it on `send` settling. Errors always end here.\n if (requestMetadata?.isStream && !failed) {\n return true;\n }\n\n // Normally the region settles long before `send` does (the SDK awaits it internally to\n // build the endpoint), but when `send` settles first (e.g. an early failure) hold the span\n // open until the region backfill lands. The error status was already applied by the\n // helper's `error` subscriber, so a plain `end()` suffices.\n const region = data._sentryRegion;\n if (region && !region.settled) {\n void region.promise.then(() => end());\n return true;\n }\n\n return false;\n },\n };\n\n // The AWS SDK's `Client.prototype.send` lives in different smithy packages across versions; the\n // transform injects one channel per package. Only the package hosting the app's client fires, so\n // subscribing to all of them is safe and never double-instruments a single call.\n const awsSendChannels = [\n CHANNELS.AWS_SMITHY_CORE_SEND,\n CHANNELS.AWS_SMITHY_CLIENT_SEND,\n CHANNELS.AWS_SDK_SMITHY_CLIENT_SEND,\n ] as const;\n\n for (const channelName of awsSendChannels) {\n bindTracingChannelToSpan(diagnosticsChannel.tracingChannel<AwsSendChannelContext>(channelName), getSpan, opts);\n }\n}\n\n/**\n * Diagnostics-channel-based aws-sdk (v3) integration.\n *\n * Subscribes to the `orchestrion:@smithy/smithy-client:send` (and equivalent) diagnostics_channel\n * Sentry's code transform injects into the AWS SDK's smithy `Client.prototype.send`, emitting\n * spans identical to the OTel `@opentelemetry/instrumentation-aws-sdk` integration. Requires the\n * Sentry runtime hook or bundler plugin.\n */\nexport const awsIntegration = defineIntegration(_awsIntegration);\n"],"mappings":";;;;;;;;;;;;;AAyBA,MAAM,mBAAmB;AAwBzB,SAAS,sBAAsB,MAAY,UAAiD;CAC1F,IAAI,CAAC,UACH;CAEF,IAAI,SAAS,WAEX,KAAK,aAAaA,iBAAgB,SAAS,SAAS;CAEtD,IAAI,SAAS,gBACX,KAAK,aAAa,2BAA2B,SAAS,cAAc;CAEtE,IAAI,SAAS,mBAEX,KAAK,aAAa,yBAAyB,SAAS,iBAAiB;AAEzE;AAKA,MAAM,oBAAoB,YAAoC;CAC5D,MAAM,qBAAqB,IAAI,mBAAmB,OAAO;CAEzD,OAAO;EACL,MAAM;EACN,MAAM,QAAQ;GACZ,iCAAiC,QAAQ,mBAAmB,kBAAkB,CAAC,kBAAkB,CAAC;EACpG;CACF;AACF;AAEA,SAAS,cAAc,IAAoB;CACzC,MAAM,aAAa,GAAG,MAAM,GAAG,CAAC,CAAC;CAGjC,OAAO,QADU,eAAe,WAAW,OAAO,WAC1B,GAAG;AAC7B;AAEA,SAAS,iBAAiB,oBAA8C;CACtE,MAAM,WAAW,SACf,0BAA0B;EACxB,MAAM,UAAU,KAAK,UAAU;EAC/B,MAAM,cAAc,SAAS,aAAa;EAC1C,IAAI,CAAC,WAAW,CAAC,aAEf;EAGF,MAAM,eAAe,KAAK,MAAM;EAChC,MAAM,cACJ,cAAc,aAGd,+BAA+B,KAAK,MAAM,aAAa,QAAQ,OAAO,QAAQ;EAQhF,IAAI,CAAC,QAAQ,OACX,QAAQ,QAAQ,CAAC;EAEnB,MAAM,oBAAoB,mBAAmB,aAAa,aAAa,QAAQ,OAAO,KAAA,CAAS;EAC/F,kBAAkB,cAAe,KAAK,UAAU,EAAE,EAAgD;EAClG,MAAM,kBAAkB,mBAAmB,mBAAmB,iBAAiB;EAI/E,MAAM,KAAK,gBAAgB,UAAU;EACrC,MAAM,OAAO,kBA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AAI;EAC1D,CAAC;EAID,IAAI,iBAAiB,YAAY,CAAC,QAChC,OAAO;EAOT,MAAM,SAAS,KAAK;EACpB,IAAI,UAAU,CAAC,OAAO,SAAS;GACxB,OAAO,QAAQ,WAAW,IAAI,CAAC;GACpC,OAAO;EACT;EAEA,OAAO;CACT,EACF;CAKA,MAAM,kBAAkB;EACtB,SAAS;EACT,SAAS;EACT,SAAS;CACX;CAEA,KAAK,MAAM,eAAe,iBACxB,yBAAyBC,eAAyD,WAAW,GAAG,SAAS,IAAI;AAEjH;;;;;;;;;AAUA,MAAa,iBAAiB,kBAAkB,eAAe"}
@@ -33,6 +33,9 @@ var ServicesExtensions = class {
33
33
  responseHook(response, span) {
34
34
  this._services.get(response.request.serviceName)?.responseHook?.(response, span);
35
35
  }
36
+ errorHook(request, error, span) {
37
+ this._services.get(request.serviceName)?.errorHook?.(request, error, span);
38
+ }
36
39
  };
37
40
  export { ServicesExtensions };
38
41