@sentry/server-utils 10.64.0 → 10.66.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 (520) hide show
  1. package/build/cjs/graphql/graphql-dc-subscriber.js +123 -0
  2. package/build/cjs/graphql/graphql-dc-subscriber.js.map +1 -0
  3. package/build/cjs/graphql/index.js +23 -0
  4. package/build/cjs/graphql/index.js.map +1 -0
  5. package/build/cjs/graphql/utils.js +92 -0
  6. package/build/cjs/graphql/utils.js.map +1 -0
  7. package/build/cjs/index.js +13 -11
  8. package/build/cjs/index.js.map +1 -1
  9. package/build/cjs/integrations/tracing-channel/amqplib.js +420 -0
  10. package/build/cjs/integrations/tracing-channel/amqplib.js.map +1 -0
  11. package/build/cjs/integrations/tracing-channel/dataloader.js +95 -0
  12. package/build/cjs/integrations/tracing-channel/dataloader.js.map +1 -0
  13. package/build/cjs/integrations/tracing-channel/express/index.js +24 -0
  14. package/build/cjs/integrations/tracing-channel/express/index.js.map +1 -0
  15. package/build/cjs/integrations/tracing-channel/express/instrumentation.js +173 -0
  16. package/build/cjs/integrations/tracing-channel/express/instrumentation.js.map +1 -0
  17. package/build/cjs/integrations/tracing-channel/express/route.js +76 -0
  18. package/build/cjs/integrations/tracing-channel/express/route.js.map +1 -0
  19. package/build/cjs/integrations/tracing-channel/fastify/instrumentation.js +1 -1
  20. package/build/cjs/integrations/tracing-channel/fastify/instrumentation.js.map +1 -1
  21. package/build/cjs/integrations/tracing-channel/generic-pool.js +34 -0
  22. package/build/cjs/integrations/tracing-channel/generic-pool.js.map +1 -0
  23. package/build/cjs/integrations/tracing-channel/google-genai.js +96 -0
  24. package/build/cjs/integrations/tracing-channel/google-genai.js.map +1 -0
  25. package/build/cjs/integrations/tracing-channel/graphql/constants.js +26 -0
  26. package/build/cjs/integrations/tracing-channel/graphql/constants.js.map +1 -0
  27. package/build/cjs/integrations/tracing-channel/graphql/index.js +66 -0
  28. package/build/cjs/integrations/tracing-channel/graphql/index.js.map +1 -0
  29. package/build/cjs/integrations/tracing-channel/graphql/resolvers.js +168 -0
  30. package/build/cjs/integrations/tracing-channel/graphql/resolvers.js.map +1 -0
  31. package/build/cjs/integrations/tracing-channel/graphql/spans.js +102 -0
  32. package/build/cjs/integrations/tracing-channel/graphql/spans.js.map +1 -0
  33. package/build/cjs/integrations/tracing-channel/ioredis.js +35 -32
  34. package/build/cjs/integrations/tracing-channel/ioredis.js.map +1 -1
  35. package/build/cjs/integrations/tracing-channel/kafkajs/consumer.js +71 -0
  36. package/build/cjs/integrations/tracing-channel/kafkajs/consumer.js.map +1 -0
  37. package/build/cjs/integrations/tracing-channel/kafkajs/index.js +70 -0
  38. package/build/cjs/integrations/tracing-channel/kafkajs/index.js.map +1 -0
  39. package/build/cjs/integrations/tracing-channel/kafkajs/semconv.js +22 -0
  40. package/build/cjs/integrations/tracing-channel/kafkajs/semconv.js.map +1 -0
  41. package/build/cjs/integrations/tracing-channel/kafkajs/spans.js +119 -0
  42. package/build/cjs/integrations/tracing-channel/kafkajs/spans.js.map +1 -0
  43. package/build/cjs/integrations/tracing-channel/knex.js +188 -0
  44. package/build/cjs/integrations/tracing-channel/knex.js.map +1 -0
  45. package/build/cjs/integrations/tracing-channel/mysql.js +1 -1
  46. package/build/cjs/integrations/tracing-channel/mysql.js.map +1 -1
  47. package/build/cjs/integrations/tracing-channel/mysql2.js +83 -0
  48. package/build/cjs/integrations/tracing-channel/mysql2.js.map +1 -0
  49. package/build/cjs/integrations/tracing-channel/openai.js.map +1 -1
  50. package/build/cjs/integrations/tracing-channel/postgres-js.js +191 -0
  51. package/build/cjs/integrations/tracing-channel/postgres-js.js.map +1 -0
  52. package/build/cjs/integrations/tracing-channel/postgres.js +5 -5
  53. package/build/cjs/integrations/tracing-channel/postgres.js.map +1 -1
  54. package/build/cjs/integrations/tracing-channel/redis.js +227 -0
  55. package/build/cjs/integrations/tracing-channel/redis.js.map +1 -0
  56. package/build/cjs/integrations/tracing-channel/vercel-ai.js +2 -2
  57. package/build/cjs/integrations/tracing-channel/vercel-ai.js.map +1 -1
  58. package/build/cjs/mongoose/mongoose-dc-subscriber.js +1 -1
  59. package/build/cjs/mongoose/mongoose-dc-subscriber.js.map +1 -1
  60. package/build/cjs/mysql2/index.js +23 -0
  61. package/build/cjs/mysql2/index.js.map +1 -0
  62. package/build/cjs/mysql2/mysql2-dc-subscriber.js +68 -0
  63. package/build/cjs/mysql2/mysql2-dc-subscriber.js.map +1 -0
  64. package/build/cjs/orchestrion/bundler/esbuild.js +11 -0
  65. package/build/cjs/orchestrion/bundler/esbuild.js.map +1 -0
  66. package/build/cjs/orchestrion/bundler/options.js +15 -0
  67. package/build/cjs/orchestrion/bundler/options.js.map +1 -0
  68. package/build/cjs/orchestrion/bundler/rollup.js +11 -0
  69. package/build/cjs/orchestrion/bundler/rollup.js.map +1 -0
  70. package/build/cjs/orchestrion/bundler/vite.js +4 -21
  71. package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
  72. package/build/cjs/orchestrion/bundler/webpack.js +32 -0
  73. package/build/cjs/orchestrion/bundler/webpack.js.map +1 -0
  74. package/build/cjs/orchestrion/channels.js +53 -11
  75. package/build/cjs/orchestrion/channels.js.map +1 -1
  76. package/build/cjs/orchestrion/config/amqplib.js +81 -0
  77. package/build/cjs/orchestrion/config/amqplib.js.map +1 -0
  78. package/build/cjs/orchestrion/config/dataloader.js +53 -0
  79. package/build/cjs/orchestrion/config/dataloader.js.map +1 -0
  80. package/build/cjs/orchestrion/config/express.js +76 -0
  81. package/build/cjs/orchestrion/config/express.js.map +1 -0
  82. package/build/cjs/orchestrion/config/firebase.js +8 -0
  83. package/build/cjs/orchestrion/config/firebase.js.map +1 -0
  84. package/build/cjs/orchestrion/config/generic-pool.js +21 -0
  85. package/build/cjs/orchestrion/config/generic-pool.js.map +1 -0
  86. package/build/cjs/orchestrion/config/google-genai.js +38 -0
  87. package/build/cjs/orchestrion/config/google-genai.js.map +1 -0
  88. package/build/cjs/orchestrion/config/graphql.js +28 -0
  89. package/build/cjs/orchestrion/config/graphql.js.map +1 -0
  90. package/build/cjs/orchestrion/config/index.js +59 -14
  91. package/build/cjs/orchestrion/config/index.js.map +1 -1
  92. package/build/cjs/orchestrion/config/kafkajs.js +30 -0
  93. package/build/cjs/orchestrion/config/kafkajs.js.map +1 -0
  94. package/build/cjs/orchestrion/config/knex.js +43 -0
  95. package/build/cjs/orchestrion/config/knex.js.map +1 -0
  96. package/build/cjs/orchestrion/config/langchain.js +8 -0
  97. package/build/cjs/orchestrion/config/langchain.js.map +1 -0
  98. package/build/cjs/orchestrion/config/langgraph.js +8 -0
  99. package/build/cjs/orchestrion/config/langgraph.js.map +1 -0
  100. package/build/cjs/orchestrion/config/mongodb.js +8 -0
  101. package/build/cjs/orchestrion/config/mongodb.js.map +1 -0
  102. package/build/cjs/orchestrion/config/mongoose.js +8 -0
  103. package/build/cjs/orchestrion/config/mongoose.js.map +1 -0
  104. package/build/cjs/orchestrion/config/mysql2.js +32 -0
  105. package/build/cjs/orchestrion/config/mysql2.js.map +1 -0
  106. package/build/cjs/orchestrion/config/nestjs.js +122 -0
  107. package/build/cjs/orchestrion/config/nestjs.js.map +1 -0
  108. package/build/cjs/orchestrion/config/postgres.js +50 -0
  109. package/build/cjs/orchestrion/config/postgres.js.map +1 -0
  110. package/build/cjs/orchestrion/config/prisma.js +8 -0
  111. package/build/cjs/orchestrion/config/prisma.js.map +1 -0
  112. package/build/cjs/orchestrion/config/react-router.js +8 -0
  113. package/build/cjs/orchestrion/config/react-router.js.map +1 -0
  114. package/build/cjs/orchestrion/config/redis.js +76 -0
  115. package/build/cjs/orchestrion/config/redis.js.map +1 -0
  116. package/build/cjs/orchestrion/config/remix.js +8 -0
  117. package/build/cjs/orchestrion/config/remix.js.map +1 -0
  118. package/build/cjs/orchestrion/config/tedious.js +8 -0
  119. package/build/cjs/orchestrion/config/tedious.js.map +1 -0
  120. package/build/cjs/orchestrion/config/vercel-ai.js +18 -14
  121. package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -1
  122. package/build/cjs/orchestrion/detect.js +12 -11
  123. package/build/cjs/orchestrion/detect.js.map +1 -1
  124. package/build/cjs/orchestrion/index.js +33 -1
  125. package/build/cjs/orchestrion/index.js.map +1 -1
  126. package/build/cjs/orchestrion/runtime/register.js +25 -14
  127. package/build/cjs/orchestrion/runtime/register.js.map +1 -1
  128. package/build/cjs/prisma/global.js +14 -0
  129. package/build/cjs/prisma/global.js.map +1 -0
  130. package/build/cjs/prisma/index.js +27 -0
  131. package/build/cjs/prisma/index.js.map +1 -0
  132. package/build/cjs/prisma/tracing-helper.js +211 -0
  133. package/build/cjs/prisma/tracing-helper.js.map +1 -0
  134. package/build/cjs/redis/index.js +23 -0
  135. package/build/cjs/redis/index.js.map +1 -0
  136. package/build/cjs/redis/redis-dc-subscriber.js +23 -35
  137. package/build/cjs/redis/redis-dc-subscriber.js.map +1 -1
  138. package/build/cjs/tracing-channel.js +7 -6
  139. package/build/cjs/tracing-channel.js.map +1 -1
  140. package/build/cjs/vercel-ai/util.js +112 -0
  141. package/build/cjs/vercel-ai/util.js.map +1 -0
  142. package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js +138 -74
  143. package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  144. package/build/cjs/vercel-ai/{vercel-ai-orchestrion-v6-subscriber.js → vercel-ai-orchestrion-subscriber.js} +153 -23
  145. package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -0
  146. package/build/esm/graphql/graphql-dc-subscriber.js +116 -0
  147. package/build/esm/graphql/graphql-dc-subscriber.js.map +1 -0
  148. package/build/esm/graphql/index.js +21 -0
  149. package/build/esm/graphql/index.js.map +1 -0
  150. package/build/esm/graphql/utils.js +87 -0
  151. package/build/esm/graphql/utils.js.map +1 -0
  152. package/build/esm/index.js +4 -1
  153. package/build/esm/index.js.map +1 -1
  154. package/build/esm/integrations/tracing-channel/amqplib.js +418 -0
  155. package/build/esm/integrations/tracing-channel/amqplib.js.map +1 -0
  156. package/build/esm/integrations/tracing-channel/anthropic.js +1 -1
  157. package/build/esm/integrations/tracing-channel/dataloader.js +93 -0
  158. package/build/esm/integrations/tracing-channel/dataloader.js.map +1 -0
  159. package/build/esm/integrations/tracing-channel/express/index.js +22 -0
  160. package/build/esm/integrations/tracing-channel/express/index.js.map +1 -0
  161. package/build/esm/integrations/tracing-channel/express/instrumentation.js +171 -0
  162. package/build/esm/integrations/tracing-channel/express/instrumentation.js.map +1 -0
  163. package/build/esm/integrations/tracing-channel/express/route.js +68 -0
  164. package/build/esm/integrations/tracing-channel/express/route.js.map +1 -0
  165. package/build/esm/integrations/tracing-channel/fastify/instrumentation.js +2 -2
  166. package/build/esm/integrations/tracing-channel/fastify/instrumentation.js.map +1 -1
  167. package/build/esm/integrations/tracing-channel/generic-pool.js +32 -0
  168. package/build/esm/integrations/tracing-channel/generic-pool.js.map +1 -0
  169. package/build/esm/integrations/tracing-channel/google-genai.js +94 -0
  170. package/build/esm/integrations/tracing-channel/google-genai.js.map +1 -0
  171. package/build/esm/integrations/tracing-channel/graphql/constants.js +14 -0
  172. package/build/esm/integrations/tracing-channel/graphql/constants.js.map +1 -0
  173. package/build/esm/integrations/tracing-channel/graphql/index.js +63 -0
  174. package/build/esm/integrations/tracing-channel/graphql/index.js.map +1 -0
  175. package/build/esm/integrations/tracing-channel/graphql/resolvers.js +164 -0
  176. package/build/esm/integrations/tracing-channel/graphql/resolvers.js.map +1 -0
  177. package/build/esm/integrations/tracing-channel/graphql/spans.js +96 -0
  178. package/build/esm/integrations/tracing-channel/graphql/spans.js.map +1 -0
  179. package/build/esm/integrations/tracing-channel/ioredis.js +36 -34
  180. package/build/esm/integrations/tracing-channel/ioredis.js.map +1 -1
  181. package/build/esm/integrations/tracing-channel/kafkajs/consumer.js +67 -0
  182. package/build/esm/integrations/tracing-channel/kafkajs/consumer.js.map +1 -0
  183. package/build/esm/integrations/tracing-channel/kafkajs/index.js +68 -0
  184. package/build/esm/integrations/tracing-channel/kafkajs/index.js.map +1 -0
  185. package/build/esm/integrations/tracing-channel/kafkajs/semconv.js +12 -0
  186. package/build/esm/integrations/tracing-channel/kafkajs/semconv.js.map +1 -0
  187. package/build/esm/integrations/tracing-channel/kafkajs/spans.js +112 -0
  188. package/build/esm/integrations/tracing-channel/kafkajs/spans.js.map +1 -0
  189. package/build/esm/integrations/tracing-channel/knex.js +186 -0
  190. package/build/esm/integrations/tracing-channel/knex.js.map +1 -0
  191. package/build/esm/integrations/tracing-channel/mysql.js +2 -2
  192. package/build/esm/integrations/tracing-channel/mysql.js.map +1 -1
  193. package/build/esm/integrations/tracing-channel/mysql2.js +81 -0
  194. package/build/esm/integrations/tracing-channel/mysql2.js.map +1 -0
  195. package/build/esm/integrations/tracing-channel/openai.js +1 -1
  196. package/build/esm/integrations/tracing-channel/openai.js.map +1 -1
  197. package/build/esm/integrations/tracing-channel/postgres-js.js +189 -0
  198. package/build/esm/integrations/tracing-channel/postgres-js.js.map +1 -0
  199. package/build/esm/integrations/tracing-channel/postgres.js +6 -6
  200. package/build/esm/integrations/tracing-channel/postgres.js.map +1 -1
  201. package/build/esm/integrations/tracing-channel/redis.js +225 -0
  202. package/build/esm/integrations/tracing-channel/redis.js.map +1 -0
  203. package/build/esm/integrations/tracing-channel/vercel-ai.js +1 -1
  204. package/build/esm/integrations/tracing-channel/vercel-ai.js.map +1 -1
  205. package/build/esm/mongoose/mongoose-dc-subscriber.js +2 -2
  206. package/build/esm/mongoose/mongoose-dc-subscriber.js.map +1 -1
  207. package/build/esm/mysql2/index.js +21 -0
  208. package/build/esm/mysql2/index.js.map +1 -0
  209. package/build/esm/mysql2/mysql2-dc-subscriber.js +62 -0
  210. package/build/esm/mysql2/mysql2-dc-subscriber.js.map +1 -0
  211. package/build/esm/orchestrion/bundler/esbuild.js +9 -0
  212. package/build/esm/orchestrion/bundler/esbuild.js.map +1 -0
  213. package/build/esm/orchestrion/bundler/options.js +13 -0
  214. package/build/esm/orchestrion/bundler/options.js.map +1 -0
  215. package/build/esm/orchestrion/bundler/rollup.js +9 -0
  216. package/build/esm/orchestrion/bundler/rollup.js.map +1 -0
  217. package/build/esm/orchestrion/bundler/vite.js +5 -22
  218. package/build/esm/orchestrion/bundler/vite.js.map +1 -1
  219. package/build/esm/orchestrion/bundler/webpack.js +27 -0
  220. package/build/esm/orchestrion/bundler/webpack.js.map +1 -0
  221. package/build/esm/orchestrion/channels.js +53 -11
  222. package/build/esm/orchestrion/channels.js.map +1 -1
  223. package/build/esm/orchestrion/config/amqplib.js +78 -0
  224. package/build/esm/orchestrion/config/amqplib.js.map +1 -0
  225. package/build/esm/orchestrion/config/dataloader.js +50 -0
  226. package/build/esm/orchestrion/config/dataloader.js.map +1 -0
  227. package/build/esm/orchestrion/config/express.js +73 -0
  228. package/build/esm/orchestrion/config/express.js.map +1 -0
  229. package/build/esm/orchestrion/config/firebase.js +5 -0
  230. package/build/esm/orchestrion/config/firebase.js.map +1 -0
  231. package/build/esm/orchestrion/config/generic-pool.js +18 -0
  232. package/build/esm/orchestrion/config/generic-pool.js.map +1 -0
  233. package/build/esm/orchestrion/config/google-genai.js +35 -0
  234. package/build/esm/orchestrion/config/google-genai.js.map +1 -0
  235. package/build/esm/orchestrion/config/graphql.js +25 -0
  236. package/build/esm/orchestrion/config/graphql.js.map +1 -0
  237. package/build/esm/orchestrion/config/index.js +59 -15
  238. package/build/esm/orchestrion/config/index.js.map +1 -1
  239. package/build/esm/orchestrion/config/kafkajs.js +27 -0
  240. package/build/esm/orchestrion/config/kafkajs.js.map +1 -0
  241. package/build/esm/orchestrion/config/knex.js +40 -0
  242. package/build/esm/orchestrion/config/knex.js.map +1 -0
  243. package/build/esm/orchestrion/config/langchain.js +5 -0
  244. package/build/esm/orchestrion/config/langchain.js.map +1 -0
  245. package/build/esm/orchestrion/config/langgraph.js +5 -0
  246. package/build/esm/orchestrion/config/langgraph.js.map +1 -0
  247. package/build/esm/orchestrion/config/mongodb.js +5 -0
  248. package/build/esm/orchestrion/config/mongodb.js.map +1 -0
  249. package/build/esm/orchestrion/config/mongoose.js +5 -0
  250. package/build/esm/orchestrion/config/mongoose.js.map +1 -0
  251. package/build/esm/orchestrion/config/mysql2.js +29 -0
  252. package/build/esm/orchestrion/config/mysql2.js.map +1 -0
  253. package/build/esm/orchestrion/config/nestjs.js +119 -0
  254. package/build/esm/orchestrion/config/nestjs.js.map +1 -0
  255. package/build/esm/orchestrion/config/postgres.js +47 -0
  256. package/build/esm/orchestrion/config/postgres.js.map +1 -0
  257. package/build/esm/orchestrion/config/prisma.js +5 -0
  258. package/build/esm/orchestrion/config/prisma.js.map +1 -0
  259. package/build/esm/orchestrion/config/react-router.js +5 -0
  260. package/build/esm/orchestrion/config/react-router.js.map +1 -0
  261. package/build/esm/orchestrion/config/redis.js +73 -0
  262. package/build/esm/orchestrion/config/redis.js.map +1 -0
  263. package/build/esm/orchestrion/config/remix.js +5 -0
  264. package/build/esm/orchestrion/config/remix.js.map +1 -0
  265. package/build/esm/orchestrion/config/tedious.js +5 -0
  266. package/build/esm/orchestrion/config/tedious.js.map +1 -0
  267. package/build/esm/orchestrion/config/vercel-ai.js +18 -14
  268. package/build/esm/orchestrion/config/vercel-ai.js.map +1 -1
  269. package/build/esm/orchestrion/detect.js +13 -12
  270. package/build/esm/orchestrion/detect.js.map +1 -1
  271. package/build/esm/orchestrion/index.js +23 -2
  272. package/build/esm/orchestrion/index.js.map +1 -1
  273. package/build/esm/orchestrion/runtime/register.js +27 -16
  274. package/build/esm/orchestrion/runtime/register.js.map +1 -1
  275. package/build/esm/package.json +1 -1
  276. package/build/esm/prisma/global.js +12 -0
  277. package/build/esm/prisma/global.js.map +1 -0
  278. package/build/esm/prisma/index.js +24 -0
  279. package/build/esm/prisma/index.js.map +1 -0
  280. package/build/esm/prisma/tracing-helper.js +209 -0
  281. package/build/esm/prisma/tracing-helper.js.map +1 -0
  282. package/build/esm/redis/index.js +21 -0
  283. package/build/esm/redis/index.js.map +1 -0
  284. package/build/esm/redis/redis-dc-subscriber.js +24 -36
  285. package/build/esm/redis/redis-dc-subscriber.js.map +1 -1
  286. package/build/esm/tracing-channel.js +8 -7
  287. package/build/esm/tracing-channel.js.map +1 -1
  288. package/build/esm/vercel-ai/util.js +106 -0
  289. package/build/esm/vercel-ai/util.js.map +1 -0
  290. package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js +121 -59
  291. package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  292. package/build/esm/vercel-ai/{vercel-ai-orchestrion-v6-subscriber.js → vercel-ai-orchestrion-subscriber.js} +153 -23
  293. package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -0
  294. package/build/types/graphql/graphql-dc-subscriber.d.ts +94 -0
  295. package/build/types/graphql/graphql-dc-subscriber.d.ts.map +1 -0
  296. package/build/types/graphql/index.d.ts +12 -0
  297. package/build/types/graphql/index.d.ts.map +1 -0
  298. package/build/types/graphql/utils.d.ts +36 -0
  299. package/build/types/graphql/utils.d.ts.map +1 -0
  300. package/build/types/index.d.ts +6 -2
  301. package/build/types/index.d.ts.map +1 -1
  302. package/build/types/integrations/tracing-channel/amqplib.d.ts +11 -0
  303. package/build/types/integrations/tracing-channel/amqplib.d.ts.map +1 -0
  304. package/build/types/integrations/tracing-channel/dataloader.d.ts +11 -0
  305. package/build/types/integrations/tracing-channel/dataloader.d.ts.map +1 -0
  306. package/build/types/integrations/tracing-channel/express/index.d.ts +18 -0
  307. package/build/types/integrations/tracing-channel/express/index.d.ts.map +1 -0
  308. package/build/types/integrations/tracing-channel/express/instrumentation.d.ts +4 -0
  309. package/build/types/integrations/tracing-channel/express/instrumentation.d.ts.map +1 -0
  310. package/build/types/integrations/tracing-channel/express/route.d.ts +28 -0
  311. package/build/types/integrations/tracing-channel/express/route.d.ts.map +1 -0
  312. package/build/types/integrations/tracing-channel/express/types.d.ts +64 -0
  313. package/build/types/integrations/tracing-channel/express/types.d.ts.map +1 -0
  314. package/build/types/integrations/tracing-channel/fastify/instrumentation.d.ts.map +1 -1
  315. package/build/types/integrations/tracing-channel/generic-pool.d.ts +10 -0
  316. package/build/types/integrations/tracing-channel/generic-pool.d.ts.map +1 -0
  317. package/build/types/integrations/tracing-channel/google-genai.d.ts +12 -0
  318. package/build/types/integrations/tracing-channel/google-genai.d.ts.map +1 -0
  319. package/build/types/integrations/tracing-channel/graphql/constants.d.ts +12 -0
  320. package/build/types/integrations/tracing-channel/graphql/constants.d.ts.map +1 -0
  321. package/build/types/integrations/tracing-channel/graphql/graphql-types.d.ts +135 -0
  322. package/build/types/integrations/tracing-channel/graphql/graphql-types.d.ts.map +1 -0
  323. package/build/types/integrations/tracing-channel/graphql/index.d.ts +28 -0
  324. package/build/types/integrations/tracing-channel/graphql/index.d.ts.map +1 -0
  325. package/build/types/integrations/tracing-channel/graphql/resolvers.d.ts +13 -0
  326. package/build/types/integrations/tracing-channel/graphql/resolvers.d.ts.map +1 -0
  327. package/build/types/integrations/tracing-channel/graphql/spans.d.ts +17 -0
  328. package/build/types/integrations/tracing-channel/graphql/spans.d.ts.map +1 -0
  329. package/build/types/integrations/tracing-channel/graphql/types.d.ts +25 -0
  330. package/build/types/integrations/tracing-channel/graphql/types.d.ts.map +1 -0
  331. package/build/types/integrations/tracing-channel/ioredis.d.ts +20 -0
  332. package/build/types/integrations/tracing-channel/ioredis.d.ts.map +1 -1
  333. package/build/types/integrations/tracing-channel/kafkajs/consumer.d.ts +8 -0
  334. package/build/types/integrations/tracing-channel/kafkajs/consumer.d.ts.map +1 -0
  335. package/build/types/integrations/tracing-channel/kafkajs/index.d.ts +17 -0
  336. package/build/types/integrations/tracing-channel/kafkajs/index.d.ts.map +1 -0
  337. package/build/types/integrations/tracing-channel/kafkajs/semconv.d.ts +10 -0
  338. package/build/types/integrations/tracing-channel/kafkajs/semconv.d.ts.map +1 -0
  339. package/build/types/integrations/tracing-channel/kafkajs/spans.d.ts +38 -0
  340. package/build/types/integrations/tracing-channel/kafkajs/spans.d.ts.map +1 -0
  341. package/build/types/integrations/tracing-channel/kafkajs/types.d.ts +40 -0
  342. package/build/types/integrations/tracing-channel/kafkajs/types.d.ts.map +1 -0
  343. package/build/types/integrations/tracing-channel/knex.d.ts +11 -0
  344. package/build/types/integrations/tracing-channel/knex.d.ts.map +1 -0
  345. package/build/types/integrations/tracing-channel/mysql.d.ts.map +1 -1
  346. package/build/types/integrations/tracing-channel/mysql2.d.ts +15 -0
  347. package/build/types/integrations/tracing-channel/mysql2.d.ts.map +1 -0
  348. package/build/types/integrations/tracing-channel/openai.d.ts.map +1 -1
  349. package/build/types/integrations/tracing-channel/postgres-js.d.ts +26 -0
  350. package/build/types/integrations/tracing-channel/postgres-js.d.ts.map +1 -0
  351. package/build/types/integrations/tracing-channel/postgres.d.ts.map +1 -1
  352. package/build/types/integrations/tracing-channel/redis.d.ts +16 -0
  353. package/build/types/integrations/tracing-channel/redis.d.ts.map +1 -0
  354. package/build/types/integrations/tracing-channel/vercel-ai.d.ts +1 -1
  355. package/build/types/mongoose/mongoose-dc-subscriber.d.ts.map +1 -1
  356. package/build/types/mysql2/index.d.ts +11 -0
  357. package/build/types/mysql2/index.d.ts.map +1 -0
  358. package/build/types/mysql2/mysql2-dc-subscriber.d.ts +59 -0
  359. package/build/types/mysql2/mysql2-dc-subscriber.d.ts.map +1 -0
  360. package/build/types/orchestrion/bundler/esbuild.d.ts +21 -0
  361. package/build/types/orchestrion/bundler/esbuild.d.ts.map +1 -0
  362. package/build/types/orchestrion/bundler/options.d.ts +19 -0
  363. package/build/types/orchestrion/bundler/options.d.ts.map +1 -0
  364. package/build/types/orchestrion/bundler/rollup.d.ts +17 -0
  365. package/build/types/orchestrion/bundler/rollup.d.ts.map +1 -0
  366. package/build/types/orchestrion/bundler/vite.d.ts +4 -17
  367. package/build/types/orchestrion/bundler/vite.d.ts.map +1 -1
  368. package/build/types/orchestrion/bundler/webpack.d.ts +19 -0
  369. package/build/types/orchestrion/bundler/webpack.d.ts.map +1 -0
  370. package/build/types/orchestrion/channels.d.ts +71 -10
  371. package/build/types/orchestrion/channels.d.ts.map +1 -1
  372. package/build/types/orchestrion/config/amqplib.d.ts +66 -0
  373. package/build/types/orchestrion/config/amqplib.d.ts.map +1 -0
  374. package/build/types/orchestrion/config/dataloader.d.ts +46 -0
  375. package/build/types/orchestrion/config/dataloader.d.ts.map +1 -0
  376. package/build/types/orchestrion/config/express.d.ts +32 -0
  377. package/build/types/orchestrion/config/express.d.ts.map +1 -0
  378. package/build/types/orchestrion/config/firebase.d.ts +4 -0
  379. package/build/types/orchestrion/config/firebase.d.ts.map +1 -0
  380. package/build/types/orchestrion/config/generic-pool.d.ts +31 -0
  381. package/build/types/orchestrion/config/generic-pool.d.ts.map +1 -0
  382. package/build/types/orchestrion/config/google-genai.d.ts +30 -0
  383. package/build/types/orchestrion/config/google-genai.d.ts.map +1 -0
  384. package/build/types/orchestrion/config/graphql.d.ts +29 -0
  385. package/build/types/orchestrion/config/graphql.d.ts.map +1 -0
  386. package/build/types/orchestrion/config/index.d.ts +18 -5
  387. package/build/types/orchestrion/config/index.d.ts.map +1 -1
  388. package/build/types/orchestrion/config/kafkajs.d.ts +17 -0
  389. package/build/types/orchestrion/config/kafkajs.d.ts.map +1 -0
  390. package/build/types/orchestrion/config/knex.d.ts +9 -0
  391. package/build/types/orchestrion/config/knex.d.ts.map +1 -0
  392. package/build/types/orchestrion/config/langchain.d.ts +4 -0
  393. package/build/types/orchestrion/config/langchain.d.ts.map +1 -0
  394. package/build/types/orchestrion/config/langgraph.d.ts +4 -0
  395. package/build/types/orchestrion/config/langgraph.d.ts.map +1 -0
  396. package/build/types/orchestrion/config/mongodb.d.ts +4 -0
  397. package/build/types/orchestrion/config/mongodb.d.ts.map +1 -0
  398. package/build/types/orchestrion/config/mongoose.d.ts +4 -0
  399. package/build/types/orchestrion/config/mongoose.d.ts.map +1 -0
  400. package/build/types/orchestrion/config/mysql2.d.ts +18 -0
  401. package/build/types/orchestrion/config/mysql2.d.ts.map +1 -0
  402. package/build/types/orchestrion/config/nestjs.d.ts +24 -0
  403. package/build/types/orchestrion/config/nestjs.d.ts.map +1 -0
  404. package/build/types/orchestrion/config/postgres.d.ts +9 -0
  405. package/build/types/orchestrion/config/postgres.d.ts.map +1 -0
  406. package/build/types/orchestrion/config/prisma.d.ts +4 -0
  407. package/build/types/orchestrion/config/prisma.d.ts.map +1 -0
  408. package/build/types/orchestrion/config/react-router.d.ts +4 -0
  409. package/build/types/orchestrion/config/react-router.d.ts.map +1 -0
  410. package/build/types/orchestrion/config/redis.d.ts +37 -0
  411. package/build/types/orchestrion/config/redis.d.ts.map +1 -0
  412. package/build/types/orchestrion/config/remix.d.ts +4 -0
  413. package/build/types/orchestrion/config/remix.d.ts.map +1 -0
  414. package/build/types/orchestrion/config/tedious.d.ts +4 -0
  415. package/build/types/orchestrion/config/tedious.d.ts.map +1 -0
  416. package/build/types/orchestrion/config/vercel-ai.d.ts +1 -0
  417. package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -1
  418. package/build/types/orchestrion/detect.d.ts +3 -10
  419. package/build/types/orchestrion/detect.d.ts.map +1 -1
  420. package/build/types/orchestrion/index.d.ts +55 -4
  421. package/build/types/orchestrion/index.d.ts.map +1 -1
  422. package/build/types/orchestrion/runtime/register.d.ts +11 -9
  423. package/build/types/orchestrion/runtime/register.d.ts.map +1 -1
  424. package/build/types/prisma/global.d.ts +5 -0
  425. package/build/types/prisma/global.d.ts.map +1 -0
  426. package/build/types/prisma/index.d.ts +45 -0
  427. package/build/types/prisma/index.d.ts.map +1 -0
  428. package/build/types/prisma/tracing-helper.d.ts +46 -0
  429. package/build/types/prisma/tracing-helper.d.ts.map +1 -0
  430. package/build/types/prisma/types.d.ts +37 -0
  431. package/build/types/prisma/types.d.ts.map +1 -0
  432. package/build/types/redis/index.d.ts +18 -0
  433. package/build/types/redis/index.d.ts.map +1 -0
  434. package/build/types/redis/redis-dc-subscriber.d.ts +0 -5
  435. package/build/types/redis/redis-dc-subscriber.d.ts.map +1 -1
  436. package/build/types/tracing-channel.d.ts +5 -0
  437. package/build/types/tracing-channel.d.ts.map +1 -1
  438. package/build/types/vercel-ai/util.d.ts +30 -0
  439. package/build/types/vercel-ai/util.d.ts.map +1 -0
  440. package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts +6 -2
  441. package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
  442. package/build/types/vercel-ai/{vercel-ai-orchestrion-v6-subscriber.d.ts → vercel-ai-orchestrion-subscriber.d.ts} +1 -1
  443. package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts.map +1 -0
  444. package/build/types-ts3.8/graphql/graphql-dc-subscriber.d.ts +94 -0
  445. package/build/types-ts3.8/graphql/index.d.ts +12 -0
  446. package/build/types-ts3.8/graphql/utils.d.ts +36 -0
  447. package/build/types-ts3.8/index.d.ts +6 -2
  448. package/build/types-ts3.8/integrations/tracing-channel/amqplib.d.ts +11 -0
  449. package/build/types-ts3.8/integrations/tracing-channel/dataloader.d.ts +11 -0
  450. package/build/types-ts3.8/integrations/tracing-channel/express/index.d.ts +18 -0
  451. package/build/types-ts3.8/integrations/tracing-channel/express/instrumentation.d.ts +4 -0
  452. package/build/types-ts3.8/integrations/tracing-channel/express/route.d.ts +28 -0
  453. package/build/types-ts3.8/integrations/tracing-channel/express/types.d.ts +64 -0
  454. package/build/types-ts3.8/integrations/tracing-channel/generic-pool.d.ts +10 -0
  455. package/build/types-ts3.8/integrations/tracing-channel/google-genai.d.ts +12 -0
  456. package/build/types-ts3.8/integrations/tracing-channel/graphql/constants.d.ts +12 -0
  457. package/build/types-ts3.8/integrations/tracing-channel/graphql/graphql-types.d.ts +135 -0
  458. package/build/types-ts3.8/integrations/tracing-channel/graphql/index.d.ts +30 -0
  459. package/build/types-ts3.8/integrations/tracing-channel/graphql/resolvers.d.ts +13 -0
  460. package/build/types-ts3.8/integrations/tracing-channel/graphql/spans.d.ts +17 -0
  461. package/build/types-ts3.8/integrations/tracing-channel/graphql/types.d.ts +25 -0
  462. package/build/types-ts3.8/integrations/tracing-channel/ioredis.d.ts +20 -0
  463. package/build/types-ts3.8/integrations/tracing-channel/kafkajs/consumer.d.ts +8 -0
  464. package/build/types-ts3.8/integrations/tracing-channel/kafkajs/index.d.ts +17 -0
  465. package/build/types-ts3.8/integrations/tracing-channel/kafkajs/semconv.d.ts +10 -0
  466. package/build/types-ts3.8/integrations/tracing-channel/kafkajs/spans.d.ts +38 -0
  467. package/build/types-ts3.8/integrations/tracing-channel/kafkajs/types.d.ts +40 -0
  468. package/build/types-ts3.8/integrations/tracing-channel/knex.d.ts +11 -0
  469. package/build/types-ts3.8/integrations/tracing-channel/mysql2.d.ts +15 -0
  470. package/build/types-ts3.8/integrations/tracing-channel/postgres-js.d.ts +26 -0
  471. package/build/types-ts3.8/integrations/tracing-channel/redis.d.ts +16 -0
  472. package/build/types-ts3.8/integrations/tracing-channel/vercel-ai.d.ts +1 -1
  473. package/build/types-ts3.8/mysql2/index.d.ts +11 -0
  474. package/build/types-ts3.8/mysql2/mysql2-dc-subscriber.d.ts +59 -0
  475. package/build/types-ts3.8/orchestrion/bundler/esbuild.d.ts +21 -0
  476. package/build/types-ts3.8/orchestrion/bundler/options.d.ts +19 -0
  477. package/build/types-ts3.8/orchestrion/bundler/rollup.d.ts +17 -0
  478. package/build/types-ts3.8/orchestrion/bundler/vite.d.ts +4 -17
  479. package/build/types-ts3.8/orchestrion/bundler/webpack.d.ts +19 -0
  480. package/build/types-ts3.8/orchestrion/channels.d.ts +71 -10
  481. package/build/types-ts3.8/orchestrion/config/amqplib.d.ts +66 -0
  482. package/build/types-ts3.8/orchestrion/config/dataloader.d.ts +46 -0
  483. package/build/types-ts3.8/orchestrion/config/express.d.ts +32 -0
  484. package/build/types-ts3.8/orchestrion/config/firebase.d.ts +4 -0
  485. package/build/types-ts3.8/orchestrion/config/generic-pool.d.ts +31 -0
  486. package/build/types-ts3.8/orchestrion/config/google-genai.d.ts +30 -0
  487. package/build/types-ts3.8/orchestrion/config/graphql.d.ts +29 -0
  488. package/build/types-ts3.8/orchestrion/config/index.d.ts +18 -5
  489. package/build/types-ts3.8/orchestrion/config/kafkajs.d.ts +17 -0
  490. package/build/types-ts3.8/orchestrion/config/knex.d.ts +9 -0
  491. package/build/types-ts3.8/orchestrion/config/langchain.d.ts +4 -0
  492. package/build/types-ts3.8/orchestrion/config/langgraph.d.ts +4 -0
  493. package/build/types-ts3.8/orchestrion/config/mongodb.d.ts +4 -0
  494. package/build/types-ts3.8/orchestrion/config/mongoose.d.ts +4 -0
  495. package/build/types-ts3.8/orchestrion/config/mysql2.d.ts +18 -0
  496. package/build/types-ts3.8/orchestrion/config/nestjs.d.ts +24 -0
  497. package/build/types-ts3.8/orchestrion/config/postgres.d.ts +9 -0
  498. package/build/types-ts3.8/orchestrion/config/prisma.d.ts +4 -0
  499. package/build/types-ts3.8/orchestrion/config/react-router.d.ts +4 -0
  500. package/build/types-ts3.8/orchestrion/config/redis.d.ts +37 -0
  501. package/build/types-ts3.8/orchestrion/config/remix.d.ts +4 -0
  502. package/build/types-ts3.8/orchestrion/config/tedious.d.ts +4 -0
  503. package/build/types-ts3.8/orchestrion/config/vercel-ai.d.ts +1 -0
  504. package/build/types-ts3.8/orchestrion/detect.d.ts +3 -10
  505. package/build/types-ts3.8/orchestrion/index.d.ts +57 -4
  506. package/build/types-ts3.8/orchestrion/runtime/register.d.ts +11 -9
  507. package/build/types-ts3.8/prisma/global.d.ts +5 -0
  508. package/build/types-ts3.8/prisma/index.d.ts +45 -0
  509. package/build/types-ts3.8/prisma/tracing-helper.d.ts +52 -0
  510. package/build/types-ts3.8/prisma/types.d.ts +40 -0
  511. package/build/types-ts3.8/redis/index.d.ts +18 -0
  512. package/build/types-ts3.8/redis/redis-dc-subscriber.d.ts +0 -5
  513. package/build/types-ts3.8/tracing-channel.d.ts +5 -0
  514. package/build/types-ts3.8/vercel-ai/util.d.ts +30 -0
  515. package/build/types-ts3.8/vercel-ai/vercel-ai-dc-subscriber.d.ts +6 -2
  516. package/build/types-ts3.8/vercel-ai/{vercel-ai-orchestrion-v6-subscriber.d.ts → vercel-ai-orchestrion-subscriber.d.ts} +1 -1
  517. package/package.json +41 -8
  518. package/build/cjs/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js.map +0 -1
  519. package/build/esm/vercel-ai/vercel-ai-orchestrion-v6-subscriber.js.map +0 -1
  520. package/build/types/vercel-ai/vercel-ai-orchestrion-v6-subscriber.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-genai.js","sources":["../../../../src/integrations/tracing-channel/google-genai.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { GoogleGenAIOptions, GoogleGenAIResponse, IntegrationFn, Span } from '@sentry/core';\nimport {\n _INTERNAL_shouldSkipAiProviderWrapping,\n addGoogleGenAIRequestAttributes,\n addGoogleGenAIResponseAttributes,\n debug,\n defineIntegration,\n extractGoogleGenAIRequestAttributes,\n GEN_AI_REQUEST_MODEL_ATTRIBUTE,\n getActiveSpan,\n instrumentGoogleGenAIStream,\n resolveAIRecordingOptions,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n shouldEnableTruncation,\n spanToJSON,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Same name as the OTel integration by design: when enabled, the OTel 'Google_GenAI'\n// integration is dropped from the default set (see the Node opt-in loader).\nconst INTEGRATION_NAME = 'Google_GenAI' as const;\n\n// Distinct from the proxy's `auto.ai.google_genai` so spans from the orchestrion path\n// are attributable separately from the OTel/proxy one.\nconst ORIGIN = 'auto.ai.orchestrion.google_genai';\n\n// Each instrumented method maps to the gen_ai operation its span reports.\nconst INSTRUMENTED_CHANNELS = [\n { channel: CHANNELS.GOOGLE_GENAI_GENERATE_CONTENT, operation: 'generate_content' },\n { channel: CHANNELS.GOOGLE_GENAI_EMBED_CONTENT, operation: 'embeddings' },\n { channel: CHANNELS.GOOGLE_GENAI_CHAT, operation: 'chat' },\n] as const;\n\ninterface GoogleGenAIChannelContext {\n arguments: unknown[];\n // The transform stashes the call's `this` here, which chat methods need since the model lives on\n // the `Chat` instance (`this.model`/`this.modelVersion`), not in the call arguments.\n self?: unknown;\n result?: unknown;\n}\n\nlet subscribed = false;\n\nconst _googleGenAIChannelIntegration = ((options: GoogleGenAIOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19, and a second `init()` would double-subscribe.\n if (!diagnosticsChannel.tracingChannel || subscribed) {\n return;\n }\n subscribed = true;\n\n // `bindTracingChannelToSpan` needs the async-context binding that `initOpenTelemetry()` registers\n // after `setupOnce` runs, so wait for it before subscribing.\n waitForTracingChannelBinding(() => {\n for (const { channel, operation } of INSTRUMENTED_CHANNELS) {\n DEBUG_BUILD && debug.log(`[orchestrion:google-genai] subscribing to channel \"${channel}\"`);\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<GoogleGenAIChannelContext>(channel),\n data => createGenAiSpan(data, operation, options),\n {\n beforeSpanEnd: (span, data) => {\n // Embeddings responses carry no content attributes.\n if (operation !== 'embeddings') {\n addGoogleGenAIResponseAttributes(\n span,\n data.result as GoogleGenAIResponse,\n resolveAIRecordingOptions(options).recordOutputs,\n );\n }\n },\n deferSpanEnd: ({ span, data }) => wrapStreamResult(span, data, options),\n },\n );\n }\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Build the span for an instrumented call.\n * Returning `undefined` opts the payload out so no span is opened.\n */\nfunction createGenAiSpan(\n data: GoogleGenAIChannelContext,\n operation: string,\n options: GoogleGenAIOptions,\n): Span | undefined {\n // When another provider (e.g. LangChain) is driving the SDK, it records the spans itself and marks this\n // provider as skipped; skip here to avoid double spans.\n if (_INTERNAL_shouldSkipAiProviderWrapping(INTEGRATION_NAME)) {\n return undefined;\n }\n\n // `chat.sendMessage()`/`sendMessageStream()` internally call `Models.generateContent(Stream)`, which\n // publishes the `generate-content` channel while the chat span is active. Skip that nested event so a\n // chat call yields a single `gen_ai.chat` span instead of a chat span wrapping a generate_content one.\n if (operation !== 'chat') {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const { op, origin } = spanToJSON(activeSpan);\n if (origin === ORIGIN && op === 'gen_ai.chat') {\n return undefined;\n }\n }\n }\n\n const args = data.arguments ?? [];\n const params = args[0] as Record<string, unknown> | undefined;\n\n const { recordInputs } = resolveAIRecordingOptions(options);\n const enableTruncation = shouldEnableTruncation(options.enableTruncation);\n\n const attributes = extractGoogleGenAIRequestAttributes(operation, params, data.self);\n const model = (attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE] as string) || 'unknown';\n attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = ORIGIN;\n\n const span = startInactiveSpan({\n name: `${operation} ${model}`,\n op: `gen_ai.${operation}`,\n attributes,\n });\n\n if (recordInputs && params) {\n addGoogleGenAIRequestAttributes(span, params, operation, enableTruncation);\n }\n\n return span;\n}\n\ntype AsyncIterableStream = { [Symbol.asyncIterator]: () => AsyncIterator<unknown> };\n\nfunction isAsyncIterable(value: unknown): value is AsyncIterableStream {\n return !!value && typeof (value as AsyncIterableStream)[Symbol.asyncIterator] === 'function';\n}\n\n/**\n * Only the streaming methods (`generateContentStream`/`sendMessageStream`) resolve to an async iterable.\n * For a stream we patch `result[Symbol.asyncIterator]` in place so `instrumentGoogleGenAIStream` ends the\n * span when iteration finishes.\n */\nfunction wrapStreamResult(span: Span, data: GoogleGenAIChannelContext, options: GoogleGenAIOptions): boolean {\n const result = data.result;\n if (!isAsyncIterable(result)) {\n return false;\n }\n\n const { recordOutputs } = resolveAIRecordingOptions(options);\n const iterate = result[Symbol.asyncIterator].bind(result);\n const instrumented = instrumentGoogleGenAIStream({ [Symbol.asyncIterator]: iterate }, span, recordOutputs ?? false);\n result[Symbol.asyncIterator] = () => instrumented;\n\n return true;\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven Google GenAI integration. Subscribes to the\n * `orchestrion:@google/genai:*` diagnostics_channels injected into the SDK's `Models`\n * (`generateContent`/`generateContentStream`/`embedContent`) and `Chat`\n * (`sendMessage`/`sendMessageStream`) methods, so it requires the orchestrion runtime hook or\n * bundler plugin.\n */\nexport const googleGenAIChannelIntegration = defineIntegration(_googleGenAIChannelIntegration);\n"],"names":["CHANNELS","waitForTracingChannelBinding","DEBUG_BUILD","debug","bindTracingChannelToSpan","addGoogleGenAIResponseAttributes","resolveAIRecordingOptions","_INTERNAL_shouldSkipAiProviderWrapping","getActiveSpan","spanToJSON","shouldEnableTruncation","extractGoogleGenAIRequestAttributes","GEN_AI_REQUEST_MODEL_ATTRIBUTE","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","startInactiveSpan","addGoogleGenAIRequestAttributes","instrumentGoogleGenAIStream","defineIntegration"],"mappings":";;;;;;;;AAyBA,MAAM,gBAAA,GAAmB,cAAA;AAIzB,MAAM,MAAA,GAAS,kCAAA;AAGf,MAAM,qBAAA,GAAwB;AAAA,EAC5B,EAAE,OAAA,EAASA,iBAAA,CAAS,6BAAA,EAA+B,WAAW,kBAAA,EAAmB;AAAA,EACjF,EAAE,OAAA,EAASA,iBAAA,CAAS,0BAAA,EAA4B,WAAW,YAAA,EAAa;AAAA,EACxE,EAAE,OAAA,EAASA,iBAAA,CAAS,iBAAA,EAAmB,WAAW,MAAA;AACpD,CAAA;AAUA,IAAI,UAAA,GAAa,KAAA;AAEjB,MAAM,8BAAA,IAAkC,CAAC,OAAA,GAA8B,EAAC,KAAM;AAC5E,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAAC,kBAAA,CAAmB,cAAA,IAAkB,UAAA,EAAY;AACpD,QAAA;AAAA,MACF;AACA,MAAA,UAAA,GAAa,IAAA;AAIb,MAAAC,iCAAA,CAA6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AO,CAAA;AAC3D,EAAA,MAAM,UAAU,MAAA,CAAO,MAAA,CAAO,aAAa,CAAA,CAAE,KAAK,MAAM,CAAA;AACxD,EAAA,MAAM,YAAA,GAAeU,gCAAA,CAA4B,EAAE,CAAC,MAAA,CAAO,aAAa,GAAG,OAAA,EAAQ,EAAG,IAAA,EAAM,aAAA,IAAiB,KAAK,CAAA;AAClH,EAAA,MAAA,CAAO,MAAA,CAAO,aAAa,CAAA,GAAI,MAAM,YAAA;AAErC,EAAA,OAAO,IAAA;AACT;AASO,MAAM,6BAAA,GAAgCC,uBAAkB,8BAA8B;;;;"}
@@ -0,0 +1,26 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const ORIGIN = "auto.graphql.diagnostic_channel";
4
+ const SPAN_NAME_PARSE = "graphql.parse";
5
+ const SPAN_NAME_VALIDATE = "graphql.validate";
6
+ const SPAN_NAME_EXECUTE = "graphql.execute";
7
+ const SPAN_NAME_RESOLVE = "graphql.resolve";
8
+ const GRAPHQL_FIELD_NAME = "graphql.field.name";
9
+ const GRAPHQL_FIELD_PATH = "graphql.field.path";
10
+ const GRAPHQL_FIELD_TYPE = "graphql.field.type";
11
+ const GRAPHQL_PARENT_NAME = "graphql.parent.name";
12
+ const GRAPHQL_DATA_SYMBOL = /* @__PURE__ */ Symbol.for("opentelemetry.graphql_data");
13
+ const GRAPHQL_PATCHED_SYMBOL = /* @__PURE__ */ Symbol.for("opentelemetry.patched");
14
+
15
+ exports.GRAPHQL_DATA_SYMBOL = GRAPHQL_DATA_SYMBOL;
16
+ exports.GRAPHQL_FIELD_NAME = GRAPHQL_FIELD_NAME;
17
+ exports.GRAPHQL_FIELD_PATH = GRAPHQL_FIELD_PATH;
18
+ exports.GRAPHQL_FIELD_TYPE = GRAPHQL_FIELD_TYPE;
19
+ exports.GRAPHQL_PARENT_NAME = GRAPHQL_PARENT_NAME;
20
+ exports.GRAPHQL_PATCHED_SYMBOL = GRAPHQL_PATCHED_SYMBOL;
21
+ exports.ORIGIN = ORIGIN;
22
+ exports.SPAN_NAME_EXECUTE = SPAN_NAME_EXECUTE;
23
+ exports.SPAN_NAME_PARSE = SPAN_NAME_PARSE;
24
+ exports.SPAN_NAME_RESOLVE = SPAN_NAME_RESOLVE;
25
+ exports.SPAN_NAME_VALIDATE = SPAN_NAME_VALIDATE;
26
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../../../src/integrations/tracing-channel/graphql/constants.ts"],"sourcesContent":["/*\n * These mirror the constants in `@sentry/server-utils`'s native graphql subscriber\n * (`src/graphql/graphql-dc-subscriber.ts`) so the orchestrion path (graphql v14–16) and the native\n * `diagnostics_channel` path (graphql >= 17) emit identical spans — same origin, span names and\n * field-attribute keys. `graphql.document`/`graphql.operation.*` and the span `op` come from\n * `@sentry/conventions` directly and are imported where used.\n */\n\nexport const ORIGIN = 'auto.graphql.diagnostic_channel';\n\nexport const SPAN_NAME_PARSE = 'graphql.parse';\nexport const SPAN_NAME_VALIDATE = 'graphql.validate';\nexport const SPAN_NAME_EXECUTE = 'graphql.execute';\nexport const SPAN_NAME_RESOLVE = 'graphql.resolve';\n\n// Field-level resolver-span attributes; not in `@sentry/conventions`.\nexport const GRAPHQL_FIELD_NAME = 'graphql.field.name';\nexport const GRAPHQL_FIELD_PATH = 'graphql.field.path';\nexport const GRAPHQL_FIELD_TYPE = 'graphql.field.type';\nexport const GRAPHQL_PARENT_NAME = 'graphql.parent.name';\n\n// `Symbol.for` keys shared with any co-resident OTel graphql instrumentation on purpose: the paths are\n// mutually exclusive at runtime, and reusing the key keeps nested-execute detection and resolver\n// parenting consistent if both ever load.\nexport const GRAPHQL_DATA_SYMBOL = Symbol.for('opentelemetry.graphql_data');\nexport const GRAPHQL_PATCHED_SYMBOL = Symbol.for('opentelemetry.patched');\n"],"names":[],"mappings":";;AAQO,MAAM,MAAA,GAAS;AAEf,MAAM,eAAA,GAAkB;AACxB,MAAM,kBAAA,GAAqB;AAC3B,MAAM,iBAAA,GAAoB;AAC1B,MAAM,iBAAA,GAAoB;AAG1B,MAAM,kBAAA,GAAqB;AAC3B,MAAM,kBAAA,GAAqB;AAC3B,MAAM,kBAAA,GAAqB;AAC3B,MAAM,mBAAA,GAAsB;AAK5B,MAAM,mBAAA,mBAAsB,MAAA,CAAO,GAAA,CAAI,4BAA4B;AACnE,MAAM,sBAAA,mBAAyB,MAAA,CAAO,GAAA,CAAI,uBAAuB;;;;;;;;;;;;;;"}
@@ -0,0 +1,66 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const diagnosticsChannel = require('node:diagnostics_channel');
4
+ const core = require('@sentry/core');
5
+ const debugBuild = require('../../../debug-build.js');
6
+ const index = require('../../../graphql/index.js');
7
+ const channels = require('../../../orchestrion/channels.js');
8
+ const tracingChannel = require('../../../tracing-channel.js');
9
+ const spans = require('./spans.js');
10
+
11
+ const INTEGRATION_NAME = "Graphql";
12
+ function getOptionsWithDefaults(options) {
13
+ return {
14
+ ignoreResolveSpans: options.ignoreResolveSpans !== false,
15
+ ignoreTrivialResolveSpans: options.ignoreTrivialResolveSpans !== false,
16
+ useOperationNameForRootSpan: options.useOperationNameForRootSpan !== false
17
+ };
18
+ }
19
+ function safe(fn) {
20
+ try {
21
+ return fn();
22
+ } catch (error) {
23
+ debugBuild.DEBUG_BUILD && core.debug.warn("[orchestrion:graphql] error building span", error);
24
+ return void 0;
25
+ }
26
+ }
27
+ const _graphqlChannelIntegration = ((options = {}) => {
28
+ const config = getOptionsWithDefaults(options);
29
+ const getConfig = () => config;
30
+ return {
31
+ name: INTEGRATION_NAME,
32
+ setupOnce() {
33
+ if (!diagnosticsChannel.tracingChannel) {
34
+ return;
35
+ }
36
+ core.waitForTracingChannelBinding(() => {
37
+ tracingChannel.bindTracingChannelToSpan(
38
+ diagnosticsChannel.tracingChannel(channels.CHANNELS.GRAPHQL_PARSE),
39
+ () => safe(() => spans.startParseSpan())
40
+ );
41
+ tracingChannel.bindTracingChannelToSpan(
42
+ diagnosticsChannel.tracingChannel(channels.CHANNELS.GRAPHQL_VALIDATE),
43
+ (data) => safe(() => spans.startValidateSpan(data.arguments[1])),
44
+ { beforeSpanEnd: (span, data) => void safe(() => spans.finalizeValidateSpan(span, data.result)) }
45
+ );
46
+ tracingChannel.bindTracingChannelToSpan(
47
+ diagnosticsChannel.tracingChannel(channels.CHANNELS.GRAPHQL_EXECUTE),
48
+ (data) => safe(() => spans.startExecuteSpan(data.arguments, data.self, config, getConfig)),
49
+ { beforeSpanEnd: (span, data) => void safe(() => spans.finalizeExecuteSpan(span, data.result)) }
50
+ );
51
+ });
52
+ }
53
+ };
54
+ });
55
+ const graphqlChannelIntegration = core.defineIntegration(_graphqlChannelIntegration);
56
+ const graphqlDiagnosticsChannelIntegration = (options) => {
57
+ const orchestrion = graphqlChannelIntegration(options);
58
+ return core.extendIntegration(index.graphqlIntegration(options), {
59
+ name: INTEGRATION_NAME,
60
+ setupOnce: () => orchestrion.setupOnce?.()
61
+ });
62
+ };
63
+
64
+ exports.graphqlChannelIntegration = graphqlChannelIntegration;
65
+ exports.graphqlDiagnosticsChannelIntegration = graphqlDiagnosticsChannelIntegration;
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing-channel/graphql/index.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn } from '@sentry/core';\nimport { debug, defineIntegration, extendIntegration, waitForTracingChannelBinding } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport { graphqlIntegration as graphqlNativeIntegration } from '../../../graphql';\nimport type { GraphqlDiagnosticChannelsOptions } from '../../../graphql/graphql-dc-subscriber';\nimport { CHANNELS } from '../../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../../tracing-channel';\nimport {\n finalizeExecuteSpan,\n finalizeValidateSpan,\n startExecuteSpan,\n startParseSpan,\n startValidateSpan,\n} from './spans';\nimport type { GraphqlResolvedConfig } from './types';\n\n// Same name as the OTel/native integration by design, so enabling injection swaps this in for it.\nconst INTEGRATION_NAME = 'Graphql' as const;\n\n// The context orchestrion's transform attaches to each channel: `arguments` is the live args of the\n// wrapped call, `result` the settled return value.\ninterface GraphqlChannelContext {\n arguments: unknown[];\n self?: unknown;\n result?: unknown;\n error?: unknown;\n}\n\nfunction getOptionsWithDefaults(options: GraphqlDiagnosticChannelsOptions): GraphqlResolvedConfig {\n return {\n ignoreResolveSpans: options.ignoreResolveSpans !== false,\n ignoreTrivialResolveSpans: options.ignoreTrivialResolveSpans !== false,\n useOperationNameForRootSpan: options.useOperationNameForRootSpan !== false,\n };\n}\n\n/**\n * Runs a span-building callback so a throw inside it can never break the user's graphql call: these\n * run inside the `tracingChannel(...).trace*` machinery wrapping the real function (as the `getSpan`\n * producer / `beforeSpanEnd` handler), where an unguarded throw would propagate into the traced call.\n */\nfunction safe<T>(fn: () => T): T | undefined {\n try {\n return fn();\n } catch (error) {\n DEBUG_BUILD && debug.warn('[orchestrion:graphql] error building span', error);\n return undefined;\n }\n}\n\nconst _graphqlChannelIntegration = ((options: GraphqlDiagnosticChannelsOptions = {}) => {\n const config = getOptionsWithDefaults(options);\n const getConfig = (): GraphqlResolvedConfig => config;\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n bindTracingChannelToSpan(diagnosticsChannel.tracingChannel<GraphqlChannelContext>(CHANNELS.GRAPHQL_PARSE), () =>\n safe(() => startParseSpan()),\n );\n\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<GraphqlChannelContext>(CHANNELS.GRAPHQL_VALIDATE),\n data => safe(() => startValidateSpan(data.arguments[1])),\n { beforeSpanEnd: (span, data) => void safe(() => finalizeValidateSpan(span, data.result)) },\n );\n\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<GraphqlChannelContext>(CHANNELS.GRAPHQL_EXECUTE),\n data => safe(() => startExecuteSpan(data.arguments, data.self, config, getConfig)),\n { beforeSpanEnd: (span, data) => void safe(() => finalizeExecuteSpan(span, data.result)) },\n );\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * EXPERIMENTAL — orchestrion-driven graphql integration for graphql v14–16 (v17 publishes native\n * `diagnostics_channel` events handled by `@sentry/server-utils`'s graphql integration instead).\n *\n * Subscribes to the `orchestrion:graphql:{parse,validate,execute}` channels the orchestrion code\n * transform injects into `graphql`'s `language/parser.js`, `validation/validate.js` and\n * `execution/execute.js`, emitting spans identical to the native path. Requires the orchestrion\n * runtime hook or bundler plugin — wire it up via `experimentalUseDiagnosticsChannelInjection()`.\n *\n * @experimental\n */\nexport const graphqlChannelIntegration = defineIntegration(_graphqlChannelIntegration);\n\n/**\n * The complete graphql diagnostics-channel integration: the native subscriber (graphql v17) composed\n * with the orchestrion subscriber (v14–16), so opting into injection instruments every supported\n * version via diagnostics channels without the OTel patcher. Reuses the OTel `Graphql` name so\n * enabling injection swaps this in for it.\n */\nexport const graphqlDiagnosticsChannelIntegration = (options?: GraphqlDiagnosticChannelsOptions) => {\n const orchestrion = graphqlChannelIntegration(options);\n return extendIntegration(graphqlNativeIntegration(options), {\n name: INTEGRATION_NAME,\n setupOnce: () => orchestrion.setupOnce?.(),\n });\n};\n"],"names":["DEBUG_BUILD","debug","waitForTracingChannelBinding","bindTracingChannelToSpan","CHANNELS","startParseSpan","startValidateSpan","finalizeValidateSpan","startExecuteSpan","finalizeExecuteSpan","defineIntegration","extendIntegration","graphqlNativeIntegration"],"mappings":";;;;;;;;;;AAkBA,MAAM,gBAAA,GAAmB,SAAA;AAWzB,SAAS,uBAAuB,OAAA,EAAkE;AAChG,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,QAAQ,kBAAA,KAAuB,KAAA;AAAA,IACnD,yBAAA,EAA2B,QAAQ,yBAAA,KAA8B,KAAA;AAAA,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,MAAMI,sBAAA,CAAiB,IAAA,CAAK,WAAW,IAAA,CAAK,IAAA,EAAM,MAAA,EAAQ,SAAS,CAAC,CAAA;AAAA,UACjF,EAAE,aAAA,EAAe,CAAC,IAAA,EAAM,IAAA,KAAS,KAAK,IAAA,CAAK,MAAMC,yBAAA,CAAoB,IAAA,EAAM,IAAA,CAAK,MAAM,CAAC,CAAA;AAAE,SAC3F;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAaO,MAAM,yBAAA,GAA4BC,uBAAkB,0BAA0B;AAQ9E,MAAM,oCAAA,GAAuC,CAAC,OAAA,KAA+C;AAClG,EAAA,MAAM,WAAA,GAAc,0BAA0B,OAAO,CAAA;AACrD,EAAA,OAAOC,sBAAA,CAAkBC,wBAAA,CAAyB,OAAO,CAAA,EAAG;AAAA,IAC1D,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,EAAW,MAAM,WAAA,CAAY,SAAA;AAAY,GAC1C,CAAA;AACH;;;;;"}
@@ -0,0 +1,168 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const op = require('@sentry/conventions/op');
4
+ const core = require('@sentry/core');
5
+ const constants = require('./constants.js');
6
+
7
+ function isPromise(value) {
8
+ return typeof value?.then === "function";
9
+ }
10
+ function wrapFields(type, getConfig) {
11
+ if (!type || type[constants.GRAPHQL_PATCHED_SYMBOL]) {
12
+ return;
13
+ }
14
+ type[constants.GRAPHQL_PATCHED_SYMBOL] = true;
15
+ const fields = type.getFields();
16
+ Object.keys(fields).forEach((key) => {
17
+ const field = fields[key];
18
+ if (!field) {
19
+ return;
20
+ }
21
+ if (field.resolve) {
22
+ field.resolve = wrapFieldResolver(getConfig, field.resolve);
23
+ }
24
+ if (field.type) {
25
+ for (const unwrappedType of unwrapType(field.type)) {
26
+ wrapFields(unwrappedType, getConfig);
27
+ }
28
+ }
29
+ });
30
+ }
31
+ function wrapFieldResolver(getConfig, fieldResolver, isDefaultResolver = false) {
32
+ if (typeof fieldResolver !== "function" || fieldResolver[constants.GRAPHQL_PATCHED_SYMBOL]) {
33
+ return fieldResolver;
34
+ }
35
+ function wrappedFieldResolver(source, args, rawContextValue, info) {
36
+ if (!fieldResolver) {
37
+ return void 0;
38
+ }
39
+ const contextValue = rawContextValue ?? {};
40
+ const config = getConfig();
41
+ if (config.ignoreTrivialResolveSpans && isDefaultResolver && (core.isObjectLike(source) || typeof source === "function")) {
42
+ const property = source[info.fieldName];
43
+ if (typeof property !== "function") {
44
+ return fieldResolver.call(this, source, args, contextValue, info);
45
+ }
46
+ }
47
+ if (!contextValue[constants.GRAPHQL_DATA_SYMBOL]) {
48
+ return fieldResolver.call(this, source, args, contextValue, info);
49
+ }
50
+ const path = pathToArray(info.path);
51
+ const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path);
52
+ const span = field.span;
53
+ return core.withActiveSpan(span, () => {
54
+ try {
55
+ const res = fieldResolver.call(this, source, args, contextValue, info);
56
+ if (isPromise(res)) {
57
+ return res.then(
58
+ (r) => {
59
+ endResolveSpan(span, spanAdded);
60
+ return r;
61
+ },
62
+ (err) => {
63
+ endResolveSpan(span, spanAdded, err);
64
+ throw err;
65
+ }
66
+ );
67
+ }
68
+ endResolveSpan(span, spanAdded);
69
+ return res;
70
+ } catch (err) {
71
+ endResolveSpan(span, spanAdded, err);
72
+ throw err;
73
+ }
74
+ });
75
+ }
76
+ wrappedFieldResolver[constants.GRAPHQL_PATCHED_SYMBOL] = true;
77
+ return wrappedFieldResolver;
78
+ }
79
+ function endResolveSpan(span, shouldEndSpan, error) {
80
+ if (!shouldEndSpan) {
81
+ return;
82
+ }
83
+ if (error) {
84
+ span.setStatus({ code: core.SPAN_STATUS_ERROR, message: error.message });
85
+ }
86
+ span.end();
87
+ }
88
+ function createFieldIfNotExists(contextValue, info, path) {
89
+ const existing = getField(contextValue, path);
90
+ if (existing) {
91
+ return { field: existing, spanAdded: false };
92
+ }
93
+ const field = { span: createResolverSpan(info, path, getParentFieldSpan(contextValue, path)) };
94
+ addField(contextValue, path, field);
95
+ return { field, spanAdded: true };
96
+ }
97
+ function createResolverSpan(info, path, parentSpan) {
98
+ const attributes = {
99
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: constants.ORIGIN,
100
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: op.WEB_SERVER_GRAPHQL_SPAN_OP,
101
+ [constants.GRAPHQL_FIELD_NAME]: info.fieldName,
102
+ [constants.GRAPHQL_FIELD_PATH]: path.join("."),
103
+ [constants.GRAPHQL_FIELD_TYPE]: info.returnType.toString(),
104
+ [constants.GRAPHQL_PARENT_NAME]: info.parentType.name
105
+ };
106
+ return core.startInactiveSpan({ name: `${constants.SPAN_NAME_RESOLVE} ${path.join(".")}`, attributes, parentSpan });
107
+ }
108
+ function addField(contextValue, path, field) {
109
+ const data = contextValue[constants.GRAPHQL_DATA_SYMBOL];
110
+ if (data) {
111
+ data.fields[path.join(".")] = field;
112
+ }
113
+ }
114
+ function getField(contextValue, path) {
115
+ return contextValue[constants.GRAPHQL_DATA_SYMBOL]?.fields[path.join(".")];
116
+ }
117
+ function getParentFieldSpan(contextValue, path) {
118
+ for (let i = path.length - 1; i > 0; i--) {
119
+ const field = getField(contextValue, path.slice(0, i));
120
+ if (field) {
121
+ return field.span;
122
+ }
123
+ }
124
+ return contextValue[constants.GRAPHQL_DATA_SYMBOL]?.span;
125
+ }
126
+ function pathToArray(path) {
127
+ const flattened = [];
128
+ let curr = path;
129
+ while (curr) {
130
+ flattened.push(String(curr.key));
131
+ curr = curr.prev;
132
+ }
133
+ return flattened.reverse();
134
+ }
135
+ function unwrapType(type) {
136
+ if ("ofType" in type && type.ofType) {
137
+ return unwrapType(type.ofType);
138
+ }
139
+ if (isGraphQLUnionType(type)) {
140
+ return type.getTypes();
141
+ }
142
+ if (isGraphQLObjectType(type)) {
143
+ return [type];
144
+ }
145
+ return [];
146
+ }
147
+ function isGraphQLUnionType(type) {
148
+ return "getTypes" in type && typeof type.getTypes === "function";
149
+ }
150
+ function isGraphQLObjectType(type) {
151
+ return "getFields" in type && typeof type.getFields === "function";
152
+ }
153
+ function getOperation(document, operationName) {
154
+ const definitions = document?.definitions;
155
+ if (!definitions || !Array.isArray(definitions)) {
156
+ return void 0;
157
+ }
158
+ const isOperation = (def) => !!def?.operation && ["query", "mutation", "subscription"].indexOf(def.operation) !== -1;
159
+ if (operationName) {
160
+ return definitions.filter(isOperation).find((def) => operationName === def?.name?.value);
161
+ }
162
+ return definitions.find(isOperation);
163
+ }
164
+
165
+ exports.getOperation = getOperation;
166
+ exports.wrapFieldResolver = wrapFieldResolver;
167
+ exports.wrapFields = wrapFields;
168
+ //# sourceMappingURL=resolvers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvers.js","sources":["../../../../../src/integrations/tracing-channel/graphql/resolvers.ts"],"sourcesContent":["/*\n * Resolver-span wrapping for the orchestrion graphql path. graphql v14–16 publishes no per-field\n * `resolve` channel (unlike v17's native one), so the schema's field resolvers are swapped for\n * span-creating proxies under the execute channel's `start` (the \"consumer trick\" — the transform\n * can't target user resolvers, but `execute` receives the schema, so we mutate it before the wrapped\n * call runs). Resolver spans use the same origin/op/field attributes as the native subscriber.\n */\n\nimport { WEB_SERVER_GRAPHQL_SPAN_OP } from '@sentry/conventions/op';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n isObjectLike,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport {\n GRAPHQL_DATA_SYMBOL,\n GRAPHQL_FIELD_NAME,\n GRAPHQL_FIELD_PATH,\n GRAPHQL_FIELD_TYPE,\n GRAPHQL_PARENT_NAME,\n GRAPHQL_PATCHED_SYMBOL,\n ORIGIN,\n SPAN_NAME_RESOLVE,\n} from './constants';\nimport type {\n DefinitionNode,\n DocumentNode,\n GraphQLFieldResolver,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLPath,\n GraphQLResolveInfo,\n GraphQLType,\n GraphQLUnionType,\n GraphqlResolvedConfig,\n Maybe,\n ObjectWithGraphQLData,\n Patched,\n} from './types';\n\nfunction isPromise(value: unknown): value is Promise<unknown> {\n return typeof (value as { then?: unknown } | undefined)?.then === 'function';\n}\n\n/**\n * Walks the query/mutation type tree and swaps each field's `resolve` for a span-creating proxy.\n * Idempotent per type via {@link GRAPHQL_PATCHED_SYMBOL}.\n */\nexport function wrapFields(type: Maybe<GraphQLObjectType & Patched>, getConfig: () => GraphqlResolvedConfig): void {\n if (!type || type[GRAPHQL_PATCHED_SYMBOL]) {\n return;\n }\n\n type[GRAPHQL_PATCHED_SYMBOL] = true;\n const fields = type.getFields();\n\n Object.keys(fields).forEach(key => {\n const field = fields[key];\n if (!field) {\n return;\n }\n\n if (field.resolve) {\n field.resolve = wrapFieldResolver(getConfig, field.resolve);\n }\n\n if (field.type) {\n for (const unwrappedType of unwrapType(field.type)) {\n wrapFields(unwrappedType, getConfig);\n }\n }\n });\n}\n\nexport function wrapFieldResolver(\n getConfig: () => GraphqlResolvedConfig,\n fieldResolver: Maybe<GraphQLFieldResolver & Patched>,\n isDefaultResolver = false,\n): GraphQLFieldResolver & Patched {\n // Return the resolver untouched if it isn't a function or is already a wrapped one — the wrapper we\n // return is marked with `GRAPHQL_PATCHED_SYMBOL` below precisely so it can be detected here. (The\n // guard must test the incoming `fieldResolver`, not the freshly-hoisted `wrappedFieldResolver`.)\n if (typeof fieldResolver !== 'function' || fieldResolver[GRAPHQL_PATCHED_SYMBOL]) {\n return fieldResolver as GraphQLFieldResolver;\n }\n\n function wrappedFieldResolver(\n this: unknown,\n source: unknown,\n args: unknown,\n rawContextValue: unknown,\n info: GraphQLResolveInfo,\n ): unknown {\n if (!fieldResolver) {\n return undefined;\n }\n\n const contextValue = (rawContextValue ?? {}) as ObjectWithGraphQLData;\n const config = getConfig();\n\n // Mirror graphql's own \"trivial resolver\" check: a default resolver that just reads a\n // non-function property is not worth a span.\n if (\n config.ignoreTrivialResolveSpans &&\n isDefaultResolver &&\n (isObjectLike(source) || typeof source === 'function')\n ) {\n const property = (source as Record<string, unknown>)[info.fieldName];\n if (typeof property !== 'function') {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n }\n\n if (!contextValue[GRAPHQL_DATA_SYMBOL]) {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n\n const path = pathToArray(info.path);\n const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path);\n const span = field.span;\n\n return withActiveSpan(span, () => {\n try {\n const res = fieldResolver.call(this, source, args, contextValue, info);\n if (isPromise(res)) {\n return res.then(\n r => {\n endResolveSpan(span, spanAdded);\n return r;\n },\n (err: Error) => {\n endResolveSpan(span, spanAdded, err);\n throw err;\n },\n );\n }\n endResolveSpan(span, spanAdded);\n return res;\n } catch (err) {\n endResolveSpan(span, spanAdded, err as Error);\n throw err;\n }\n });\n }\n\n (wrappedFieldResolver as Patched)[GRAPHQL_PATCHED_SYMBOL] = true;\n return wrappedFieldResolver;\n}\n\nfunction endResolveSpan(span: Span, shouldEndSpan: boolean, error?: Error): void {\n if (!shouldEndSpan) {\n return;\n }\n if (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n}\n\nfunction createFieldIfNotExists(\n contextValue: ObjectWithGraphQLData,\n info: GraphQLResolveInfo,\n path: string[],\n): { field: { span: Span }; spanAdded: boolean } {\n const existing = getField(contextValue, path);\n if (existing) {\n return { field: existing, spanAdded: false };\n }\n\n const field = { span: createResolverSpan(info, path, getParentFieldSpan(contextValue, path)) };\n addField(contextValue, path, field);\n return { field, spanAdded: true };\n}\n\nfunction createResolverSpan(info: GraphQLResolveInfo, path: string[], parentSpan?: Span): Span {\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: WEB_SERVER_GRAPHQL_SPAN_OP,\n [GRAPHQL_FIELD_NAME]: info.fieldName,\n [GRAPHQL_FIELD_PATH]: path.join('.'),\n [GRAPHQL_FIELD_TYPE]: info.returnType.toString(),\n [GRAPHQL_PARENT_NAME]: info.parentType.name,\n };\n\n return startInactiveSpan({ name: `${SPAN_NAME_RESOLVE} ${path.join('.')}`, attributes, parentSpan });\n}\n\nfunction addField(contextValue: ObjectWithGraphQLData, path: string[], field: { span: Span }): void {\n const data = contextValue[GRAPHQL_DATA_SYMBOL];\n if (data) {\n data.fields[path.join('.')] = field;\n }\n}\n\nfunction getField(contextValue: ObjectWithGraphQLData, path: string[]): { span: Span } | undefined {\n return contextValue[GRAPHQL_DATA_SYMBOL]?.fields[path.join('.')];\n}\n\nfunction getParentFieldSpan(contextValue: ObjectWithGraphQLData, path: string[]): Span | undefined {\n for (let i = path.length - 1; i > 0; i--) {\n const field = getField(contextValue, path.slice(0, i));\n if (field) {\n return field.span;\n }\n }\n return contextValue[GRAPHQL_DATA_SYMBOL]?.span;\n}\n\nfunction pathToArray(path: GraphQLPath): string[] {\n const flattened: string[] = [];\n let curr: GraphQLPath | undefined = path;\n while (curr) {\n flattened.push(String(curr.key));\n curr = curr.prev;\n }\n return flattened.reverse();\n}\n\nfunction unwrapType(type: GraphQLOutputType): readonly (GraphQLObjectType & Patched)[] {\n // The structural index signature widens `ofType` to `unknown`, so narrow it back explicitly.\n if ('ofType' in type && type.ofType) {\n return unwrapType(type.ofType as GraphQLOutputType);\n }\n if (isGraphQLUnionType(type)) {\n return type.getTypes();\n }\n if (isGraphQLObjectType(type)) {\n return [type];\n }\n return [];\n}\n\nfunction isGraphQLUnionType(type: GraphQLType): type is GraphQLUnionType {\n return 'getTypes' in type && typeof type.getTypes === 'function';\n}\n\nfunction isGraphQLObjectType(type: GraphQLType): type is GraphQLObjectType {\n return 'getFields' in type && typeof (type as GraphQLObjectType).getFields === 'function';\n}\n\n/**\n * Returns the operation definition for `operationName` (or the first operation) from a parsed\n * document, or `undefined` for schema documents / when no operation is present.\n */\nexport function getOperation(document: DocumentNode, operationName?: Maybe<string>): DefinitionNode | undefined {\n const definitions: readonly DefinitionNode[] | undefined = document?.definitions;\n if (!definitions || !Array.isArray(definitions)) {\n return undefined;\n }\n\n const isOperation = (def: DefinitionNode): boolean =>\n !!def?.operation && ['query', 'mutation', 'subscription'].indexOf(def.operation) !== -1;\n\n if (operationName) {\n return definitions.filter(isOperation).find((def: DefinitionNode) => operationName === def?.name?.value);\n }\n return definitions.find(isOperation);\n}\n"],"names":["GRAPHQL_PATCHED_SYMBOL","isObjectLike","GRAPHQL_DATA_SYMBOL","withActiveSpan","SPAN_STATUS_ERROR","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","WEB_SERVER_GRAPHQL_SPAN_OP","GRAPHQL_FIELD_NAME","GRAPHQL_FIELD_PATH","GRAPHQL_FIELD_TYPE","GRAPHQL_PARENT_NAME","startInactiveSpan","SPAN_NAME_RESOLVE"],"mappings":";;;;;;AA4CA,SAAS,UAAU,KAAA,EAA2C;AAC5D,EAAA,OAAO,OAAQ,OAA0C,IAAA,KAAS,UAAA;AACpE;AAMO,SAAS,UAAA,CAAW,MAA0C,SAAA,EAA8C;AACjH,EAAA,IAAI,CAAC,IAAA,IAAQ,IAAA,CAAKA,gCAAsB,CAAA,EAAG;AACzC,IAAA;AAAA,EACF;AAEA,EAAA,IAAA,CAAKA,gCAAsB,CAAA,GAAI,IAAA;AAC/B,EAAA,MAAM,MAAA,GAAS,KAAK,SAAA,EAAU;AAE9B,EAAA,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAAE,OAAA,CAAQ,CAAA,GAAA,KAAO;AACjC,IAAA,MAAM,KAAA,GAAQ,OAAO,GAAG,CAAA;AACxB,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,MAAM,OAAA,E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AAG;AAC5B,IAAA,OAAO,KAAK,QAAA,EAAS;AAAA,EACvB;AACA,EAAA,IAAI,mBAAA,CAAoB,IAAI,CAAA,EAAG;AAC7B,IAAA,OAAO,CAAC,IAAI,CAAA;AAAA,EACd;AACA,EAAA,OAAO,EAAC;AACV;AAEA,SAAS,mBAAmB,IAAA,EAA6C;AACvE,EAAA,OAAO,UAAA,IAAc,IAAA,IAAQ,OAAO,IAAA,CAAK,QAAA,KAAa,UAAA;AACxD;AAEA,SAAS,oBAAoB,IAAA,EAA8C;AACzE,EAAA,OAAO,WAAA,IAAe,IAAA,IAAQ,OAAQ,IAAA,CAA2B,SAAA,KAAc,UAAA;AACjF;AAMO,SAAS,YAAA,CAAa,UAAwB,aAAA,EAA2D;AAC9G,EAAA,MAAM,cAAqD,QAAA,EAAU,WAAA;AACrE,EAAA,IAAI,CAAC,WAAA,IAAe,CAAC,KAAA,CAAM,OAAA,CAAQ,WAAW,CAAA,EAAG;AAC/C,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,WAAA,GAAc,CAAC,GAAA,KACnB,CAAC,CAAC,GAAA,EAAK,SAAA,IAAa,CAAC,OAAA,EAAS,YAAY,cAAc,CAAA,CAAE,OAAA,CAAQ,GAAA,CAAI,SAAS,CAAA,KAAM,EAAA;AAEvF,EAAA,IAAI,aAAA,EAAe;AACjB,IAAA,OAAO,WAAA,CAAY,MAAA,CAAO,WAAW,CAAA,CAAE,IAAA,CAAK,CAAC,GAAA,KAAwB,aAAA,KAAkB,GAAA,EAAK,IAAA,EAAM,KAAK,CAAA;AAAA,EACzG;AACA,EAAA,OAAO,WAAA,CAAY,KAAK,WAAW,CAAA;AACrC;;;;;;"}
@@ -0,0 +1,102 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const attributes = require('@sentry/conventions/attributes');
4
+ const op = require('@sentry/conventions/op');
5
+ const core = require('@sentry/core');
6
+ const utils = require('../../../graphql/utils.js');
7
+ const constants = require('./constants.js');
8
+ const resolvers = require('./resolvers.js');
9
+
10
+ const BASE_ATTRIBUTES = {
11
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: constants.ORIGIN,
12
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: op.WEB_SERVER_GRAPHQL_SPAN_OP
13
+ };
14
+ function startParseSpan() {
15
+ return core.startInactiveSpan({ name: constants.SPAN_NAME_PARSE, attributes: { ...BASE_ATTRIBUTES } });
16
+ }
17
+ function startValidateSpan(documentAST) {
18
+ return core.startInactiveSpan({
19
+ name: constants.SPAN_NAME_VALIDATE,
20
+ attributes: { ...BASE_ATTRIBUTES, [attributes.GRAPHQL_DOCUMENT]: utils.collectGraphqlDocument(documentAST) }
21
+ });
22
+ }
23
+ function finalizeValidateSpan(span, result) {
24
+ if (Array.isArray(result) && result.length > 0) {
25
+ span.setStatus({ code: core.SPAN_STATUS_ERROR, message: "invalid_argument" });
26
+ }
27
+ }
28
+ function normalizeExecuteArgs(argsArray) {
29
+ if (argsArray.length >= 2) {
30
+ return {
31
+ schema: argsArray[0 /* SCHEMA */],
32
+ document: argsArray[1 /* DOCUMENT */],
33
+ contextValue: argsArray[3 /* CONTEXT_VALUE */] ?? {},
34
+ operationName: argsArray[5 /* OPERATION_NAME */],
35
+ fieldResolver: argsArray[6 /* FIELD_RESOLVER */],
36
+ writeBack: (contextValue, fieldResolver) => {
37
+ argsArray[3 /* CONTEXT_VALUE */] = contextValue;
38
+ argsArray[6 /* FIELD_RESOLVER */] = fieldResolver;
39
+ }
40
+ };
41
+ }
42
+ const obj = argsArray[0] ?? {};
43
+ return {
44
+ schema: obj.schema,
45
+ document: obj.document,
46
+ contextValue: obj.contextValue ?? {},
47
+ operationName: obj.operationName,
48
+ fieldResolver: obj.fieldResolver,
49
+ writeBack: (contextValue, fieldResolver) => {
50
+ obj.contextValue = contextValue;
51
+ obj.fieldResolver = fieldResolver;
52
+ }
53
+ };
54
+ }
55
+ function startExecuteSpan(argsArray, self, config, getConfig) {
56
+ const args = normalizeExecuteArgs(argsArray);
57
+ const { schema, document } = args;
58
+ let { contextValue, fieldResolver } = args;
59
+ const alreadyInstrumented = !!contextValue[constants.GRAPHQL_DATA_SYMBOL];
60
+ if (!config.ignoreResolveSpans && !alreadyInstrumented) {
61
+ const isUsingDefaultResolver = fieldResolver == null;
62
+ const defaultFieldResolver = self?.defaultFieldResolver;
63
+ const fieldResolverForExecute = fieldResolver ?? defaultFieldResolver;
64
+ if (fieldResolverForExecute) {
65
+ fieldResolver = resolvers.wrapFieldResolver(getConfig, fieldResolverForExecute, isUsingDefaultResolver);
66
+ }
67
+ if (schema) {
68
+ resolvers.wrapFields(schema.getQueryType(), getConfig);
69
+ resolvers.wrapFields(schema.getMutationType(), getConfig);
70
+ }
71
+ }
72
+ const operation = resolvers.getOperation(document, args.operationName);
73
+ const operationType = operation?.operation;
74
+ const operationName = operation?.name?.value ?? args.operationName ?? void 0;
75
+ const span = core.startInactiveSpan({
76
+ name: utils.getOperationSpanName(operationType, operationName || void 0, constants.SPAN_NAME_EXECUTE),
77
+ attributes: {
78
+ ...BASE_ATTRIBUTES,
79
+ [attributes.GRAPHQL_OPERATION_TYPE]: operationType,
80
+ [attributes.GRAPHQL_OPERATION_NAME]: operationName || void 0,
81
+ [attributes.GRAPHQL_DOCUMENT]: utils.collectGraphqlDocument(document)
82
+ }
83
+ });
84
+ if (config.useOperationNameForRootSpan && operationType) {
85
+ utils.renameRootSpanWithOperation(span, operationType, operationName || void 0);
86
+ }
87
+ contextValue[constants.GRAPHQL_DATA_SYMBOL] = { source: document, span, fields: {} };
88
+ args.writeBack(contextValue, fieldResolver);
89
+ return span;
90
+ }
91
+ function finalizeExecuteSpan(span, result) {
92
+ if (utils.hasResultErrors(result)) {
93
+ span.setStatus({ code: core.SPAN_STATUS_ERROR, message: "internal_error" });
94
+ }
95
+ }
96
+
97
+ exports.finalizeExecuteSpan = finalizeExecuteSpan;
98
+ exports.finalizeValidateSpan = finalizeValidateSpan;
99
+ exports.startExecuteSpan = startExecuteSpan;
100
+ exports.startParseSpan = startParseSpan;
101
+ exports.startValidateSpan = startValidateSpan;
102
+ //# sourceMappingURL=spans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spans.js","sources":["../../../../../src/integrations/tracing-channel/graphql/spans.ts"],"sourcesContent":["/*\n * Span builders for the orchestrion graphql channels (v14–16). They emit the same spans as the native\n * `diagnostics_channel` subscriber (`../../../graphql/graphql-dc-subscriber.ts`, graphql >= 17) by\n * reusing its `utils` and conventions — only the data source differs: here the payloads are the raw\n * arguments of the injected `parse`/`validate`/`execute` calls rather than graphql's native events.\n */\n\nimport { GRAPHQL_DOCUMENT, GRAPHQL_OPERATION_NAME, GRAPHQL_OPERATION_TYPE } from '@sentry/conventions/attributes';\nimport { WEB_SERVER_GRAPHQL_SPAN_OP } from '@sentry/conventions/op';\nimport type { Span } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n} from '@sentry/core';\nimport type { GraphqlDocumentNode } from '../../../graphql/utils';\nimport {\n collectGraphqlDocument,\n getOperationSpanName,\n hasResultErrors,\n renameRootSpanWithOperation,\n} from '../../../graphql/utils';\nimport { GRAPHQL_DATA_SYMBOL, ORIGIN, SPAN_NAME_EXECUTE, SPAN_NAME_PARSE, SPAN_NAME_VALIDATE } from './constants';\nimport { getOperation, wrapFields, wrapFieldResolver } from './resolvers';\nimport type {\n DocumentNode,\n GraphQLFieldResolver,\n GraphQLSchema,\n GraphqlResolvedConfig,\n Maybe,\n ObjectWithGraphQLData,\n} from './types';\n\nconst BASE_ATTRIBUTES = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: WEB_SERVER_GRAPHQL_SPAN_OP,\n} as const;\n\nexport function startParseSpan(): Span {\n return startInactiveSpan({ name: SPAN_NAME_PARSE, attributes: { ...BASE_ATTRIBUTES } });\n}\n\n/** `documentAST` is the 2nd argument to `validate(schema, documentAST, …)`. */\nexport function startValidateSpan(documentAST: unknown): Span {\n return startInactiveSpan({\n name: SPAN_NAME_VALIDATE,\n attributes: { ...BASE_ATTRIBUTES, [GRAPHQL_DOCUMENT]: collectGraphqlDocument(documentAST as GraphqlDocumentNode) },\n });\n}\n\n/** `result` is validation's return value: a (possibly empty) array of errors. */\nexport function finalizeValidateSpan(span: Span, result: unknown): void {\n if (Array.isArray(result) && result.length > 0) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'invalid_argument' });\n }\n}\n\n/** Positional slots of a `graphql.execute(schema, document, …)` call (v14/v15 legacy signature). */\nconst enum ExecuteArg {\n SCHEMA = 0,\n DOCUMENT = 1,\n CONTEXT_VALUE = 3,\n OPERATION_NAME = 5,\n FIELD_RESOLVER = 6,\n}\n\ninterface NormalizedExecuteArgs {\n schema?: GraphQLSchema;\n document?: DocumentNode;\n contextValue: ObjectWithGraphQLData;\n operationName?: Maybe<string>;\n fieldResolver?: Maybe<GraphQLFieldResolver>;\n /** Writes `contextValue`/`fieldResolver` mutations back to the live channel `arguments`. */\n writeBack: (contextValue: ObjectWithGraphQLData, fieldResolver: Maybe<GraphQLFieldResolver>) => void;\n}\n\n/**\n * `execute` accepts either a single `ExecutionArgs` object (modern callers, always in v16) or\n * positional args (v14/v15). Both are normalized here; `writeBack` puts mutations onto the correct\n * slot so they reach the real call.\n */\nfunction normalizeExecuteArgs(argsArray: unknown[]): NormalizedExecuteArgs {\n if (argsArray.length >= 2) {\n return {\n schema: argsArray[ExecuteArg.SCHEMA] as GraphQLSchema | undefined,\n document: argsArray[ExecuteArg.DOCUMENT] as DocumentNode | undefined,\n contextValue: (argsArray[ExecuteArg.CONTEXT_VALUE] ?? {}) as ObjectWithGraphQLData,\n operationName: argsArray[ExecuteArg.OPERATION_NAME] as Maybe<string>,\n fieldResolver: argsArray[ExecuteArg.FIELD_RESOLVER] as Maybe<GraphQLFieldResolver>,\n writeBack: (contextValue, fieldResolver) => {\n argsArray[ExecuteArg.CONTEXT_VALUE] = contextValue;\n argsArray[ExecuteArg.FIELD_RESOLVER] = fieldResolver;\n },\n };\n }\n\n const obj = (argsArray[0] ?? {}) as {\n schema?: GraphQLSchema;\n document?: DocumentNode;\n contextValue?: unknown;\n operationName?: Maybe<string>;\n fieldResolver?: Maybe<GraphQLFieldResolver>;\n };\n return {\n schema: obj.schema,\n document: obj.document,\n contextValue: (obj.contextValue ?? {}) as ObjectWithGraphQLData,\n operationName: obj.operationName,\n fieldResolver: obj.fieldResolver,\n writeBack: (contextValue, fieldResolver) => {\n obj.contextValue = contextValue;\n obj.fieldResolver = fieldResolver;\n },\n };\n}\n\n/**\n * Opens the execute span and, unless resolver spans are disabled, swaps the schema's field resolvers\n * (and the default field resolver) for span-creating proxies — mutating the live `arguments` in place\n * so the wrapped `execute` call runs with them. Always returns a span; the caller guards against\n * throws (see `safe` in `index.ts`).\n */\nexport function startExecuteSpan(\n argsArray: unknown[],\n self: unknown,\n config: GraphqlResolvedConfig,\n getConfig: () => GraphqlResolvedConfig,\n): Span {\n const args = normalizeExecuteArgs(argsArray);\n const { schema, document } = args;\n let { contextValue, fieldResolver } = args;\n\n // Skip resolver wrapping when disabled or when a parent execute already set up this context\n // (nested execute reusing the same contextValue).\n const alreadyInstrumented = !!contextValue[GRAPHQL_DATA_SYMBOL];\n if (!config.ignoreResolveSpans && !alreadyInstrumented) {\n const isUsingDefaultResolver = fieldResolver == null;\n const defaultFieldResolver = (self as { defaultFieldResolver?: GraphQLFieldResolver } | undefined)\n ?.defaultFieldResolver;\n const fieldResolverForExecute = fieldResolver ?? defaultFieldResolver;\n if (fieldResolverForExecute) {\n fieldResolver = wrapFieldResolver(getConfig, fieldResolverForExecute, isUsingDefaultResolver);\n }\n\n if (schema) {\n wrapFields(schema.getQueryType(), getConfig);\n wrapFields(schema.getMutationType(), getConfig);\n }\n }\n\n // v14–16 channels carry only the raw args, so derive the operation from the document (native v17\n // provides `operationType`/`operationName` on the event directly).\n const operation = getOperation(document as DocumentNode, args.operationName);\n const operationType = operation?.operation;\n const operationName = operation?.name?.value ?? args.operationName ?? undefined;\n\n const span = startInactiveSpan({\n name: getOperationSpanName(operationType, operationName || undefined, SPAN_NAME_EXECUTE),\n attributes: {\n ...BASE_ATTRIBUTES,\n [GRAPHQL_OPERATION_TYPE]: operationType,\n [GRAPHQL_OPERATION_NAME]: operationName || undefined,\n [GRAPHQL_DOCUMENT]: collectGraphqlDocument(document as GraphqlDocumentNode | undefined),\n },\n });\n\n if (config.useOperationNameForRootSpan && operationType) {\n renameRootSpanWithOperation(span, operationType, operationName || undefined);\n }\n\n // The resolver proxies read the execute span (and their own bookkeeping) off this symbol.\n contextValue[GRAPHQL_DATA_SYMBOL] = { source: document, span, fields: {} };\n args.writeBack(contextValue, fieldResolver);\n\n return span;\n}\n\n/** `result` is the settled `ExecutionResult`; GraphQL errors surface on `result.errors`, not a throw. */\nexport function finalizeExecuteSpan(span: Span, result: unknown): void {\n if (hasResultErrors(result)) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","WEB_SERVER_GRAPHQL_SPAN_OP","startInactiveSpan","SPAN_NAME_PARSE","SPAN_NAME_VALIDATE","GRAPHQL_DOCUMENT","collectGraphqlDocument","SPAN_STATUS_ERROR","GRAPHQL_DATA_SYMBOL","wrapFieldResolver","wrapFields","getOperation","getOperationSpanName","SPAN_NAME_EXECUTE","GRAPHQL_OPERATION_TYPE","GRAPHQL_OPERATION_NAME","renameRootSpanWithOperation","hasResultErrors"],"mappings":";;;;;;;;;AAkCA,MAAM,eAAA,GAAkB;AAAA,EACtB,CAACA,qCAAgC,GAAGC,gBAAA;AAAA,EACpC,CAACC,iCAA4B,GAAGC;AAClC,C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CAAa,QAAA,EAA0B,IAAA,CAAK,aAAa,CAAA;AAC3E,EAAA,MAAM,gBAAgB,SAAA,EAAW,SAAA;AACjC,EAAA,MAAM,aAAA,GAAgB,SAAA,EAAW,IAAA,EAAM,KAAA,IAAS,KAAK,aAAA,IAAiB,MAAA;AAEtE,EAAA,MAAM,OAAOT,sBAAA,CAAkB;AAAA,IAC7B,IAAA,EAAMU,0BAAA,CAAqB,aAAA,EAAe,aAAA,IAAiB,QAAWC,2BAAiB,CAAA;AAAA,IACvF,UAAA,EAAY;AAAA,MACV,GAAG,eAAA;AAAA,MACH,CAACC,iCAAsB,GAAG,aAAA;AAAA,MAC1B,CAACC,iCAAsB,GAAG,aAAA,IAAiB,MAAA;AAAA,MAC3C,CAACV,2BAAgB,GAAGC,4BAAA,CAAuB,QAA2C;AAAA;AACxF,GACD,CAAA;AAED,EAAA,IAAI,MAAA,CAAO,+BAA+B,aAAA,EAAe;AACvD,IAAAU,iCAAA,CAA4B,IAAA,EAAM,aAAA,EAAe,aAAA,IAAiB,MAAS,CAAA;AAAA,EAC7E;AAGA,EAAA,YAAA,CAAaR,6BAAmB,IAAI,EAAE,MAAA,EAAQ,UAAU,IAAA,EAAM,MAAA,EAAQ,EAAC,EAAE;AACzE,EAAA,IAAA,CAAK,SAAA,CAAU,cAAc,aAAa,CAAA;AAE1C,EAAA,OAAO,IAAA;AACT;AAGO,SAAS,mBAAA,CAAoB,MAAY,MAAA,EAAuB;AACrE,EAAA,IAAIS,qBAAA,CAAgB,MAAM,CAAA,EAAG;AAC3B,IAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAMV,sBAAA,EAAmB,OAAA,EAAS,kBAAkB,CAAA;AAAA,EACvE;AACF;;;;;;;;"}
@@ -23,6 +23,24 @@ function connectionAttributes(host, port) {
23
23
  [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN
24
24
  };
25
25
  }
26
+ const tracedCommands = /* @__PURE__ */ new WeakSet();
27
+ function startIORedisCommandSpan(data) {
28
+ const command = data.arguments?.[0];
29
+ if (!command || typeof command !== "object") {
30
+ return void 0;
31
+ }
32
+ if (tracedCommands.has(command)) {
33
+ return void 0;
34
+ }
35
+ tracedCommands.add(command);
36
+ const { host, port } = getConnectionOptions(data.self);
37
+ const statement = redisStatementSerializer.defaultDbStatementSerializer(command.name, command.args ?? []);
38
+ return core.startInactiveSpan({
39
+ name: statement,
40
+ op: "db",
41
+ attributes: { ...connectionAttributes(host, port), [attributes.DB_STATEMENT]: statement }
42
+ });
43
+ }
26
44
  const _ioredisChannelIntegration = ((options = {}) => {
27
45
  const responseHook = options.responseHook;
28
46
  return {
@@ -39,47 +57,31 @@ const _ioredisChannelIntegration = ((options = {}) => {
39
57
  channels.CHANNELS.IOREDIS_CONNECT
40
58
  );
41
59
  core.waitForTracingChannelBinding(() => {
42
- tracingChannel.bindTracingChannelToSpan(
43
- commandChannel,
44
- (data) => {
45
- if (!core.getActiveSpan()) {
46
- return void 0;
60
+ tracingChannel.bindTracingChannelToSpan(commandChannel, startIORedisCommandSpan, {
61
+ // ioredis' `requireParentSpan` default: only create a span under an active span.
62
+ requiresParentSpan: true,
63
+ beforeSpanEnd(span, data) {
64
+ if ("error" in data || !responseHook) {
65
+ return;
47
66
  }
48
67
  const command = data.arguments?.[0];
49
- if (!command || typeof command !== "object") {
50
- return void 0;
68
+ if (command) {
69
+ runResponseHook(responseHook, span, command, data.result);
51
70
  }
71
+ }
72
+ });
73
+ tracingChannel.bindTracingChannelToSpan(
74
+ connectChannel,
75
+ (data) => {
52
76
  const { host, port } = getConnectionOptions(data.self);
53
- const statement = redisStatementSerializer.defaultDbStatementSerializer(command.name, command.args ?? []);
54
77
  return core.startInactiveSpan({
55
- name: statement,
78
+ name: "connect",
56
79
  op: "db",
57
- attributes: { ...connectionAttributes(host, port), [attributes.DB_STATEMENT]: statement }
80
+ attributes: { ...connectionAttributes(host, port), [attributes.DB_STATEMENT]: "connect" }
58
81
  });
59
82
  },
60
- {
61
- beforeSpanEnd(span, data) {
62
- if ("error" in data || !responseHook) {
63
- return;
64
- }
65
- const command = data.arguments?.[0];
66
- if (command) {
67
- runResponseHook(responseHook, span, command, data.result);
68
- }
69
- }
70
- }
83
+ { requiresParentSpan: true }
71
84
  );
72
- tracingChannel.bindTracingChannelToSpan(connectChannel, (data) => {
73
- if (!core.getActiveSpan()) {
74
- return void 0;
75
- }
76
- const { host, port } = getConnectionOptions(data.self);
77
- return core.startInactiveSpan({
78
- name: "connect",
79
- op: "db",
80
- attributes: { ...connectionAttributes(host, port), [attributes.DB_STATEMENT]: "connect" }
81
- });
82
- });
83
85
  });
84
86
  }
85
87
  };
@@ -93,4 +95,5 @@ function runResponseHook(hook, span, command, result) {
93
95
  const ioredisChannelIntegration = core.defineIntegration(_ioredisChannelIntegration);
94
96
 
95
97
  exports.ioredisChannelIntegration = ioredisChannelIntegration;
98
+ exports.startIORedisCommandSpan = startIORedisCommandSpan;
96
99
  //# sourceMappingURL=ioredis.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ioredis.js","sources":["../../../../src/integrations/tracing-channel/ioredis.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated -- we intentionally emit the OLD db/net semconv\n to match `@opentelemetry/instrumentation-ioredis` (and Sentry's `inferDbSpanData`, which keys off\n `db.statement`). TODO(v11): switch to the non-deprecated `db.system.name`/`db.query.text`/\n `server.address`/`server.port` conventions and drop this disable. */\nimport * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { DB_STATEMENT, DB_SYSTEM, NET_PEER_NAME, NET_PEER_PORT } from '@sentry/conventions/attributes';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { defaultDbStatementSerializer } from '../../redis/redis-statement-serializer';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Distinct from the OTel `Redis` integration, which is composite (node-redis +\n// ioredis + the >=5.11.0 diagnostics_channel subscriber) and stays in the set;\n// only its ioredis monkey-patch is gated off in the node SDK when this is active.\nconst INTEGRATION_NAME = 'IORedis' as const;\n\nconst ORIGIN = 'auto.db.orchestrion.redis';\n\n// todo(v11): Let's drop this as this is already covered with host and port\nconst ATTR_DB_CONNECTION_STRING = 'db.connection_string';\n\n/** Mirrors `@opentelemetry/instrumentation-ioredis`' response hook. Not called for failed commands. */\nexport type IORedisResponseHook = (span: Span, command: string, args: Array<string | Buffer>, result: unknown) => void;\n\nexport interface IORedisChannelIntegrationOptions {\n responseHook?: IORedisResponseHook;\n}\n\n/** Structural type for the command object ioredis passes to `sendCommand`. */\ninterface RedisCommand {\n name: string;\n args: Array<string | Buffer>;\n}\n\ninterface RedisClientLike {\n options?: { host?: string; port?: number };\n}\n\ninterface IORedisCommandContext {\n arguments?: unknown[];\n self?: RedisClientLike;\n result?: unknown;\n error?: unknown;\n}\n\ntype IORedisConnectContext = Omit<IORedisCommandContext, 'arguments'>;\n\nfunction getConnectionOptions(self: RedisClientLike | undefined): { host?: string; port?: number } {\n return { host: self?.options?.host, port: self?.options?.port };\n}\n\nfunction connectionAttributes(host: string | undefined, port: number | undefined): Record<string, unknown> {\n return {\n [DB_SYSTEM]: 'redis',\n [ATTR_DB_CONNECTION_STRING]: `redis://${host}:${port}`,\n [NET_PEER_NAME]: host,\n [NET_PEER_PORT]: port,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n}\n\nconst _ioredisChannelIntegration = ((options: IORedisChannelIntegrationOptions = {}) => {\n const responseHook = options.responseHook;\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19.\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(`[orchestrion:ioredis] subscribing to \"${CHANNELS.IOREDIS_COMMAND}\"/\"${CHANNELS.IOREDIS_CONNECT}\"`);\n\n const commandChannel = diagnosticsChannel.tracingChannel<IORedisCommandContext, IORedisCommandContext>(\n CHANNELS.IOREDIS_COMMAND,\n );\n const connectChannel = diagnosticsChannel.tracingChannel<IORedisConnectContext, IORedisConnectContext>(\n CHANNELS.IOREDIS_CONNECT,\n );\n\n // `bindTracingChannelToSpan` uses `bindStore`, which needs the async-context\n // binding that `initOpenTelemetry()` registers after integration `setupOnce` —\n // defer until it's available (matches the native redis diagnostics-channel subscriber).\n waitForTracingChannelBinding(() => {\n bindTracingChannelToSpan(\n commandChannel,\n data => {\n // ioredis' `requireParentSpan` default: only create a span under an active span.\n if (!getActiveSpan()) {\n return undefined;\n }\n const command = data.arguments?.[0] as RedisCommand | undefined;\n if (!command || typeof command !== 'object') {\n return undefined;\n }\n const { host, port } = getConnectionOptions(data.self);\n const statement = defaultDbStatementSerializer(command.name, command.args ?? []);\n return startInactiveSpan({\n name: statement,\n op: 'db',\n attributes: { ...connectionAttributes(host, port), [DB_STATEMENT]: statement },\n });\n },\n {\n beforeSpanEnd(span, data) {\n if ('error' in data || !responseHook) {\n return;\n }\n const command = data.arguments?.[0] as RedisCommand | undefined;\n if (command) {\n runResponseHook(responseHook, span, command, data.result);\n }\n },\n },\n );\n\n bindTracingChannelToSpan(connectChannel, data => {\n if (!getActiveSpan()) {\n return undefined;\n }\n const { host, port } = getConnectionOptions(data.self);\n return startInactiveSpan({\n name: 'connect',\n op: 'db',\n attributes: { ...connectionAttributes(host, port), [DB_STATEMENT]: 'connect' },\n });\n });\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction runResponseHook(hook: IORedisResponseHook, span: Span, command: RedisCommand, result: unknown): void {\n try {\n hook(span, command.name, command.args, result);\n } catch {\n // never let a user-provided response hook break instrumentation\n }\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven ioredis integration. Subscribes to\n * `orchestrion:ioredis:command` / `:connect` (injected into ioredis' `<5.11.0`\n * `sendCommand`/`connect`) and creates db spans matching\n * `@opentelemetry/instrumentation-ioredis`. Requires the orchestrion runtime hook\n * or bundler plugin.\n */\nexport const ioredisChannelIntegration = defineIntegration(_ioredisChannelIntegration);\n"],"names":["DB_SYSTEM","NET_PEER_NAME","NET_PEER_PORT","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","DEBUG_BUILD","debug","CHANNELS","waitForTracingChannelBinding","bindTracingChannelToSpan","getActiveSpan","defaultDbStatementSerializer","startInactiveSpan","DB_STATEMENT","defineIntegration"],"mappings":";;;;;;;;;;AAuBA,MAAM,gBAAA,GAAmB,SAAA;AAEzB,MAAM,MAAA,GAAS,2BAAA;AAGf,MAAM,yBAAA,GAA4B,sBAAA;AA4BlC,SAAS,qBAAqB,IAAA,EAAqE;AACjG,EAAA,OAAO,EAAE,MAAM,IAAA,EAAM,OAAA,EAAS,MAAM,IAAA,EAAM,IAAA,EAAM,SAAS,IAAA,EAAK;AAChE;AAEA,SAAS,oBAAA,CAAqB,MAA0B,IAAA,EAAmD;AACzG,EAAA,OAAO;AAAA,IACL,CAACA,oBAAS,GAAG,OAAA;AAAA,IACb,CAAC,yBAAyB,GAAG,CAAA,QAAA,EAAW,IAAI,IAAI,IAAI,CAAA,CAAA;AAAA,IACpD,CAACC,wBAAa,GAAG,IAAA;AAAA,IACjB,CAACC,wBAAa,GAAG,IAAA;AAAA,IACjB,CAACC,qCAAgC,GAAG;AAAA,GACtC;AACF;AAEA,MAAM,0BAAA,IAA8B,CAAC,OAAA,GAA4C,EAAC,KAAM;AACtF,EAAA,MAAM,eAAe,OAAA,CAAQ,YAAA;AAE7B,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAAC,mBAAmB,cAAA,EAAgB;AACtC,QAAA;AAAA,MACF;AAEA,MAAAC,sBAAA,IACEC,UAAA,CAAM,IAAI,CAAA,sCAAA,EAAyCC,iBA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EAAS;AACX,gBAAA,eAAA,CAAgB,YAAA,EAAc,IAAA,EAAM,OAAA,EAAS,IAAA,CAAK,MAAM,CAAA;AAAA,cAC1D;AAAA,YACF;AAAA;AACF,SACF;AAEA,QAAAJ,uCAAA,CAAyB,gBAAgB,CAAA,IAAA,KAAQ;AAC/C,UAAA,IAAI,CAACC,oBAAc,EAAG;AACpB,YAAA,OAAO,MAAA;AAAA,UACT;AACA,UAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAK,GAAI,oBAAA,CAAqB,KAAK,IAAI,CAAA;AACrD,UAAA,OAAOE,sBAAA,CAAkB;AAAA,YACvB,IAAA,EAAM,SAAA;AAAA,YACN,EAAA,EAAI,IAAA;AAAA,YACJ,UAAA,EAAY,EAAE,GAAG,oBAAA,CAAqB,IAAA,EAAM,IAAI,CAAA,EAAG,CAACC,uBAAY,GAAG,SAAA;AAAU,WAC9E,CAAA;AAAA,QACH,CAAC,CAAA;AAAA,MACH,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAEA,SAAS,eAAA,CAAgB,IAAA,EAA2B,IAAA,EAAY,OAAA,EAAuB,MAAA,EAAuB;AAC5G,EAAA,IAAI;AACF,IAAA,IAAA,CAAK,IAAA,EAAM,OAAA,CAAQ,IAAA,EAAM,OAAA,CAAQ,MAAM,MAAM,CAAA;AAAA,EAC/C,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AASO,MAAM,yBAAA,GAA4BC,uBAAkB,0BAA0B;;;;"}
1
+ {"version":3,"file":"ioredis.js","sources":["../../../../src/integrations/tracing-channel/ioredis.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated -- we intentionally emit the OLD db/net semconv\n to match `@opentelemetry/instrumentation-ioredis` (and Sentry's `inferDbSpanData`, which keys off\n `db.statement`). TODO(v11): switch to the non-deprecated `db.system.name`/`db.query.text`/\n `server.address`/`server.port` conventions and drop this disable. */\nimport * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { DB_STATEMENT, DB_SYSTEM, NET_PEER_NAME, NET_PEER_PORT } from '@sentry/conventions/attributes';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { defaultDbStatementSerializer } from '../../redis/redis-statement-serializer';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Distinct from the OTel `Redis` integration, which is composite (node-redis +\n// ioredis + the >=5.11.0 diagnostics_channel subscriber) and stays in the set;\n// only its ioredis monkey-patch is gated off in the node SDK when this is active.\nconst INTEGRATION_NAME = 'IORedis' as const;\n\nconst ORIGIN = 'auto.db.orchestrion.redis';\n\n// todo(v11): Let's drop this as this is already covered with host and port\nconst ATTR_DB_CONNECTION_STRING = 'db.connection_string';\n\n/** Mirrors `@opentelemetry/instrumentation-ioredis`' response hook. Not called for failed commands. */\nexport type IORedisResponseHook = (span: Span, command: string, args: Array<string | Buffer>, result: unknown) => void;\n\nexport interface IORedisChannelIntegrationOptions {\n responseHook?: IORedisResponseHook;\n}\n\n/** Structural type for the command object ioredis passes to `sendCommand`. */\ninterface RedisCommand {\n name: string;\n args: Array<string | Buffer>;\n}\n\ninterface RedisClientLike {\n options?: { host?: string; port?: number };\n}\n\ninterface IORedisCommandContext {\n arguments?: unknown[];\n self?: RedisClientLike;\n result?: unknown;\n error?: unknown;\n}\n\ntype IORedisConnectContext = Omit<IORedisCommandContext, 'arguments'>;\n\nfunction getConnectionOptions(self: RedisClientLike | undefined): { host?: string; port?: number } {\n return { host: self?.options?.host, port: self?.options?.port };\n}\n\nfunction connectionAttributes(host: string | undefined, port: number | undefined): Record<string, unknown> {\n return {\n [DB_SYSTEM]: 'redis',\n [ATTR_DB_CONNECTION_STRING]: `redis://${host}:${port}`,\n [NET_PEER_NAME]: host,\n [NET_PEER_PORT]: port,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n}\n\n// ioredis re-enters `sendCommand` with the same command object when it drains\n// the offline queue on connect which leads to duplicate spans.\n// Track commands we've already traced so each logical command produces one span.\nconst tracedCommands = new WeakSet<object>();\n\n/**\n * Builds the db span for an `orchestrion:ioredis:command` payload, or returns `undefined` to skip\n * it: for a non-command payload, or the offline-queue re-send of an already-traced command.\n *\n * Exported for unit testing.\n */\nexport function startIORedisCommandSpan(data: IORedisCommandContext): Span | undefined {\n const command = data.arguments?.[0] as RedisCommand | undefined;\n if (!command || typeof command !== 'object') {\n return undefined;\n }\n // guard against duplicate spans\n if (tracedCommands.has(command)) {\n return undefined;\n }\n tracedCommands.add(command);\n const { host, port } = getConnectionOptions(data.self);\n const statement = defaultDbStatementSerializer(command.name, command.args ?? []);\n return startInactiveSpan({\n name: statement,\n op: 'db',\n attributes: { ...connectionAttributes(host, port), [DB_STATEMENT]: statement },\n });\n}\n\nconst _ioredisChannelIntegration = ((options: IORedisChannelIntegrationOptions = {}) => {\n const responseHook = options.responseHook;\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19.\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(`[orchestrion:ioredis] subscribing to \"${CHANNELS.IOREDIS_COMMAND}\"/\"${CHANNELS.IOREDIS_CONNECT}\"`);\n\n const commandChannel = diagnosticsChannel.tracingChannel<IORedisCommandContext, IORedisCommandContext>(\n CHANNELS.IOREDIS_COMMAND,\n );\n const connectChannel = diagnosticsChannel.tracingChannel<IORedisConnectContext, IORedisConnectContext>(\n CHANNELS.IOREDIS_CONNECT,\n );\n\n // `bindTracingChannelToSpan` uses `bindStore`, which needs the async-context\n // binding that `initOpenTelemetry()` registers after integration `setupOnce` —\n // defer until it's available (matches the native redis diagnostics-channel subscriber).\n waitForTracingChannelBinding(() => {\n bindTracingChannelToSpan(commandChannel, startIORedisCommandSpan, {\n // ioredis' `requireParentSpan` default: only create a span under an active span.\n requiresParentSpan: true,\n beforeSpanEnd(span, data) {\n if ('error' in data || !responseHook) {\n return;\n }\n const command = data.arguments?.[0] as RedisCommand | undefined;\n if (command) {\n runResponseHook(responseHook, span, command, data.result);\n }\n },\n });\n\n bindTracingChannelToSpan(\n connectChannel,\n data => {\n const { host, port } = getConnectionOptions(data.self);\n return startInactiveSpan({\n name: 'connect',\n op: 'db',\n attributes: { ...connectionAttributes(host, port), [DB_STATEMENT]: 'connect' },\n });\n },\n { requiresParentSpan: true },\n );\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction runResponseHook(hook: IORedisResponseHook, span: Span, command: RedisCommand, result: unknown): void {\n try {\n hook(span, command.name, command.args, result);\n } catch {\n // never let a user-provided response hook break instrumentation\n }\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven ioredis integration. Subscribes to\n * `orchestrion:ioredis:command` / `:connect` (injected into ioredis' `<5.11.0`\n * `sendCommand`/`connect`) and creates db spans matching\n * `@opentelemetry/instrumentation-ioredis`. Requires the orchestrion runtime hook\n * or bundler plugin.\n */\nexport const ioredisChannelIntegration = defineIntegration(_ioredisChannelIntegration);\n"],"names":["DB_SYSTEM","NET_PEER_NAME","NET_PEER_PORT","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","defaultDbStatementSerializer","startInactiveSpan","DB_STATEMENT","DEBUG_BUILD","debug","CHANNELS","waitForTracingChannelBinding","bindTracingChannelToSpan","defineIntegration"],"mappings":";;;;;;;;;;AAsBA,MAAM,gBAAA,GAAmB,SAAA;AAEzB,MAAM,MAAA,GAAS,2BAAA;AAGf,MAAM,yBAAA,GAA4B,sBAAA;AA4BlC,SAAS,qBAAqB,IAAA,EAAqE;AACjG,EAAA,OAAO,EAAE,MAAM,IAAA,EAAM,OAAA,EAAS,MAAM,IAAA,EAAM,IAAA,EAAM,SAAS,IAAA,EAAK;AAChE;AAEA,SAAS,o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