@sentry/server-utils 11.21.0 → 11.23.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 (261) hide show
  1. package/build/THIRD-PARTY-LICENSES.txt +10 -10
  2. package/build/cjs/chunks/config.js +4 -2
  3. package/build/cjs/chunks/config.js.map +1 -1
  4. package/build/cjs/chunks/core.js +0 -1
  5. package/build/cjs/chunks/exports.js +76 -28
  6. package/build/cjs/chunks/exports.js.map +1 -1
  7. package/build/cjs/chunks/module-details-from-path.js +427 -428
  8. package/build/cjs/chunks/module-details-from-path.js.map +1 -1
  9. package/build/cjs/chunks/moduleInjectedTransform.js +419 -421
  10. package/build/cjs/chunks/moduleInjectedTransform.js.map +1 -1
  11. package/build/cjs/chunks/rolldown-runtime.js +8 -6
  12. package/build/cjs/index.js +95 -41
  13. package/build/cjs/index.js.map +1 -1
  14. package/build/cjs/index.request-handler.js +2 -2
  15. package/build/cjs/orchestrion/bundler/bun.js +1 -1
  16. package/build/cjs/orchestrion/bundler/esbuild.js +1 -1
  17. package/build/cjs/orchestrion/bundler/rollup.js +1 -1
  18. package/build/cjs/orchestrion/bundler/vite.js +2 -2
  19. package/build/cjs/orchestrion/bundler/webpack-loader.js +2 -2
  20. package/build/cjs/orchestrion/bundler/webpack.js +4 -4
  21. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/defineProperty.js +1 -1
  22. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/assertClassBrand.js +1 -1
  23. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/checkPrivateRedeclaration.js +1 -1
  24. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/classPrivateFieldGet2.js +1 -1
  25. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/classPrivateFieldInitSpec.js +1 -1
  26. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/classPrivateFieldSet2.js +1 -1
  27. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/classPrivateMethodInitSpec.js +1 -1
  28. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/defineProperty.js +1 -1
  29. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/toPrimitive.js +1 -1
  30. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/toPropertyKey.js +1 -1
  31. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/typeof.js +1 -1
  32. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/toPrimitive.js +1 -1
  33. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/toPropertyKey.js +1 -1
  34. package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/typeof.js +1 -1
  35. package/build/esm/_virtual/_rolldown/runtime.js +8 -6
  36. package/build/esm/ai/anthropic-ai/index.js +2 -2
  37. package/build/esm/ai/anthropic-ai/streaming.js +11 -2
  38. package/build/esm/ai/anthropic-ai/streaming.js.map +1 -1
  39. package/build/esm/ai/anthropic-ai/tool-runner.js +3 -3
  40. package/build/esm/ai/anthropic-ai/utils.js +2 -2
  41. package/build/esm/ai/core/span-hooks.js +1 -1
  42. package/build/esm/ai/core/time-to-first-chunk.js +1 -1
  43. package/build/esm/ai/core/utils.js +2 -2
  44. package/build/esm/ai/flue/index.js +2 -2
  45. package/build/esm/ai/flue/utils.js +2 -2
  46. package/build/esm/ai/google-genai/decisions.js +1 -1
  47. package/build/esm/ai/google-genai/index.js +2 -2
  48. package/build/esm/ai/google-genai/streaming.js +9 -2
  49. package/build/esm/ai/google-genai/streaming.js.map +1 -1
  50. package/build/esm/ai/google-genai/utils.js +1 -1
  51. package/build/esm/ai/langchain/embeddings.js +3 -3
  52. package/build/esm/ai/langchain/index.js +15 -9
  53. package/build/esm/ai/langchain/index.js.map +1 -1
  54. package/build/esm/ai/langchain/typesafe-classifier.js +2 -2
  55. package/build/esm/ai/langchain/utils.js +3 -4
  56. package/build/esm/ai/langchain/utils.js.map +1 -1
  57. package/build/esm/ai/langgraph/agent-span.js +3 -3
  58. package/build/esm/ai/langgraph/index.js +1 -1
  59. package/build/esm/ai/langgraph/stream.js +2 -2
  60. package/build/esm/ai/langgraph/utils.js +3 -3
  61. package/build/esm/ai/mastra/index.js +2 -2
  62. package/build/esm/ai/mastra/span-registry.js +1 -1
  63. package/build/esm/ai/mastra/utils.js +2 -2
  64. package/build/esm/ai/mistral/index.js +2 -2
  65. package/build/esm/ai/mistral/streaming.js +18 -9
  66. package/build/esm/ai/mistral/streaming.js.map +1 -1
  67. package/build/esm/ai/openai/index.js +2 -2
  68. package/build/esm/ai/openai/mapping.js +1 -1
  69. package/build/esm/ai/openai/streaming.js +15 -2
  70. package/build/esm/ai/openai/streaming.js.map +1 -1
  71. package/build/esm/ai/openai/utils.js +2 -2
  72. package/build/esm/ai/pi-ai/chat.js +12 -4
  73. package/build/esm/ai/pi-ai/chat.js.map +1 -1
  74. package/build/esm/ai/pi-ai/providers.js +1 -1
  75. package/build/esm/ai/pi-ai/recording.js +1 -1
  76. package/build/esm/ai/pi-durable/index.js +2 -2
  77. package/build/esm/ai/pi-durable/runs.js +3 -3
  78. package/build/esm/ai/pi-durable/tools.js +3 -3
  79. package/build/esm/ai/tanstack-ai/index.js +2 -2
  80. package/build/esm/ai/tanstack-ai/utils.js +2 -2
  81. package/build/esm/ai/typesafe/index.js +3 -3
  82. package/build/esm/ai/workers-ai/index.js +2 -2
  83. package/build/esm/ai/workers-ai/streaming.js +7 -5
  84. package/build/esm/ai/workers-ai/streaming.js.map +1 -1
  85. package/build/esm/ai/workers-ai/utils.js +7 -4
  86. package/build/esm/ai/workers-ai/utils.js.map +1 -1
  87. package/build/esm/async-context.js +1 -1
  88. package/build/esm/cron/common.js +1 -1
  89. package/build/esm/cron/cron.js +1 -1
  90. package/build/esm/cron/node-cron.js +1 -1
  91. package/build/esm/cron/node-schedule.js +1 -1
  92. package/build/esm/eve.js +1 -1
  93. package/build/esm/integrations/amqplib.js +3 -3
  94. package/build/esm/integrations/anthropic.js +3 -4
  95. package/build/esm/integrations/anthropic.js.map +1 -1
  96. package/build/esm/integrations/aws-sdk/index.js +3 -3
  97. package/build/esm/integrations/aws-sdk/services/MessageAttributes.js +1 -1
  98. package/build/esm/integrations/aws-sdk/services/bedrock-runtime-content.js +2 -2
  99. package/build/esm/integrations/aws-sdk/services/bedrock-runtime.js +3 -3
  100. package/build/esm/integrations/aws-sdk/services/dynamodb.js +1 -1
  101. package/build/esm/integrations/aws-sdk/services/lambda.js +2 -2
  102. package/build/esm/integrations/aws-sdk/services/sns.js +3 -3
  103. package/build/esm/integrations/aws-sdk/services/sqs.js +2 -2
  104. package/build/esm/integrations/bullmq/meter.js +2 -2
  105. package/build/esm/integrations/bullmq/tracer.js +2 -2
  106. package/build/esm/integrations/clickhouse.js +3 -3
  107. package/build/esm/integrations/cron.js +1 -1
  108. package/build/esm/integrations/dataloader.js +3 -3
  109. package/build/esm/integrations/express/error-handler.js +1 -1
  110. package/build/esm/integrations/express/index.js +1 -1
  111. package/build/esm/integrations/express/instrumentation.js +3 -3
  112. package/build/esm/integrations/fastify/errors.js +1 -1
  113. package/build/esm/integrations/fastify/index.js +1 -1
  114. package/build/esm/integrations/fastify/instrumentation.js +8 -4
  115. package/build/esm/integrations/fastify/instrumentation.js.map +1 -1
  116. package/build/esm/integrations/firebase/firestore.js +2 -2
  117. package/build/esm/integrations/firebase/functions.js +1 -1
  118. package/build/esm/integrations/firebase/index.js +1 -1
  119. package/build/esm/integrations/flue.js +1 -1
  120. package/build/esm/integrations/generic-pool.js +3 -3
  121. package/build/esm/integrations/google-genai.js +2 -2
  122. package/build/esm/integrations/graphql/graphql-dc-subscriber.js +3 -3
  123. package/build/esm/integrations/graphql/index.js +1 -1
  124. package/build/esm/integrations/graphql/resolvers.js +2 -2
  125. package/build/esm/integrations/graphql/spans.js +3 -3
  126. package/build/esm/integrations/groq.js +1 -1
  127. package/build/esm/integrations/hapi/hapi-error-handler.js +1 -1
  128. package/build/esm/integrations/hapi/hapi-utils.js +4 -5
  129. package/build/esm/integrations/hapi/hapi-utils.js.map +1 -1
  130. package/build/esm/integrations/hapi/index.js +1 -1
  131. package/build/esm/integrations/hono/applyPatches.js +1 -1
  132. package/build/esm/integrations/hono/createHonoMiddleware.js +1 -1
  133. package/build/esm/integrations/hono/honoIntegration.js +3 -3
  134. package/build/esm/integrations/hono/matchResult.js +1 -1
  135. package/build/esm/integrations/hono/middlewareHandlers.js +2 -2
  136. package/build/esm/integrations/hono/patchAppRequest.js +3 -3
  137. package/build/esm/integrations/hono/patchAppUse.js +1 -1
  138. package/build/esm/integrations/hono/patchRoute.js +1 -1
  139. package/build/esm/integrations/hono/wrapMiddlewareSpan.js +3 -3
  140. package/build/esm/integrations/kafkajs/consumer.js +2 -2
  141. package/build/esm/integrations/kafkajs/index.js +1 -1
  142. package/build/esm/integrations/kafkajs/spans.js +2 -2
  143. package/build/esm/integrations/knex.js +3 -3
  144. package/build/esm/integrations/koa/index.js +3 -3
  145. package/build/esm/integrations/langchain.js +1 -1
  146. package/build/esm/integrations/langgraph.js +1 -1
  147. package/build/esm/integrations/lru-memoizer.js +1 -1
  148. package/build/esm/integrations/mastra-classifier.js +2 -2
  149. package/build/esm/integrations/mastra.js +4 -4
  150. package/build/esm/integrations/mcp-server.js +2 -2
  151. package/build/esm/integrations/mistral.js +2 -2
  152. package/build/esm/integrations/mongodb/index.js +1 -1
  153. package/build/esm/integrations/mongodb/mongodb-span.js +1 -1
  154. package/build/esm/integrations/mongoose/index.js +1 -1
  155. package/build/esm/integrations/mongoose/mongoose-dc-subscriber.js +3 -3
  156. package/build/esm/integrations/mongoose/mongoose-legacy-span.js +1 -1
  157. package/build/esm/integrations/mysql.js +3 -3
  158. package/build/esm/integrations/mysql2/index.js +1 -1
  159. package/build/esm/integrations/mysql2/mysql2-dc-subscriber.js +3 -3
  160. package/build/esm/integrations/neon.js +13 -5
  161. package/build/esm/integrations/neon.js.map +1 -1
  162. package/build/esm/integrations/nitro/captureStorageEvents.js +3 -3
  163. package/build/esm/integrations/nitro/captureTracingEvents.js +3 -3
  164. package/build/esm/integrations/nitro/index.js +1 -1
  165. package/build/esm/integrations/nitro/setServerTimingHeaders.js +1 -1
  166. package/build/esm/integrations/node-cron.js +1 -1
  167. package/build/esm/integrations/node-schedule.js +1 -1
  168. package/build/esm/integrations/openai-compatible.js +2 -2
  169. package/build/esm/integrations/openai.js +2 -2
  170. package/build/esm/integrations/pg.js +43 -16
  171. package/build/esm/integrations/pg.js.map +1 -1
  172. package/build/esm/integrations/pi-ai.js +1 -1
  173. package/build/esm/integrations/pi-durable.js +1 -1
  174. package/build/esm/integrations/pino.js +1 -1
  175. package/build/esm/integrations/pino.js.map +1 -1
  176. package/build/esm/integrations/postgresjs/index.js +3 -3
  177. package/build/esm/integrations/postgresjs/postgresjs-dc-subscriber.js +3 -3
  178. package/build/esm/integrations/postgresjs-wrapper.js +1 -1
  179. package/build/esm/integrations/prisma/index.js +1 -1
  180. package/build/esm/integrations/prisma/orchestrion.js +8 -12
  181. package/build/esm/integrations/prisma/orchestrion.js.map +1 -1
  182. package/build/esm/integrations/prisma/tracing-helper.js +2 -2
  183. package/build/esm/integrations/redis/index.js +3 -3
  184. package/build/esm/integrations/redis/ioredis-channel-subscriber.js +3 -3
  185. package/build/esm/integrations/redis/redis-cache.js +1 -1
  186. package/build/esm/integrations/redis/redis-dc-subscriber.js +3 -3
  187. package/build/esm/integrations/serveTunnel.js +2 -2
  188. package/build/esm/integrations/tanstack-ai.js +1 -1
  189. package/build/esm/integrations/tedious.js +4 -4
  190. package/build/esm/integrations/together-ai.js +1 -1
  191. package/build/esm/integrations/typesafe.js +1 -1
  192. package/build/esm/integrations/vercel-ai/extract.js +2 -3
  193. package/build/esm/integrations/vercel-ai/extract.js.map +1 -1
  194. package/build/esm/integrations/vercel-ai/index.js +1 -1
  195. package/build/esm/integrations/vercel-ai/util.js +21 -2
  196. package/build/esm/integrations/vercel-ai/util.js.map +1 -1
  197. package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js +3 -3
  198. package/build/esm/integrations/vercel-ai/vercel-ai-orchestrion-subscriber.js +1 -1
  199. package/build/esm/integrations/vercel-ai/vercel-ai-tool-telemetry.js +3 -3
  200. package/build/esm/integrations/winston.js +1 -1
  201. package/build/esm/opentelemetry.js +1 -1
  202. package/build/esm/orchestrion/bundler/esbuild.js +1 -1
  203. package/build/esm/orchestrion/bundler/externalRequire.js +1 -1
  204. package/build/esm/orchestrion/bundler/rollup.js +1 -1
  205. package/build/esm/orchestrion/bundler/webpack-loader.js +1 -1
  206. package/build/esm/orchestrion/bundler/webpack.js +1 -1
  207. package/build/esm/orchestrion/config/index.js +1 -1
  208. package/build/esm/orchestrion/config/mistral.js +1 -1
  209. package/build/esm/orchestrion/config/mistral.js.map +1 -1
  210. package/build/esm/orchestrion/config/prisma.js +2 -0
  211. package/build/esm/orchestrion/config/prisma.js.map +1 -1
  212. package/build/esm/orchestrion/detect.js +1 -1
  213. package/build/esm/orchestrion/instrumentation.js +1 -1
  214. package/build/esm/package.json +1 -1
  215. package/build/esm/tracing-channel.js +1 -2
  216. package/build/esm/tracing-channel.js.map +1 -1
  217. package/build/esm/utils/cronMonitoring.js +1 -1
  218. package/build/esm/utils/diagnosticsChannel.js +1 -1
  219. package/build/esm/utils/module.js +2 -2
  220. package/build/esm/utils/module.js.map +1 -1
  221. package/build/esm/utils/monitorStream.js +1 -1
  222. package/build/esm/utils/serverTimingTraceHeader.js +1 -1
  223. package/build/esm/utils/tunnelServer.js +1 -1
  224. package/build/esm/utils/wrapServerRequestHandler.js +4 -4
  225. package/build/esm/vendored/@apm-js-collab/code-transformer/lib/matcher.js +3 -3
  226. package/build/esm/vendored/@apm-js-collab/code-transformer/lib/transformer.js +5 -5
  227. package/build/esm/vendored/@apm-js-collab/code-transformer-bundler-plugins/dist/esm/core-BiWIBBjf.js +1 -1
  228. package/build/esm/vendored/@apm-js-collab/code-transformer-bundler-plugins/dist/esm/webpack-loader-factory.js +1 -1
  229. package/build/esm/vendored/esquery/dist/esquery.min.js +1 -0
  230. package/build/esm/vendored/esquery/dist/esquery.min.js.map +1 -1
  231. package/build/esm/vendored/meriyah/dist/meriyah.js +416 -418
  232. package/build/esm/vendored/meriyah/dist/meriyah.js.map +1 -1
  233. package/build/esm/vendored/meriyah/dist/meriyah2.js +416 -418
  234. package/build/esm/vendored/meriyah/dist/meriyah2.js.map +1 -1
  235. package/build/esm/vendored/source-map/lib/base64-vlq.js +1 -1
  236. package/build/esm/vendored/source-map/lib/base64-vlq.js.map +1 -1
  237. package/build/types/ai/anthropic-ai/streaming.d.ts.map +1 -1
  238. package/build/types/ai/anthropic-ai/types.d.ts +1 -0
  239. package/build/types/ai/anthropic-ai/types.d.ts.map +1 -1
  240. package/build/types/ai/google-genai/streaming.d.ts.map +1 -1
  241. package/build/types/ai/langchain/index.d.ts.map +1 -1
  242. package/build/types/ai/mistral/streaming.d.ts.map +1 -1
  243. package/build/types/ai/openai/streaming.d.ts.map +1 -1
  244. package/build/types/ai/pi-ai/chat.d.ts.map +1 -1
  245. package/build/types/ai/workers-ai/streaming.d.ts.map +1 -1
  246. package/build/types/ai/workers-ai/utils.d.ts.map +1 -1
  247. package/build/types/integrations/fastify/instrumentation.d.ts.map +1 -1
  248. package/build/types/integrations/neon.d.ts.map +1 -1
  249. package/build/types/integrations/pg.d.ts +6 -1
  250. package/build/types/integrations/pg.d.ts.map +1 -1
  251. package/build/types/integrations/pino.d.ts.map +1 -1
  252. package/build/types/integrations/vercel-ai/extract.d.ts +2 -5
  253. package/build/types/integrations/vercel-ai/extract.d.ts.map +1 -1
  254. package/build/types/integrations/vercel-ai/util.d.ts.map +1 -1
  255. package/build/types/orchestrion/channels.d.ts +1 -0
  256. package/build/types/orchestrion/channels.d.ts.map +1 -1
  257. package/build/types/orchestrion/config/mistral.d.ts +3 -3
  258. package/build/types/orchestrion/config/prisma.d.ts +2 -1
  259. package/build/types/orchestrion/config/prisma.d.ts.map +1 -1
  260. package/build/types/tracing-channel.d.ts.map +1 -1
  261. package/package.json +4 -4
@@ -15,12 +15,14 @@ var __esmMin = (fn, res, err) => () => {
15
15
  };
16
16
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
17
17
  var __copyProps = (to, from, except, desc) => {
18
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
- key = keys[i];
20
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
- get: ((k) => from[k]).bind(null, key),
22
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
- });
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
20
+ desc = __getOwnPropDesc(from, key);
21
+ __defProp(to, key, {
22
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
23
+ enumerable: !desc || desc.enumerable
24
+ });
25
+ }
24
26
  }
25
27
  return to;
26
28
  };
@@ -1,21 +1,21 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./chunks/rolldown-runtime.js");
3
3
  const require_exports = require("./chunks/exports.js");
4
+ let _sentry_core = require("@sentry/core");
4
5
  const require_debug_build = require("./chunks/debug-build.js");
5
- const require_config = require("./chunks/config.js");
6
- const require_pi_ai = require("./chunks/pi-ai.js");
7
6
  let _sentry_conventions_attributes = require("@sentry/conventions/attributes");
8
- let _sentry_core = require("@sentry/core");
9
7
  let _sentry_conventions_op = require("@sentry/conventions/op");
10
- let _sentry_core_server = require("@sentry/core/server");
11
8
  let node_diagnostics_channel = require("node:diagnostics_channel");
12
- node_diagnostics_channel = require_rolldown_runtime.__toESM(node_diagnostics_channel);
9
+ const require_config = require("./chunks/config.js");
10
+ const require_pi_ai = require("./chunks/pi-ai.js");
13
11
  let _sentry_conventions_metrics = require("@sentry/conventions/metrics");
14
12
  let node_module = require("node:module");
15
13
  let node_path = require("node:path");
16
14
  let node_url = require("node:url");
15
+ let _sentry_core_server = require("@sentry/core/server");
17
16
  let node_events = require("node:events");
18
17
  let node_net = require("node:net");
18
+ node_diagnostics_channel = require_rolldown_runtime.__toESM(node_diagnostics_channel);
19
19
  node_net = require_rolldown_runtime.__toESM(node_net);
20
20
  // src/integrations/koa/koa-error-handler.ts
21
21
  const ERROR_HANDLER_ATTACHED = "__SENTRY_KOA_ERROR_HANDLER_ATTACHED__";
@@ -260,8 +260,7 @@ function wrapExtArguments(args, pluginName) {
260
260
  return;
261
261
  } else if (isDirectExtInput(args)) {
262
262
  const extInput = args;
263
- const method = extInput[1];
264
- args[1] = wrapExtMethods(method, extInput[0], pluginName);
263
+ args[1] = wrapExtMethods(extInput[1], extInput[0], pluginName);
265
264
  return;
266
265
  } else if (isLifecycleExtEventObj(args[0])) {
267
266
  const lifecycleEventObj = args[0];
@@ -460,7 +459,6 @@ function getErrorInfo(error) {
460
459
  };
461
460
  }
462
461
  function getStoreWithActiveSpan(asyncLocalStorage, span) {
463
- if ((0, _sentry_core.spanIsIgnored)(span) && (0, _sentry_core.getRootSpan)(span) !== span) return asyncLocalStorage.getStore();
464
462
  return (0, _sentry_core.withActiveSpan)(span, () => {
465
463
  return asyncLocalStorage.getStore();
466
464
  });
@@ -766,6 +764,10 @@ function onRequest(request, _reply, hookDone) {
766
764
  const routeName = getRequestRouteUrl(request);
767
765
  const method = request.method || "GET";
768
766
  (0, _sentry_core.getIsolationScope)().setTransactionName(`${method} ${routeName}`);
767
+ if (!(0, _sentry_core.getActiveSpan)()) {
768
+ hookDone();
769
+ return;
770
+ }
769
771
  const attributes = {
770
772
  [_sentry_conventions_attributes.SENTRY_ORIGIN]: ORIGIN$23,
771
773
  [_sentry_conventions_attributes.SENTRY_OP]: _sentry_conventions_op.HANDLER,
@@ -864,7 +866,7 @@ function handlerWrapper(handler, hookName, spanAttributes = {}) {
864
866
  if (!request) return handler.call(this, ...args);
865
867
  const parentSpan = request[kRequestSpan] ?? void 0;
866
868
  const effectiveParentSpan = parentSpan ?? (0, _sentry_core.getActiveSpan)();
867
- if (effectiveParentSpan && !(0, _sentry_core.spanIsSampled)(effectiveParentSpan)) return handler.call(this, ...args);
869
+ if (!effectiveParentSpan || !(0, _sentry_core.spanIsSampled)(effectiveParentSpan)) return handler.call(this, ...args);
868
870
  const handlerName = handler.name?.length > 0 ? handler.name : this.pluginName ?? ANONYMOUS_FUNCTION_NAME;
869
871
  const hookType = spanAttributes[ATTRIBUTE_FASTIFY_TYPE];
870
872
  const op = hookType === HOOK_TYPE_INSTANCE ? _sentry_conventions_op.MIDDLEWARE : hookType === HOOK_TYPE_HANDLER ? _sentry_conventions_op.HANDLER : void 0;
@@ -1296,7 +1298,7 @@ function patchConsumption(result, span, end) {
1296
1298
  const toArray = result.toArray;
1297
1299
  const asyncIterator = result[Symbol.asyncIterator];
1298
1300
  const patchedToArray = function() {
1299
- return runUnderSpan(span, () => toArray.call(this)).then((value) => {
1301
+ return (0, _sentry_core.withActiveSpan)(span, () => toArray.call(this)).then((value) => {
1300
1302
  end();
1301
1303
  return value;
1302
1304
  }, (error) => {
@@ -1305,16 +1307,12 @@ function patchConsumption(result, span, end) {
1305
1307
  });
1306
1308
  };
1307
1309
  const patchedAsyncIterator = function() {
1308
- return wrapIterator(runUnderSpan(span, () => asyncIterator.call(this)), span, end);
1310
+ return wrapIterator((0, _sentry_core.withActiveSpan)(span, () => asyncIterator.call(this)), span, end);
1309
1311
  };
1310
1312
  result.toArray = patchedToArray;
1311
1313
  result[Symbol.asyncIterator] = patchedAsyncIterator;
1312
1314
  return true;
1313
1315
  }
1314
- function runUnderSpan(span, callback) {
1315
- if ((0, _sentry_core.spanIsIgnored)(span) && (0, _sentry_core.getRootSpan)(span) !== span) return callback();
1316
- return (0, _sentry_core.withActiveSpan)(span, callback);
1317
- }
1318
1316
  function wrapIterator(iterator, span, end) {
1319
1317
  const settle = (step) => step.then((result) => {
1320
1318
  if (result.done) end();
@@ -1324,7 +1322,7 @@ function wrapIterator(iterator, span, end) {
1324
1322
  throw error;
1325
1323
  });
1326
1324
  return {
1327
- next: (...args) => settle(runUnderSpan(span, () => iterator.next(...args))),
1325
+ next: (...args) => settle((0, _sentry_core.withActiveSpan)(span, () => iterator.next(...args))),
1328
1326
  return: (value) => {
1329
1327
  const iteratorReturn = iterator.return?.bind(iterator);
1330
1328
  if (!iteratorReturn) {
@@ -1334,7 +1332,7 @@ function wrapIterator(iterator, span, end) {
1334
1332
  value
1335
1333
  });
1336
1334
  }
1337
- return settle(runUnderSpan(span, () => iteratorReturn(value)));
1335
+ return settle((0, _sentry_core.withActiveSpan)(span, () => iteratorReturn(value)));
1338
1336
  },
1339
1337
  throw: (error) => {
1340
1338
  const iteratorThrow = iterator.throw?.bind(iterator);
@@ -1342,7 +1340,7 @@ function wrapIterator(iterator, span, end) {
1342
1340
  end(error);
1343
1341
  return Promise.reject(error);
1344
1342
  }
1345
- return settle(runUnderSpan(span, () => iteratorThrow(error)));
1343
+ return settle((0, _sentry_core.withActiveSpan)(span, () => iteratorThrow(error)));
1346
1344
  },
1347
1345
  [Symbol.asyncIterator]() {
1348
1346
  return this;
@@ -1949,8 +1947,7 @@ function instrumentAnthropic(options) {
1949
1947
  function createGenAiSpan$4(data, operation, options, stream) {
1950
1948
  const args = data.arguments ?? [];
1951
1949
  if (require_exports.shouldSkipAiProviderSpan(INTEGRATION_NAME$32)) return;
1952
- const requestOptions = args[1];
1953
- if (isStreamHelperRequest(requestOptions?.headers) && isInsideStreamHelperSpan()) return;
1950
+ if (isStreamHelperRequest(args[1]?.headers) && isInsideStreamHelperSpan()) return;
1954
1951
  const params = typeof args[0] === "object" && args[0] !== null ? args[0] : void 0;
1955
1952
  const call = {
1956
1953
  operation,
@@ -3615,10 +3612,7 @@ function beforeSchedule(change, options) {
3615
3612
  * keeps runs from an earlier spec, the job doesn't check in.
3616
3613
  */
3617
3614
  function onSchedule(change) {
3618
- if (change.result === true) {
3619
- const job = change.self;
3620
- updateMonitorConfig(job?.job, addsToPendingRuns.has(change) ? void 0 : getMonitorConfig(change.arguments[0]));
3621
- }
3615
+ if (change.result === true) updateMonitorConfig(change.self?.job, addsToPendingRuns.has(change) ? void 0 : getMonitorConfig(change.arguments[0]));
3622
3616
  }
3623
3617
  /** Whether node-schedule runs a job with this spec once: a `Date`, a timestamp, or a date string. */
3624
3618
  function isOneOffSpec(spec) {
@@ -6361,6 +6355,14 @@ function getRequestContentAttributes(context) {
6361
6355
  };
6362
6356
  }
6363
6357
  /**
6358
+ * Whether an event carries new model output. `start`, empty `*_start`, `*_end` and `done` events do not.
6359
+ */
6360
+ function hasOutput$1(event) {
6361
+ const { type, delta } = event ?? {};
6362
+ if (type === "text_delta" || type === "thinking_delta" || type === "toolcall_delta") return !!delta;
6363
+ return type === "toolcall_start";
6364
+ }
6365
+ /**
6364
6366
  * Records `gen_ai.response.time_to_first_chunk` for a streamed request. The stream has one consumer,
6365
6367
  * so instead of reading it, this wraps `push`, which the provider calls for each event as it decodes
6366
6368
  * it. The wrapper is removed after the first chunk.
@@ -6369,7 +6371,7 @@ function observePiAiFirstChunk(span, events) {
6369
6371
  const push = events?.push;
6370
6372
  if (!events || typeof push !== "function") return;
6371
6373
  events.push = function(event) {
6372
- if (event?.type !== "start") {
6374
+ if (hasOutput$1(event)) {
6373
6375
  require_exports.recordTimeToFirstChunk(span);
6374
6376
  events.push = push;
6375
6377
  }
@@ -8848,15 +8850,16 @@ function instrumentPostgres(options) {
8848
8850
  * streamable `Submittable` result, so it's the only one that defers span-ending to the emitter.
8849
8851
  */
8850
8852
  function bindPgQueryChannel(channelName, options) {
8851
- subscribeQueryLikeChannel(channelName, (ctx) => querySpanOptions(ctx, options), { deferStreamedResult: true });
8853
+ subscribeQueryLikeChannel(channelName, (ctx) => querySpanOptions(ctx, options), { isQuery: true });
8852
8854
  }
8853
8855
  /**
8854
8856
  * Subscribe to a pg tracing-channel and manage a span across its lifecycle.
8855
8857
  * Shared by the query/connect/pool-connect channels. They differ only in how
8856
8858
  * the span's name + attributes are built (`getSpanOptions`), and whether the
8857
- * result can be a streamable emitter (`deferStreamedResult`, query-only).
8859
+ * result is a query result that can be a streamable emitter and carries a row
8860
+ * count (`isQuery`).
8858
8861
  */
8859
- function subscribeQueryLikeChannel(channelName, getSpanOptions, { deferStreamedResult = false } = {}) {
8862
+ function subscribeQueryLikeChannel(channelName, getSpanOptions, { isQuery = false } = {}) {
8860
8863
  bindTracingChannelToSpan(tracingChannel(channelName), (data) => {
8861
8864
  data._sentryCallerScope = (0, _sentry_core.getCurrentScope)();
8862
8865
  const spanOptions = getSpanOptions(data);
@@ -8868,15 +8871,24 @@ function subscribeQueryLikeChannel(channelName, getSpanOptions, { deferStreamedR
8868
8871
  [_sentry_conventions_attributes.SENTRY_KIND]: "client"
8869
8872
  }
8870
8873
  });
8871
- }, deferStreamedResult ? { deferSpanEnd({ data, end }) {
8872
- const result = data.result;
8873
- if (!result || typeof result !== "object" || !hasOnMethod(result)) return false;
8874
- const callerScope = data._sentryCallerScope;
8875
- if (callerScope) (0, _sentry_core.bindScopeToEmitter)(result, callerScope);
8876
- result.on("error", (err) => end(err));
8877
- result.on("end", () => end());
8878
- return true;
8879
- } } : void 0);
8874
+ }, isQuery ? {
8875
+ beforeSpanEnd(span, data) {
8876
+ if ("error" in data || (0, _sentry_core.isObjectLike)(data.result) && hasOnMethod(data.result)) return;
8877
+ setReturnedRows(span, data.result);
8878
+ },
8879
+ deferSpanEnd({ span, data, end }) {
8880
+ const result = data.result;
8881
+ if (!result || typeof result !== "object" || !hasOnMethod(result)) return false;
8882
+ const callerScope = data._sentryCallerScope;
8883
+ if (callerScope) (0, _sentry_core.bindScopeToEmitter)(result, callerScope);
8884
+ result.on("error", (err) => end(err));
8885
+ result.on("end", (endResult) => {
8886
+ if (!hasReadMethod(result)) setReturnedRows(span, endResult);
8887
+ end();
8888
+ });
8889
+ return true;
8890
+ }
8891
+ } : void 0);
8880
8892
  }
8881
8893
  function querySpanOptions(ctx, { origin, connectionString }) {
8882
8894
  const params = ctx.self?.connectionParameters ?? {};
@@ -8916,6 +8928,23 @@ function poolConnectSpanOptions(ctx) {
8916
8928
  function hasOnMethod(obj) {
8917
8929
  return "on" in obj && typeof obj.on === "function";
8918
8930
  }
8931
+ function hasReadMethod(obj) {
8932
+ return "read" in obj && typeof obj.read === "function";
8933
+ }
8934
+ /**
8935
+ * Sets `db.response.returned_rows` from a pg-style result (`{ rowCount, rows }`), or an array of them
8936
+ * (one per statement of a multi-statement query), summed. Sets nothing when no count is known.
8937
+ */
8938
+ function setReturnedRows(span, results) {
8939
+ const counts = (Array.isArray(results) ? results : [results]).map(getRowCount).filter((count) => count !== void 0);
8940
+ if (counts.length) span.setAttribute(_sentry_conventions_attributes.DB_RESPONSE_RETURNED_ROWS, counts.reduce((sum, count) => sum + count, 0));
8941
+ }
8942
+ function getRowCount(result) {
8943
+ if (!(0, _sentry_core.isObjectLike)(result)) return;
8944
+ const { rowCount, rows } = result;
8945
+ if (typeof rowCount === "number") return rowCount;
8946
+ return Array.isArray(rows) ? rows.length : void 0;
8947
+ }
8919
8948
  function extractQueryConfig(args) {
8920
8949
  const arg0 = args[0];
8921
8950
  if (typeof arg0 === "string") return { text: arg0 };
@@ -9209,7 +9238,11 @@ function instrumentNeon() {
9209
9238
  const span = (0, _sentry_core.startInactiveSpan)(httpQuerySpanOptions(data.arguments));
9210
9239
  httpQuerySpans.add(span);
9211
9240
  return span;
9212
- });
9241
+ }, { beforeSpanEnd(span, data) {
9242
+ if ("error" in data) return;
9243
+ const { result } = data;
9244
+ setReturnedRows(span, Array.isArray(data.arguments[0]) && Array.isArray(result) ? result.map(toPgResult) : toPgResult(result));
9245
+ } });
9213
9246
  tracingChannel(CHANNELS.NEON_RESOLVE_CONNECTION).subscribe({
9214
9247
  start: NOOP$2,
9215
9248
  end: NOOP$2,
@@ -9251,6 +9284,9 @@ function httpQuerySpanOptions(args) {
9251
9284
  attributes
9252
9285
  };
9253
9286
  }
9287
+ function toPgResult(result) {
9288
+ return Array.isArray(result) ? { rows: result } : result;
9289
+ }
9254
9290
  function getBatchOperationName(statements) {
9255
9291
  const operations = new Set(statements.map((s) => s[_sentry_conventions_attributes.DB_OPERATION_NAME]?.toUpperCase()));
9256
9292
  const [operation] = operations;
@@ -9622,7 +9658,7 @@ function tapModelCallStream(span, stream, onFinal, onError) {
9622
9658
  controller.close();
9623
9659
  return;
9624
9660
  }
9625
- if (value?.type !== "stream-start") require_exports.recordTimeToFirstChunk(span);
9661
+ if (hasOutput(value)) require_exports.recordTimeToFirstChunk(span);
9626
9662
  text += accumulateChunk(state, value) ?? "";
9627
9663
  controller.enqueue(value);
9628
9664
  } catch (error) {
@@ -9637,6 +9673,25 @@ function tapModelCallStream(span, stream, onFinal, onError) {
9637
9673
  });
9638
9674
  }
9639
9675
  /**
9676
+ * Whether a chunk carries new model output, which is what `gen_ai.response.time_to_first_chunk` measures.
9677
+ * `stream-start`, `response-metadata`, empty `*-start` and `finish` chunks do not.
9678
+ */
9679
+ function hasOutput(chunk) {
9680
+ if (!(0, _sentry_core.isObjectLike)(chunk)) return false;
9681
+ const { type, delta, textDelta, argsTextDelta } = chunk;
9682
+ switch (type) {
9683
+ case "text-delta":
9684
+ case "reasoning-delta":
9685
+ case "tool-input-delta": return !!(delta ?? textDelta);
9686
+ case "reasoning": return !!textDelta;
9687
+ case "tool-call-delta": return !!argsTextDelta;
9688
+ case "tool-input-start":
9689
+ case "tool-call":
9690
+ case "file": return true;
9691
+ default: return false;
9692
+ }
9693
+ }
9694
+ /**
9640
9695
  * Fold a single streamed chunk into the running aggregate. Returns any text delta so the caller can
9641
9696
  * accumulate it (kept out of `state` until the end to avoid re-joining on every chunk).
9642
9697
  */
@@ -9672,7 +9727,6 @@ function mapObjectValues(record, fn) {
9672
9727
  return Object.fromEntries(Object.entries(record).map(([key, value]) => [key, (0, _sentry_core.isObjectLike)(value) ? fn(value, key) : value]));
9673
9728
  }
9674
9729
  // src/integrations/vercel-ai/extract.ts
9675
- /** Maps the AI SDK `experimental_extract` input and output to the Clairic shape of the `gen_ai.extract` schemas. */
9676
9730
  /**
9677
9731
  * Joins the text of the AI SDK state parts into one Clairic `state` string. The gateway does this join on
9678
9732
  * the server and does not show its separator, so this one is our choice. It only makes the recorded text
@@ -9733,7 +9787,7 @@ function toExtractAnswers(answers, parts) {
9733
9787
  return mapObjectValues(answers, ({ pNull, source, items, ...rest }) => {
9734
9788
  const mapped = {
9735
9789
  ...rest,
9736
- p_null: pNull
9790
+ p_null: asNumber(pNull)
9737
9791
  };
9738
9792
  const span = toExtractSpan(source, parts);
9739
9793
  if (span) {