@sentry/server-utils 11.22.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 (241) hide show
  1. package/build/THIRD-PARTY-LICENSES.txt +10 -10
  2. package/build/cjs/chunks/config.js +2 -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 +72 -27
  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 +42 -25
  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 +3 -3
  86. package/build/esm/async-context.js +1 -1
  87. package/build/esm/cron/common.js +1 -1
  88. package/build/esm/cron/cron.js +1 -1
  89. package/build/esm/cron/node-cron.js +1 -1
  90. package/build/esm/cron/node-schedule.js +1 -1
  91. package/build/esm/eve.js +1 -1
  92. package/build/esm/integrations/amqplib.js +3 -3
  93. package/build/esm/integrations/anthropic.js +3 -4
  94. package/build/esm/integrations/anthropic.js.map +1 -1
  95. package/build/esm/integrations/aws-sdk/index.js +3 -3
  96. package/build/esm/integrations/aws-sdk/services/MessageAttributes.js +1 -1
  97. package/build/esm/integrations/aws-sdk/services/bedrock-runtime-content.js +2 -2
  98. package/build/esm/integrations/aws-sdk/services/bedrock-runtime.js +3 -3
  99. package/build/esm/integrations/aws-sdk/services/dynamodb.js +1 -1
  100. package/build/esm/integrations/aws-sdk/services/lambda.js +2 -2
  101. package/build/esm/integrations/aws-sdk/services/sns.js +3 -3
  102. package/build/esm/integrations/aws-sdk/services/sqs.js +2 -2
  103. package/build/esm/integrations/bullmq/meter.js +2 -2
  104. package/build/esm/integrations/bullmq/tracer.js +2 -2
  105. package/build/esm/integrations/clickhouse.js +3 -3
  106. package/build/esm/integrations/cron.js +1 -1
  107. package/build/esm/integrations/dataloader.js +3 -3
  108. package/build/esm/integrations/express/error-handler.js +1 -1
  109. package/build/esm/integrations/express/index.js +1 -1
  110. package/build/esm/integrations/express/instrumentation.js +3 -3
  111. package/build/esm/integrations/fastify/errors.js +1 -1
  112. package/build/esm/integrations/fastify/index.js +1 -1
  113. package/build/esm/integrations/fastify/instrumentation.js +3 -3
  114. package/build/esm/integrations/firebase/firestore.js +2 -2
  115. package/build/esm/integrations/firebase/functions.js +1 -1
  116. package/build/esm/integrations/firebase/index.js +1 -1
  117. package/build/esm/integrations/flue.js +1 -1
  118. package/build/esm/integrations/generic-pool.js +3 -3
  119. package/build/esm/integrations/google-genai.js +2 -2
  120. package/build/esm/integrations/graphql/graphql-dc-subscriber.js +3 -3
  121. package/build/esm/integrations/graphql/index.js +1 -1
  122. package/build/esm/integrations/graphql/resolvers.js +2 -2
  123. package/build/esm/integrations/graphql/spans.js +3 -3
  124. package/build/esm/integrations/groq.js +1 -1
  125. package/build/esm/integrations/hapi/hapi-error-handler.js +1 -1
  126. package/build/esm/integrations/hapi/hapi-utils.js +4 -5
  127. package/build/esm/integrations/hapi/hapi-utils.js.map +1 -1
  128. package/build/esm/integrations/hapi/index.js +1 -1
  129. package/build/esm/integrations/hono/applyPatches.js +1 -1
  130. package/build/esm/integrations/hono/createHonoMiddleware.js +1 -1
  131. package/build/esm/integrations/hono/honoIntegration.js +3 -3
  132. package/build/esm/integrations/hono/matchResult.js +1 -1
  133. package/build/esm/integrations/hono/middlewareHandlers.js +2 -2
  134. package/build/esm/integrations/hono/patchAppRequest.js +3 -3
  135. package/build/esm/integrations/hono/patchAppUse.js +1 -1
  136. package/build/esm/integrations/hono/patchRoute.js +1 -1
  137. package/build/esm/integrations/hono/wrapMiddlewareSpan.js +3 -3
  138. package/build/esm/integrations/kafkajs/consumer.js +2 -2
  139. package/build/esm/integrations/kafkajs/index.js +1 -1
  140. package/build/esm/integrations/kafkajs/spans.js +2 -2
  141. package/build/esm/integrations/knex.js +3 -3
  142. package/build/esm/integrations/koa/index.js +3 -3
  143. package/build/esm/integrations/langchain.js +1 -1
  144. package/build/esm/integrations/langgraph.js +1 -1
  145. package/build/esm/integrations/lru-memoizer.js +1 -1
  146. package/build/esm/integrations/mastra-classifier.js +2 -2
  147. package/build/esm/integrations/mastra.js +4 -4
  148. package/build/esm/integrations/mcp-server.js +2 -2
  149. package/build/esm/integrations/mistral.js +2 -2
  150. package/build/esm/integrations/mongodb/index.js +1 -1
  151. package/build/esm/integrations/mongodb/mongodb-span.js +1 -1
  152. package/build/esm/integrations/mongoose/index.js +1 -1
  153. package/build/esm/integrations/mongoose/mongoose-dc-subscriber.js +3 -3
  154. package/build/esm/integrations/mongoose/mongoose-legacy-span.js +1 -1
  155. package/build/esm/integrations/mysql.js +3 -3
  156. package/build/esm/integrations/mysql2/index.js +1 -1
  157. package/build/esm/integrations/mysql2/mysql2-dc-subscriber.js +3 -3
  158. package/build/esm/integrations/neon.js +3 -3
  159. package/build/esm/integrations/nitro/captureStorageEvents.js +3 -3
  160. package/build/esm/integrations/nitro/captureTracingEvents.js +3 -3
  161. package/build/esm/integrations/nitro/index.js +1 -1
  162. package/build/esm/integrations/nitro/setServerTimingHeaders.js +1 -1
  163. package/build/esm/integrations/node-cron.js +1 -1
  164. package/build/esm/integrations/node-schedule.js +1 -1
  165. package/build/esm/integrations/openai-compatible.js +2 -2
  166. package/build/esm/integrations/openai.js +2 -2
  167. package/build/esm/integrations/pg.js +3 -3
  168. package/build/esm/integrations/pi-ai.js +1 -1
  169. package/build/esm/integrations/pi-durable.js +1 -1
  170. package/build/esm/integrations/pino.js +1 -1
  171. package/build/esm/integrations/postgresjs/index.js +3 -3
  172. package/build/esm/integrations/postgresjs/postgresjs-dc-subscriber.js +3 -3
  173. package/build/esm/integrations/postgresjs-wrapper.js +1 -1
  174. package/build/esm/integrations/prisma/index.js +1 -1
  175. package/build/esm/integrations/prisma/orchestrion.js +8 -12
  176. package/build/esm/integrations/prisma/orchestrion.js.map +1 -1
  177. package/build/esm/integrations/prisma/tracing-helper.js +2 -2
  178. package/build/esm/integrations/redis/index.js +3 -3
  179. package/build/esm/integrations/redis/ioredis-channel-subscriber.js +3 -3
  180. package/build/esm/integrations/redis/redis-cache.js +1 -1
  181. package/build/esm/integrations/redis/redis-dc-subscriber.js +3 -3
  182. package/build/esm/integrations/serveTunnel.js +2 -2
  183. package/build/esm/integrations/tanstack-ai.js +1 -1
  184. package/build/esm/integrations/tedious.js +4 -4
  185. package/build/esm/integrations/together-ai.js +1 -1
  186. package/build/esm/integrations/typesafe.js +1 -1
  187. package/build/esm/integrations/vercel-ai/extract.js +1 -1
  188. package/build/esm/integrations/vercel-ai/index.js +1 -1
  189. package/build/esm/integrations/vercel-ai/util.js +21 -2
  190. package/build/esm/integrations/vercel-ai/util.js.map +1 -1
  191. package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js +3 -3
  192. package/build/esm/integrations/vercel-ai/vercel-ai-orchestrion-subscriber.js +1 -1
  193. package/build/esm/integrations/vercel-ai/vercel-ai-tool-telemetry.js +3 -3
  194. package/build/esm/integrations/winston.js +1 -1
  195. package/build/esm/opentelemetry.js +1 -1
  196. package/build/esm/orchestrion/bundler/esbuild.js +1 -1
  197. package/build/esm/orchestrion/bundler/externalRequire.js +1 -1
  198. package/build/esm/orchestrion/bundler/rollup.js +1 -1
  199. package/build/esm/orchestrion/bundler/webpack-loader.js +1 -1
  200. package/build/esm/orchestrion/bundler/webpack.js +1 -1
  201. package/build/esm/orchestrion/config/index.js +1 -1
  202. package/build/esm/orchestrion/config/mistral.js +1 -1
  203. package/build/esm/orchestrion/config/mistral.js.map +1 -1
  204. package/build/esm/orchestrion/detect.js +1 -1
  205. package/build/esm/orchestrion/instrumentation.js +1 -1
  206. package/build/esm/package.json +1 -1
  207. package/build/esm/tracing-channel.js +1 -2
  208. package/build/esm/tracing-channel.js.map +1 -1
  209. package/build/esm/utils/cronMonitoring.js +1 -1
  210. package/build/esm/utils/diagnosticsChannel.js +1 -1
  211. package/build/esm/utils/module.js +2 -2
  212. package/build/esm/utils/module.js.map +1 -1
  213. package/build/esm/utils/monitorStream.js +1 -1
  214. package/build/esm/utils/serverTimingTraceHeader.js +1 -1
  215. package/build/esm/utils/tunnelServer.js +1 -1
  216. package/build/esm/utils/wrapServerRequestHandler.js +4 -4
  217. package/build/esm/vendored/@apm-js-collab/code-transformer/lib/matcher.js +3 -3
  218. package/build/esm/vendored/@apm-js-collab/code-transformer/lib/transformer.js +5 -5
  219. package/build/esm/vendored/@apm-js-collab/code-transformer-bundler-plugins/dist/esm/core-BiWIBBjf.js +1 -1
  220. package/build/esm/vendored/@apm-js-collab/code-transformer-bundler-plugins/dist/esm/webpack-loader-factory.js +1 -1
  221. package/build/esm/vendored/esquery/dist/esquery.min.js +1 -0
  222. package/build/esm/vendored/esquery/dist/esquery.min.js.map +1 -1
  223. package/build/esm/vendored/meriyah/dist/meriyah.js +416 -418
  224. package/build/esm/vendored/meriyah/dist/meriyah.js.map +1 -1
  225. package/build/esm/vendored/meriyah/dist/meriyah2.js +416 -418
  226. package/build/esm/vendored/meriyah/dist/meriyah2.js.map +1 -1
  227. package/build/esm/vendored/source-map/lib/base64-vlq.js +1 -1
  228. package/build/esm/vendored/source-map/lib/base64-vlq.js.map +1 -1
  229. package/build/types/ai/anthropic-ai/streaming.d.ts.map +1 -1
  230. package/build/types/ai/anthropic-ai/types.d.ts +1 -0
  231. package/build/types/ai/anthropic-ai/types.d.ts.map +1 -1
  232. package/build/types/ai/google-genai/streaming.d.ts.map +1 -1
  233. package/build/types/ai/langchain/index.d.ts.map +1 -1
  234. package/build/types/ai/mistral/streaming.d.ts.map +1 -1
  235. package/build/types/ai/openai/streaming.d.ts.map +1 -1
  236. package/build/types/ai/pi-ai/chat.d.ts.map +1 -1
  237. package/build/types/ai/workers-ai/streaming.d.ts.map +1 -1
  238. package/build/types/integrations/vercel-ai/util.d.ts.map +1 -1
  239. package/build/types/orchestrion/config/mistral.d.ts +3 -3
  240. package/build/types/tracing-channel.d.ts.map +1 -1
  241. package/package.json +3 -3
@@ -1,4 +1,6 @@
1
+ import { SENTRY_ORIGIN } from "@sentry/conventions/attributes";
1
2
  import { tracingChannel } from "../utils/diagnosticsChannel.js";
3
+ import { defineIntegration, getClient, hasSpanStreamingEnabled, startInactiveSpan } from "@sentry/core";
2
4
  import { getGenAiSpanOp, getRequestSignal, markCancelledIfAborted, resolveGenAiCallRecording } from "../ai/core/utils.js";
3
5
  import { addRequestAttributes, extractRequestAttributes } from "../ai/openai/index.js";
4
6
  import { wrapApiPromiseResponse } from "../ai/core/apiPromise.js";
@@ -10,8 +12,6 @@ import { CHANNELS } from "../orchestrion/channels.js";
10
12
  import { bindTracingChannelToSpan } from "../tracing-channel.js";
11
13
  import { openaiModuleNames } from "../orchestrion/config/openai.js";
12
14
  import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
13
- import { SENTRY_ORIGIN } from "@sentry/conventions/attributes";
14
- import { defineIntegration, getClient, hasSpanStreamingEnabled, startInactiveSpan } from "@sentry/core";
15
15
  // src/integrations/openai.ts
16
16
  const INTEGRATION_NAME = "OpenAI";
17
17
  const ORIGIN = "auto.ai.openai";
@@ -1,12 +1,12 @@
1
1
  import { tracingChannel } from "../utils/diagnosticsChannel.js";
2
+ import { DB_CONNECTION_STRING, DB_NAMESPACE, DB_RESPONSE_RETURNED_ROWS, DB_SYSTEM_NAME, DB_USER, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
3
+ import { DB } from "@sentry/conventions/op";
4
+ import { bindScopeToEmitter, defineIntegration, getCurrentScope, isObjectLike, startInactiveSpan } from "@sentry/core";
2
5
  import { getSqlQueryAttributes, getSqlSpanName } from "../utils/sql.js";
3
6
  import { CHANNELS } from "../orchestrion/channels.js";
4
7
  import { bindTracingChannelToSpan } from "../tracing-channel.js";
5
8
  import { pgModuleNames } from "../orchestrion/config/pg.js";
6
9
  import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
7
- import { DB_CONNECTION_STRING, DB_NAMESPACE, DB_RESPONSE_RETURNED_ROWS, DB_SYSTEM_NAME, DB_USER, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
8
- import { bindScopeToEmitter, defineIntegration, getCurrentScope, isObjectLike, startInactiveSpan } from "@sentry/core";
9
- import { DB } from "@sentry/conventions/op";
10
10
  // src/integrations/pg.ts
11
11
  const INTEGRATION_NAME = "Postgres";
12
12
  const ORIGIN = "auto.db.postgres";
@@ -1,4 +1,5 @@
1
1
  import { tracingChannel } from "../utils/diagnosticsChannel.js";
2
+ import { defineIntegration, isThenable, startInactiveSpan } from "@sentry/core";
2
3
  import { runGenAiSpanEnd, runGenAiSpanStart } from "../ai/core/span-hooks.js";
3
4
  import { getPiAiChatSpanOptions, observePiAiFirstChunk, setPiAiResponseAttributes } from "../ai/pi-ai/chat.js";
4
5
  import { PI_AI_INTEGRATION_NAME } from "../ai/pi-ai/constants.js";
@@ -8,7 +9,6 @@ import { CHANNELS } from "../orchestrion/channels.js";
8
9
  import { piAiModuleNames } from "../orchestrion/config/pi-ai.js";
9
10
  import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
10
11
  import { bindTracingChannelToSpan } from "../tracing-channel.js";
11
- import { defineIntegration, isThenable, startInactiveSpan } from "@sentry/core";
12
12
  // src/integrations/pi-ai.ts
13
13
  const _piAiIntegration = ((options = {}) => {
14
14
  return {
@@ -1,4 +1,5 @@
1
1
  import { tracingChannel } from "../utils/diagnosticsChannel.js";
2
+ import { debug, defineIntegration, isObjectLike } from "@sentry/core";
2
3
  import { endRunsOnClose, instrumentPiDurableHarnessOptions } from "../ai/pi-durable/index.js";
3
4
  import { PI_DURABLE_INTEGRATION_NAME } from "../ai/pi-durable/constants.js";
4
5
  import { markBuiltInTool } from "../ai/pi-durable/tools.js";
@@ -6,7 +7,6 @@ import { DEBUG_BUILD } from "../debug-build.js";
6
7
  import { CHANNELS } from "../orchestrion/channels.js";
7
8
  import { piDurableModuleNames } from "../orchestrion/config/pi-durable.js";
8
9
  import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
9
- import { debug, defineIntegration, isObjectLike } from "@sentry/core";
10
10
  // src/integrations/pi-durable.ts
11
11
  const _piDurableIntegration = ((options = {}) => {
12
12
  return {
@@ -1,6 +1,6 @@
1
- import { tracingChannel } from "../utils/diagnosticsChannel.js";
2
1
  import { SENTRY_ORIGIN } from "@sentry/conventions/attributes";
3
2
  import { addExceptionMechanism, captureException, captureLogEvent, captureMessage, defineIntegration, isObjectLike, severityLevelFromString, withScope } from "@sentry/core";
3
+ import { tracingChannel } from "../utils/diagnosticsChannel.js";
4
4
  // src/integrations/pino.ts
5
5
  const SENTRY_TRACK_SYMBOL = Symbol("sentry-track-pino-logger");
6
6
  /**
@@ -1,4 +1,7 @@
1
1
  import { tracingChannel } from "../../utils/diagnosticsChannel.js";
2
+ import { DB_OPERATION_NAME, DB_QUERY_TEXT, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
3
+ import { DB } from "@sentry/conventions/op";
4
+ import { debug, defineIntegration, startInactiveSpan, waitForTracingChannelBinding } from "@sentry/core";
2
5
  import { DEBUG_BUILD } from "../../debug-build.js";
3
6
  import { getSqlQueryAttributes, getSqlSpanName } from "../../utils/sql.js";
4
7
  import { _buildConnectionContext, _getConnectionAttributes, _reconstructQuery, _wrapQuerySettlement } from "../postgresjs-wrapper.js";
@@ -7,9 +10,6 @@ import { bindTracingChannelToSpan } from "../../tracing-channel.js";
7
10
  import { postgresJsModuleNames } from "../../orchestrion/config/postgres.js";
8
11
  import { invokeOrchestrionInstrumentation } from "../../orchestrion/instrumentation.js";
9
12
  import { subscribePostgresJsDiagnosticChannels } from "./postgresjs-dc-subscriber.js";
10
- import { DB_OPERATION_NAME, DB_QUERY_TEXT, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
11
- import { debug, defineIntegration, startInactiveSpan, waitForTracingChannelBinding } from "@sentry/core";
12
- import { DB } from "@sentry/conventions/op";
13
13
  // src/integrations/postgresjs/index.ts
14
14
  const INTEGRATION_NAME = "PostgresJs";
15
15
  const ORIGIN = "auto.db.postgresjs";
@@ -1,10 +1,10 @@
1
+ import { DB_OPERATION_NAME, DB_QUERY_TEXT, DB_RESPONSE_STATUS_CODE, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
2
+ import { DB } from "@sentry/conventions/op";
3
+ import { debug, getActiveSpan, isObjectLike, startInactiveSpan } from "@sentry/core";
1
4
  import { DEBUG_BUILD } from "../../debug-build.js";
2
5
  import { bindTracingChannelToSpan } from "../../tracing-channel.js";
3
6
  import { getSqlQueryAttributes, getSqlSpanName } from "../../utils/sql.js";
4
7
  import { _getConnectionAttributes, _isPostgresJsWrapperSpan } from "../postgresjs-wrapper.js";
5
- import { DB_OPERATION_NAME, DB_QUERY_TEXT, DB_RESPONSE_STATUS_CODE, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
6
- import { debug, getActiveSpan, isObjectLike, startInactiveSpan } from "@sentry/core";
7
- import { DB } from "@sentry/conventions/op";
8
8
  // src/integrations/postgresjs/postgresjs-dc-subscriber.ts
9
9
  /**
10
10
  * Tracing channel published by `postgres` >= 4.0.0 for every query (see postgres `src/diagnostics.js`).
@@ -1,7 +1,7 @@
1
+ import { SPAN_STATUS_ERROR, addNonEnumerableProperty, debug, getActiveSpan, isObjectLike, startSpanManual } from "@sentry/core";
1
2
  import { DEBUG_BUILD } from "../debug-build.js";
2
3
  import { getSqlQueryAttributes, getSqlSpanName } from "../utils/sql.js";
3
4
  import { DB_NAMESPACE, DB_OPERATION_NAME, DB_QUERY_TEXT, DB_RESPONSE_STATUS_CODE, DB_SYSTEM_NAME, ERROR_TYPE, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
4
- import { SPAN_STATUS_ERROR, addNonEnumerableProperty, debug, getActiveSpan, isObjectLike, startSpanManual } from "@sentry/core";
5
5
  import { DB } from "@sentry/conventions/op";
6
6
  // src/integrations/postgresjs-wrapper.ts
7
7
  const CONNECTION_CONTEXT_SYMBOL = Symbol("sentryPostgresConnectionContext");
@@ -1,9 +1,9 @@
1
+ import { defineIntegration } from "@sentry/core";
1
2
  import { prismaModuleNames } from "../../orchestrion/config/prisma.js";
2
3
  import { invokeOrchestrionInstrumentation } from "../../orchestrion/instrumentation.js";
3
4
  import { setGlobalTracingHelper } from "./global.js";
4
5
  import { instrumentPrismaV8 } from "./orchestrion.js";
5
6
  import { ActiveTracingHelper } from "./tracing-helper.js";
6
- import { defineIntegration } from "@sentry/core";
7
7
  // src/integrations/prisma/index.ts
8
8
  const INTEGRATION_NAME = "Prisma";
9
9
  /**
@@ -1,10 +1,10 @@
1
1
  import { tracingChannel } from "../../utils/diagnosticsChannel.js";
2
+ import { getActiveSpan, startInactiveSpan, withActiveSpan } from "@sentry/core";
3
+ import { DB_COLLECTION_NAME, DB_OPERATION_NAME, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
4
+ import { DB } from "@sentry/conventions/op";
2
5
  import { PRISMA_LAZY_TERMINALS, prismaChannels } from "../../orchestrion/config/prisma.js";
3
6
  import { bindTracingChannelToSpan, safeChannelCallback } from "../../tracing-channel.js";
4
7
  import { shouldIgnoreSpan } from "./tracing-helper.js";
5
- import { DB_COLLECTION_NAME, DB_OPERATION_NAME, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
6
- import { getActiveSpan, getRootSpan, spanIsIgnored, startInactiveSpan, withActiveSpan } from "@sentry/core";
7
- import { DB } from "@sentry/conventions/op";
8
8
  // src/integrations/prisma/orchestrion.ts
9
9
  const OPERATION_SPAN_NAME = "prisma:client:operation";
10
10
  const PRISMA_ORIGIN = "auto.db.prisma";
@@ -52,7 +52,7 @@ function patchConsumption(result, span, end) {
52
52
  const toArray = result.toArray;
53
53
  const asyncIterator = result[Symbol.asyncIterator];
54
54
  const patchedToArray = function() {
55
- return runUnderSpan(span, () => toArray.call(this)).then((value) => {
55
+ return withActiveSpan(span, () => toArray.call(this)).then((value) => {
56
56
  end();
57
57
  return value;
58
58
  }, (error) => {
@@ -61,16 +61,12 @@ function patchConsumption(result, span, end) {
61
61
  });
62
62
  };
63
63
  const patchedAsyncIterator = function() {
64
- return wrapIterator(runUnderSpan(span, () => asyncIterator.call(this)), span, end);
64
+ return wrapIterator(withActiveSpan(span, () => asyncIterator.call(this)), span, end);
65
65
  };
66
66
  result.toArray = patchedToArray;
67
67
  result[Symbol.asyncIterator] = patchedAsyncIterator;
68
68
  return true;
69
69
  }
70
- function runUnderSpan(span, callback) {
71
- if (spanIsIgnored(span) && getRootSpan(span) !== span) return callback();
72
- return withActiveSpan(span, callback);
73
- }
74
70
  function wrapIterator(iterator, span, end) {
75
71
  const settle = (step) => step.then((result) => {
76
72
  if (result.done) end();
@@ -80,7 +76,7 @@ function wrapIterator(iterator, span, end) {
80
76
  throw error;
81
77
  });
82
78
  return {
83
- next: (...args) => settle(runUnderSpan(span, () => iterator.next(...args))),
79
+ next: (...args) => settle(withActiveSpan(span, () => iterator.next(...args))),
84
80
  return: (value) => {
85
81
  const iteratorReturn = iterator.return?.bind(iterator);
86
82
  if (!iteratorReturn) {
@@ -90,7 +86,7 @@ function wrapIterator(iterator, span, end) {
90
86
  value
91
87
  });
92
88
  }
93
- return settle(runUnderSpan(span, () => iteratorReturn(value)));
89
+ return settle(withActiveSpan(span, () => iteratorReturn(value)));
94
90
  },
95
91
  throw: (error) => {
96
92
  const iteratorThrow = iterator.throw?.bind(iterator);
@@ -98,7 +94,7 @@ function wrapIterator(iterator, span, end) {
98
94
  end(error);
99
95
  return Promise.reject(error);
100
96
  }
101
- return settle(runUnderSpan(span, () => iteratorThrow(error)));
97
+ return settle(withActiveSpan(span, () => iteratorThrow(error)));
102
98
  },
103
99
  [Symbol.asyncIterator]() {
104
100
  return this;
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrion.js","names":["diagnosticsChannel.tracingChannel"],"sources":["../../../../src/integrations/prisma/orchestrion.ts"],"sourcesContent":["import * as diagnosticsChannel from '../../utils/diagnosticsChannel';\nimport type { Span } from '@sentry/core';\nimport { getActiveSpan, getRootSpan, spanIsIgnored, startInactiveSpan, withActiveSpan } from '@sentry/core';\nimport { DB_COLLECTION_NAME, DB_OPERATION_NAME, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport { DB } from '@sentry/conventions/op';\nimport type { OrchestrionChannelContext } from '../../orchestrion/types';\nimport { prismaChannels, PRISMA_LAZY_TERMINALS } from '../../orchestrion/config/prisma';\nimport type { TracingChannelLifeCycleOptions } from '../../tracing-channel';\nimport { bindTracingChannelToSpan, safeChannelCallback } from '../../tracing-channel';\nimport { shouldIgnoreSpan } from './tracing-helper';\n\n// Same span name as Prisma v5–v7's own operation span, so the tree looks the same across majors.\nconst OPERATION_SPAN_NAME = 'prisma:client:operation';\nconst PRISMA_ORIGIN = 'auto.db.prisma';\n\n// Terminals call each other (`delete` reads the row through `first`); only the outermost call is the operation.\nconst operationSpans = new WeakSet<Span>();\n\ninterface PrismaCollection {\n modelName?: unknown;\n tableName?: unknown;\n}\n\ninterface PrismaTerminalChannelContext extends OrchestrionChannelContext {\n self?: PrismaCollection;\n}\n\n// Prisma's `AsyncIterableResult`: `await`, `.then()` and `.first()` all funnel through `toArray()`; only\n// `for await` goes through the iterator.\ninterface LazyResult {\n toArray: () => Promise<unknown>;\n [Symbol.asyncIterator]: () => AsyncIterator<unknown>;\n}\n\ninterface PrismaV8InstrumentationOptions {\n ignoreSpanTypes: (string | RegExp)[];\n}\n\n/**\n * Opens a `prisma:client:operation` span per ORM call, kept active while the terminal runs so the `pg`\n * query spans nest under it like the `db_query` spans did on v5–v7.\n */\nexport function instrumentPrismaV8(options: PrismaV8InstrumentationOptions): void {\n if (shouldIgnoreSpan(OPERATION_SPAN_NAME, options.ignoreSpanTypes)) {\n return;\n }\n\n for (const channelName of Object.values(prismaChannels)) {\n const method = channelName.slice(channelName.lastIndexOf(':') + 1);\n const isLazy = (PRISMA_LAZY_TERMINALS as readonly string[]).includes(method);\n\n bindTracingChannelToSpan<PrismaTerminalChannelContext>(\n diagnosticsChannel.tracingChannel<PrismaTerminalChannelContext>(channelName),\n data => startOperationSpan(method, data),\n isLazy ? { deferSpanEnd: deferSpanEndUntilConsumed } : undefined,\n );\n }\n}\n\nfunction startOperationSpan(method: string, data: PrismaTerminalChannelContext): Span | undefined {\n const parentSpan = getActiveSpan();\n if (parentSpan && operationSpans.has(parentSpan)) {\n return undefined;\n }\n\n const model = stringOrUndefined(data.self?.modelName);\n const table = stringOrUndefined(data.self?.tableName);\n\n const span = startInactiveSpan({\n name: OPERATION_SPAN_NAME,\n onlyIfParent: true,\n parentSpan,\n attributes: {\n [SENTRY_ORIGIN]: PRISMA_ORIGIN,\n [SENTRY_OP]: DB,\n [DB_OPERATION_NAME]: method,\n [DB_COLLECTION_NAME]: table ?? model,\n // Prisma v5–v7's own attributes, kept so existing queries keep matching across the major.\n method,\n model,\n name: model ? `${model}.${method}` : method,\n },\n });\n operationSpans.add(span);\n return span;\n}\n\n// A lazy terminal returns before anything is queried, so the span stays open until the result is consumed,\n// with consumption re-routed through the span's context so the driver call lands under it. A result that is\n// never consumed never ran a query; its span is simply never ended.\nconst deferSpanEndUntilConsumed: NonNullable<\n TracingChannelLifeCycleOptions<PrismaTerminalChannelContext>['deferSpanEnd']\n> = ({ span, data, end }) => {\n const result = data.result;\n if (!isLazyResult(result)) {\n return false;\n }\n\n // A throw in a channel subscriber is an uncaught exception; an unpatchable (frozen) result ends the span now.\n return safeChannelCallback(() => patchConsumption(result, span, end)) ?? false;\n};\n\nfunction patchConsumption(result: LazyResult, span: Span, end: (error?: unknown) => void): boolean {\n const toArray = result.toArray;\n const asyncIterator = result[Symbol.asyncIterator];\n\n // Built before either is installed, so a failed assignment can't leave a half-patched result.\n const patchedToArray = function (this: LazyResult): Promise<unknown> {\n const rows: Promise<unknown> = runUnderSpan(span, () => toArray.call(this));\n // Chained, not side-observed, so a rejected fire-and-forget `toArray()` still surfaces as unhandled.\n return rows.then(\n value => {\n end();\n return value;\n },\n (error: unknown) => {\n end(error);\n throw error;\n },\n );\n };\n const patchedAsyncIterator = function (this: LazyResult): AsyncIterableIterator<unknown> {\n return wrapIterator(\n runUnderSpan(span, () => asyncIterator.call(this)),\n span,\n end,\n );\n };\n\n result.toArray = patchedToArray;\n result[Symbol.asyncIterator] = patchedAsyncIterator;\n\n return true;\n}\n\n// An ignored child span is never emitted, so its children must keep parenting to the nearest emitted span\n// (same rule as the tracing-channel binding and core `startSpan`).\nfunction runUnderSpan<T>(span: Span, callback: () => T): T {\n if (spanIsIgnored(span) && getRootSpan(span) !== span) {\n return callback();\n }\n return withActiveSpan(span, callback);\n}\n\nfunction wrapIterator(\n iterator: AsyncIterator<unknown>,\n span: Span,\n end: (error?: unknown) => void,\n): AsyncIterableIterator<unknown> {\n const settle = (step: Promise<IteratorResult<unknown>>): Promise<IteratorResult<unknown>> =>\n step.then(\n result => {\n if (result.done) {\n end();\n }\n return result;\n },\n error => {\n end(error);\n throw error;\n },\n );\n\n return {\n next: (...args) => settle(runUnderSpan(span, () => iterator.next(...args))),\n return: value => {\n const iteratorReturn = iterator.return?.bind(iterator);\n if (!iteratorReturn) {\n end();\n return Promise.resolve({ done: true, value });\n }\n return settle(runUnderSpan(span, () => iteratorReturn(value)));\n },\n throw: error => {\n const iteratorThrow = iterator.throw?.bind(iterator);\n if (!iteratorThrow) {\n end(error);\n return Promise.reject(error);\n }\n return settle(runUnderSpan(span, () => iteratorThrow(error)));\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n };\n}\n\nfunction stringOrUndefined(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction isLazyResult(value: unknown): value is LazyResult {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as LazyResult).toArray === 'function' &&\n typeof (value as LazyResult)[Symbol.asyncIterator] === 'function'\n );\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,sBAAsB;AAC5B,MAAM,gBAAgB;AAGtB,MAAM,iCAAiB,IAAI,QAAc;;;;;AA0BzC,SAAgB,mB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E3D"}
1
+ {"version":3,"file":"orchestrion.js","names":["diagnosticsChannel.tracingChannel"],"sources":["../../../../src/integrations/prisma/orchestrion.ts"],"sourcesContent":["import * as diagnosticsChannel from '../../utils/diagnosticsChannel';\nimport type { Span } from '@sentry/core';\nimport { getActiveSpan, startInactiveSpan, withActiveSpan } from '@sentry/core';\nimport { DB_COLLECTION_NAME, DB_OPERATION_NAME, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport { DB } from '@sentry/conventions/op';\nimport type { OrchestrionChannelContext } from '../../orchestrion/types';\nimport { prismaChannels, PRISMA_LAZY_TERMINALS } from '../../orchestrion/config/prisma';\nimport type { TracingChannelLifeCycleOptions } from '../../tracing-channel';\nimport { bindTracingChannelToSpan, safeChannelCallback } from '../../tracing-channel';\nimport { shouldIgnoreSpan } from './tracing-helper';\n\n// Same span name as Prisma v5–v7's own operation span, so the tree looks the same across majors.\nconst OPERATION_SPAN_NAME = 'prisma:client:operation';\nconst PRISMA_ORIGIN = 'auto.db.prisma';\n\n// Terminals call each other (`delete` reads the row through `first`); only the outermost call is the operation.\nconst operationSpans = new WeakSet<Span>();\n\ninterface PrismaCollection {\n modelName?: unknown;\n tableName?: unknown;\n}\n\ninterface PrismaTerminalChannelContext extends OrchestrionChannelContext {\n self?: PrismaCollection;\n}\n\n// Prisma's `AsyncIterableResult`: `await`, `.then()` and `.first()` all funnel through `toArray()`; only\n// `for await` goes through the iterator.\ninterface LazyResult {\n toArray: () => Promise<unknown>;\n [Symbol.asyncIterator]: () => AsyncIterator<unknown>;\n}\n\ninterface PrismaV8InstrumentationOptions {\n ignoreSpanTypes: (string | RegExp)[];\n}\n\n/**\n * Opens a `prisma:client:operation` span per ORM call, kept active while the terminal runs so the `pg`\n * query spans nest under it like the `db_query` spans did on v5–v7.\n */\nexport function instrumentPrismaV8(options: PrismaV8InstrumentationOptions): void {\n if (shouldIgnoreSpan(OPERATION_SPAN_NAME, options.ignoreSpanTypes)) {\n return;\n }\n\n for (const channelName of Object.values(prismaChannels)) {\n const method = channelName.slice(channelName.lastIndexOf(':') + 1);\n const isLazy = (PRISMA_LAZY_TERMINALS as readonly string[]).includes(method);\n\n bindTracingChannelToSpan<PrismaTerminalChannelContext>(\n diagnosticsChannel.tracingChannel<PrismaTerminalChannelContext>(channelName),\n data => startOperationSpan(method, data),\n isLazy ? { deferSpanEnd: deferSpanEndUntilConsumed } : undefined,\n );\n }\n}\n\nfunction startOperationSpan(method: string, data: PrismaTerminalChannelContext): Span | undefined {\n const parentSpan = getActiveSpan();\n if (parentSpan && operationSpans.has(parentSpan)) {\n return undefined;\n }\n\n const model = stringOrUndefined(data.self?.modelName);\n const table = stringOrUndefined(data.self?.tableName);\n\n const span = startInactiveSpan({\n name: OPERATION_SPAN_NAME,\n onlyIfParent: true,\n parentSpan,\n attributes: {\n [SENTRY_ORIGIN]: PRISMA_ORIGIN,\n [SENTRY_OP]: DB,\n [DB_OPERATION_NAME]: method,\n [DB_COLLECTION_NAME]: table ?? model,\n // Prisma v5–v7's own attributes, kept so existing queries keep matching across the major.\n method,\n model,\n name: model ? `${model}.${method}` : method,\n },\n });\n operationSpans.add(span);\n return span;\n}\n\n// A lazy terminal returns before anything is queried, so the span stays open until the result is consumed,\n// with consumption re-routed through the span's context so the driver call lands under it. A result that is\n// never consumed never ran a query; its span is simply never ended.\nconst deferSpanEndUntilConsumed: NonNullable<\n TracingChannelLifeCycleOptions<PrismaTerminalChannelContext>['deferSpanEnd']\n> = ({ span, data, end }) => {\n const result = data.result;\n if (!isLazyResult(result)) {\n return false;\n }\n\n // A throw in a channel subscriber is an uncaught exception; an unpatchable (frozen) result ends the span now.\n return safeChannelCallback(() => patchConsumption(result, span, end)) ?? false;\n};\n\nfunction patchConsumption(result: LazyResult, span: Span, end: (error?: unknown) => void): boolean {\n const toArray = result.toArray;\n const asyncIterator = result[Symbol.asyncIterator];\n\n // Built before either is installed, so a failed assignment can't leave a half-patched result.\n const patchedToArray = function (this: LazyResult): Promise<unknown> {\n const rows: Promise<unknown> = withActiveSpan(span, () => toArray.call(this));\n // Chained, not side-observed, so a rejected fire-and-forget `toArray()` still surfaces as unhandled.\n return rows.then(\n value => {\n end();\n return value;\n },\n (error: unknown) => {\n end(error);\n throw error;\n },\n );\n };\n const patchedAsyncIterator = function (this: LazyResult): AsyncIterableIterator<unknown> {\n return wrapIterator(\n withActiveSpan(span, () => asyncIterator.call(this)),\n span,\n end,\n );\n };\n\n result.toArray = patchedToArray;\n result[Symbol.asyncIterator] = patchedAsyncIterator;\n\n return true;\n}\n\nfunction wrapIterator(\n iterator: AsyncIterator<unknown>,\n span: Span,\n end: (error?: unknown) => void,\n): AsyncIterableIterator<unknown> {\n const settle = (step: Promise<IteratorResult<unknown>>): Promise<IteratorResult<unknown>> =>\n step.then(\n result => {\n if (result.done) {\n end();\n }\n return result;\n },\n error => {\n end(error);\n throw error;\n },\n );\n\n return {\n next: (...args) => settle(withActiveSpan(span, () => iterator.next(...args))),\n return: value => {\n const iteratorReturn = iterator.return?.bind(iterator);\n if (!iteratorReturn) {\n end();\n return Promise.resolve({ done: true, value });\n }\n return settle(withActiveSpan(span, () => iteratorReturn(value)));\n },\n throw: error => {\n const iteratorThrow = iterator.throw?.bind(iterator);\n if (!iteratorThrow) {\n end(error);\n return Promise.reject(error);\n }\n return settle(withActiveSpan(span, () => iteratorThrow(error)));\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n };\n}\n\nfunction stringOrUndefined(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction isLazyResult(value: unknown): value is LazyResult {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as LazyResult).toArray === 'function' &&\n typeof (value as LazyResult)[Symbol.asyncIterator] === 'function'\n );\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,sBAAsB;AAC5B,MAAM,gBAAgB;AAGtB,MAAM,iCAAiB,IAAI,QAAc;;;;;AA0BzC,SAAgB,mBAAmB,SAA+C;CAChF,IAAI,iBAAiB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,aACL,eAAe,YAAY,cAAc,KAAK,IAAI,CAAC,GACnD,MACA,GACF;CACF;CAEA,OAAO,UAAU;CACjB,OAAO,OAAO,iBAAiB;CAE/B,OAAO;AACT;AAEA,SAAS,aACP,UACA,MACA,KACgC;CAChC,MAAM,UAAU,SACd,KAAK,MACH,WAAU;EACR,IAAI,OAAO,MACT,IAAI;EAEN,OAAO;CACT,IACA,UAAS;EACP,IAAI,KAAK;EACT,MAAM;CACR,CACF;CAEF,OAAO;EACL,OAAO,GAAG,SAAS,OAAO,eAAe,YAAY,SAAS,KAAK,GAAG,IAAI,CAAC,CAAC;EAC5E,SAAQ,UAAS;GACf,MAAM,iBAAiB,SAAS,QAAQ,KAAK,QAAQ;GACrD,IAAI,CAAC,gBAAgB;IACnB,IAAI;IACJ,OAAO,QAAQ,QAAQ;KAAE,MAAM;KAAM;IAAM,CAAC;GAC9C;GACA,OAAO,OAAO,eAAe,YAAY,eAAe,KAAK,CAAC,CAAC;EACjE;EACA,QAAO,UAAS;GACd,MAAM,gBAAgB,SAAS,OAAO,KAAK,QAAQ;GACnD,IAAI,CAAC,eAAe;IAClB,IAAI,KAAK;IACT,OAAO,QAAQ,OAAO,KAAK;GAC7B;GACA,OAAO,OAAO,eAAe,YAAY,cAAc,KAAK,CAAC,CAAC;EAChE;EACA,CAAC,OAAO,iBAAiB;GACvB,OAAO;EACT;CACF;AACF;AAEA,SAAS,kBAAkB,OAAoC;CAC7D,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAA;AAC7C;AAEA,SAAS,aAAa,OAAqC;CACzD,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAqB,YAAY,cACzC,OAAQ,MAAqB,OAAO,mBAAmB;AAE3D"}
@@ -1,7 +1,7 @@
1
+ import { LRUMap, debug, getActiveSpan, startInactiveSpan, startSpanManual } from "@sentry/core";
1
2
  import { DEBUG_BUILD } from "../../debug-build.js";
2
- import { getSqlQueryAttributes, getSqlSpanName, toSqlDialect } from "../../utils/sql.js";
3
3
  import { DB_QUERY_SUMMARY, DB_QUERY_TEXT, DB_STATEMENT, DB_SYSTEM, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
4
- import { LRUMap, debug, getActiveSpan, startInactiveSpan, startSpanManual } from "@sentry/core";
4
+ import { getSqlQueryAttributes, getSqlSpanName, toSqlDialect } from "../../utils/sql.js";
5
5
  // src/integrations/prisma/tracing-helper.ts
6
6
  const showAllTraces = (() => {
7
7
  try {
@@ -1,4 +1,7 @@
1
1
  import { tracingChannel } from "../../utils/diagnosticsChannel.js";
2
+ import { DB_OPERATION_BATCH_SIZE, DB_OPERATION_NAME, DB_QUERY_TEXT, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
3
+ import { DB, DB_QUERY } from "@sentry/conventions/op";
4
+ import { SPAN_STATUS_ERROR, defineIntegration, getActiveSpan, isObjectLike, startInactiveSpan, waitForTracingChannelBinding, withActiveSpan } from "@sentry/core";
2
5
  import { CHANNELS } from "../../orchestrion/channels.js";
3
6
  import { getRedisQueryNaming } from "./redis-span-name.js";
4
7
  import { defaultDbStatementSerializer } from "./redis-statement-serializer.js";
@@ -9,9 +12,6 @@ import { ioredisModuleNames } from "../../orchestrion/config/ioredis.js";
9
12
  import { invokeOrchestrionInstrumentation } from "../../orchestrion/instrumentation.js";
10
13
  import { subscribeRedisDiagnosticChannels } from "./redis-dc-subscriber.js";
11
14
  import { instrumentIoredis } from "./ioredis-channel-subscriber.js";
12
- import { DB_OPERATION_BATCH_SIZE, DB_OPERATION_NAME, DB_QUERY_TEXT, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
13
- import { SPAN_STATUS_ERROR, defineIntegration, getActiveSpan, isObjectLike, startInactiveSpan, waitForTracingChannelBinding, withActiveSpan } from "@sentry/core";
14
- import { DB, DB_QUERY } from "@sentry/conventions/op";
15
15
  // src/integrations/redis/index.ts
16
16
  const INTEGRATION_NAME = "Redis";
17
17
  const ORIGIN = "auto.db.redis";
@@ -1,12 +1,12 @@
1
1
  import { tracingChannel } from "../../utils/diagnosticsChannel.js";
2
+ import { DB_OPERATION_NAME, DB_QUERY_TEXT, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
3
+ import { DB, DB_QUERY } from "@sentry/conventions/op";
4
+ import { startInactiveSpan } from "@sentry/core";
2
5
  import { CHANNELS } from "../../orchestrion/channels.js";
3
6
  import { bindTracingChannelToSpan } from "../../tracing-channel.js";
4
7
  import { applyCacheResponseAttributes, getRedisCacheAttributes } from "./redis-cache.js";
5
8
  import { getRedisQueryNaming } from "./redis-span-name.js";
6
9
  import { defaultDbStatementSerializer } from "./redis-statement-serializer.js";
7
- import { DB_OPERATION_NAME, DB_QUERY_TEXT, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
8
- import { startInactiveSpan } from "@sentry/core";
9
- import { DB, DB_QUERY } from "@sentry/conventions/op";
10
10
  // src/integrations/redis/ioredis-channel-subscriber.ts
11
11
  const ORIGIN = "auto.db.redis";
12
12
  const DB_SYSTEM_VALUE_REDIS = "redis";
@@ -1,6 +1,6 @@
1
1
  import { CACHE_HIT, CACHE_ITEM_SIZE, CACHE_KEY, CACHE_OPERATION, NETWORK_PEER_ADDRESS, NETWORK_PEER_PORT, SENTRY_OP, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
2
- import { CACHE_OPERATION_NAMES, getClient, hasSpanStreamingEnabled, spanToJSON, truncate } from "@sentry/core";
3
2
  import { CACHE_GET, CACHE_PUT, CACHE_REMOVE } from "@sentry/conventions/op";
3
+ import { CACHE_OPERATION_NAMES, getClient, hasSpanStreamingEnabled, spanToJSON, truncate } from "@sentry/core";
4
4
  // src/integrations/redis/redis-cache.ts
5
5
  const SINGLE_ARG_COMMANDS = [
6
6
  "get",
@@ -1,9 +1,9 @@
1
+ import { DB_OPERATION_BATCH_SIZE, DB_OPERATION_NAME, DB_QUERY_TEXT, DB_SYSTEM_NAME, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
2
+ import { DB, DB_QUERY } from "@sentry/conventions/op";
3
+ import { startInactiveSpan } from "@sentry/core";
1
4
  import { bindTracingChannelToSpan } from "../../tracing-channel.js";
2
5
  import { applyCacheResponseAttributes, getRedisCacheAttributes } from "./redis-cache.js";
3
6
  import { getRedisQueryNaming } from "./redis-span-name.js";
4
- import { DB_OPERATION_BATCH_SIZE, DB_OPERATION_NAME, DB_QUERY_TEXT, DB_SYSTEM_NAME, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
5
- import { startInactiveSpan } from "@sentry/core";
6
- import { DB, DB_QUERY } from "@sentry/conventions/op";
7
7
  // src/integrations/redis/redis-dc-subscriber.ts
8
8
  const REDIS_DC_CHANNEL_COMMAND = "node-redis:command";
9
9
  const REDIS_DC_CHANNEL_BATCH = "node-redis:batch";
@@ -1,7 +1,7 @@
1
- import { subscribe } from "../utils/diagnosticsChannel.js";
2
- import { instrumentTunnelServer } from "../utils/tunnelServer.js";
3
1
  import { defineIntegration } from "@sentry/core";
4
2
  import { HTTP_ON_SERVER_REQUEST, handleServedNodeTunnelRequest, serveTunnelIntegration, setNodeTunnelHandler } from "@sentry/core/server";
3
+ import { subscribe } from "../utils/diagnosticsChannel.js";
4
+ import { instrumentTunnelServer } from "../utils/tunnelServer.js";
5
5
  // src/integrations/serveTunnel.ts
6
6
  let isSubscribed = false;
7
7
  /**
@@ -1,11 +1,11 @@
1
1
  import { tracingChannel } from "../utils/diagnosticsChannel.js";
2
+ import { consoleSandbox, defineIntegration, isObjectLike } from "@sentry/core";
2
3
  import { createTanstackAIMiddleware } from "../ai/tanstack-ai/index.js";
3
4
  import { TANSTACK_AI_INTEGRATION_NAME, TANSTACK_AI_MIDDLEWARE_BRAND } from "../ai/tanstack-ai/constants.js";
4
5
  import { CHANNELS } from "../orchestrion/channels.js";
5
6
  import { tanstackAiModuleNames } from "../orchestrion/config/tanstack-ai.js";
6
7
  import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
7
8
  import { safeChannelCallback } from "../tracing-channel.js";
8
- import { consoleSandbox, defineIntegration, isObjectLike } from "@sentry/core";
9
9
  // src/integrations/tanstack-ai.ts
10
10
  const _tanstackAIIntegration = ((options = {}) => {
11
11
  return {
@@ -1,12 +1,12 @@
1
+ import { EventEmitter } from "node:events";
1
2
  import { tracingChannel } from "../utils/diagnosticsChannel.js";
3
+ import { SPAN_STATUS_ERROR, defineIntegration, getClient, hasSpanStreamingEnabled, startInactiveSpan } from "@sentry/core";
4
+ import { DB_NAMESPACE, DB_OPERATION_NAME, DB_QUERY_SUMMARY, DB_QUERY_TEXT, DB_SYSTEM_NAME, DB_USER, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
5
+ import { DB } from "@sentry/conventions/op";
2
6
  import { CHANNELS } from "../orchestrion/channels.js";
3
7
  import { tediousModuleNames } from "../orchestrion/config/tedious.js";
4
8
  import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
5
9
  import { getSqlQueryAttributes } from "../utils/sql.js";
6
- import { DB_NAMESPACE, DB_OPERATION_NAME, DB_QUERY_SUMMARY, DB_QUERY_TEXT, DB_SYSTEM_NAME, DB_USER, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
7
- import { SPAN_STATUS_ERROR, defineIntegration, getClient, hasSpanStreamingEnabled, startInactiveSpan } from "@sentry/core";
8
- import { DB } from "@sentry/conventions/op";
9
- import { EventEmitter } from "node:events";
10
10
  // src/integrations/tedious.ts
11
11
  const INTEGRATION_NAME = "Tedious";
12
12
  const ORIGIN = "auto.db.tedious";
@@ -1,7 +1,7 @@
1
+ import { defineIntegration } from "@sentry/core";
1
2
  import { CHANNELS } from "../orchestrion/channels.js";
2
3
  import { togetherAiModuleNames } from "../orchestrion/config/together-ai.js";
3
4
  import { createOpenAiCompatibleIntegration } from "./openai-compatible.js";
4
- import { defineIntegration } from "@sentry/core";
5
5
  // src/integrations/together-ai.ts
6
6
  /**
7
7
  * Instruments the `together-ai` client (chat completions and embeddings). Together speaks the OpenAI wire
@@ -1,4 +1,5 @@
1
1
  import { tracingChannel } from "../utils/diagnosticsChannel.js";
2
+ import { defineIntegration } from "@sentry/core";
2
3
  import { runGenAiSpanEnd, runGenAiSpanStart } from "../ai/core/span-hooks.js";
3
4
  import { resolveGenAiCallRecording } from "../ai/core/utils.js";
4
5
  import { addResponseAttributes, onSystemOneResponse, startDecideSpan } from "../ai/typesafe/index.js";
@@ -7,7 +8,6 @@ import { CHANNELS } from "../orchestrion/channels.js";
7
8
  import { typesafeModuleNames } from "../orchestrion/config/typesafe.js";
8
9
  import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
9
10
  import { bindTracingChannelToSpan } from "../tracing-channel.js";
10
- import { defineIntegration } from "@sentry/core";
11
11
  // src/integrations/typesafe.ts
12
12
  const _typesafeIntegration = ((options = {}) => {
13
13
  return {
@@ -1,5 +1,5 @@
1
- import { asNumber, mapObjectValues } from "./util.js";
2
1
  import { isObjectLike, stringify } from "@sentry/core";
2
+ import { asNumber, mapObjectValues } from "./util.js";
3
3
  // src/integrations/vercel-ai/extract.ts
4
4
  /**
5
5
  * Joins the text of the AI SDK state parts into one Clairic `state` string. The gateway does this join on
@@ -1,10 +1,10 @@
1
+ import { defineIntegration, waitForTracingChannelBinding } from "@sentry/core";
1
2
  import { subscribeVercelAiTracingChannel } from "./vercel-ai-dc-subscriber.js";
2
3
  import { registerVercelAiToolTelemetry } from "./vercel-ai-tool-telemetry.js";
3
4
  import { tracingChannel } from "../../utils/diagnosticsChannel.js";
4
5
  import { invokeOrchestrionInstrumentation } from "../../orchestrion/instrumentation.js";
5
6
  import { vercelAiModuleNames } from "../../orchestrion/config/vercel-ai.js";
6
7
  import { subscribeVercelAiOrchestrionChannels } from "./vercel-ai-orchestrion-subscriber.js";
7
- import { defineIntegration, waitForTracingChannelBinding } from "@sentry/core";
8
8
  // src/integrations/vercel-ai/index.ts
9
9
  const _vercelAIIntegration = ((options = {}) => {
10
10
  return {
@@ -1,6 +1,6 @@
1
+ import { isObjectLike } from "@sentry/core";
1
2
  import { recordTimeToFirstChunk } from "../../ai/core/time-to-first-chunk.js";
2
3
  import { isReadableStream } from "../../ai/core/utils.js";
3
- import { isObjectLike } from "@sentry/core";
4
4
  // src/integrations/vercel-ai/util.ts
5
5
  /** Narrow to a string, or `undefined` for anything else. */
6
6
  function asString(value) {
@@ -48,7 +48,7 @@ function tapModelCallStream(span, stream, onFinal, onError) {
48
48
  controller.close();
49
49
  return;
50
50
  }
51
- if (value?.type !== "stream-start") recordTimeToFirstChunk(span);
51
+ if (hasOutput(value)) recordTimeToFirstChunk(span);
52
52
  text += accumulateChunk(state, value) ?? "";
53
53
  controller.enqueue(value);
54
54
  } catch (error) {
@@ -63,6 +63,25 @@ function tapModelCallStream(span, stream, onFinal, onError) {
63
63
  });
64
64
  }
65
65
  /**
66
+ * Whether a chunk carries new model output, which is what `gen_ai.response.time_to_first_chunk` measures.
67
+ * `stream-start`, `response-metadata`, empty `*-start` and `finish` chunks do not.
68
+ */
69
+ function hasOutput(chunk) {
70
+ if (!isObjectLike(chunk)) return false;
71
+ const { type, delta, textDelta, argsTextDelta } = chunk;
72
+ switch (type) {
73
+ case "text-delta":
74
+ case "reasoning-delta":
75
+ case "tool-input-delta": return !!(delta ?? textDelta);
76
+ case "reasoning": return !!textDelta;
77
+ case "tool-call-delta": return !!argsTextDelta;
78
+ case "tool-input-start":
79
+ case "tool-call":
80
+ case "file": return true;
81
+ default: return false;
82
+ }
83
+ }
84
+ /**
66
85
  * Fold a single streamed chunk into the running aggregate. Returns any text delta so the caller can
67
86
  * accumulate it (kept out of `state` until the end to avoid re-joining on every chunk).
68
87
  */
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","names":[],"sources":["../../../../src/integrations/vercel-ai/util.ts"],"sourcesContent":["/** Shared, state-free helpers for the Vercel AI (`ai`) channel subscribers, plus the streamed model-call tap. */\n\nimport type { Span } from '@sentry/core';\nimport { isObjectLike } from '@sentry/core';\nimport { recordTimeToFirstChunk } from '../../ai/core/time-to-first-chunk';\n\n/** Narrow to a string, or `undefined` for anything else. */\nexport function asString(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\n/** Narrow to a finite number, or `undefined` for anything else (including `NaN`). */\nexport function asNumber(value: unknown): number | undefined {\n return typeof value === 'number' && !isNaN(value) ? value : undefined;\n}\n\n/** Add two optional numbers, treating a missing operand as `0` but returning `undefined` when both are absent. */\nexport function sum(a: number | undefined, b: number | undefined): number | undefined {\n return a === undefined && b === undefined ? undefined : (a ?? 0) + (b ?? 0);\n}\n\n/*\n * Streaming support for the `ai:telemetry` tracing channel.\n *\n * For a streamed model call (`doStream`) the SDK resolves the `languageModelCall` channel promise as\n * soon as it hands back the *unconsumed* stream — so `result.stream` is a `ReadableStream` and the\n * final usage / finish reason / output only arrive later, as the stream is drained (they ride the\n * stream's own `finish`/`text-delta`/`tool-call` chunks, never the channel context). The SDK\n * deliberately leaves `result` undefined on the `streamText`/`step` contexts and exposes the stream\n * only on the model call, expecting consumers to tap it themselves.\n * @see https://github.com/vercel/ai/pull/15660 (discussion: \"tee off and aggregate ourselves\")\n *\n * We replace `result.stream` with a passthrough that forwards every chunk untouched (so the SDK's own\n * consumption is unaffected) while accumulating the data we need, then hand the aggregate back once the\n * stream settles so the model-call span can be enriched and ended out-of-band.\n */\n\n/** The subset of a streamed provider chunk we read. Unknown chunk types are forwarded and ignored. */\ninterface StreamChunk {\n type?: unknown;\n delta?: unknown;\n // v4 text-delta chunks carry the text on `textDelta`; v5+ uses `delta`.\n textDelta?: unknown;\n id?: unknown;\n modelId?: unknown;\n toolCallId?: unknown;\n toolName?: unknown;\n input?: unknown;\n args?: unknown;\n finishReason?: unknown;\n usage?: unknown;\n providerMetadata?: unknown;\n error?: unknown;\n}\n\n/** The aggregate handed back once a streamed model call finishes, in the shape `enrichSpanOnEnd` expects. */\nexport interface StreamedModelCallResult {\n text?: string;\n toolCalls: Array<Record<string, unknown>>;\n usage?: unknown;\n finishReason?: unknown;\n responseId?: string;\n responseModel?: string;\n providerMetadata?: unknown;\n}\n\n/** The streamed model call exposes a web `ReadableStream` on `result.stream`. */\nexport { isReadableStream } from '../../ai/core/utils';\n\n/**\n * Wrap a streamed model call's `ReadableStream` so its chunks are observed as the SDK consumes them,\n * without altering what the SDK sees. Returns a replacement stream to swap onto `result.stream`.\n *\n * `onFinal` runs exactly once when the stream drains cleanly; `onError` runs exactly once if it errors\n * or is cancelled. Reading one source chunk per `pull` preserves the SDK's backpressure. The\n * `try/catch` around every read guarantees the owning span is always ended — a leaked open span on a\n * mid-stream failure would be worse than a slightly-less-enriched one.\n */\nexport function tapModelCallStream(\n span: Span,\n stream: ReadableStream<unknown>,\n onFinal: (result: StreamedModelCallResult) => void,\n onError: (error: unknown) => void,\n): ReadableStream<unknown> {\n const reader = stream.getReader();\n const state: StreamedModelCallResult = { toolCalls: [] };\n let text = '';\n let settled = false;\n\n const finalize = (): void => {\n if (settled) {\n return;\n }\n settled = true;\n if (text) {\n state.text = text;\n }\n onFinal(state);\n };\n\n const fail = (error: unknown): void => {\n if (settled) {\n return;\n }\n settled = true;\n onError(error);\n };\n\n return new ReadableStream<unknown>({\n async pull(controller) {\n try {\n const { done, value } = await reader.read();\n if (done) {\n finalize();\n controller.close();\n\n return;\n }\n // The model emits `stream-start` before the response arrives.\n if ((value as StreamChunk | undefined)?.type !== 'stream-start') {\n recordTimeToFirstChunk(span);\n }\n text += accumulateChunk(state, value) ?? '';\n controller.enqueue(value);\n } catch (error) {\n fail(error);\n controller.error(error);\n }\n },\n cancel(reason) {\n // Consumer stopped reading early (e.g. a `break` out of `for await`); close out the span with\n // whatever we have rather than leave it open. A non-error reason is a deliberate stop, not a failure.\n finalize();\n\n return reader.cancel(reason);\n },\n });\n}\n\n/**\n * Fold a single streamed chunk into the running aggregate. Returns any text delta so the caller can\n * accumulate it (kept out of `state` until the end to avoid re-joining on every chunk).\n */\nfunction accumulateChunk(state: StreamedModelCallResult, chunk: unknown): string | undefined {\n if (!isObjectLike(chunk)) {\n return undefined;\n }\n const {\n type,\n delta,\n textDelta,\n id,\n modelId,\n toolCallId,\n toolName,\n input,\n args,\n finishReason,\n usage,\n providerMetadata,\n } = chunk as StreamChunk;\n\n switch (type) {\n case 'text-delta': {\n const textChunk = delta ?? textDelta;\n return typeof textChunk === 'string' ? textChunk : undefined;\n }\n case 'tool-call':\n state.toolCalls.push({ toolCallId, toolName, input: input ?? args });\n\n return undefined;\n case 'response-metadata':\n if (typeof id === 'string') {\n state.responseId = id;\n }\n if (typeof modelId === 'string') {\n state.responseModel = modelId;\n }\n\n return undefined;\n case 'finish':\n state.finishReason = finishReason;\n state.usage = usage;\n if (providerMetadata !== undefined) {\n state.providerMetadata = providerMetadata;\n }\n\n return undefined;\n default:\n return undefined;\n }\n}\n\n/** Maps each object value of `record` and keeps the other values as they are. */\nexport function mapObjectValues(\n record: Record<string, unknown>,\n fn: (value: Record<string, unknown>, key: string) => unknown,\n): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(record).map(([key, value]) => [key, isObjectLike(value) ? fn(value, key) : value]),\n );\n}\n"],"mappings":";;;;;AAOA,SAAgB,SAAS,OAAoC;CAC3D,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAA;AAC7C;;AAGA,SAAgB,SAAS,OAAoC;CAC3D,OA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AK;GACH,MAAM,UAAU,KAAK;IAAE;IAAY;IAAU,OAAO,SAAS;GAAK,CAAC;GAEnE;EACF,KAAK;GACH,IAAI,OAAO,OAAO,UAChB,MAAM,aAAa;GAErB,IAAI,OAAO,YAAY,UACrB,MAAM,gBAAgB;GAGxB;EACF,KAAK;GACH,MAAM,eAAe;GACrB,MAAM,QAAQ;GACd,IAAI,qBAAqB,KAAA,GACvB,MAAM,mBAAmB;GAG3B;EACF,SACE;CACJ;AACF;;AAGA,SAAgB,gBACd,QACA,IACyB;CACzB,OAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,aAAa,KAAK,IAAI,GAAG,OAAO,GAAG,IAAI,KAAK,CAAC,CAClG;AACF"}
1
+ {"version":3,"file":"util.js","names":[],"sources":["../../../../src/integrations/vercel-ai/util.ts"],"sourcesContent":["/** Shared, state-free helpers for the Vercel AI (`ai`) channel subscribers, plus the streamed model-call tap. */\n\nimport type { Span } from '@sentry/core';\nimport { isObjectLike } from '@sentry/core';\nimport { recordTimeToFirstChunk } from '../../ai/core/time-to-first-chunk';\n\n/** Narrow to a string, or `undefined` for anything else. */\nexport function asString(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\n/** Narrow to a finite number, or `undefined` for anything else (including `NaN`). */\nexport function asNumber(value: unknown): number | undefined {\n return typeof value === 'number' && !isNaN(value) ? value : undefined;\n}\n\n/** Add two optional numbers, treating a missing operand as `0` but returning `undefined` when both are absent. */\nexport function sum(a: number | undefined, b: number | undefined): number | undefined {\n return a === undefined && b === undefined ? undefined : (a ?? 0) + (b ?? 0);\n}\n\n/*\n * Streaming support for the `ai:telemetry` tracing channel.\n *\n * For a streamed model call (`doStream`) the SDK resolves the `languageModelCall` channel promise as\n * soon as it hands back the *unconsumed* stream — so `result.stream` is a `ReadableStream` and the\n * final usage / finish reason / output only arrive later, as the stream is drained (they ride the\n * stream's own `finish`/`text-delta`/`tool-call` chunks, never the channel context). The SDK\n * deliberately leaves `result` undefined on the `streamText`/`step` contexts and exposes the stream\n * only on the model call, expecting consumers to tap it themselves.\n * @see https://github.com/vercel/ai/pull/15660 (discussion: \"tee off and aggregate ourselves\")\n *\n * We replace `result.stream` with a passthrough that forwards every chunk untouched (so the SDK's own\n * consumption is unaffected) while accumulating the data we need, then hand the aggregate back once the\n * stream settles so the model-call span can be enriched and ended out-of-band.\n */\n\n/** The subset of a streamed provider chunk we read. Unknown chunk types are forwarded and ignored. */\ninterface StreamChunk {\n type?: unknown;\n delta?: unknown;\n // v4 text-delta chunks carry the text on `textDelta`; v5+ uses `delta`.\n textDelta?: unknown;\n id?: unknown;\n modelId?: unknown;\n toolCallId?: unknown;\n toolName?: unknown;\n input?: unknown;\n args?: unknown;\n finishReason?: unknown;\n usage?: unknown;\n providerMetadata?: unknown;\n error?: unknown;\n}\n\n/** The aggregate handed back once a streamed model call finishes, in the shape `enrichSpanOnEnd` expects. */\nexport interface StreamedModelCallResult {\n text?: string;\n toolCalls: Array<Record<string, unknown>>;\n usage?: unknown;\n finishReason?: unknown;\n responseId?: string;\n responseModel?: string;\n providerMetadata?: unknown;\n}\n\n/** The streamed model call exposes a web `ReadableStream` on `result.stream`. */\nexport { isReadableStream } from '../../ai/core/utils';\n\n/**\n * Wrap a streamed model call's `ReadableStream` so its chunks are observed as the SDK consumes them,\n * without altering what the SDK sees. Returns a replacement stream to swap onto `result.stream`.\n *\n * `onFinal` runs exactly once when the stream drains cleanly; `onError` runs exactly once if it errors\n * or is cancelled. Reading one source chunk per `pull` preserves the SDK's backpressure. The\n * `try/catch` around every read guarantees the owning span is always ended — a leaked open span on a\n * mid-stream failure would be worse than a slightly-less-enriched one.\n */\nexport function tapModelCallStream(\n span: Span,\n stream: ReadableStream<unknown>,\n onFinal: (result: StreamedModelCallResult) => void,\n onError: (error: unknown) => void,\n): ReadableStream<unknown> {\n const reader = stream.getReader();\n const state: StreamedModelCallResult = { toolCalls: [] };\n let text = '';\n let settled = false;\n\n const finalize = (): void => {\n if (settled) {\n return;\n }\n settled = true;\n if (text) {\n state.text = text;\n }\n onFinal(state);\n };\n\n const fail = (error: unknown): void => {\n if (settled) {\n return;\n }\n settled = true;\n onError(error);\n };\n\n return new ReadableStream<unknown>({\n async pull(controller) {\n try {\n const { done, value } = await reader.read();\n if (done) {\n finalize();\n controller.close();\n\n return;\n }\n if (hasOutput(value)) {\n recordTimeToFirstChunk(span);\n }\n text += accumulateChunk(state, value) ?? '';\n controller.enqueue(value);\n } catch (error) {\n fail(error);\n controller.error(error);\n }\n },\n cancel(reason) {\n // Consumer stopped reading early (e.g. a `break` out of `for await`); close out the span with\n // whatever we have rather than leave it open. A non-error reason is a deliberate stop, not a failure.\n finalize();\n\n return reader.cancel(reason);\n },\n });\n}\n\n/**\n * Whether a chunk carries new model output, which is what `gen_ai.response.time_to_first_chunk` measures.\n * `stream-start`, `response-metadata`, empty `*-start` and `finish` chunks do not.\n */\nfunction hasOutput(chunk: unknown): boolean {\n if (!isObjectLike(chunk)) {\n return false;\n }\n const { type, delta, textDelta, argsTextDelta } = chunk as StreamChunk & { argsTextDelta?: unknown };\n switch (type) {\n case 'text-delta':\n case 'reasoning-delta':\n case 'tool-input-delta':\n return !!(delta ?? textDelta);\n // v4 streams reasoning on `textDelta` and tool arguments on `argsTextDelta`.\n case 'reasoning':\n return !!textDelta;\n case 'tool-call-delta':\n return !!argsTextDelta;\n // These carry a tool name, a whole tool call or a generated file.\n case 'tool-input-start':\n case 'tool-call':\n case 'file':\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Fold a single streamed chunk into the running aggregate. Returns any text delta so the caller can\n * accumulate it (kept out of `state` until the end to avoid re-joining on every chunk).\n */\nfunction accumulateChunk(state: StreamedModelCallResult, chunk: unknown): string | undefined {\n if (!isObjectLike(chunk)) {\n return undefined;\n }\n const {\n type,\n delta,\n textDelta,\n id,\n modelId,\n toolCallId,\n toolName,\n input,\n args,\n finishReason,\n usage,\n providerMetadata,\n } = chunk as StreamChunk;\n\n switch (type) {\n case 'text-delta': {\n const textChunk = delta ?? textDelta;\n return typeof textChunk === 'string' ? textChunk : undefined;\n }\n case 'tool-call':\n state.toolCalls.push({ toolCallId, toolName, input: input ?? args });\n\n return undefined;\n case 'response-metadata':\n if (typeof id === 'string') {\n state.responseId = id;\n }\n if (typeof modelId === 'string') {\n state.responseModel = modelId;\n }\n\n return undefined;\n case 'finish':\n state.finishReason = finishReason;\n state.usage = usage;\n if (providerMetadata !== undefined) {\n state.providerMetadata = providerMetadata;\n }\n\n return undefined;\n default:\n return undefined;\n }\n}\n\n/** Maps each object value of `record` and keeps the other values as they are. */\nexport function mapObjectValues(\n record: Record<string, unknown>,\n fn: (value: Record<string, unknown>, key: string) => unknown,\n): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(record).map(([key, value]) => [key, isObjectLike(value) ? fn(value, key) : value]),\n );\n}\n"],"mappings":";;;;;AAOA,SAAgB,SAAS,OAAoC;CAC3D,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAA;AAC7C;;AAGA,SAAgB,SAAS,OAAoC;CAC3D,OAAO,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK,IAAI,QAAQ,KAAA;AAC9D;;AAGA,SAAgB,IAAI,GAAuB,GAA2C;CACpF,OAAO,MAAM,KAAA,KAAa,MAAM,KAAA,IAAY,KAAA,KAAa,KAAK,MAAM,KAAK;AAC3E;;;;;;;;;;AA2DA,SAAgB,mBACd,MACA,QACA,SACA,SACyB;CACzB,MAAM,SAAS,OAAO,UAAU;CAChC,MAAM,QAAiC,EAAE,WAAW,CAAC,EAAE;CACvD,IAAI,OAAO;CACX,IAAI,UAAU;CAEd,MAAM,iBAAuB;EAC3B,IAAI,SACF;EAEF,UAAU;EACV,IAAI,MACF,MAAM,OAAO;EAEf,QAAQ,KAAK;CACf;CAEA,MAAM,QAAQ,UAAyB;EACrC,IAAI,SACF;EAEF,UAAU;EACV,QAAQ,KAAK;CACf;CAEA,OAAO,IA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ACrB,MAAM,QAAQ;GACd,IAAI,qBAAqB,KAAA,GACvB,MAAM,mBAAmB;GAG3B;EACF,SACE;CACJ;AACF;;AAGA,SAAgB,gBACd,QACA,IACyB;CACzB,OAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,aAAa,KAAK,IAAI,GAAG,OAAO,GAAG,IAAI,KAAK,CAAC,CAClG;AACF"}
@@ -1,3 +1,6 @@
1
+ import { GEN_AI_CONVERSATION_ID, GEN_AI_COST_TOTAL_TOKENS, GEN_AI_EMBEDDINGS_INPUT, GEN_AI_FUNCTION_ID, GEN_AI_INPUT_MESSAGES, GEN_AI_OPERATION_NAME, GEN_AI_OUTPUT_MESSAGES, GEN_AI_PROVIDER_NAME, GEN_AI_REQUEST_MODEL, GEN_AI_RESPONSE_FINISH_REASONS, GEN_AI_RESPONSE_ID, GEN_AI_RESPONSE_MODEL, GEN_AI_RESPONSE_STREAMING, GEN_AI_SYSTEM_INSTRUCTIONS, GEN_AI_TOOL_CALL_ARGUMENTS, GEN_AI_TOOL_CALL_RESULT, GEN_AI_TOOL_DEFINITIONS, GEN_AI_TOOL_DESCRIPTION, GEN_AI_TOOL_NAME, GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, GEN_AI_USAGE_INPUT_TOKENS, GEN_AI_USAGE_OUTPUT_TOKENS, GEN_AI_USAGE_REASONING_OUTPUT_TOKENS, GEN_AI_USAGE_TOTAL_TOKENS, SENTRY_OP, SENTRY_ORIGIN, VERCEL_AI_SETTINGS_CONTEXT_KEY_BASE, VERCEL_AI_TOOL_CALL_CONTEXT_KEY_BASE } from "@sentry/conventions/attributes";
2
+ import { GEN_AI_DECIDE, GEN_AI_EMBEDDINGS, GEN_AI_EXECUTE_TOOL, GEN_AI_EXTRACT, GEN_AI_GENERATE_CONTENT, GEN_AI_INVOKE_AGENT, GEN_AI_RERANK } from "@sentry/conventions/op";
3
+ import { SPAN_STATUS_ERROR, _INTERNAL_skipAiProviderWrapping, captureException, getActiveSpan, getClient, isObjectLike, isPlainObject, spanToJSON, spanToTraceContext, startInactiveSpan, stringify, withScope } from "@sentry/core";
1
4
  import { GEN_AI_TOOL_CALL_ID_ATTRIBUTE } from "../../ai/core/gen-ai-attributes.js";
2
5
  import { runGenAiSpanEnd, runGenAiSpanStart } from "../../ai/core/span-hooks.js";
3
6
  import { isEveGenAiRecordingDefault } from "./gen-ai-recording-mode.js";
@@ -7,9 +10,6 @@ import { WORKERS_AI_INTEGRATION_NAME } from "../../ai/workers-ai/constants.js";
7
10
  import { bindTracingChannelToSpan } from "../../tracing-channel.js";
8
11
  import { toExtractAnswers, toExtractFields, toExtractState } from "./extract.js";
9
12
  import { asNumber, asString, mapObjectValues, sum, tapModelCallStream } from "./util.js";
10
- import { GEN_AI_CONVERSATION_ID, GEN_AI_COST_TOTAL_TOKENS, GEN_AI_EMBEDDINGS_INPUT, GEN_AI_FUNCTION_ID, GEN_AI_INPUT_MESSAGES, GEN_AI_OPERATION_NAME, GEN_AI_OUTPUT_MESSAGES, GEN_AI_PROVIDER_NAME, GEN_AI_REQUEST_MODEL, GEN_AI_RESPONSE_FINISH_REASONS, GEN_AI_RESPONSE_ID, GEN_AI_RESPONSE_MODEL, GEN_AI_RESPONSE_STREAMING, GEN_AI_SYSTEM_INSTRUCTIONS, GEN_AI_TOOL_CALL_ARGUMENTS, GEN_AI_TOOL_CALL_RESULT, GEN_AI_TOOL_DEFINITIONS, GEN_AI_TOOL_DESCRIPTION, GEN_AI_TOOL_NAME, GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, GEN_AI_USAGE_INPUT_TOKENS, GEN_AI_USAGE_OUTPUT_TOKENS, GEN_AI_USAGE_REASONING_OUTPUT_TOKENS, GEN_AI_USAGE_TOTAL_TOKENS, SENTRY_OP, SENTRY_ORIGIN, VERCEL_AI_SETTINGS_CONTEXT_KEY_BASE, VERCEL_AI_TOOL_CALL_CONTEXT_KEY_BASE } from "@sentry/conventions/attributes";
11
- import { SPAN_STATUS_ERROR, _INTERNAL_skipAiProviderWrapping, captureException, getActiveSpan, getClient, isObjectLike, isPlainObject, spanToJSON, spanToTraceContext, startInactiveSpan, stringify, withScope } from "@sentry/core";
12
- import { GEN_AI_DECIDE, GEN_AI_EMBEDDINGS, GEN_AI_EXECUTE_TOOL, GEN_AI_EXTRACT, GEN_AI_GENERATE_CONTENT, GEN_AI_INVOKE_AGENT, GEN_AI_RERANK } from "@sentry/conventions/op";
13
13
  // src/integrations/vercel-ai/vercel-ai-dc-subscriber.ts
14
14
  /**
15
15
  * The single tracing channel the `ai` package (>= 7) publishes all telemetry lifecycle events to
@@ -1,10 +1,10 @@
1
+ import { SPAN_STATUS_ERROR, addNonEnumerableProperty, debug, getActiveSpan, isObjectLike, withActiveSpan } from "@sentry/core";
1
2
  import { DEBUG_BUILD } from "../../debug-build.js";
2
3
  import { isReadableStream } from "../../ai/core/utils.js";
3
4
  import { CHANNELS } from "../../orchestrion/channels.js";
4
5
  import { bindTracingChannelToSpan } from "../../tracing-channel.js";
5
6
  import { captureToolError, clearOperationCallId, clearOperationId, createSpanFromMessage, enrichSpanOnEnd, runVercelAiSpanEnd, streamedResultToChannelResult } from "./vercel-ai-dc-subscriber.js";
6
7
  import { asString, tapModelCallStream } from "./util.js";
7
- import { SPAN_STATUS_ERROR, addNonEnumerableProperty, debug, getActiveSpan, isObjectLike, withActiveSpan } from "@sentry/core";
8
8
  // src/integrations/vercel-ai/vercel-ai-orchestrion-subscriber.ts
9
9
  const PATCHED = Symbol("SentryVercelAiModelPatched");
10
10
  const TOOL_PATCHED = Symbol("SentryVercelAiToolPatched");
@@ -1,9 +1,9 @@
1
+ import { SENTRY_OP } from "@sentry/conventions/attributes";
2
+ import { GEN_AI_GENERATE_CONTENT } from "@sentry/conventions/op";
3
+ import { getActiveSpan, handleCallbackErrors, spanToJSON } from "@sentry/core";
1
4
  import "../../ai/core/gen-ai-attributes.js";
2
5
  import { tracingChannel } from "../../utils/diagnosticsChannel.js";
3
6
  import { AI_SDK_TELEMETRY_TRACING_CHANNEL, fallbackChannelResults } from "./vercel-ai-dc-subscriber.js";
4
- import { SENTRY_OP } from "@sentry/conventions/attributes";
5
- import { getActiveSpan, handleCallbackErrors, spanToJSON } from "@sentry/core";
6
- import { GEN_AI_GENERATE_CONTENT } from "@sentry/conventions/op";
7
7
  // src/integrations/vercel-ai/vercel-ai-tool-telemetry.ts
8
8
  const openToolCalls = /* @__PURE__ */ new Map();
9
9
  function isRecordingOff(event) {
@@ -1,6 +1,6 @@
1
- import { DEBUG_BUILD } from "../debug-build.js";
2
1
  import { SENTRY_ORIGIN } from "@sentry/conventions/attributes";
3
2
  import { captureLogEvent, debug, isObjectLike } from "@sentry/core";
3
+ import { DEBUG_BUILD } from "../debug-build.js";
4
4
  // src/integrations/winston.ts
5
5
  const DEFAULT_CAPTURED_LEVELS = [
6
6
  "trace",
@@ -1,5 +1,5 @@
1
- import { SENTRY_API_VERSION, defineIntegration, dsnFromString, registerExternalPropagationContext } from "@sentry/core";
2
1
  import { isSpanContextValid, trace } from "@opentelemetry/api";
2
+ import { SENTRY_API_VERSION, defineIntegration, dsnFromString, registerExternalPropagationContext } from "@sentry/core";
3
3
  // src/opentelemetry.ts
4
4
  const INTEGRATION_NAME = "OpenTelemetry";
5
5
  const _openTelemetryIntegration = (() => {
@@ -1,8 +1,8 @@
1
1
  import codeTransformerEsbuild from "../../vendored/@apm-js-collab/code-transformer-bundler-plugins/dist/esm/esbuild.js";
2
+ import { escapeStringForRegex } from "@sentry/core";
2
3
  import { instrumentedModuleNames } from "../config/index.js";
3
4
  import { externalEntryMatchesModule, externalizedModulesWarning, orchestrionTransformOptions } from "./options.js";
4
5
  import { SNIPPET_IMPORT_SPECIFIER_FILTER, resolveOrchestrionRuntimeRequest } from "./resolve.js";
5
- import { escapeStringForRegex } from "@sentry/core";
6
6
  // src/orchestrion/bundler/esbuild.ts
7
7
  function matchesEsbuildExternal(entry, moduleName) {
8
8
  if (entry.includes("*")) return new RegExp(`^${entry.split("*").map(escapeStringForRegex).join(".*")}$`).test(moduleName);
@@ -1,7 +1,7 @@
1
1
  import { isPlainObject } from "@sentry/core";
2
+ import { readFileSync } from "node:fs";
2
3
  import { createRequire, isBuiltin } from "node:module";
3
4
  import { isAbsolute } from "node:path";
4
- import { readFileSync } from "node:fs";
5
5
  // src/orchestrion/bundler/externalRequire.ts
6
6
  const NODE_MODULES = "/node_modules/";
7
7
  /**
@@ -1,9 +1,9 @@
1
+ import { isBuiltin } from "node:module";
1
2
  import "../../vendored/@apm-js-collab/code-transformer-bundler-plugins/dist/esm/rollup.js";
2
3
  import { t as codeTransformerRollup } from "../../vendored/@apm-js-collab/code-transformer-bundler-plugins/dist/esm/rollup-CzqrjlS4.js";
3
4
  import { instrumentedModuleNames } from "../config/index.js";
4
5
  import { externalEntryMatchesModule, externalizedModulesWarning, orchestrionTransformOptions } from "./options.js";
5
6
  import { resolveOrchestrionRuntimeRequest } from "./resolve.js";
6
- import { isBuiltin } from "node:module";
7
7
  // src/orchestrion/bundler/rollup.ts
8
8
  /**
9
9
  * Whether a raw (un-normalized) `external` input option marks `name` as