@sentry/cloudflare 11.11.0 → 11.13.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 (628) hide show
  1. package/build/cjs/dev/_virtual/_rolldown/runtime.js +22 -0
  2. package/build/cjs/dev/baseSdk.js +98 -103
  3. package/build/cjs/dev/baseSdk.js.map +1 -1
  4. package/build/cjs/dev/client.js +213 -237
  5. package/build/cjs/dev/client.js.map +1 -1
  6. package/build/cjs/dev/clientCache.js +8 -8
  7. package/build/cjs/dev/clientCache.js.map +1 -1
  8. package/build/cjs/dev/debug-build.js +9 -5
  9. package/build/cjs/dev/debug-build.js.map +1 -1
  10. package/build/cjs/dev/defineCloudflareOptions.js +5 -8
  11. package/build/cjs/dev/defineCloudflareOptions.js.map +1 -1
  12. package/build/cjs/dev/durableobject.js +290 -163
  13. package/build/cjs/dev/durableobject.js.map +1 -1
  14. package/build/cjs/dev/flush.js +104 -77
  15. package/build/cjs/dev/flush.js.map +1 -1
  16. package/build/cjs/dev/index.js +181 -182
  17. package/build/cjs/dev/instrument.js +53 -39
  18. package/build/cjs/dev/instrument.js.map +1 -1
  19. package/build/cjs/dev/instrumentations/agents/index.js +34 -13
  20. package/build/cjs/dev/instrumentations/agents/index.js.map +1 -1
  21. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
  22. package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  23. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
  24. package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  25. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
  26. package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  27. package/build/cjs/dev/instrumentations/agents/types.js +103 -58
  28. package/build/cjs/dev/instrumentations/agents/types.js.map +1 -1
  29. package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -118
  30. package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  31. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -44
  32. package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  33. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js +70 -71
  34. package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  35. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
  36. package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  37. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js +50 -52
  38. package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
  39. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -123
  40. package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  41. package/build/cjs/dev/instrumentations/worker/instrumentD1.js +131 -146
  42. package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  43. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js +63 -61
  44. package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  45. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js +83 -87
  46. package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  47. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js +41 -48
  48. package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  49. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js +25 -21
  50. package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
  51. package/build/cjs/dev/instrumentations/worker/instrumentKV.js +54 -67
  52. package/build/cjs/dev/instrumentations/worker/instrumentKV.js.map +1 -1
  53. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js +100 -76
  54. package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  55. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js +91 -75
  56. package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  57. package/build/cjs/dev/instrumentations/worker/instrumentR2.js +128 -115
  58. package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  59. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js +90 -94
  60. package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  61. package/build/cjs/dev/instrumentations/worker/instrumentTail.js +100 -55
  62. package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  63. package/build/cjs/dev/integrations/cronTriggers.js +130 -85
  64. package/build/cjs/dev/integrations/cronTriggers.js.map +1 -1
  65. package/build/cjs/dev/integrations/fetch.js +9 -9
  66. package/build/cjs/dev/integrations/fetch.js.map +1 -1
  67. package/build/cjs/dev/integrations/httpServer.js +41 -22
  68. package/build/cjs/dev/integrations/httpServer.js.map +1 -1
  69. package/build/cjs/dev/integrations/spotlight.js +52 -55
  70. package/build/cjs/dev/integrations/spotlight.js.map +1 -1
  71. package/build/cjs/dev/opentelemetry/tracer.js +10 -8
  72. package/build/cjs/dev/opentelemetry/tracer.js.map +1 -1
  73. package/build/cjs/dev/options.js +55 -39
  74. package/build/cjs/dev/options.js.map +1 -1
  75. package/build/cjs/dev/orchestrion-deferred-channels.js +45 -29
  76. package/build/cjs/dev/orchestrion-deferred-channels.js.map +1 -1
  77. package/build/cjs/dev/orchestrion-diagnostics-channel.js +97 -72
  78. package/build/cjs/dev/orchestrion-diagnostics-channel.js.map +1 -1
  79. package/build/cjs/dev/pages-plugin.js +20 -21
  80. package/build/cjs/dev/pages-plugin.js.map +1 -1
  81. package/build/cjs/dev/request.js +16 -10
  82. package/build/cjs/dev/request.js.map +1 -1
  83. package/build/cjs/dev/scope-utils.js +12 -12
  84. package/build/cjs/dev/scope-utils.js.map +1 -1
  85. package/build/cjs/dev/sdk.js +24 -15
  86. package/build/cjs/dev/sdk.js.map +1 -1
  87. package/build/cjs/dev/transport.js +93 -86
  88. package/build/cjs/dev/transport.js.map +1 -1
  89. package/build/cjs/dev/utils/asyncContextStrategy.js +10 -10
  90. package/build/cjs/dev/utils/asyncContextStrategy.js.map +1 -1
  91. package/build/cjs/dev/utils/bindingPropagation.js +24 -0
  92. package/build/cjs/dev/utils/bindingPropagation.js.map +1 -0
  93. package/build/cjs/dev/utils/cloudflareTrace.js +34 -0
  94. package/build/cjs/dev/utils/cloudflareTrace.js.map +1 -0
  95. package/build/cjs/dev/utils/instrumentContext.js +74 -58
  96. package/build/cjs/dev/utils/instrumentContext.js.map +1 -1
  97. package/build/cjs/dev/utils/internalSqlQuery.js +38 -21
  98. package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -1
  99. package/build/cjs/dev/utils/internalStorageKey.js +41 -38
  100. package/build/cjs/dev/utils/internalStorageKey.js.map +1 -1
  101. package/build/cjs/dev/utils/invocationContext.js +42 -32
  102. package/build/cjs/dev/utils/invocationContext.js.map +1 -1
  103. package/build/cjs/dev/utils/invocationScope.js +45 -21
  104. package/build/cjs/dev/utils/invocationScope.js.map +1 -1
  105. package/build/cjs/dev/utils/isBinding.js +47 -15
  106. package/build/cjs/dev/utils/isBinding.js.map +1 -1
  107. package/build/cjs/dev/utils/isCloudflareClass.js +11 -20
  108. package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -1
  109. package/build/cjs/dev/utils/queueTraceMeta.js +33 -0
  110. package/build/cjs/dev/utils/queueTraceMeta.js.map +1 -0
  111. package/build/cjs/dev/utils/rpcMeta.js +37 -27
  112. package/build/cjs/dev/utils/rpcMeta.js.map +1 -1
  113. package/build/cjs/dev/utils/traceLinks.js +52 -42
  114. package/build/cjs/dev/utils/traceLinks.js.map +1 -1
  115. package/build/cjs/dev/vendor/stacktrace.js +32 -24
  116. package/build/cjs/dev/vendor/stacktrace.js.map +1 -1
  117. package/build/cjs/dev/vite/agentClass.js +105 -98
  118. package/build/cjs/dev/vite/agentClass.js.map +1 -1
  119. package/build/cjs/dev/vite/autoInstrument.js +121 -122
  120. package/build/cjs/dev/vite/autoInstrument.js.map +1 -1
  121. package/build/cjs/dev/vite/index.js +44 -21
  122. package/build/cjs/dev/vite/index.js.map +1 -1
  123. package/build/cjs/dev/vite/instrumentFile.js +37 -20
  124. package/build/cjs/dev/vite/instrumentFile.js.map +1 -1
  125. package/build/cjs/dev/vite/mastraObservability.js +19 -12
  126. package/build/cjs/dev/vite/mastraObservability.js.map +1 -1
  127. package/build/cjs/dev/vite/moduleShape.js +220 -201
  128. package/build/cjs/dev/vite/moduleShape.js.map +1 -1
  129. package/build/cjs/dev/vite/providedModulePlugin.js +62 -45
  130. package/build/cjs/dev/vite/providedModulePlugin.js.map +1 -1
  131. package/build/cjs/dev/vite/transform.js +333 -284
  132. package/build/cjs/dev/vite/transform.js.map +1 -1
  133. package/build/cjs/dev/vite/workerEntrypoint.js +66 -57
  134. package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -1
  135. package/build/cjs/dev/vite/wranglerConfig.js +92 -67
  136. package/build/cjs/dev/vite/wranglerConfig.js.map +1 -1
  137. package/build/cjs/dev/withSentry.js +32 -26
  138. package/build/cjs/dev/withSentry.js.map +1 -1
  139. package/build/cjs/dev/workflows.js +165 -149
  140. package/build/cjs/dev/workflows.js.map +1 -1
  141. package/build/cjs/dev/wrapMethodWithSentry.js +148 -169
  142. package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -1
  143. package/build/cjs/dev/wrapRequestHandlerWithInit.js +78 -72
  144. package/build/cjs/dev/wrapRequestHandlerWithInit.js.map +1 -1
  145. package/build/cjs/prod/_virtual/_rolldown/runtime.js +22 -0
  146. package/build/cjs/prod/baseSdk.js +94 -93
  147. package/build/cjs/prod/baseSdk.js.map +1 -1
  148. package/build/cjs/prod/client.js +213 -237
  149. package/build/cjs/prod/client.js.map +1 -1
  150. package/build/cjs/prod/clientCache.js +8 -8
  151. package/build/cjs/prod/clientCache.js.map +1 -1
  152. package/build/cjs/prod/debug-build.js +9 -5
  153. package/build/cjs/prod/debug-build.js.map +1 -1
  154. package/build/cjs/prod/defineCloudflareOptions.js +5 -8
  155. package/build/cjs/prod/defineCloudflareOptions.js.map +1 -1
  156. package/build/cjs/prod/durableobject.js +290 -163
  157. package/build/cjs/prod/durableobject.js.map +1 -1
  158. package/build/cjs/prod/flush.js +104 -77
  159. package/build/cjs/prod/flush.js.map +1 -1
  160. package/build/cjs/prod/index.js +181 -182
  161. package/build/cjs/prod/instrument.js +53 -39
  162. package/build/cjs/prod/instrument.js.map +1 -1
  163. package/build/cjs/prod/instrumentations/agents/index.js +34 -13
  164. package/build/cjs/prod/instrumentations/agents/index.js.map +1 -1
  165. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
  166. package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  167. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
  168. package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  169. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
  170. package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  171. package/build/cjs/prod/instrumentations/agents/types.js +103 -58
  172. package/build/cjs/prod/instrumentations/agents/types.js.map +1 -1
  173. package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -118
  174. package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  175. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -44
  176. package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  177. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +70 -71
  178. package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  179. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
  180. package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  181. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +50 -52
  182. package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
  183. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -123
  184. package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  185. package/build/cjs/prod/instrumentations/worker/instrumentD1.js +131 -146
  186. package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  187. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -61
  188. package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  189. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +83 -87
  190. package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  191. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +41 -48
  192. package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  193. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +25 -21
  194. package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
  195. package/build/cjs/prod/instrumentations/worker/instrumentKV.js +54 -67
  196. package/build/cjs/prod/instrumentations/worker/instrumentKV.js.map +1 -1
  197. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +100 -76
  198. package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  199. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +91 -75
  200. package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  201. package/build/cjs/prod/instrumentations/worker/instrumentR2.js +128 -115
  202. package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  203. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +90 -94
  204. package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  205. package/build/cjs/prod/instrumentations/worker/instrumentTail.js +100 -55
  206. package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  207. package/build/cjs/prod/integrations/cronTriggers.js +130 -85
  208. package/build/cjs/prod/integrations/cronTriggers.js.map +1 -1
  209. package/build/cjs/prod/integrations/fetch.js +9 -9
  210. package/build/cjs/prod/integrations/fetch.js.map +1 -1
  211. package/build/cjs/prod/integrations/httpServer.js +41 -22
  212. package/build/cjs/prod/integrations/httpServer.js.map +1 -1
  213. package/build/cjs/prod/integrations/spotlight.js +52 -55
  214. package/build/cjs/prod/integrations/spotlight.js.map +1 -1
  215. package/build/cjs/prod/opentelemetry/tracer.js +10 -8
  216. package/build/cjs/prod/opentelemetry/tracer.js.map +1 -1
  217. package/build/cjs/prod/options.js +37 -24
  218. package/build/cjs/prod/options.js.map +1 -1
  219. package/build/cjs/prod/orchestrion-deferred-channels.js +45 -29
  220. package/build/cjs/prod/orchestrion-deferred-channels.js.map +1 -1
  221. package/build/cjs/prod/orchestrion-diagnostics-channel.js +97 -72
  222. package/build/cjs/prod/orchestrion-diagnostics-channel.js.map +1 -1
  223. package/build/cjs/prod/pages-plugin.js +20 -21
  224. package/build/cjs/prod/pages-plugin.js.map +1 -1
  225. package/build/cjs/prod/request.js +16 -10
  226. package/build/cjs/prod/request.js.map +1 -1
  227. package/build/cjs/prod/scope-utils.js +12 -12
  228. package/build/cjs/prod/scope-utils.js.map +1 -1
  229. package/build/cjs/prod/sdk.js +24 -15
  230. package/build/cjs/prod/sdk.js.map +1 -1
  231. package/build/cjs/prod/transport.js +93 -86
  232. package/build/cjs/prod/transport.js.map +1 -1
  233. package/build/cjs/prod/utils/asyncContextStrategy.js +10 -10
  234. package/build/cjs/prod/utils/asyncContextStrategy.js.map +1 -1
  235. package/build/cjs/prod/utils/bindingPropagation.js +24 -0
  236. package/build/cjs/prod/utils/bindingPropagation.js.map +1 -0
  237. package/build/cjs/prod/utils/cloudflareTrace.js +34 -0
  238. package/build/cjs/prod/utils/cloudflareTrace.js.map +1 -0
  239. package/build/cjs/prod/utils/instrumentContext.js +74 -58
  240. package/build/cjs/prod/utils/instrumentContext.js.map +1 -1
  241. package/build/cjs/prod/utils/internalSqlQuery.js +38 -21
  242. package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -1
  243. package/build/cjs/prod/utils/internalStorageKey.js +41 -38
  244. package/build/cjs/prod/utils/internalStorageKey.js.map +1 -1
  245. package/build/cjs/prod/utils/invocationContext.js +42 -32
  246. package/build/cjs/prod/utils/invocationContext.js.map +1 -1
  247. package/build/cjs/prod/utils/invocationScope.js +45 -21
  248. package/build/cjs/prod/utils/invocationScope.js.map +1 -1
  249. package/build/cjs/prod/utils/isBinding.js +47 -15
  250. package/build/cjs/prod/utils/isBinding.js.map +1 -1
  251. package/build/cjs/prod/utils/isCloudflareClass.js +11 -20
  252. package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -1
  253. package/build/cjs/prod/utils/queueTraceMeta.js +33 -0
  254. package/build/cjs/prod/utils/queueTraceMeta.js.map +1 -0
  255. package/build/cjs/prod/utils/rpcMeta.js +37 -27
  256. package/build/cjs/prod/utils/rpcMeta.js.map +1 -1
  257. package/build/cjs/prod/utils/traceLinks.js +52 -42
  258. package/build/cjs/prod/utils/traceLinks.js.map +1 -1
  259. package/build/cjs/prod/vendor/stacktrace.js +32 -24
  260. package/build/cjs/prod/vendor/stacktrace.js.map +1 -1
  261. package/build/cjs/prod/vite/agentClass.js +105 -98
  262. package/build/cjs/prod/vite/agentClass.js.map +1 -1
  263. package/build/cjs/prod/vite/autoInstrument.js +121 -122
  264. package/build/cjs/prod/vite/autoInstrument.js.map +1 -1
  265. package/build/cjs/prod/vite/index.js +44 -21
  266. package/build/cjs/prod/vite/index.js.map +1 -1
  267. package/build/cjs/prod/vite/instrumentFile.js +37 -20
  268. package/build/cjs/prod/vite/instrumentFile.js.map +1 -1
  269. package/build/cjs/prod/vite/mastraObservability.js +19 -12
  270. package/build/cjs/prod/vite/mastraObservability.js.map +1 -1
  271. package/build/cjs/prod/vite/moduleShape.js +220 -201
  272. package/build/cjs/prod/vite/moduleShape.js.map +1 -1
  273. package/build/cjs/prod/vite/providedModulePlugin.js +62 -45
  274. package/build/cjs/prod/vite/providedModulePlugin.js.map +1 -1
  275. package/build/cjs/prod/vite/transform.js +333 -284
  276. package/build/cjs/prod/vite/transform.js.map +1 -1
  277. package/build/cjs/prod/vite/workerEntrypoint.js +66 -57
  278. package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -1
  279. package/build/cjs/prod/vite/wranglerConfig.js +92 -67
  280. package/build/cjs/prod/vite/wranglerConfig.js.map +1 -1
  281. package/build/cjs/prod/withSentry.js +32 -26
  282. package/build/cjs/prod/withSentry.js.map +1 -1
  283. package/build/cjs/prod/workflows.js +165 -149
  284. package/build/cjs/prod/workflows.js.map +1 -1
  285. package/build/cjs/prod/wrapMethodWithSentry.js +148 -169
  286. package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -1
  287. package/build/cjs/prod/wrapRequestHandlerWithInit.js +78 -72
  288. package/build/cjs/prod/wrapRequestHandlerWithInit.js.map +1 -1
  289. package/build/esm/dev/baseSdk.js +98 -101
  290. package/build/esm/dev/baseSdk.js.map +1 -1
  291. package/build/esm/dev/client.js +213 -235
  292. package/build/esm/dev/client.js.map +1 -1
  293. package/build/esm/dev/clientCache.js +8 -6
  294. package/build/esm/dev/clientCache.js.map +1 -1
  295. package/build/esm/dev/debug-build.js +9 -3
  296. package/build/esm/dev/debug-build.js.map +1 -1
  297. package/build/esm/dev/defineCloudflareOptions.js +5 -6
  298. package/build/esm/dev/defineCloudflareOptions.js.map +1 -1
  299. package/build/esm/dev/durableobject.js +290 -161
  300. package/build/esm/dev/durableobject.js.map +1 -1
  301. package/build/esm/dev/flush.js +104 -75
  302. package/build/esm/dev/flush.js.map +1 -1
  303. package/build/esm/dev/index.js +19 -18
  304. package/build/esm/dev/instrument.js +53 -37
  305. package/build/esm/dev/instrument.js.map +1 -1
  306. package/build/esm/dev/instrumentations/agents/index.js +34 -11
  307. package/build/esm/dev/instrumentations/agents/index.js.map +1 -1
  308. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
  309. package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  310. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
  311. package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  312. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
  313. package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  314. package/build/esm/dev/instrumentations/agents/types.js +103 -56
  315. package/build/esm/dev/instrumentations/agents/types.js.map +1 -1
  316. package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -116
  317. package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  318. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -42
  319. package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  320. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js +70 -69
  321. package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  322. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
  323. package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  324. package/build/esm/dev/instrumentations/instrumentSqlStorage.js +50 -50
  325. package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
  326. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -121
  327. package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  328. package/build/esm/dev/instrumentations/worker/instrumentD1.js +131 -144
  329. package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -1
  330. package/build/esm/dev/instrumentations/worker/instrumentEmail.js +63 -59
  331. package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
  332. package/build/esm/dev/instrumentations/worker/instrumentEnv.js +83 -85
  333. package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
  334. package/build/esm/dev/instrumentations/worker/instrumentFetch.js +41 -46
  335. package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
  336. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js +25 -19
  337. package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
  338. package/build/esm/dev/instrumentations/worker/instrumentKV.js +54 -65
  339. package/build/esm/dev/instrumentations/worker/instrumentKV.js.map +1 -1
  340. package/build/esm/dev/instrumentations/worker/instrumentQueue.js +100 -74
  341. package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
  342. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js +91 -73
  343. package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  344. package/build/esm/dev/instrumentations/worker/instrumentR2.js +128 -113
  345. package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -1
  346. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js +90 -92
  347. package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
  348. package/build/esm/dev/instrumentations/worker/instrumentTail.js +100 -53
  349. package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -1
  350. package/build/esm/dev/integrations/cronTriggers.js +129 -82
  351. package/build/esm/dev/integrations/cronTriggers.js.map +1 -1
  352. package/build/esm/dev/integrations/fetch.js +9 -6
  353. package/build/esm/dev/integrations/fetch.js.map +1 -1
  354. package/build/esm/dev/integrations/httpServer.js +40 -19
  355. package/build/esm/dev/integrations/httpServer.js.map +1 -1
  356. package/build/esm/dev/integrations/spotlight.js +51 -52
  357. package/build/esm/dev/integrations/spotlight.js.map +1 -1
  358. package/build/esm/dev/opentelemetry/tracer.js +10 -6
  359. package/build/esm/dev/opentelemetry/tracer.js.map +1 -1
  360. package/build/esm/dev/options.js +55 -37
  361. package/build/esm/dev/options.js.map +1 -1
  362. package/build/esm/dev/orchestrion-deferred-channels.js +45 -27
  363. package/build/esm/dev/orchestrion-deferred-channels.js.map +1 -1
  364. package/build/esm/dev/orchestrion-diagnostics-channel.js +87 -66
  365. package/build/esm/dev/orchestrion-diagnostics-channel.js.map +1 -1
  366. package/build/esm/dev/package.json +1 -1
  367. package/build/esm/dev/pages-plugin.js +20 -19
  368. package/build/esm/dev/pages-plugin.js.map +1 -1
  369. package/build/esm/dev/request.js +14 -7
  370. package/build/esm/dev/request.js.map +1 -1
  371. package/build/esm/dev/scope-utils.js +12 -10
  372. package/build/esm/dev/scope-utils.js.map +1 -1
  373. package/build/esm/dev/sdk.js +23 -13
  374. package/build/esm/dev/sdk.js.map +1 -1
  375. package/build/esm/dev/transport.js +93 -84
  376. package/build/esm/dev/transport.js.map +1 -1
  377. package/build/esm/dev/utils/asyncContextStrategy.js +10 -8
  378. package/build/esm/dev/utils/asyncContextStrategy.js.map +1 -1
  379. package/build/esm/dev/utils/bindingPropagation.js +23 -0
  380. package/build/esm/dev/utils/bindingPropagation.js.map +1 -0
  381. package/build/esm/dev/utils/cloudflareTrace.js +34 -0
  382. package/build/esm/dev/utils/cloudflareTrace.js.map +1 -0
  383. package/build/esm/dev/utils/instrumentContext.js +74 -56
  384. package/build/esm/dev/utils/instrumentContext.js.map +1 -1
  385. package/build/esm/dev/utils/internalSqlQuery.js +38 -19
  386. package/build/esm/dev/utils/internalSqlQuery.js.map +1 -1
  387. package/build/esm/dev/utils/internalStorageKey.js +41 -36
  388. package/build/esm/dev/utils/internalStorageKey.js.map +1 -1
  389. package/build/esm/dev/utils/invocationContext.js +42 -30
  390. package/build/esm/dev/utils/invocationContext.js.map +1 -1
  391. package/build/esm/dev/utils/invocationScope.js +45 -19
  392. package/build/esm/dev/utils/invocationScope.js.map +1 -1
  393. package/build/esm/dev/utils/isBinding.js +47 -13
  394. package/build/esm/dev/utils/isBinding.js.map +1 -1
  395. package/build/esm/dev/utils/isCloudflareClass.js +11 -18
  396. package/build/esm/dev/utils/isCloudflareClass.js.map +1 -1
  397. package/build/esm/dev/utils/queueTraceMeta.js +32 -0
  398. package/build/esm/dev/utils/queueTraceMeta.js.map +1 -0
  399. package/build/esm/dev/utils/rpcMeta.js +37 -25
  400. package/build/esm/dev/utils/rpcMeta.js.map +1 -1
  401. package/build/esm/dev/utils/traceLinks.js +52 -40
  402. package/build/esm/dev/utils/traceLinks.js.map +1 -1
  403. package/build/esm/dev/vendor/stacktrace.js +31 -21
  404. package/build/esm/dev/vendor/stacktrace.js.map +1 -1
  405. package/build/esm/dev/vite/agentClass.js +105 -96
  406. package/build/esm/dev/vite/agentClass.js.map +1 -1
  407. package/build/esm/dev/vite/autoInstrument.js +121 -120
  408. package/build/esm/dev/vite/autoInstrument.js.map +1 -1
  409. package/build/esm/dev/vite/index.js +43 -19
  410. package/build/esm/dev/vite/index.js.map +1 -1
  411. package/build/esm/dev/vite/instrumentFile.js +37 -18
  412. package/build/esm/dev/vite/instrumentFile.js.map +1 -1
  413. package/build/esm/dev/vite/mastraObservability.js +19 -10
  414. package/build/esm/dev/vite/mastraObservability.js.map +1 -1
  415. package/build/esm/dev/vite/moduleShape.js +220 -199
  416. package/build/esm/dev/vite/moduleShape.js.map +1 -1
  417. package/build/esm/dev/vite/providedModulePlugin.js +60 -43
  418. package/build/esm/dev/vite/providedModulePlugin.js.map +1 -1
  419. package/build/esm/dev/vite/transform.js +331 -282
  420. package/build/esm/dev/vite/transform.js.map +1 -1
  421. package/build/esm/dev/vite/workerEntrypoint.js +66 -55
  422. package/build/esm/dev/vite/workerEntrypoint.js.map +1 -1
  423. package/build/esm/dev/vite/wranglerConfig.js +92 -65
  424. package/build/esm/dev/vite/wranglerConfig.js.map +1 -1
  425. package/build/esm/dev/withSentry.js +32 -24
  426. package/build/esm/dev/withSentry.js.map +1 -1
  427. package/build/esm/dev/workflows.js +165 -147
  428. package/build/esm/dev/workflows.js.map +1 -1
  429. package/build/esm/dev/wrapMethodWithSentry.js +148 -167
  430. package/build/esm/dev/wrapMethodWithSentry.js.map +1 -1
  431. package/build/esm/dev/wrapRequestHandlerWithInit.js +78 -70
  432. package/build/esm/dev/wrapRequestHandlerWithInit.js.map +1 -1
  433. package/build/esm/prod/baseSdk.js +94 -91
  434. package/build/esm/prod/baseSdk.js.map +1 -1
  435. package/build/esm/prod/client.js +213 -235
  436. package/build/esm/prod/client.js.map +1 -1
  437. package/build/esm/prod/clientCache.js +8 -6
  438. package/build/esm/prod/clientCache.js.map +1 -1
  439. package/build/esm/prod/debug-build.js +9 -3
  440. package/build/esm/prod/debug-build.js.map +1 -1
  441. package/build/esm/prod/defineCloudflareOptions.js +5 -6
  442. package/build/esm/prod/defineCloudflareOptions.js.map +1 -1
  443. package/build/esm/prod/durableobject.js +290 -161
  444. package/build/esm/prod/durableobject.js.map +1 -1
  445. package/build/esm/prod/flush.js +104 -75
  446. package/build/esm/prod/flush.js.map +1 -1
  447. package/build/esm/prod/index.js +19 -18
  448. package/build/esm/prod/instrument.js +53 -37
  449. package/build/esm/prod/instrument.js.map +1 -1
  450. package/build/esm/prod/instrumentations/agents/index.js +34 -11
  451. package/build/esm/prod/instrumentations/agents/index.js.map +1 -1
  452. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
  453. package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
  454. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
  455. package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
  456. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
  457. package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
  458. package/build/esm/prod/instrumentations/agents/types.js +103 -56
  459. package/build/esm/prod/instrumentations/agents/types.js.map +1 -1
  460. package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -116
  461. package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
  462. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -42
  463. package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  464. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -69
  465. package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  466. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
  467. package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
  468. package/build/esm/prod/instrumentations/instrumentSqlStorage.js +50 -50
  469. package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
  470. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -121
  471. package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  472. package/build/esm/prod/instrumentations/worker/instrumentD1.js +131 -144
  473. package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -1
  474. package/build/esm/prod/instrumentations/worker/instrumentEmail.js +63 -59
  475. package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
  476. package/build/esm/prod/instrumentations/worker/instrumentEnv.js +83 -85
  477. package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
  478. package/build/esm/prod/instrumentations/worker/instrumentFetch.js +41 -46
  479. package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
  480. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +25 -19
  481. package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
  482. package/build/esm/prod/instrumentations/worker/instrumentKV.js +54 -65
  483. package/build/esm/prod/instrumentations/worker/instrumentKV.js.map +1 -1
  484. package/build/esm/prod/instrumentations/worker/instrumentQueue.js +100 -74
  485. package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
  486. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +91 -73
  487. package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  488. package/build/esm/prod/instrumentations/worker/instrumentR2.js +128 -113
  489. package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -1
  490. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +90 -92
  491. package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
  492. package/build/esm/prod/instrumentations/worker/instrumentTail.js +100 -53
  493. package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -1
  494. package/build/esm/prod/integrations/cronTriggers.js +129 -82
  495. package/build/esm/prod/integrations/cronTriggers.js.map +1 -1
  496. package/build/esm/prod/integrations/fetch.js +9 -6
  497. package/build/esm/prod/integrations/fetch.js.map +1 -1
  498. package/build/esm/prod/integrations/httpServer.js +40 -19
  499. package/build/esm/prod/integrations/httpServer.js.map +1 -1
  500. package/build/esm/prod/integrations/spotlight.js +51 -52
  501. package/build/esm/prod/integrations/spotlight.js.map +1 -1
  502. package/build/esm/prod/opentelemetry/tracer.js +10 -6
  503. package/build/esm/prod/opentelemetry/tracer.js.map +1 -1
  504. package/build/esm/prod/options.js +37 -22
  505. package/build/esm/prod/options.js.map +1 -1
  506. package/build/esm/prod/orchestrion-deferred-channels.js +45 -27
  507. package/build/esm/prod/orchestrion-deferred-channels.js.map +1 -1
  508. package/build/esm/prod/orchestrion-diagnostics-channel.js +87 -66
  509. package/build/esm/prod/orchestrion-diagnostics-channel.js.map +1 -1
  510. package/build/esm/prod/package.json +1 -1
  511. package/build/esm/prod/pages-plugin.js +20 -19
  512. package/build/esm/prod/pages-plugin.js.map +1 -1
  513. package/build/esm/prod/request.js +14 -7
  514. package/build/esm/prod/request.js.map +1 -1
  515. package/build/esm/prod/scope-utils.js +12 -10
  516. package/build/esm/prod/scope-utils.js.map +1 -1
  517. package/build/esm/prod/sdk.js +23 -13
  518. package/build/esm/prod/sdk.js.map +1 -1
  519. package/build/esm/prod/transport.js +93 -84
  520. package/build/esm/prod/transport.js.map +1 -1
  521. package/build/esm/prod/utils/asyncContextStrategy.js +10 -8
  522. package/build/esm/prod/utils/asyncContextStrategy.js.map +1 -1
  523. package/build/esm/prod/utils/bindingPropagation.js +23 -0
  524. package/build/esm/prod/utils/bindingPropagation.js.map +1 -0
  525. package/build/esm/prod/utils/cloudflareTrace.js +34 -0
  526. package/build/esm/prod/utils/cloudflareTrace.js.map +1 -0
  527. package/build/esm/prod/utils/instrumentContext.js +74 -56
  528. package/build/esm/prod/utils/instrumentContext.js.map +1 -1
  529. package/build/esm/prod/utils/internalSqlQuery.js +38 -19
  530. package/build/esm/prod/utils/internalSqlQuery.js.map +1 -1
  531. package/build/esm/prod/utils/internalStorageKey.js +41 -36
  532. package/build/esm/prod/utils/internalStorageKey.js.map +1 -1
  533. package/build/esm/prod/utils/invocationContext.js +42 -30
  534. package/build/esm/prod/utils/invocationContext.js.map +1 -1
  535. package/build/esm/prod/utils/invocationScope.js +45 -19
  536. package/build/esm/prod/utils/invocationScope.js.map +1 -1
  537. package/build/esm/prod/utils/isBinding.js +47 -13
  538. package/build/esm/prod/utils/isBinding.js.map +1 -1
  539. package/build/esm/prod/utils/isCloudflareClass.js +11 -18
  540. package/build/esm/prod/utils/isCloudflareClass.js.map +1 -1
  541. package/build/esm/prod/utils/queueTraceMeta.js +32 -0
  542. package/build/esm/prod/utils/queueTraceMeta.js.map +1 -0
  543. package/build/esm/prod/utils/rpcMeta.js +37 -25
  544. package/build/esm/prod/utils/rpcMeta.js.map +1 -1
  545. package/build/esm/prod/utils/traceLinks.js +52 -40
  546. package/build/esm/prod/utils/traceLinks.js.map +1 -1
  547. package/build/esm/prod/vendor/stacktrace.js +31 -21
  548. package/build/esm/prod/vendor/stacktrace.js.map +1 -1
  549. package/build/esm/prod/vite/agentClass.js +105 -96
  550. package/build/esm/prod/vite/agentClass.js.map +1 -1
  551. package/build/esm/prod/vite/autoInstrument.js +121 -120
  552. package/build/esm/prod/vite/autoInstrument.js.map +1 -1
  553. package/build/esm/prod/vite/index.js +43 -19
  554. package/build/esm/prod/vite/index.js.map +1 -1
  555. package/build/esm/prod/vite/instrumentFile.js +37 -18
  556. package/build/esm/prod/vite/instrumentFile.js.map +1 -1
  557. package/build/esm/prod/vite/mastraObservability.js +19 -10
  558. package/build/esm/prod/vite/mastraObservability.js.map +1 -1
  559. package/build/esm/prod/vite/moduleShape.js +220 -199
  560. package/build/esm/prod/vite/moduleShape.js.map +1 -1
  561. package/build/esm/prod/vite/providedModulePlugin.js +60 -43
  562. package/build/esm/prod/vite/providedModulePlugin.js.map +1 -1
  563. package/build/esm/prod/vite/transform.js +331 -282
  564. package/build/esm/prod/vite/transform.js.map +1 -1
  565. package/build/esm/prod/vite/workerEntrypoint.js +66 -55
  566. package/build/esm/prod/vite/workerEntrypoint.js.map +1 -1
  567. package/build/esm/prod/vite/wranglerConfig.js +92 -65
  568. package/build/esm/prod/vite/wranglerConfig.js.map +1 -1
  569. package/build/esm/prod/withSentry.js +32 -24
  570. package/build/esm/prod/withSentry.js.map +1 -1
  571. package/build/esm/prod/workflows.js +165 -147
  572. package/build/esm/prod/workflows.js.map +1 -1
  573. package/build/esm/prod/wrapMethodWithSentry.js +148 -167
  574. package/build/esm/prod/wrapMethodWithSentry.js.map +1 -1
  575. package/build/esm/prod/wrapRequestHandlerWithInit.js +78 -70
  576. package/build/esm/prod/wrapRequestHandlerWithInit.js.map +1 -1
  577. package/build/types/client.d.ts +32 -1
  578. package/build/types/client.d.ts.map +1 -1
  579. package/build/types/durableobject.d.ts.map +1 -1
  580. package/build/types/index.d.ts +3 -2
  581. package/build/types/index.d.ts.map +1 -1
  582. package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
  583. package/build/types/instrumentations/worker/instrumentEnv.d.ts +1 -1
  584. package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -1
  585. package/build/types/instrumentations/worker/instrumentFetcher.d.ts.map +1 -1
  586. package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
  587. package/build/types/instrumentations/worker/instrumentQueueProducer.d.ts +1 -1
  588. package/build/types/instrumentations/worker/instrumentQueueProducer.d.ts.map +1 -1
  589. package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
  590. package/build/types/instrumentations/worker/instrumentTail.d.ts +4 -2
  591. package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
  592. package/build/types/utils/{rpcPropagation.d.ts → bindingPropagation.d.ts} +6 -1
  593. package/build/types/utils/bindingPropagation.d.ts.map +1 -0
  594. package/build/types/utils/cloudflareTrace.d.ts +13 -0
  595. package/build/types/utils/cloudflareTrace.d.ts.map +1 -0
  596. package/build/types/utils/queueTraceMeta.d.ts +7 -0
  597. package/build/types/utils/queueTraceMeta.d.ts.map +1 -0
  598. package/build/types/vite/autoInstrument.d.ts.map +1 -1
  599. package/build/types/vite/index.d.ts.map +1 -1
  600. package/build/types/vite/providedModulePlugin.d.ts +15 -11
  601. package/build/types/vite/providedModulePlugin.d.ts.map +1 -1
  602. package/build/types/workflows.d.ts.map +1 -1
  603. package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
  604. package/build/types/wrapRequestHandlerWithInit.d.ts.map +1 -1
  605. package/package.json +20 -21
  606. package/build/cjs/dev/index.js.map +0 -1
  607. package/build/cjs/dev/utils/rpcPropagation.js +0 -15
  608. package/build/cjs/dev/utils/rpcPropagation.js.map +0 -1
  609. package/build/cjs/dev/vite/flueRuntime.js +0 -15
  610. package/build/cjs/dev/vite/flueRuntime.js.map +0 -1
  611. package/build/cjs/prod/index.js.map +0 -1
  612. package/build/cjs/prod/utils/rpcPropagation.js +0 -15
  613. package/build/cjs/prod/utils/rpcPropagation.js.map +0 -1
  614. package/build/cjs/prod/vite/flueRuntime.js +0 -15
  615. package/build/cjs/prod/vite/flueRuntime.js.map +0 -1
  616. package/build/esm/dev/index.js.map +0 -1
  617. package/build/esm/dev/utils/rpcPropagation.js +0 -13
  618. package/build/esm/dev/utils/rpcPropagation.js.map +0 -1
  619. package/build/esm/dev/vite/flueRuntime.js +0 -13
  620. package/build/esm/dev/vite/flueRuntime.js.map +0 -1
  621. package/build/esm/prod/index.js.map +0 -1
  622. package/build/esm/prod/utils/rpcPropagation.js +0 -13
  623. package/build/esm/prod/utils/rpcPropagation.js.map +0 -1
  624. package/build/esm/prod/vite/flueRuntime.js +0 -13
  625. package/build/esm/prod/vite/flueRuntime.js.map +0 -1
  626. package/build/types/utils/rpcPropagation.d.ts.map +0 -1
  627. package/build/types/vite/flueRuntime.d.ts +0 -12
  628. package/build/types/vite/flueRuntime.d.ts.map +0 -1
@@ -1,174 +1,153 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const attributes = require('@sentry/conventions/attributes');
4
- const op = require('@sentry/conventions/op');
5
- const core = require('@sentry/core');
6
- const flush = require('./flush.js');
7
- const instrument = require('./instrument.js');
8
- const sdk = require('./sdk.js');
9
- const invocationContext = require('./utils/invocationContext.js');
10
- const invocationScope = require('./utils/invocationScope.js');
11
- const rpcMeta = require('./utils/rpcMeta.js');
12
- const traceLinks = require('./utils/traceLinks.js');
13
-
1
+ const require_flush = require("./flush.js");
2
+ const require_instrument = require("./instrument.js");
3
+ const require_sdk = require("./sdk.js");
4
+ const require_cloudflareTrace = require("./utils/cloudflareTrace.js");
5
+ const require_invocationContext = require("./utils/invocationContext.js");
6
+ const require_invocationScope = require("./utils/invocationScope.js");
7
+ const require_rpcMeta = require("./utils/rpcMeta.js");
8
+ const require_traceLinks = require("./utils/traceLinks.js");
9
+ let _sentry_core = require("@sentry/core");
10
+ let _sentry_conventions_attributes = require("@sentry/conventions/attributes");
11
+ let _sentry_conventions_op = require("@sentry/conventions/op");
12
+ // src/wrapMethodWithSentry.ts
13
+ /**
14
+ * Resolves uninstrumented DO storage for the current invocation.
15
+ * Prefer `thisArg.ctx` (the live Durable Object instance) over the context captured at
16
+ * construction time to avoid cross-DO I/O errors in the same isolate.
17
+ */
14
18
  function resolveOriginalStorage(context, thisArg) {
15
- if (core.isObjectLike(thisArg) && "ctx" in thisArg) {
16
- const doCtx = thisArg.ctx;
17
- if (doCtx?.originalStorage) {
18
- return doCtx.originalStorage;
19
- }
20
- }
21
- if (context && "originalStorage" in context && context.originalStorage) {
22
- return context.originalStorage;
23
- }
24
- return void 0;
19
+ if ((0, _sentry_core.isObjectLike)(thisArg) && "ctx" in thisArg) {
20
+ const doCtx = thisArg.ctx;
21
+ if (doCtx?.originalStorage) return doCtx.originalStorage;
22
+ }
23
+ if (context && "originalStorage" in context && context.originalStorage) return context.originalStorage;
25
24
  }
25
+ /**
26
+ * Wraps a method with Sentry error tracking and optional tracing.
27
+ * Supports starting new traces and linking to previous invocations via Durable Object storage.
28
+ *
29
+ * @param wrapperOptions - The options for the wrapper.
30
+ * @param handler - The method to wrap.
31
+ * @param callback - The callback to call.
32
+ * @param noMark - Whether to mark the method as instrumented.
33
+ * @returns The wrapped method.
34
+ */
26
35
  function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
27
- return instrument.ensureInstrumented(
28
- handler,
29
- (original) => new Proxy(original, {
30
- apply(target, thisArg, rawArgs) {
31
- const { startNewTrace, origin } = wrapperOptions;
32
- let args = rawArgs;
33
- let rpcMeta$1;
34
- if (wrapperOptions.spanOp === "rpc") {
35
- const extracted = rpcMeta.extractRpcMeta(rawArgs);
36
- args = extracted.args;
37
- rpcMeta$1 = extracted.rpcMeta;
38
- }
39
- const spanName = typeof wrapperOptions.spanName === "function" ? wrapperOptions.spanName(rpcMeta$1) : wrapperOptions.spanName;
40
- const wrappedFunction = (scope) => {
41
- const context = wrapperOptions.context;
42
- const invocationState = invocationContext.getInvocationState();
43
- const waitUntil = invocationState ? invocationContext.getInvocationWaitUntil(invocationState) : context ? flush.getOriginalWaitUntil(context)?.bind(context) : void 0;
44
- const storage = resolveOriginalStorage(context, thisArg);
45
- let scopeClient = scope.getClient();
46
- if (startNewTrace || !scopeClient?.getTransport()) {
47
- const client = sdk.init({
48
- ...wrapperOptions.options,
49
- ctx: context
50
- });
51
- scope.setClient(client);
52
- scopeClient = client;
53
- }
54
- const clientToDispose = scopeClient;
55
- const methodName = spanName || "unknown";
56
- const teardown = async () => {
57
- if (startNewTrace && storage) {
58
- traceLinks.storeSpanContext(storage, methodName);
59
- }
60
- await flush.flushAndDispose(clientToDispose);
61
- };
62
- const onFulfilled = (res) => {
63
- waitUntil?.(teardown());
64
- return res;
65
- };
66
- const captureAndRethrow = (e) => {
67
- core.captureException(e, {
68
- mechanism: {
69
- type: origin,
70
- handled: false
71
- }
72
- });
73
- throw e;
74
- };
75
- const onRejected = (e) => {
76
- try {
77
- return captureAndRethrow(e);
78
- } finally {
79
- waitUntil?.(teardown());
80
- }
81
- };
82
- if (!spanName) {
83
- try {
84
- if (callback) {
85
- callback(...args);
86
- }
87
- const result = Reflect.apply(target, thisArg, args);
88
- if (core.isThenable(result)) {
89
- return result.then(onFulfilled, onRejected);
90
- } else {
91
- return onFulfilled(result);
92
- }
93
- } catch (e) {
94
- return onRejected(e);
95
- }
96
- }
97
- const attributes$1 = wrapperOptions.spanOp ? {
98
- [attributes.SENTRY_OP]: wrapperOptions.spanOp,
99
- [attributes.SENTRY_ORIGIN]: origin,
100
- // `function` spans are already named like their function name, so we just set `code.function.name` here.
101
- ...wrapperOptions.spanOp === op.FUNCTION && { [attributes.CODE_FUNCTION_NAME]: methodName }
102
- } : {};
103
- const executeSpan = () => {
104
- return core.startSpan({ name: methodName, attributes: attributes$1 }, (span) => {
105
- if (startNewTrace && storage) {
106
- const storedContext = traceLinks.getStoredSpanContext(storage, methodName);
107
- if (storedContext) {
108
- span.addLinks(traceLinks.buildSpanLinks(storedContext));
109
- const sampledFlag = storedContext.sampled ? "1" : "0";
110
- span.setAttribute(
111
- "sentry.previous_trace",
112
- `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`
113
- );
114
- }
115
- }
116
- try {
117
- const result = Reflect.apply(target, thisArg, args);
118
- if (core.isThenable(result)) {
119
- return result.then(void 0, captureAndRethrow);
120
- }
121
- return result;
122
- } catch (e) {
123
- return captureAndRethrow(e);
124
- }
125
- });
126
- };
127
- const runWithTeardown = (run) => {
128
- let out;
129
- try {
130
- out = run();
131
- } catch (e) {
132
- waitUntil?.(teardown());
133
- throw e;
134
- }
135
- if (core.isThenable(out)) {
136
- return out.then(
137
- (res) => {
138
- waitUntil?.(teardown());
139
- return res;
140
- },
141
- (e) => {
142
- waitUntil?.(teardown());
143
- throw e;
144
- }
145
- );
146
- }
147
- waitUntil?.(teardown());
148
- return out;
149
- };
150
- if (rpcMeta$1) {
151
- return runWithTeardown(
152
- () => core.continueTrace(
153
- { sentryTrace: rpcMeta$1["sentry-trace"] || "", baggage: rpcMeta$1.baggage || "" },
154
- executeSpan
155
- )
156
- );
157
- }
158
- if (startNewTrace) {
159
- return runWithTeardown(() => core.startNewTrace(() => executeSpan()));
160
- }
161
- return runWithTeardown(executeSpan);
162
- };
163
- return invocationScope.withInvocationIsolationScope(
164
- wrappedFunction,
165
- wrapperOptions.context
166
- );
167
- }
168
- }),
169
- noMark
170
- );
36
+ return require_instrument.ensureInstrumented(handler, (original) => new Proxy(original, { apply(target, thisArg, rawArgs) {
37
+ const { startNewTrace, origin } = wrapperOptions;
38
+ let args = rawArgs;
39
+ let rpcMeta;
40
+ if (wrapperOptions.spanOp === "rpc") {
41
+ const extracted = require_rpcMeta.extractRpcMeta(rawArgs);
42
+ args = extracted.args;
43
+ rpcMeta = extracted.rpcMeta;
44
+ }
45
+ const spanName = typeof wrapperOptions.spanName === "function" ? wrapperOptions.spanName(rpcMeta) : wrapperOptions.spanName;
46
+ const wrappedFunction = (scope) => {
47
+ const context = wrapperOptions.context;
48
+ const invocationState = require_invocationContext.getInvocationState();
49
+ const waitUntil = invocationState ? require_invocationContext.getInvocationWaitUntil(invocationState) : context ? require_flush.getOriginalWaitUntil(context)?.bind(context) : void 0;
50
+ const storage = resolveOriginalStorage(context, thisArg);
51
+ let scopeClient = scope.getClient();
52
+ if (startNewTrace || !scopeClient?.getTransport()) {
53
+ const client = require_sdk.init({
54
+ ...wrapperOptions.options,
55
+ ctx: context
56
+ });
57
+ scope.setClient(client);
58
+ scopeClient = client;
59
+ }
60
+ const clientToDispose = scopeClient;
61
+ const methodName = spanName || "unknown";
62
+ const teardown = async () => {
63
+ if (startNewTrace && storage) require_traceLinks.storeSpanContext(storage, methodName);
64
+ await require_flush.flushAndDispose(clientToDispose);
65
+ };
66
+ const onFulfilled = (res) => {
67
+ waitUntil?.(teardown());
68
+ return res;
69
+ };
70
+ const captureAndRethrow = (e) => {
71
+ (0, _sentry_core.captureException)(e, { mechanism: {
72
+ type: origin,
73
+ handled: false
74
+ } });
75
+ throw e;
76
+ };
77
+ const onRejected = (e) => {
78
+ try {
79
+ return captureAndRethrow(e);
80
+ } finally {
81
+ waitUntil?.(teardown());
82
+ }
83
+ };
84
+ require_cloudflareTrace.continueCloudflareTrace(context);
85
+ if (!spanName) try {
86
+ if (callback) callback(...args);
87
+ const result = Reflect.apply(target, thisArg, args);
88
+ if ((0, _sentry_core.isThenable)(result)) return result.then(onFulfilled, onRejected);
89
+ else return onFulfilled(result);
90
+ } catch (e) {
91
+ return onRejected(e);
92
+ }
93
+ const attributes = wrapperOptions.spanOp ? {
94
+ [_sentry_conventions_attributes.SENTRY_OP]: wrapperOptions.spanOp,
95
+ [_sentry_conventions_attributes.SENTRY_ORIGIN]: origin,
96
+ ...wrapperOptions.spanOp === _sentry_conventions_op.FUNCTION && { [_sentry_conventions_attributes.CODE_FUNCTION_NAME]: methodName }
97
+ } : {};
98
+ const executeSpan = () => {
99
+ return (0, _sentry_core.startSpan)({
100
+ name: methodName,
101
+ attributes
102
+ }, (span) => {
103
+ if (startNewTrace && storage) {
104
+ const storedContext = require_traceLinks.getStoredSpanContext(storage, methodName);
105
+ if (storedContext) {
106
+ span.addLinks(require_traceLinks.buildSpanLinks(storedContext));
107
+ const sampledFlag = storedContext.sampled ? "1" : "0";
108
+ span.setAttribute("sentry.previous_trace", `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`);
109
+ }
110
+ }
111
+ try {
112
+ const result = Reflect.apply(target, thisArg, args);
113
+ if ((0, _sentry_core.isThenable)(result)) return result.then(void 0, captureAndRethrow);
114
+ return result;
115
+ } catch (e) {
116
+ return captureAndRethrow(e);
117
+ }
118
+ });
119
+ };
120
+ const runWithTeardown = (run) => {
121
+ let out;
122
+ try {
123
+ out = run();
124
+ } catch (e) {
125
+ waitUntil?.(teardown());
126
+ throw e;
127
+ }
128
+ if ((0, _sentry_core.isThenable)(out)) return out.then((res) => {
129
+ waitUntil?.(teardown());
130
+ return res;
131
+ }, (e) => {
132
+ waitUntil?.(teardown());
133
+ throw e;
134
+ });
135
+ waitUntil?.(teardown());
136
+ return out;
137
+ };
138
+ if (rpcMeta) return runWithTeardown(() => (0, _sentry_core.continueTrace)({
139
+ sentryTrace: rpcMeta["sentry-trace"] || "",
140
+ baggage: rpcMeta.baggage || ""
141
+ }, () => {
142
+ require_cloudflareTrace.continueCloudflareTrace(context);
143
+ return executeSpan();
144
+ }));
145
+ if (startNewTrace) return runWithTeardown(() => (0, _sentry_core.startNewTrace)(() => executeSpan()));
146
+ return runWithTeardown(executeSpan);
147
+ };
148
+ return require_invocationScope.withInvocationIsolationScope(wrappedFunction, wrapperOptions.context);
149
+ } }), noMark);
171
150
  }
172
-
173
151
  exports.wrapMethodWithSentry = wrapMethodWithSentry;
174
- //# sourceMappingURL=wrapMethodWithSentry.js.map
152
+
153
+ //# sourceMappingURL=wrapMethodWithSentry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrapMethodWithSentry.js","sources":["../../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport { CODE_FUNCTION_NAME, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport { FUNCTION } from '@sentry/conventions/op';\nimport {\n isObjectLike,\n captureException,\n continueTrace,\n isThenable,\n type Scope,\n startNewTrace as startNewTraceCore,\n startSpan,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { getInvocationState, getInvocationWaitUntil } from './utils/invocationContext';\nimport { withInvocationIsolationScope } from './utils/invocationScope';\nimport { extractRpcMeta } from './utils/rpcMeta';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\nexport interface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\n/**\n * Resolves uninstrumented DO storage for the current invocation.\n * Prefer `thisArg.ctx` (the live Durable Object instance) over the context captured at\n * construction time to avoid cross-DO I/O errors in the same isolate.\n */\nfunction resolveOriginalStorage(\n context: ExecutionContext | InstrumentedDurableObjectState | undefined,\n thisArg: unknown,\n): DurableObjectStorage | undefined {\n if (isObjectLike(thisArg) && 'ctx' in thisArg) {\n const doCtx = (thisArg as { ctx: InstrumentedDurableObjectState }).ctx;\n if (doCtx?.originalStorage) {\n return doCtx.originalStorage;\n }\n }\n\n if (context && 'originalStorage' in context && context.originalStorage) {\n return context.originalStorage;\n }\n\n return undefined;\n}\n\ntype MethodWrapperOptions = {\n /**\n * The span name, or a resolver called with the RPC metadata of the current call.\n * Returning `undefined` skips the span and only captures errors.\n */\n spanName?: string | ((rpcMeta: SerializedTraceData | undefined) => string | undefined);\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | InstrumentedDurableObjectState;\n /**\n * If true, starts a fresh trace instead of inheriting from a parent trace.\n * Useful for scheduled/independent invocations like alarms.\n *\n * If true, it also stores the current span context and links to the previous invocation's span.\n * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`\n * in a `waitUntil` to avoid blocking.\n *\n * @default false\n */\n startNewTrace?: boolean;\n /**\n * The trace origin identifying which instrumentation created the span, e.g. `auto.faas.cloudflare.durable_object`.\n * Used both as the span's `sentry.origin` attribute and as the `mechanism.type` for captured exceptions.\n */\n origin: string;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry error tracking and optional tracing.\n * Supports starting new traces and linking to previous invocations via Durable Object storage.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n return ensureInstrumented(\n handler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, rawArgs: Parameters<T>) {\n const { startNewTrace, origin } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\n\n const spanName =\n typeof wrapperOptions.spanName === 'function' ? wrapperOptions.spanName(rpcMeta) : wrapperOptions.spanName;\n\n const wrappedFunction = (scope: Scope): unknown | Promise<unknown> => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context: typeof wrapperOptions.context | undefined = wrapperOptions.context;\n\n // see: https://github.com/getsentry/sentry-javascript/issues/22328\n // Resolved once per invocation and cached on its state: reading `ctx.waitUntil`\n // on a native context is a runtime getter call.\n const invocationState = getInvocationState();\n const waitUntil = invocationState\n ? getInvocationWaitUntil(invocationState)\n : context\n ? getOriginalWaitUntil(context as ExecutionContextCompat)?.bind(context)\n : undefined;\n const storage = resolveOriginalStorage(context, thisArg);\n\n let scopeClient = scope.getClient();\n // Re-init when the scope has no usable client (a previous handler disposed it, e.g.\n // DO alarm handlers) or for `startNewTrace`, so the client points at this\n // invocation's context. With `cacheClient: true` `init()` returns the isolate's\n // cached client and only creates (and caches) a fresh one when nothing is cached yet;\n // `cacheClient: false` creates one per invocation.\n if (startNewTrace || !scopeClient?.getTransport()) {\n const client = init({\n ...wrapperOptions.options,\n ctx: context as unknown as ExecutionContext | undefined,\n });\n scope.setClient(client);\n scopeClient = client;\n }\n\n const clientToDispose = scopeClient;\n const methodName = spanName || 'unknown';\n\n const teardown = async (): Promise<void> => {\n if (startNewTrace && storage) {\n storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n const onFulfilled = (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n };\n\n const captureAndRethrow = (e: unknown): never => {\n captureException(e, {\n mechanism: {\n type: origin,\n handled: false,\n },\n });\n throw e;\n };\n\n const onRejected = (e: unknown) => {\n try {\n return captureAndRethrow(e);\n } finally {\n waitUntil?.(teardown());\n }\n };\n\n if (!spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SENTRY_OP]: wrapperOptions.spanOp,\n [SENTRY_ORIGIN]: origin,\n // `function` spans are already named like their function name, so we just set `code.function.name` here.\n ...(wrapperOptions.spanOp === FUNCTION && { [CODE_FUNCTION_NAME]: methodName }),\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n if (startNewTrace && storage) {\n const storedContext = getStoredSpanContext(storage, methodName);\n\n if (storedContext) {\n span.addLinks(buildSpanLinks(storedContext));\n\n // TODO(v12): Remove once EAP can filter span links by type. The Sentry trace view searches this attribute to find the NEXT trace.\n // Sentry 26.9 and older also read it to find the PREVIOUS trace. Newer versions read the span link.\n const sampledFlag = storedContext.sampled ? '1' : '0';\n span.setAttribute(\n 'sentry.previous_trace',\n `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,\n );\n }\n }\n\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(undefined, captureAndRethrow);\n }\n return result;\n } catch (e) {\n return captureAndRethrow(e);\n }\n });\n };\n\n // The boundary flush (teardown) must run after the method span has ended, so the\n // span is in the buffer when that flush drains it. Running it inside the span\n // callback (before `startSpan` ends the span) would leave the span for the eager\n // path and cost a second flush per invocation.\n const runWithTeardown = (run: () => unknown): unknown => {\n let out: unknown;\n try {\n out = run();\n } catch (e) {\n // Synchronous throw: `startSpan` already ended the span and rethrew.\n waitUntil?.(teardown());\n throw e;\n }\n if (isThenable(out)) {\n return out.then(\n res => {\n waitUntil?.(teardown());\n return res;\n },\n e => {\n waitUntil?.(teardown());\n throw e;\n },\n );\n }\n waitUntil?.(teardown());\n return out;\n };\n\n if (rpcMeta) {\n return runWithTeardown(() =>\n continueTrace(\n { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },\n executeSpan,\n ),\n );\n }\n\n if (startNewTrace) {\n return runWithTeardown(() => startNewTraceCore(() => executeSpan()));\n }\n\n return runWithTeardown(executeSpan);\n };\n\n return withInvocationIsolationScope(\n wrappedFunction,\n wrapperOptions.context as ExecutionContextCompat | undefined,\n );\n },\n }),\n noMark,\n );\n}\n"],"names":["isObjectLike","ensureInstrumented","rpcMeta","extractRpcMeta","getInvocationState","getInvocationWaitUntil","getOriginalWaitUntil","init","storeSpanContext","flushAndDispose","captureException","isThenable","attributes","SENTRY_OP","SENTRY_ORIGIN","FUNCTION","CODE_FUNCTION_NAME","startSpan","getStoredSpanContext","buildSpanLinks","continueTrace","startNewTraceCore","withInvocationIsolationScope"],"mappings":";;;;;;;;;;;;;AAiCA,SAAS,sBAAA,CACP,SACA,OAA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A,OAAO,eAAA;AAAA,cAAgB,MACrBkB,kBAAA;AAAA,gBACE,EAAE,aAAalB,SAAA,CAAQ,cAAc,KAAK,EAAA,EAAI,OAAA,EAASA,SAAA,CAAQ,OAAA,IAAW,EAAA,EAAG;AAAA,gBAC7E;AAAA;AACF,aACF;AAAA,UACF;AAEA,UAAA,IAAI,aAAA,EAAe;AACjB,YAAA,OAAO,gBAAgB,MAAMmB,kBAAA,CAAkB,MAAM,WAAA,EAAa,CAAC,CAAA;AAAA,UACrE;AAEA,UAAA,OAAO,gBAAgB,WAAW,CAAA;AAAA,QACpC,CAAA;AAEA,QAAA,OAAOC,4CAAA;AAAA,UACL,eAAA;AAAA,UACA,cAAA,CAAe;AAAA,SACjB;AAAA,MACF;AAAA,KACD,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"wrapMethodWithSentry.js","names":["isObjectLike","ensureInstrumented","extractRpcMeta","getInvocationState","getInvocationWaitUntil","getOriginalWaitUntil","init","storeSpanContext","flushAndDispose","captureException","continueCloudflareTrace","isThenable","SENTRY_OP","SENTRY_ORIGIN","FUNCTION","CODE_FUNCTION_NAME","startSpan","getStoredSpanContext","buildSpanLinks","continueTrace","startNewTraceCore","withInvocationIsolationScope"],"sources":["../../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport { CODE_FUNCTION_NAME, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport { FUNCTION } from '@sentry/conventions/op';\nimport {\n isObjectLike,\n captureException,\n continueTrace,\n isThenable,\n type Scope,\n startNewTrace as startNewTraceCore,\n startSpan,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { continueCloudflareTrace } from './utils/cloudflareTrace';\nimport { getInvocationState, getInvocationWaitUntil } from './utils/invocationContext';\nimport { withInvocationIsolationScope } from './utils/invocationScope';\nimport { extractRpcMeta } from './utils/rpcMeta';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\nexport interface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\n/**\n * Resolves uninstrumented DO storage for the current invocation.\n * Prefer `thisArg.ctx` (the live Durable Object instance) over the context captured at\n * construction time to avoid cross-DO I/O errors in the same isolate.\n */\nfunction resolveOriginalStorage(\n context: ExecutionContext | InstrumentedDurableObjectState | undefined,\n thisArg: unknown,\n): DurableObjectStorage | undefined {\n if (isObjectLike(thisArg) && 'ctx' in thisArg) {\n const doCtx = (thisArg as { ctx: InstrumentedDurableObjectState }).ctx;\n if (doCtx?.originalStorage) {\n return doCtx.originalStorage;\n }\n }\n\n if (context && 'originalStorage' in context && context.originalStorage) {\n return context.originalStorage;\n }\n\n return undefined;\n}\n\ntype MethodWrapperOptions = {\n /**\n * The span name, or a resolver called with the RPC metadata of the current call.\n * Returning `undefined` skips the span and only captures errors.\n */\n spanName?: string | ((rpcMeta: SerializedTraceData | undefined) => string | undefined);\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | InstrumentedDurableObjectState;\n /**\n * If true, starts a fresh trace instead of inheriting from a parent trace.\n * Useful for scheduled/independent invocations like alarms.\n *\n * If true, it also stores the current span context and links to the previous invocation's span.\n * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`\n * in a `waitUntil` to avoid blocking.\n *\n * @default false\n */\n startNewTrace?: boolean;\n /**\n * The trace origin identifying which instrumentation created the span, e.g. `auto.faas.cloudflare.durable_object`.\n * Used both as the span's `sentry.origin` attribute and as the `mechanism.type` for captured exceptions.\n */\n origin: string;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry error tracking and optional tracing.\n * Supports starting new traces and linking to previous invocations via Durable Object storage.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n return ensureInstrumented(\n handler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, rawArgs: Parameters<T>) {\n const { startNewTrace, origin } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\n\n const spanName =\n typeof wrapperOptions.spanName === 'function' ? wrapperOptions.spanName(rpcMeta) : wrapperOptions.spanName;\n\n const wrappedFunction = (scope: Scope): unknown | Promise<unknown> => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context: typeof wrapperOptions.context | undefined = wrapperOptions.context;\n\n // see: https://github.com/getsentry/sentry-javascript/issues/22328\n // Resolved once per invocation and cached on its state: reading `ctx.waitUntil`\n // on a native context is a runtime getter call.\n const invocationState = getInvocationState();\n const waitUntil = invocationState\n ? getInvocationWaitUntil(invocationState)\n : context\n ? getOriginalWaitUntil(context as ExecutionContextCompat)?.bind(context)\n : undefined;\n const storage = resolveOriginalStorage(context, thisArg);\n\n let scopeClient = scope.getClient();\n // Re-init when the scope has no usable client (a previous handler disposed it, e.g.\n // DO alarm handlers) or for `startNewTrace`, so the client points at this\n // invocation's context. With `cacheClient: true` `init()` returns the isolate's\n // cached client and only creates (and caches) a fresh one when nothing is cached yet;\n // `cacheClient: false` creates one per invocation.\n if (startNewTrace || !scopeClient?.getTransport()) {\n const client = init({\n ...wrapperOptions.options,\n ctx: context as unknown as ExecutionContext | undefined,\n });\n scope.setClient(client);\n scopeClient = client;\n }\n\n const clientToDispose = scopeClient;\n const methodName = spanName || 'unknown';\n\n const teardown = async (): Promise<void> => {\n if (startNewTrace && storage) {\n storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n const onFulfilled = (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n };\n\n const captureAndRethrow = (e: unknown): never => {\n captureException(e, {\n mechanism: {\n type: origin,\n handled: false,\n },\n });\n throw e;\n };\n\n const onRejected = (e: unknown) => {\n try {\n return captureAndRethrow(e);\n } finally {\n waitUntil?.(teardown());\n }\n };\n\n continueCloudflareTrace(context);\n\n if (!spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SENTRY_OP]: wrapperOptions.spanOp,\n [SENTRY_ORIGIN]: origin,\n // `function` spans are already named like their function name, so we just set `code.function.name` here.\n ...(wrapperOptions.spanOp === FUNCTION && { [CODE_FUNCTION_NAME]: methodName }),\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n if (startNewTrace && storage) {\n const storedContext = getStoredSpanContext(storage, methodName);\n\n if (storedContext) {\n span.addLinks(buildSpanLinks(storedContext));\n\n // TODO(v12): Remove once EAP can filter span links by type. The Sentry trace view searches this attribute to find the NEXT trace.\n // Sentry 26.9 and older also read it to find the PREVIOUS trace. Newer versions read the span link.\n const sampledFlag = storedContext.sampled ? '1' : '0';\n span.setAttribute(\n 'sentry.previous_trace',\n `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,\n );\n }\n }\n\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(undefined, captureAndRethrow);\n }\n return result;\n } catch (e) {\n return captureAndRethrow(e);\n }\n });\n };\n\n // The boundary flush (teardown) must run after the method span has ended, so the\n // span is in the buffer when that flush drains it. Running it inside the span\n // callback (before `startSpan` ends the span) would leave the span for the eager\n // path and cost a second flush per invocation.\n const runWithTeardown = (run: () => unknown): unknown => {\n let out: unknown;\n try {\n out = run();\n } catch (e) {\n // Synchronous throw: `startSpan` already ended the span and rethrew.\n waitUntil?.(teardown());\n throw e;\n }\n if (isThenable(out)) {\n return out.then(\n res => {\n waitUntil?.(teardown());\n return res;\n },\n e => {\n waitUntil?.(teardown());\n throw e;\n },\n );\n }\n waitUntil?.(teardown());\n return out;\n };\n\n if (rpcMeta) {\n return runWithTeardown(() =>\n continueTrace({ sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' }, () => {\n continueCloudflareTrace(context);\n return executeSpan();\n }),\n );\n }\n\n if (startNewTrace) {\n return runWithTeardown(() => startNewTraceCore(() => executeSpan()));\n }\n\n return runWithTeardown(executeSpan);\n };\n\n return withInvocationIsolationScope(\n wrappedFunction,\n wrapperOptions.context as ExecutionContextCompat | undefined,\n );\n },\n }),\n noMark,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkCA,SAAS,uBACP,SACA,SACkC;CAClC,KAAA,GAAIA,aAAAA,aAAAA,CAAa,OAAO,KAAK,SAAS,SAAS;EAC7C,MAAM,QAAS,QAAoD;EACnE,IAAI,OAAO,iBACT,OAAO,MAAM;CAEjB;CAEA,IAAI,WAAW,qBAAqB,WAAW,QAAQ,iBACrD,OAAO,QAAQ;AAInB;;;;;;;;;;;AA2CA,SAAgB,qBACd,gBACA,SACA,UACA,QACG;CACH,OAAOC,mBAAAA,mBACL,UACA,aACE,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AChB,OAAO,IAAI,MACT,QAAO;KACL,YAAY,SAAS,CAAC;KACtB,OAAO;IACT,IACA,MAAK;KACH,YAAY,SAAS,CAAC;KACtB,MAAM;IACR,CACF;IAEF,YAAY,SAAS,CAAC;IACtB,OAAO;GACT;GAEA,IAAI,SACF,OAAO,uBAAA,GACLQ,aAAAA,cAAAA,CAAc;IAAE,aAAa,QAAQ,mBAAmB;IAAI,SAAS,QAAQ,WAAW;GAAG,SAAS;IAClGT,wBAAAA,wBAAwB,OAAO;IAC/B,OAAO,YAAY;GACrB,CAAC,CACH;GAGF,IAAI,eACF,OAAO,uBAAA,GAAsBU,aAAAA,cAAAA,OAAwB,YAAY,CAAC,CAAC;GAGrE,OAAO,gBAAgB,WAAW;EACpC;EAEA,OAAOC,wBAAAA,6BACL,iBACA,eAAe,OACjB;CACF,EACF,CAAC,GACH,MACF;AACF"}
@@ -1,77 +1,83 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const attributes = require('@sentry/conventions/attributes');
4
- const core = require('@sentry/core');
5
- const requestHandler = require('@sentry/server-utils/request-handler');
6
- const debugBuild = require('./debug-build.js');
7
- const httpServer = require('./integrations/httpServer.js');
8
- const orchestrionDeferredChannels = require('./orchestrion-deferred-channels.js');
9
- const flush = require('./flush.js');
10
- const scopeUtils = require('./scope-utils.js');
11
- const invocationContext = require('./utils/invocationContext.js');
12
- const invocationScope = require('./utils/invocationScope.js');
13
-
1
+ const require_debug_build = require("./debug-build.js");
2
+ const require_httpServer = require("./integrations/httpServer.js");
3
+ const require_orchestrion_deferred_channels = require("./orchestrion-deferred-channels.js");
4
+ const require_flush = require("./flush.js");
5
+ const require_scope_utils = require("./scope-utils.js");
6
+ const require_cloudflareTrace = require("./utils/cloudflareTrace.js");
7
+ const require_invocationContext = require("./utils/invocationContext.js");
8
+ const require_invocationScope = require("./utils/invocationScope.js");
9
+ let _sentry_core = require("@sentry/core");
10
+ let _sentry_core_server = require("@sentry/core/server");
11
+ let _sentry_conventions_attributes = require("@sentry/conventions/attributes");
12
+ let _sentry_server_utils_request_handler = require("@sentry/server-utils/request-handler");
13
+ // src/wrapRequestHandlerWithInit.ts
14
+ function isDurableObjectContext(context) {
15
+ return !!context && "storage" in context;
16
+ }
14
17
  function getRequestErrorMechanismType(context) {
15
- return context && "storage" in context ? "auto.faas.cloudflare.durable_object" : "auto.http.cloudflare";
18
+ return isDurableObjectContext(context) ? "auto.faas.cloudflare.durable_object" : "auto.http.cloudflare";
16
19
  }
20
+ /**
21
+ * Same as {@link wrapRequestHandler}, but with the SDK initialization injected.
22
+ *
23
+ * Wrappers that are only reachable from the main entry point — where `nodejs_compat` is a
24
+ * requirement anyway — pass `init` from `sdk.ts` so `enableOpenTelemetrySetup` is honored.
25
+ *
26
+ * @internal
27
+ */
17
28
  function wrapRequestHandlerWithInit(wrapperOptions, handler, initSdk) {
18
- return invocationScope.withInvocationIsolationScope(async (isolationScope) => {
19
- const { options, request, captureErrors = true } = wrapperOptions;
20
- const context = wrapperOptions.context;
21
- const invocationState = invocationContext.getInvocationState();
22
- const waitUntil = invocationState ? invocationContext.getInvocationWaitUntil(invocationState) : context ? flush.getOriginalWaitUntil(context).bind(context) : void 0;
23
- const client = initSdk({ ...options, ctx: context });
24
- isolationScope.setClient(client);
25
- orchestrionDeferredChannels.flushDeferredChannelEvents();
26
- scopeUtils.addCloudResourceContext(isolationScope);
27
- const attributes$1 = {};
28
- if (request.cf) {
29
- scopeUtils.addCultureContext(isolationScope, request.cf);
30
- if (typeof request.cf.httpProtocol === "string") {
31
- const [protocolName, protocolVersion] = request.cf.httpProtocol.toLowerCase().split("/");
32
- attributes$1[attributes.NETWORK_PROTOCOL_NAME] = protocolName;
33
- attributes$1[attributes.NETWORK_PROTOCOL_VERSION] = protocolVersion;
34
- }
35
- }
36
- if (!client) {
37
- try {
38
- return await handler();
39
- } finally {
40
- waitUntil?.(flush.flushAndDispose(client));
41
- }
42
- }
43
- return requestHandler.wrapServerRequestHandler(
44
- {
45
- request,
46
- client,
47
- // Without `AsyncLocalStorage`, `withInvocationIsolationScope` does not fork, and the scope it
48
- // passes in is not the current one. The request data has to go on the current scope, where
49
- // events captured in the handler read it.
50
- isolationScope: core.getIsolationScope(),
51
- options: httpServer.getHttpServerRequestOptions(client),
52
- origin: "auto.http.cloudflare",
53
- mechanism: captureErrors ? { handled: false, type: getRequestErrorMechanismType(context) } : void 0,
54
- attributes: attributes$1,
55
- isStreamingResponse: (response) => {
56
- const classification = core.safeCallback(
57
- debugBuild.DEBUG_BUILD ? "Error in `isStreamingResponse`, using the default classification:" : "",
58
- () => options.isStreamingResponse?.(response, request),
59
- () => void 0
60
- );
61
- return typeof classification === "boolean" ? classification : void 0;
62
- },
63
- onDone: (response) => {
64
- if (response?.status === 101) {
65
- waitUntil?.(client.flush(2e3));
66
- } else {
67
- waitUntil?.(flush.flushAndDispose(client));
68
- }
69
- }
70
- },
71
- () => handler()
72
- );
73
- }, wrapperOptions.context);
29
+ return require_invocationScope.withInvocationIsolationScope(async (isolationScope) => {
30
+ const { options, request, captureErrors = true } = wrapperOptions;
31
+ const context = wrapperOptions.context;
32
+ const invocationState = require_invocationContext.getInvocationState();
33
+ const waitUntil = invocationState ? require_invocationContext.getInvocationWaitUntil(invocationState) : context ? require_flush.getOriginalWaitUntil(context).bind(context) : void 0;
34
+ const client = initSdk({
35
+ ...options,
36
+ ctx: context
37
+ });
38
+ isolationScope.setClient(client);
39
+ if (waitUntil) (0, _sentry_core_server._INTERNAL_setScopeFlushedByRuntime)(isolationScope);
40
+ require_orchestrion_deferred_channels.flushDeferredChannelEvents();
41
+ const tunnelResponse = !isDurableObjectContext(context) && (0, _sentry_core_server._INTERNAL_handleServedTunnelRequest)(request, client);
42
+ if (tunnelResponse) return tunnelResponse.finally(() => waitUntil?.(require_flush.flushAndDispose(client)));
43
+ require_scope_utils.addCloudResourceContext(isolationScope);
44
+ const attributes = {};
45
+ if (request.cf) {
46
+ require_scope_utils.addCultureContext(isolationScope, request.cf);
47
+ if (typeof request.cf.httpProtocol === "string") {
48
+ const [protocolName, protocolVersion] = request.cf.httpProtocol.toLowerCase().split("/");
49
+ attributes[_sentry_conventions_attributes.NETWORK_PROTOCOL_NAME] = protocolName;
50
+ attributes[_sentry_conventions_attributes.NETWORK_PROTOCOL_VERSION] = protocolVersion;
51
+ }
52
+ }
53
+ if (!client) try {
54
+ return await handler();
55
+ } finally {
56
+ waitUntil?.(require_flush.flushAndDispose(client));
57
+ }
58
+ return (0, _sentry_server_utils_request_handler.wrapServerRequestHandler)({
59
+ request,
60
+ client,
61
+ isolationScope: (0, _sentry_core.getIsolationScope)(),
62
+ options: require_httpServer.getHttpServerRequestOptions(client),
63
+ origin: "auto.http.cloudflare",
64
+ mechanism: captureErrors ? {
65
+ handled: false,
66
+ type: getRequestErrorMechanismType(context)
67
+ } : void 0,
68
+ attributes,
69
+ onTraceContinued: () => require_cloudflareTrace.continueCloudflareTrace(context),
70
+ isStreamingResponse: (response) => {
71
+ const classification = (0, _sentry_core.safeCallback)(require_debug_build.DEBUG_BUILD ? "Error in `isStreamingResponse`, using the default classification:" : "", () => options.isStreamingResponse?.(response, request), () => void 0);
72
+ return typeof classification === "boolean" ? classification : void 0;
73
+ },
74
+ onDone: (response) => {
75
+ if (response?.status === 101) waitUntil?.(client.flush(2e3));
76
+ else waitUntil?.(require_flush.flushAndDispose(client));
77
+ }
78
+ }, () => handler());
79
+ }, wrapperOptions.context);
74
80
  }
75
-
76
81
  exports.wrapRequestHandlerWithInit = wrapRequestHandlerWithInit;
77
- //# sourceMappingURL=wrapRequestHandlerWithInit.js.map
82
+
83
+ //# sourceMappingURL=wrapRequestHandlerWithInit.js.map