@sentry/server-utils 10.63.0 → 10.65.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 (398) hide show
  1. package/build/cjs/graphql/graphql-dc-subscriber.js +125 -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 +86 -0
  6. package/build/cjs/graphql/utils.js.map +1 -0
  7. package/build/cjs/index.js +12 -9
  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/anthropic.js +101 -0
  12. package/build/cjs/integrations/tracing-channel/anthropic.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/google-genai.js +96 -0
  22. package/build/cjs/integrations/tracing-channel/google-genai.js.map +1 -0
  23. package/build/cjs/integrations/tracing-channel/graphql/constants.js +26 -0
  24. package/build/cjs/integrations/tracing-channel/graphql/constants.js.map +1 -0
  25. package/build/cjs/integrations/tracing-channel/graphql/index.js +66 -0
  26. package/build/cjs/integrations/tracing-channel/graphql/index.js.map +1 -0
  27. package/build/cjs/integrations/tracing-channel/graphql/resolvers.js +168 -0
  28. package/build/cjs/integrations/tracing-channel/graphql/resolvers.js.map +1 -0
  29. package/build/cjs/integrations/tracing-channel/graphql/spans.js +102 -0
  30. package/build/cjs/integrations/tracing-channel/graphql/spans.js.map +1 -0
  31. package/build/cjs/integrations/tracing-channel/hapi-types.js +30 -0
  32. package/build/cjs/integrations/tracing-channel/hapi-types.js.map +1 -0
  33. package/build/cjs/integrations/tracing-channel/hapi-utils.js +177 -0
  34. package/build/cjs/integrations/tracing-channel/hapi-utils.js.map +1 -0
  35. package/build/cjs/integrations/tracing-channel/hapi.js +52 -0
  36. package/build/cjs/integrations/tracing-channel/hapi.js.map +1 -0
  37. package/build/cjs/integrations/tracing-channel/ioredis.js +96 -0
  38. package/build/cjs/integrations/tracing-channel/ioredis.js.map +1 -0
  39. package/build/cjs/integrations/tracing-channel/mysql.js +2 -1
  40. package/build/cjs/integrations/tracing-channel/mysql.js.map +1 -1
  41. package/build/cjs/integrations/tracing-channel/openai.js +83 -0
  42. package/build/cjs/integrations/tracing-channel/openai.js.map +1 -0
  43. package/build/cjs/integrations/tracing-channel/postgres-js.js +191 -0
  44. package/build/cjs/integrations/tracing-channel/postgres-js.js.map +1 -0
  45. package/build/cjs/integrations/tracing-channel/postgres.js +170 -0
  46. package/build/cjs/integrations/tracing-channel/postgres.js.map +1 -0
  47. package/build/cjs/integrations/tracing-channel/redis.js +227 -0
  48. package/build/cjs/integrations/tracing-channel/redis.js.map +1 -0
  49. package/build/cjs/integrations/tracing-channel/vercel-ai.js +25 -0
  50. package/build/cjs/integrations/tracing-channel/vercel-ai.js.map +1 -0
  51. package/build/cjs/mongoose/index.js +23 -0
  52. package/build/cjs/mongoose/index.js.map +1 -0
  53. package/build/cjs/mongoose/mongoose-dc-subscriber.js +97 -0
  54. package/build/cjs/mongoose/mongoose-dc-subscriber.js.map +1 -0
  55. package/build/cjs/mysql2/index.js +23 -0
  56. package/build/cjs/mysql2/index.js.map +1 -0
  57. package/build/cjs/mysql2/mysql2-dc-subscriber.js +68 -0
  58. package/build/cjs/mysql2/mysql2-dc-subscriber.js.map +1 -0
  59. package/build/cjs/orchestrion/bundler/vite.js +3 -3
  60. package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
  61. package/build/cjs/orchestrion/channels.js +29 -2
  62. package/build/cjs/orchestrion/channels.js.map +1 -1
  63. package/build/cjs/orchestrion/config/amqplib.js +81 -0
  64. package/build/cjs/orchestrion/config/amqplib.js.map +1 -0
  65. package/build/cjs/orchestrion/config/anthropic-ai.js +43 -0
  66. package/build/cjs/orchestrion/config/anthropic-ai.js.map +1 -0
  67. package/build/cjs/orchestrion/config/express.js +76 -0
  68. package/build/cjs/orchestrion/config/express.js.map +1 -0
  69. package/build/cjs/orchestrion/config/google-genai.js +38 -0
  70. package/build/cjs/orchestrion/config/google-genai.js.map +1 -0
  71. package/build/cjs/orchestrion/config/graphql.js +28 -0
  72. package/build/cjs/orchestrion/config/graphql.js.map +1 -0
  73. package/build/cjs/orchestrion/config/hapi.js +26 -0
  74. package/build/cjs/orchestrion/config/hapi.js.map +1 -0
  75. package/build/cjs/orchestrion/config/index.js +48 -0
  76. package/build/cjs/orchestrion/config/index.js.map +1 -0
  77. package/build/cjs/orchestrion/config/ioredis.js +35 -0
  78. package/build/cjs/orchestrion/config/ioredis.js.map +1 -0
  79. package/build/cjs/orchestrion/config/lru-memoizer.js +17 -0
  80. package/build/cjs/orchestrion/config/lru-memoizer.js.map +1 -0
  81. package/build/cjs/orchestrion/config/mysql.js +16 -0
  82. package/build/cjs/orchestrion/config/mysql.js.map +1 -0
  83. package/build/cjs/orchestrion/config/openai.js +40 -0
  84. package/build/cjs/orchestrion/config/openai.js.map +1 -0
  85. package/build/cjs/orchestrion/config/pg.js +51 -0
  86. package/build/cjs/orchestrion/config/pg.js.map +1 -0
  87. package/build/cjs/orchestrion/config/postgres.js +50 -0
  88. package/build/cjs/orchestrion/config/postgres.js.map +1 -0
  89. package/build/cjs/orchestrion/config/redis.js +76 -0
  90. package/build/cjs/orchestrion/config/redis.js.map +1 -0
  91. package/build/cjs/orchestrion/config/vercel-ai.js +48 -0
  92. package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -0
  93. package/build/cjs/orchestrion/detect.js +6 -1
  94. package/build/cjs/orchestrion/detect.js.map +1 -1
  95. package/build/cjs/orchestrion/index.js +44 -5
  96. package/build/cjs/orchestrion/index.js.map +1 -1
  97. package/build/cjs/orchestrion/runtime/register.js +10 -7
  98. package/build/cjs/orchestrion/runtime/register.js.map +1 -1
  99. package/build/cjs/redis/index.js +23 -0
  100. package/build/cjs/redis/index.js.map +1 -0
  101. package/build/cjs/redis/redis-dc-subscriber.js +23 -35
  102. package/build/cjs/redis/redis-dc-subscriber.js.map +1 -1
  103. package/build/cjs/redis/redis-statement-serializer.js +34 -0
  104. package/build/cjs/redis/redis-statement-serializer.js.map +1 -0
  105. package/build/cjs/tracing-channel.js +8 -7
  106. package/build/cjs/tracing-channel.js.map +1 -1
  107. package/build/cjs/vercel-ai/util.js +123 -0
  108. package/build/cjs/vercel-ai/util.js.map +1 -0
  109. package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js +147 -76
  110. package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  111. package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js +386 -0
  112. package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -0
  113. package/build/esm/graphql/graphql-dc-subscriber.js +118 -0
  114. package/build/esm/graphql/graphql-dc-subscriber.js.map +1 -0
  115. package/build/esm/graphql/index.js +21 -0
  116. package/build/esm/graphql/index.js.map +1 -0
  117. package/build/esm/graphql/utils.js +81 -0
  118. package/build/esm/graphql/utils.js.map +1 -0
  119. package/build/esm/index.js +5 -1
  120. package/build/esm/index.js.map +1 -1
  121. package/build/esm/integrations/tracing-channel/amqplib.js +418 -0
  122. package/build/esm/integrations/tracing-channel/amqplib.js.map +1 -0
  123. package/build/esm/integrations/tracing-channel/anthropic.js +99 -0
  124. package/build/esm/integrations/tracing-channel/anthropic.js.map +1 -0
  125. package/build/esm/integrations/tracing-channel/express/index.js +22 -0
  126. package/build/esm/integrations/tracing-channel/express/index.js.map +1 -0
  127. package/build/esm/integrations/tracing-channel/express/instrumentation.js +171 -0
  128. package/build/esm/integrations/tracing-channel/express/instrumentation.js.map +1 -0
  129. package/build/esm/integrations/tracing-channel/express/route.js +68 -0
  130. package/build/esm/integrations/tracing-channel/express/route.js.map +1 -0
  131. package/build/esm/integrations/tracing-channel/fastify/instrumentation.js +2 -2
  132. package/build/esm/integrations/tracing-channel/fastify/instrumentation.js.map +1 -1
  133. package/build/esm/integrations/tracing-channel/google-genai.js +94 -0
  134. package/build/esm/integrations/tracing-channel/google-genai.js.map +1 -0
  135. package/build/esm/integrations/tracing-channel/graphql/constants.js +14 -0
  136. package/build/esm/integrations/tracing-channel/graphql/constants.js.map +1 -0
  137. package/build/esm/integrations/tracing-channel/graphql/index.js +63 -0
  138. package/build/esm/integrations/tracing-channel/graphql/index.js.map +1 -0
  139. package/build/esm/integrations/tracing-channel/graphql/resolvers.js +164 -0
  140. package/build/esm/integrations/tracing-channel/graphql/resolvers.js.map +1 -0
  141. package/build/esm/integrations/tracing-channel/graphql/spans.js +96 -0
  142. package/build/esm/integrations/tracing-channel/graphql/spans.js.map +1 -0
  143. package/build/esm/integrations/tracing-channel/hapi-types.js +25 -0
  144. package/build/esm/integrations/tracing-channel/hapi-types.js.map +1 -0
  145. package/build/esm/integrations/tracing-channel/hapi-utils.js +172 -0
  146. package/build/esm/integrations/tracing-channel/hapi-utils.js.map +1 -0
  147. package/build/esm/integrations/tracing-channel/hapi.js +50 -0
  148. package/build/esm/integrations/tracing-channel/hapi.js.map +1 -0
  149. package/build/esm/integrations/tracing-channel/ioredis.js +94 -0
  150. package/build/esm/integrations/tracing-channel/ioredis.js.map +1 -0
  151. package/build/esm/integrations/tracing-channel/mysql.js +3 -2
  152. package/build/esm/integrations/tracing-channel/mysql.js.map +1 -1
  153. package/build/esm/integrations/tracing-channel/openai.js +81 -0
  154. package/build/esm/integrations/tracing-channel/openai.js.map +1 -0
  155. package/build/esm/integrations/tracing-channel/postgres-js.js +189 -0
  156. package/build/esm/integrations/tracing-channel/postgres-js.js.map +1 -0
  157. package/build/esm/integrations/tracing-channel/postgres.js +168 -0
  158. package/build/esm/integrations/tracing-channel/postgres.js.map +1 -0
  159. package/build/esm/integrations/tracing-channel/redis.js +225 -0
  160. package/build/esm/integrations/tracing-channel/redis.js.map +1 -0
  161. package/build/esm/integrations/tracing-channel/vercel-ai.js +23 -0
  162. package/build/esm/integrations/tracing-channel/vercel-ai.js.map +1 -0
  163. package/build/esm/mongoose/index.js +21 -0
  164. package/build/esm/mongoose/index.js.map +1 -0
  165. package/build/esm/mongoose/mongoose-dc-subscriber.js +89 -0
  166. package/build/esm/mongoose/mongoose-dc-subscriber.js.map +1 -0
  167. package/build/esm/mysql2/index.js +21 -0
  168. package/build/esm/mysql2/index.js.map +1 -0
  169. package/build/esm/mysql2/mysql2-dc-subscriber.js +62 -0
  170. package/build/esm/mysql2/mysql2-dc-subscriber.js.map +1 -0
  171. package/build/esm/orchestrion/bundler/vite.js +1 -1
  172. package/build/esm/orchestrion/channels.js +29 -2
  173. package/build/esm/orchestrion/channels.js.map +1 -1
  174. package/build/esm/orchestrion/config/amqplib.js +78 -0
  175. package/build/esm/orchestrion/config/amqplib.js.map +1 -0
  176. package/build/esm/orchestrion/config/anthropic-ai.js +40 -0
  177. package/build/esm/orchestrion/config/anthropic-ai.js.map +1 -0
  178. package/build/esm/orchestrion/config/express.js +73 -0
  179. package/build/esm/orchestrion/config/express.js.map +1 -0
  180. package/build/esm/orchestrion/config/google-genai.js +35 -0
  181. package/build/esm/orchestrion/config/google-genai.js.map +1 -0
  182. package/build/esm/orchestrion/config/graphql.js +25 -0
  183. package/build/esm/orchestrion/config/graphql.js.map +1 -0
  184. package/build/esm/orchestrion/config/hapi.js +23 -0
  185. package/build/esm/orchestrion/config/hapi.js.map +1 -0
  186. package/build/esm/orchestrion/config/index.js +44 -0
  187. package/build/esm/orchestrion/config/index.js.map +1 -0
  188. package/build/esm/orchestrion/config/ioredis.js +32 -0
  189. package/build/esm/orchestrion/config/ioredis.js.map +1 -0
  190. package/build/esm/orchestrion/config/lru-memoizer.js +14 -0
  191. package/build/esm/orchestrion/config/lru-memoizer.js.map +1 -0
  192. package/build/esm/orchestrion/config/mysql.js +13 -0
  193. package/build/esm/orchestrion/config/mysql.js.map +1 -0
  194. package/build/esm/orchestrion/config/openai.js +37 -0
  195. package/build/esm/orchestrion/config/openai.js.map +1 -0
  196. package/build/esm/orchestrion/config/pg.js +48 -0
  197. package/build/esm/orchestrion/config/pg.js.map +1 -0
  198. package/build/esm/orchestrion/config/postgres.js +47 -0
  199. package/build/esm/orchestrion/config/postgres.js.map +1 -0
  200. package/build/esm/orchestrion/config/redis.js +73 -0
  201. package/build/esm/orchestrion/config/redis.js.map +1 -0
  202. package/build/esm/orchestrion/config/vercel-ai.js +45 -0
  203. package/build/esm/orchestrion/config/vercel-ai.js.map +1 -0
  204. package/build/esm/orchestrion/detect.js +6 -2
  205. package/build/esm/orchestrion/detect.js.map +1 -1
  206. package/build/esm/orchestrion/index.js +33 -3
  207. package/build/esm/orchestrion/index.js.map +1 -1
  208. package/build/esm/orchestrion/runtime/register.js +8 -4
  209. package/build/esm/orchestrion/runtime/register.js.map +1 -1
  210. package/build/esm/package.json +1 -1
  211. package/build/esm/redis/index.js +21 -0
  212. package/build/esm/redis/index.js.map +1 -0
  213. package/build/esm/redis/redis-dc-subscriber.js +24 -36
  214. package/build/esm/redis/redis-dc-subscriber.js.map +1 -1
  215. package/build/esm/redis/redis-statement-serializer.js +32 -0
  216. package/build/esm/redis/redis-statement-serializer.js.map +1 -0
  217. package/build/esm/tracing-channel.js +9 -8
  218. package/build/esm/tracing-channel.js.map +1 -1
  219. package/build/esm/vercel-ai/util.js +116 -0
  220. package/build/esm/vercel-ai/util.js.map +1 -0
  221. package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js +122 -54
  222. package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  223. package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js +384 -0
  224. package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -0
  225. package/build/types/graphql/graphql-dc-subscriber.d.ts +94 -0
  226. package/build/types/graphql/graphql-dc-subscriber.d.ts.map +1 -0
  227. package/build/types/graphql/index.d.ts +12 -0
  228. package/build/types/graphql/index.d.ts.map +1 -0
  229. package/build/types/graphql/utils.d.ts +40 -0
  230. package/build/types/graphql/utils.d.ts.map +1 -0
  231. package/build/types/index.d.ts +6 -2
  232. package/build/types/index.d.ts.map +1 -1
  233. package/build/types/integrations/tracing-channel/amqplib.d.ts +11 -0
  234. package/build/types/integrations/tracing-channel/amqplib.d.ts.map +1 -0
  235. package/build/types/integrations/tracing-channel/anthropic.d.ts +10 -0
  236. package/build/types/integrations/tracing-channel/anthropic.d.ts.map +1 -0
  237. package/build/types/integrations/tracing-channel/express/index.d.ts +18 -0
  238. package/build/types/integrations/tracing-channel/express/index.d.ts.map +1 -0
  239. package/build/types/integrations/tracing-channel/express/instrumentation.d.ts +4 -0
  240. package/build/types/integrations/tracing-channel/express/instrumentation.d.ts.map +1 -0
  241. package/build/types/integrations/tracing-channel/express/route.d.ts +28 -0
  242. package/build/types/integrations/tracing-channel/express/route.d.ts.map +1 -0
  243. package/build/types/integrations/tracing-channel/express/types.d.ts +64 -0
  244. package/build/types/integrations/tracing-channel/express/types.d.ts.map +1 -0
  245. package/build/types/integrations/tracing-channel/fastify/instrumentation.d.ts.map +1 -1
  246. package/build/types/integrations/tracing-channel/google-genai.d.ts +12 -0
  247. package/build/types/integrations/tracing-channel/google-genai.d.ts.map +1 -0
  248. package/build/types/integrations/tracing-channel/graphql/constants.d.ts +12 -0
  249. package/build/types/integrations/tracing-channel/graphql/constants.d.ts.map +1 -0
  250. package/build/types/integrations/tracing-channel/graphql/graphql-types.d.ts +135 -0
  251. package/build/types/integrations/tracing-channel/graphql/graphql-types.d.ts.map +1 -0
  252. package/build/types/integrations/tracing-channel/graphql/index.d.ts +28 -0
  253. package/build/types/integrations/tracing-channel/graphql/index.d.ts.map +1 -0
  254. package/build/types/integrations/tracing-channel/graphql/resolvers.d.ts +13 -0
  255. package/build/types/integrations/tracing-channel/graphql/resolvers.d.ts.map +1 -0
  256. package/build/types/integrations/tracing-channel/graphql/spans.d.ts +17 -0
  257. package/build/types/integrations/tracing-channel/graphql/spans.d.ts.map +1 -0
  258. package/build/types/integrations/tracing-channel/graphql/types.d.ts +25 -0
  259. package/build/types/integrations/tracing-channel/graphql/types.d.ts.map +1 -0
  260. package/build/types/integrations/tracing-channel/hapi-types.d.ts +53 -0
  261. package/build/types/integrations/tracing-channel/hapi-types.d.ts.map +1 -0
  262. package/build/types/integrations/tracing-channel/hapi-utils.d.ts +25 -0
  263. package/build/types/integrations/tracing-channel/hapi-utils.d.ts.map +1 -0
  264. package/build/types/integrations/tracing-channel/hapi.d.ts +9 -0
  265. package/build/types/integrations/tracing-channel/hapi.d.ts.map +1 -0
  266. package/build/types/integrations/tracing-channel/ioredis.d.ts +17 -0
  267. package/build/types/integrations/tracing-channel/ioredis.d.ts.map +1 -0
  268. package/build/types/integrations/tracing-channel/mysql.d.ts.map +1 -1
  269. package/build/types/integrations/tracing-channel/openai.d.ts +10 -0
  270. package/build/types/integrations/tracing-channel/openai.d.ts.map +1 -0
  271. package/build/types/integrations/tracing-channel/postgres-js.d.ts +26 -0
  272. package/build/types/integrations/tracing-channel/postgres-js.d.ts.map +1 -0
  273. package/build/types/integrations/tracing-channel/postgres.d.ts +15 -0
  274. package/build/types/integrations/tracing-channel/postgres.d.ts.map +1 -0
  275. package/build/types/integrations/tracing-channel/redis.d.ts +16 -0
  276. package/build/types/integrations/tracing-channel/redis.d.ts.map +1 -0
  277. package/build/types/integrations/tracing-channel/vercel-ai.d.ts +13 -0
  278. package/build/types/integrations/tracing-channel/vercel-ai.d.ts.map +1 -0
  279. package/build/types/mongoose/index.d.ts +11 -0
  280. package/build/types/mongoose/index.d.ts.map +1 -0
  281. package/build/types/mongoose/mongoose-dc-subscriber.d.ts +63 -0
  282. package/build/types/mongoose/mongoose-dc-subscriber.d.ts.map +1 -0
  283. package/build/types/mysql2/index.d.ts +11 -0
  284. package/build/types/mysql2/index.d.ts.map +1 -0
  285. package/build/types/mysql2/mysql2-dc-subscriber.d.ts +59 -0
  286. package/build/types/mysql2/mysql2-dc-subscriber.d.ts.map +1 -0
  287. package/build/types/orchestrion/channels.d.ts +55 -1
  288. package/build/types/orchestrion/channels.d.ts.map +1 -1
  289. package/build/types/orchestrion/config/amqplib.d.ts +66 -0
  290. package/build/types/orchestrion/config/amqplib.d.ts.map +1 -0
  291. package/build/types/orchestrion/config/anthropic-ai.d.ts +31 -0
  292. package/build/types/orchestrion/config/anthropic-ai.d.ts.map +1 -0
  293. package/build/types/orchestrion/config/express.d.ts +32 -0
  294. package/build/types/orchestrion/config/express.d.ts.map +1 -0
  295. package/build/types/orchestrion/config/google-genai.d.ts +30 -0
  296. package/build/types/orchestrion/config/google-genai.d.ts.map +1 -0
  297. package/build/types/orchestrion/config/graphql.d.ts +29 -0
  298. package/build/types/orchestrion/config/graphql.d.ts.map +1 -0
  299. package/build/types/orchestrion/config/hapi.d.ts +17 -0
  300. package/build/types/orchestrion/config/hapi.d.ts.map +1 -0
  301. package/build/types/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
  302. package/build/types/orchestrion/config/index.d.ts.map +1 -0
  303. package/build/types/orchestrion/config/ioredis.d.ts +7 -0
  304. package/build/types/orchestrion/config/ioredis.d.ts.map +1 -0
  305. package/build/types/orchestrion/config/lru-memoizer.d.ts +16 -0
  306. package/build/types/orchestrion/config/lru-memoizer.d.ts.map +1 -0
  307. package/build/types/orchestrion/config/mysql.d.ts +16 -0
  308. package/build/types/orchestrion/config/mysql.d.ts.map +1 -0
  309. package/build/types/orchestrion/config/openai.d.ts +20 -0
  310. package/build/types/orchestrion/config/openai.d.ts.map +1 -0
  311. package/build/types/orchestrion/config/pg.d.ts +33 -0
  312. package/build/types/orchestrion/config/pg.d.ts.map +1 -0
  313. package/build/types/orchestrion/config/postgres.d.ts +9 -0
  314. package/build/types/orchestrion/config/postgres.d.ts.map +1 -0
  315. package/build/types/orchestrion/config/redis.d.ts +37 -0
  316. package/build/types/orchestrion/config/redis.d.ts.map +1 -0
  317. package/build/types/orchestrion/config/vercel-ai.d.ts +12 -0
  318. package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -0
  319. package/build/types/orchestrion/detect.d.ts +10 -0
  320. package/build/types/orchestrion/detect.d.ts.map +1 -1
  321. package/build/types/orchestrion/index.d.ts +80 -3
  322. package/build/types/orchestrion/index.d.ts.map +1 -1
  323. package/build/types/orchestrion/runtime/register.d.ts.map +1 -1
  324. package/build/types/redis/index.d.ts +18 -0
  325. package/build/types/redis/index.d.ts.map +1 -0
  326. package/build/types/redis/redis-dc-subscriber.d.ts +0 -5
  327. package/build/types/redis/redis-dc-subscriber.d.ts.map +1 -1
  328. package/build/types/redis/redis-statement-serializer.d.ts +6 -0
  329. package/build/types/redis/redis-statement-serializer.d.ts.map +1 -0
  330. package/build/types/tracing-channel.d.ts +5 -0
  331. package/build/types/tracing-channel.d.ts.map +1 -1
  332. package/build/types/vercel-ai/util.d.ts +32 -0
  333. package/build/types/vercel-ai/util.d.ts.map +1 -0
  334. package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts +15 -5
  335. package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
  336. package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts +12 -0
  337. package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts.map +1 -0
  338. package/build/types-ts3.8/graphql/graphql-dc-subscriber.d.ts +94 -0
  339. package/build/types-ts3.8/graphql/index.d.ts +12 -0
  340. package/build/types-ts3.8/graphql/utils.d.ts +40 -0
  341. package/build/types-ts3.8/index.d.ts +6 -2
  342. package/build/types-ts3.8/integrations/tracing-channel/amqplib.d.ts +11 -0
  343. package/build/types-ts3.8/integrations/tracing-channel/anthropic.d.ts +10 -0
  344. package/build/types-ts3.8/integrations/tracing-channel/express/index.d.ts +18 -0
  345. package/build/types-ts3.8/integrations/tracing-channel/express/instrumentation.d.ts +4 -0
  346. package/build/types-ts3.8/integrations/tracing-channel/express/route.d.ts +28 -0
  347. package/build/types-ts3.8/integrations/tracing-channel/express/types.d.ts +64 -0
  348. package/build/types-ts3.8/integrations/tracing-channel/google-genai.d.ts +12 -0
  349. package/build/types-ts3.8/integrations/tracing-channel/graphql/constants.d.ts +12 -0
  350. package/build/types-ts3.8/integrations/tracing-channel/graphql/graphql-types.d.ts +135 -0
  351. package/build/types-ts3.8/integrations/tracing-channel/graphql/index.d.ts +30 -0
  352. package/build/types-ts3.8/integrations/tracing-channel/graphql/resolvers.d.ts +13 -0
  353. package/build/types-ts3.8/integrations/tracing-channel/graphql/spans.d.ts +17 -0
  354. package/build/types-ts3.8/integrations/tracing-channel/graphql/types.d.ts +25 -0
  355. package/build/types-ts3.8/integrations/tracing-channel/hapi-types.d.ts +65 -0
  356. package/build/types-ts3.8/integrations/tracing-channel/hapi-utils.d.ts +25 -0
  357. package/build/types-ts3.8/integrations/tracing-channel/hapi.d.ts +9 -0
  358. package/build/types-ts3.8/integrations/tracing-channel/ioredis.d.ts +17 -0
  359. package/build/types-ts3.8/integrations/tracing-channel/openai.d.ts +10 -0
  360. package/build/types-ts3.8/integrations/tracing-channel/postgres-js.d.ts +26 -0
  361. package/build/types-ts3.8/integrations/tracing-channel/postgres.d.ts +15 -0
  362. package/build/types-ts3.8/integrations/tracing-channel/redis.d.ts +16 -0
  363. package/build/types-ts3.8/integrations/tracing-channel/vercel-ai.d.ts +13 -0
  364. package/build/types-ts3.8/mongoose/index.d.ts +11 -0
  365. package/build/types-ts3.8/mongoose/mongoose-dc-subscriber.d.ts +63 -0
  366. package/build/types-ts3.8/mysql2/index.d.ts +11 -0
  367. package/build/types-ts3.8/mysql2/mysql2-dc-subscriber.d.ts +59 -0
  368. package/build/types-ts3.8/orchestrion/channels.d.ts +55 -1
  369. package/build/types-ts3.8/orchestrion/config/amqplib.d.ts +66 -0
  370. package/build/types-ts3.8/orchestrion/config/anthropic-ai.d.ts +31 -0
  371. package/build/types-ts3.8/orchestrion/config/express.d.ts +32 -0
  372. package/build/types-ts3.8/orchestrion/config/google-genai.d.ts +30 -0
  373. package/build/types-ts3.8/orchestrion/config/graphql.d.ts +29 -0
  374. package/build/types-ts3.8/orchestrion/config/hapi.d.ts +17 -0
  375. package/build/types-ts3.8/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
  376. package/build/types-ts3.8/orchestrion/config/ioredis.d.ts +7 -0
  377. package/build/types-ts3.8/orchestrion/config/lru-memoizer.d.ts +16 -0
  378. package/build/types-ts3.8/orchestrion/config/mysql.d.ts +16 -0
  379. package/build/types-ts3.8/orchestrion/config/openai.d.ts +20 -0
  380. package/build/types-ts3.8/orchestrion/config/pg.d.ts +33 -0
  381. package/build/types-ts3.8/orchestrion/config/postgres.d.ts +9 -0
  382. package/build/types-ts3.8/orchestrion/config/redis.d.ts +37 -0
  383. package/build/types-ts3.8/orchestrion/config/vercel-ai.d.ts +12 -0
  384. package/build/types-ts3.8/orchestrion/detect.d.ts +10 -0
  385. package/build/types-ts3.8/orchestrion/index.d.ts +82 -3
  386. package/build/types-ts3.8/redis/index.d.ts +18 -0
  387. package/build/types-ts3.8/redis/redis-dc-subscriber.d.ts +0 -5
  388. package/build/types-ts3.8/redis/redis-statement-serializer.d.ts +6 -0
  389. package/build/types-ts3.8/tracing-channel.d.ts +5 -0
  390. package/build/types-ts3.8/vercel-ai/util.d.ts +32 -0
  391. package/build/types-ts3.8/vercel-ai/vercel-ai-dc-subscriber.d.ts +15 -5
  392. package/build/types-ts3.8/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts +12 -0
  393. package/package.json +9 -9
  394. package/build/cjs/orchestrion/config.js +0 -44
  395. package/build/cjs/orchestrion/config.js.map +0 -1
  396. package/build/esm/orchestrion/config.js +0 -40
  397. package/build/esm/orchestrion/config.js.map +0 -1
  398. package/build/types/orchestrion/config.d.ts.map +0 -1
@@ -3,13 +3,17 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const core = require('@sentry/core');
4
4
  const debugBuild = require('../debug-build.js');
5
5
 
6
+ function isOrchestrionInjected() {
7
+ const marker = globalThis.__SENTRY_ORCHESTRION__;
8
+ return !!(marker?.runtime || marker?.bundler);
9
+ }
6
10
  function detectOrchestrionSetup() {
7
11
  if (!debugBuild.DEBUG_BUILD) return;
8
12
  const marker = globalThis.__SENTRY_ORCHESTRION__;
9
13
  const runtime = !!marker?.runtime;
10
14
  const bundler = !!marker?.bundler;
11
15
  debugBuild.DEBUG_BUILD && core.debug.log(`[orchestrion] detect: runtime=${runtime} bundler=${bundler}`);
12
- if (!runtime && !bundler) {
16
+ if (!isOrchestrionInjected()) {
13
17
  debugBuild.DEBUG_BUILD && core.debug.warn(
14
18
  "[Sentry] No diagnostics-channel injection detected. Channel-based integrations (mysql, \u2026) will not record spans. Make sure the diagnostics channels are injected via the runtime `--import` hook or a bundler plugin before the instrumented modules load."
15
19
  );
@@ -17,4 +21,5 @@ function detectOrchestrionSetup() {
17
21
  }
18
22
 
19
23
  exports.detectOrchestrionSetup = detectOrchestrionSetup;
24
+ exports.isOrchestrionInjected = isOrchestrionInjected;
20
25
  //# sourceMappingURL=detect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"detect.js","sources":["../../../src/orchestrion/detect.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __SENTRY_ORCHESTRION__: { runtime?: boolean; bundler?: boolean } | undefined;\n}\n\n/**\n * Verifies that the diagnostics channels have been injected either by the\n * runtime `--import` hook (or init-time registration), a bundler plugin, or\n * both, and warns if not.\n *\n * Both injectors being active at once is fine: they operate on disjoint module\n * sets (a module is either loaded through Node's loader and transformed by the\n * runtime hook, or inlined by the bundler and transformed by the plugin), so\n * a single module can't be double-wrapped. A hybrid setup, with some deps\n * external and runtime-instrumented, others bundled and plugin-instrumented,\n * is fine.\n *\n * Note: intentionally does NOT warn in production, only in debug builds,\n * because production warnings are reserved for truly critical issues.\n */\nexport function detectOrchestrionSetup(): void {\n if (!DEBUG_BUILD) return;\n\n const marker = globalThis.__SENTRY_ORCHESTRION__;\n const runtime = !!marker?.runtime;\n const bundler = !!marker?.bundler;\n\n DEBUG_BUILD && debug.log(`[orchestrion] detect: runtime=${runtime} bundler=${bundler}`);\n\n if (!runtime && !bundler) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] No diagnostics-channel injection detected. Channel-based integrations ' +\n '(mysql, …) will not record spans. Make sure the diagnostics channels are injected ' +\n 'via the runtime `--import` hook or a bundler plugin before the instrumented modules load.',\n );\n }\n}\n"],"names":["DEBUG_BUILD","debug"],"mappings":";;;;;AAuBO,SAAS,sBAAA,GAA+B;AAC7C,EAAA,IAAI,CAACA,sBAAA,EAAa;AAElB,EAAA,MAAM,SAAS,UAAA,CAAW,sBAAA;AAC1B,EAAA,MAAM,OAAA,GAAU,CAAC,CAAC,MAAA,EAAQ,OAAA;AAC1B,EAAA,MAAM,OAAA,GAAU,CAAC,CAAC,MAAA,EAAQ,OAAA;AAE1B,EAAAA,sBAAA,IAAeC,WAAM,GAAA,CAAI,CAAA,8BAAA,EAAiC,OAAO,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,CAAA;AAEtF,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,OAAA,EAAS;AACxB,IAAAD,sBAAA,IACEC,UAAA,CAAM,IAAA;AAAA,MACJ;AAAA,KAGF;AAAA,EACJ;AACF;;;;"}
1
+ {"version":3,"file":"detect.js","sources":["../../../src/orchestrion/detect.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __SENTRY_ORCHESTRION__: { runtime?: boolean; bundler?: boolean } | undefined;\n}\n\n/**\n * Whether orchestrion has injected the diagnostics channels into this process,\n * either by the runtime `--import` hook / init-time registration (`runtime`)\n * or a bundler plugin (`bundler`). Both injectors set a flag on the\n * `globalThis.__SENTRY_ORCHESTRION__` marker.\n *\n * Use this to avoid wiring up channel-subscriber integrations when nothing\n * will ever publish to those channels.\n */\nexport function isOrchestrionInjected(): boolean {\n const marker = globalThis.__SENTRY_ORCHESTRION__;\n return !!(marker?.runtime || marker?.bundler);\n}\n\n/**\n * Verifies that the diagnostics channels have been injected either by the\n * runtime `--import` hook (or init-time registration), a bundler plugin, or\n * both, and warns if not.\n *\n * Both injectors being active at once is fine: they operate on disjoint module\n * sets (a module is either loaded through Node's loader and transformed by the\n * runtime hook, or inlined by the bundler and transformed by the plugin), so\n * a single module can't be double-wrapped. A hybrid setup, with some deps\n * external and runtime-instrumented, others bundled and plugin-instrumented,\n * is fine.\n *\n * Note: intentionally does NOT warn in production, only in debug builds,\n * because production warnings are reserved for truly critical issues.\n */\nexport function detectOrchestrionSetup(): void {\n if (!DEBUG_BUILD) return;\n\n const marker = globalThis.__SENTRY_ORCHESTRION__;\n const runtime = !!marker?.runtime;\n const bundler = !!marker?.bundler;\n\n DEBUG_BUILD && debug.log(`[orchestrion] detect: runtime=${runtime} bundler=${bundler}`);\n\n if (!isOrchestrionInjected()) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] No diagnostics-channel injection detected. Channel-based integrations ' +\n '(mysql, …) will not record spans. Make sure the diagnostics channels are injected ' +\n 'via the runtime `--import` hook or a bundler plugin before the instrumented modules load.',\n );\n }\n}\n"],"names":["DEBUG_BUILD","debug"],"mappings":";;;;;AAiBO,SAAS,qBAAA,GAAiC;AAC/C,EAAA,MAAM,SAAS,UAAA,CAAW,sBAAA;AAC1B,EAAA,OAAO,CAAC,EAAE,MAAA,EAAQ,OAAA,IAAW,MAAA,EAAQ,OAAA,CAAA;AACvC;AAiBO,SAAS,sBAAA,GAA+B;AAC7C,EAAA,IAAI,CAACA,sBAAA,EAAa;AAElB,EAAA,MAAM,SAAS,UAAA,CAAW,sBAAA;AAC1B,EAAA,MAAM,OAAA,GAAU,CAAC,CAAC,MAAA,EAAQ,OAAA;AAC1B,EAAA,MAAM,OAAA,GAAU,CAAC,CAAC,MAAA,EAAQ,OAAA;AAE1B,EAAAA,sBAAA,IAAeC,WAAM,GAAA,CAAI,CAAA,8BAAA,EAAiC,OAAO,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,CAAA;AAEtF,EAAA,IAAI,CAAC,uBAAsB,EAAG;AAC5B,IAAAD,sBAAA,IACEC,UAAA,CAAM,IAAA;AAAA,MACJ;AAAA,KAGF;AAAA,EACJ;AACF;;;;;"}
@@ -1,12 +1,51 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const detect = require('./detect.js');
4
- const mysql = require('../integrations/tracing-channel/mysql.js');
3
+ const amqplib = require('../integrations/tracing-channel/amqplib.js');
4
+ const anthropic = require('../integrations/tracing-channel/anthropic.js');
5
+ const googleGenai = require('../integrations/tracing-channel/google-genai.js');
6
+ const index$1 = require('../integrations/tracing-channel/graphql/index.js');
7
+ const hapi = require('../integrations/tracing-channel/hapi.js');
8
+ const ioredis = require('../integrations/tracing-channel/ioredis.js');
5
9
  const lruMemoizer = require('../integrations/tracing-channel/lru-memoizer.js');
10
+ const mysql = require('../integrations/tracing-channel/mysql.js');
11
+ const openai = require('../integrations/tracing-channel/openai.js');
12
+ const postgres = require('../integrations/tracing-channel/postgres.js');
13
+ const postgresJs = require('../integrations/tracing-channel/postgres-js.js');
14
+ const vercelAi = require('../integrations/tracing-channel/vercel-ai.js');
15
+ const index = require('../integrations/tracing-channel/express/index.js');
16
+ const detect = require('./detect.js');
17
+ const redis = require('../integrations/tracing-channel/redis.js');
6
18
 
19
+ const channelIntegrations = {
20
+ postgresIntegration: postgres.postgresChannelIntegration,
21
+ postgresJsIntegration: postgresJs.postgresJsChannelIntegration,
22
+ mysqlIntegration: mysql.mysqlChannelIntegration,
23
+ lruMemoizerIntegration: lruMemoizer.lruMemoizerChannelIntegration,
24
+ openaiIntegration: openai.openaiChannelIntegration,
25
+ anthropicIntegration: anthropic.anthropicChannelIntegration,
26
+ googleGenAIIntegration: googleGenai.googleGenAIChannelIntegration,
27
+ vercelAiIntegration: vercelAi.vercelAiChannelIntegration,
28
+ amqplibIntegration: amqplib.amqplibChannelIntegration,
29
+ hapiIntegration: hapi.hapiChannelIntegration,
30
+ expressIntegration: index.expressChannelIntegration,
31
+ graphqlIntegration: index$1.graphqlDiagnosticsChannelIntegration
32
+ };
7
33
 
8
-
9
- exports.detectOrchestrionSetup = detect.detectOrchestrionSetup;
10
- exports.mysqlChannelIntegration = mysql.mysqlChannelIntegration;
34
+ exports.amqplibChannelIntegration = amqplib.amqplibChannelIntegration;
35
+ exports.anthropicChannelIntegration = anthropic.anthropicChannelIntegration;
36
+ exports.googleGenAIChannelIntegration = googleGenai.googleGenAIChannelIntegration;
37
+ exports.graphqlChannelIntegration = index$1.graphqlChannelIntegration;
38
+ exports.hapiChannelIntegration = hapi.hapiChannelIntegration;
39
+ exports.ioredisChannelIntegration = ioredis.ioredisChannelIntegration;
11
40
  exports.lruMemoizerChannelIntegration = lruMemoizer.lruMemoizerChannelIntegration;
41
+ exports.mysqlChannelIntegration = mysql.mysqlChannelIntegration;
42
+ exports.openaiChannelIntegration = openai.openaiChannelIntegration;
43
+ exports.postgresChannelIntegration = postgres.postgresChannelIntegration;
44
+ exports.postgresJsChannelIntegration = postgresJs.postgresJsChannelIntegration;
45
+ exports.vercelAiChannelIntegration = vercelAi.vercelAiChannelIntegration;
46
+ exports.expressChannelIntegration = index.expressChannelIntegration;
47
+ exports.detectOrchestrionSetup = detect.detectOrchestrionSetup;
48
+ exports.isOrchestrionInjected = detect.isOrchestrionInjected;
49
+ exports.redisChannelIntegration = redis.redisChannelIntegration;
50
+ exports.channelIntegrations = channelIntegrations;
12
51
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/orchestrion/index.ts"],"sourcesContent":["import { amqplibChannelIntegration } from '../integrations/tracing-channel/amqplib';\nimport { anthropicChannelIntegration } from '../integrations/tracing-channel/anthropic';\nimport { googleGenAIChannelIntegration } from '../integrations/tracing-channel/google-genai';\nimport {\n graphqlChannelIntegration,\n graphqlDiagnosticsChannelIntegration,\n} from '../integrations/tracing-channel/graphql';\nimport { hapiChannelIntegration } from '../integrations/tracing-channel/hapi';\nimport { ioredisChannelIntegration } from '../integrations/tracing-channel/ioredis';\nimport { lruMemoizerChannelIntegration } from '../integrations/tracing-channel/lru-memoizer';\nimport { mysqlChannelIntegration } from '../integrations/tracing-channel/mysql';\nimport { openaiChannelIntegration } from '../integrations/tracing-channel/openai';\nimport { postgresChannelIntegration } from '../integrations/tracing-channel/postgres';\nimport { postgresJsChannelIntegration } from '../integrations/tracing-channel/postgres-js';\nimport { vercelAiChannelIntegration } from '../integrations/tracing-channel/vercel-ai';\nimport { expressChannelIntegration } from '../integrations/tracing-channel/express';\n\nexport { detectOrchestrionSetup, isOrchestrionInjected } from './detect';\nexport {\n amqplibChannelIntegration,\n anthropicChannelIntegration,\n googleGenAIChannelIntegration,\n graphqlChannelIntegration,\n hapiChannelIntegration,\n ioredisChannelIntegration,\n lruMemoizerChannelIntegration,\n mysqlChannelIntegration,\n openaiChannelIntegration,\n postgresChannelIntegration,\n postgresJsChannelIntegration,\n vercelAiChannelIntegration,\n expressChannelIntegration,\n};\nexport type { IORedisChannelIntegrationOptions, IORedisResponseHook } from '../integrations/tracing-channel/ioredis';\nexport type { PostgresJsChannelIntegrationOptions } from '../integrations/tracing-channel/postgres-js';\nexport { redisChannelIntegration } from '../integrations/tracing-channel/redis';\nexport type { RedisChannelIntegrationOptions, RedisResponseHook } from '../integrations/tracing-channel/redis';\n\n// The structural `graphql` package types are the single source of truth shared with `@sentry/node`'s\n// vendored OTel graphql instrumentation (re-exported from here so the two can't drift).\nexport type * from '../integrations/tracing-channel/graphql/graphql-types';\n\n/**\n * The canonical set of orchestrion diagnostics-channel integrations, keyed by their public\n * (OTel-parity) factory name.\n *\n * Single source of truth: add a new channel integration here and every consumer — the `@sentry/node`\n * opt-in helper (`experimentalUseDiagnosticsChannelInjection`) and its public\n * `diagnosticsChannelInjectionIntegrations()` map — picks it up automatically, so there's no separate\n * list to keep in sync.\n *\n * NOTE: `ioredisChannelIntegration` and `redisChannelIntegration` are intentionally NOT here. They\n * only partially replace the composite OTel `Redis` integration and need the node SDK's redis cache\n * `responseHook` (which can't live in `server-utils`), so `@sentry/node` wires them up separately.\n */\nexport const channelIntegrations = {\n postgresIntegration: postgresChannelIntegration,\n postgresJsIntegration: postgresJsChannelIntegration,\n mysqlIntegration: mysqlChannelIntegration,\n lruMemoizerIntegration: lruMemoizerChannelIntegration,\n openaiIntegration: openaiChannelIntegration,\n anthropicIntegration: anthropicChannelIntegration,\n googleGenAIIntegration: googleGenAIChannelIntegration,\n vercelAiIntegration: vercelAiChannelIntegration,\n amqplibIntegration: amqplibChannelIntegration,\n hapiIntegration: hapiChannelIntegration,\n expressIntegration: expressChannelIntegration,\n graphqlIntegration: graphqlDiagnosticsChannelIntegration,\n} as const;\n"],"names":["postgresChannelIntegration","postgresJsChannelIntegration","mysqlChannelIntegration","lruMemoizerChannelIntegration","openaiChannelIntegration","anthropicChannelIntegration","googleGenAIChannelIntegration","vercelAiChannelIntegration","amqplibChannelIntegration","hapiChannelIntegration","expressChannelIntegration","graphqlDiagnosticsChannelIntegration"],"mappings":";;;;;;;;;;;;;;;;;;AAuDO,MAAM,mBAAA,GAAsB;AAAA,EACjC,mBAAA,EAAqBA,mCAAA;AAAA,EACrB,qBAAA,EAAuBC,uCAAA;AAAA,EACvB,gBAAA,EAAkBC,6BAAA;AAAA,EAClB,sBAAA,EAAwBC,yCAAA;AAAA,EACxB,iBAAA,EAAmBC,+BAAA;AAAA,EACnB,oBAAA,EAAsBC,qCAAA;AAAA,EACtB,sBAAA,EAAwBC,yCAAA;AAAA,EACxB,mBAAA,EAAqBC,mCAAA;AAAA,EACrB,kBAAA,EAAoBC,iCAAA;AAAA,EACpB,eAAA,EAAiBC,2BAAA;AAAA,EACjB,kBAAA,EAAoBC,+BAAA;AAAA,EACpB,kBAAA,EAAoBC;AACtB;;;;;;;;;;;;;;;;;;;;"}
@@ -4,9 +4,8 @@ const core = require('@sentry/core');
4
4
  const Module = require('node:module');
5
5
  const node_url = require('node:url');
6
6
  const debugBuild = require('../../debug-build.js');
7
- const config = require('../config.js');
7
+ const index = require('../config/index.js');
8
8
 
9
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
9
  function registerDiagnosticsChannelInjection() {
11
10
  const g = globalThis.__SENTRY_ORCHESTRION__ ?? (globalThis.__SENTRY_ORCHESTRION__ = {});
12
11
  if (g.runtime || g.bundler) {
@@ -17,20 +16,24 @@ function registerDiagnosticsChannelInjection() {
17
16
  const nodeVersion = parseVersion(process.versions.node ?? "0.0.0");
18
17
  const denoVersion = parseVersion(globalAny.Deno?.version?.deno ?? "0.0.0");
19
18
  const stableSyncHooks = (nodeVersion[0] ?? 0) > 25 || nodeVersion[0] === 25 && (nodeVersion[1] ?? 0) >= 1 || nodeVersion[0] === 24 && (nodeVersion[1] ?? 0) >= 13 || (denoVersion[0] ?? 0) > 2 || denoVersion[0] === 2 && (denoVersion[1] ?? 0) >= 8;
20
- const nodeRequire = typeof require === "function" ? require : Module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('orchestrion/runtime/register.js', document.baseURI).href)));
19
+ let nodeRequire;
20
+ nodeRequire = require;
21
21
  const mod = Module;
22
22
  try {
23
23
  if (typeof mod.registerHooks === "function" && stableSyncHooks) {
24
24
  const { initialize, resolve, load } = nodeRequire("@apm-js-collab/tracing-hooks/hook-sync.mjs");
25
- initialize({ instrumentations: config.SENTRY_INSTRUMENTATIONS });
25
+ initialize({ instrumentations: index.SENTRY_INSTRUMENTATIONS });
26
26
  mod.registerHooks({ resolve, load });
27
27
  debugBuild.DEBUG_BUILD && core.debug.log("[orchestrion] registered diagnostics-channel injection via Module.registerHooks()");
28
28
  } else if (typeof mod.register === "function" && !globalAny.Bun && !globalAny.Deno) {
29
- mod.register(node_url.pathToFileURL(nodeRequire.resolve("@apm-js-collab/tracing-hooks/hook.mjs")).href, {
30
- data: { instrumentations: config.SENTRY_INSTRUMENTATIONS }
29
+ let parentURL;
30
+ parentURL = node_url.pathToFileURL(__filename).href;
31
+ mod.register("@apm-js-collab/tracing-hooks/hook.mjs", {
32
+ parentURL,
33
+ data: { instrumentations: index.SENTRY_INSTRUMENTATIONS }
31
34
  });
32
35
  const ModulePatch = nodeRequire("@apm-js-collab/tracing-hooks");
33
- new ModulePatch({ instrumentations: config.SENTRY_INSTRUMENTATIONS }).patch();
36
+ new ModulePatch({ instrumentations: index.SENTRY_INSTRUMENTATIONS }).patch();
34
37
  debugBuild.DEBUG_BUILD && core.debug.log("[orchestrion] registered diagnostics-channel injection via Module.register()");
35
38
  } else {
36
39
  debugBuild.DEBUG_BUILD && core.debug.warn("[Sentry] No available Node API to register diagnostics-channel injection hooks; skipping.");
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","sources":["../../../../src/orchestrion/runtime/register.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport { createRequire } from 'node:module';\nimport * as Module from 'node:module';\nimport { pathToFileURL } from 'node:url';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { SENTRY_INSTRUMENTATIONS } from '../config';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __SENTRY_ORCHESTRION__: { runtime?: boolean; bundler?: boolean } | undefined;\n}\n\n/**\n * Synchronously register the diagnostics-channel injection module hooks.\n *\n * This is the single source of truth for the registration logic. It is used by:\n * - `Sentry.init()` (the Node SDK calls it directly — that's why this module\n * must be CJS-compatible / dual-built, so it can be `require()`d synchronously\n * before the app's `import`s resolve), and\n * - `import-hook.mjs`, the side-effecting `--import` entry, which just calls it.\n *\n * Libraries imported *after* this call publish the `tracingChannel` events that\n * the channel-based integrations subscribe to.\n *\n * Idempotent via `globalThis.__SENTRY_ORCHESTRION__` — a no-op if the runtime\n * `--import` hook or a bundler plugin already injected the channels.\n */\nexport function registerDiagnosticsChannelInjection(): void {\n const g = (globalThis.__SENTRY_ORCHESTRION__ ??= {});\n\n // Already injected (runtime --import hook or bundler plugin) — nothing to do.\n if (g.runtime || g.bundler) {\n return;\n }\n\n const globalAny = globalThis as { Bun?: unknown; Deno?: { version?: { deno?: string } } };\n const parseVersion = (v: string): number[] => v.split('.').map(n => parseInt(n, 10));\n const nodeVersion = parseVersion(process.versions.node ?? '0.0.0');\n const denoVersion = parseVersion(globalAny.Deno?.version?.deno ?? '0.0.0');\n // `Module.registerHooks` only became stable in Node 24.13 / 25.1 and Deno 2.8.\n const stableSyncHooks =\n (nodeVersion[0] ?? 0) > 25 ||\n (nodeVersion[0] === 25 && (nodeVersion[1] ?? 0) >= 1) ||\n (nodeVersion[0] === 24 && (nodeVersion[1] ?? 0) >= 13) ||\n (denoVersion[0] ?? 0) > 2 ||\n (denoVersion[0] === 2 && (denoVersion[1] ?? 0) >= 8);\n\n // Prefer the builtin `require` if possible. This is present in CommonJS,\n // including a bundler's CJS output, so no need to ever have to evaluate\n // `import.meta.url` there.\n //\n // esbuild and friends rewrite `import.meta.url` to `{}` for CJS output,\n // which would make `createRequire(undefined)` throw.\n // Only use `import.meta.url` in true ESM, where there's no `require`\n const nodeRequire = typeof require === 'function' ? require : createRequire(import.meta.url);\n\n // `Module.registerHooks` / `Module.register` are newer than the @types/node\n // we build against, hence the cast.\n const mod = Module as unknown as {\n registerHooks?: (hooks: unknown) => void;\n register?: (specifier: string, options: unknown) => void;\n };\n\n // runs both at `--import` time and (synchronously) inside `Sentry.init()`,\n // so an unguarded throw would either abort startup or make `init()` throw.\n // On any failure (e.g. dep resolution, `require(esm)` / Node-compat\n // incompatibility) we warn (DEBUG only) and continue without channel\n // injection\n try {\n if (typeof mod.registerHooks === 'function' && stableSyncHooks) {\n // Sync hooks cover CJS and ESM, no separate `_compile` patch needed.\n // We require() the module here so that we can synchronously load it,\n // including from a CommonJS Sentry build, without bundlers pulling in.\n // All versions in stableSyncHooks support this.\n const { initialize, resolve, load } = nodeRequire('@apm-js-collab/tracing-hooks/hook-sync.mjs') as {\n initialize: (opts: { instrumentations: unknown }) => void;\n resolve: unknown;\n load: unknown;\n };\n initialize({ instrumentations: SENTRY_INSTRUMENTATIONS });\n mod.registerHooks({ resolve, load });\n DEBUG_BUILD && debug.log('[orchestrion] registered diagnostics-channel injection via Module.registerHooks()');\n } else if (typeof mod.register === 'function' && !globalAny.Bun && !globalAny.Deno) {\n // `Module.register` + the `_compile` patch is Node 18.19–24.12 / 25.0\n // path. Bun/Deno are excluded: they don't support this combination and\n // must use the stable `registerHooks` path above (or none at all).\n // Resolve the hook to an absolute file URL ourselves so\n // `Module.register` needs no `parentURL`, so no need for\n // `import.meta.url` polyfilling\n mod.register(pathToFileURL(nodeRequire.resolve('@apm-js-collab/tracing-hooks/hook.mjs')).href, {\n data: { instrumentations: SENTRY_INSTRUMENTATIONS },\n });\n\n // ALSO patch `Module.prototype._compile` for the CJS side: when an ESM\n // file `import`s a CJS package, the package's internal `require()` calls\n // are resolved through the CJS machinery and never reach the ESM\n // register hook, so without this patch the file we want to instrument\n // loads untransformed.\n const ModulePatch = nodeRequire('@apm-js-collab/tracing-hooks') as new (opts: { instrumentations: unknown }) => {\n patch: () => void;\n };\n new ModulePatch({ instrumentations: SENTRY_INSTRUMENTATIONS }).patch();\n DEBUG_BUILD && debug.log('[orchestrion] registered diagnostics-channel injection via Module.register()');\n } else {\n DEBUG_BUILD &&\n debug.warn('[Sentry] No available Node API to register diagnostics-channel injection hooks; skipping.');\n return;\n }\n } catch (error) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] Failed to register diagnostics-channel injection hooks; channel-based integrations ' +\n 'will not record spans.',\n error,\n );\n return;\n }\n\n g.runtime = true;\n}\n"],"names":["createRequire","SENTRY_INSTRUMENTATIONS","DEBUG_BUILD","debug","pathToFileURL"],"mappings":";;;;;;;;;AA2BO,SAAS,mCAAA,GAA4C;AAC1D,EAAA,MAAM,CAAA,GAAK,UAAA,CAAW,sBAAA,KAAX,UAAA,CAAW,yBAA2B,EAAC,CAAA;AAGlD,EAAA,IAAI,CAAA,CAAE,OAAA,IAAW,CAAA,CAAE,OAAA,EAAS;AAC1B,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,UAAA;AAClB,EAAA,MAAM,YAAA,GAAe,CAAC,CAAA,KAAwB,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA,CAAE,GAAA,CAAI,CAAA,CAAA,KAAK,QAAA,CAAS,CAAA,EAAG,EAAE,CAAC,CAAA;AACnF,EAAA,MAAM,WAAA,GAAc,YAAA,CAAa,OAAA,CAAQ,QAAA,CAAS,QAAQ,OAAO,CAAA;AACjE,EAAA,MAAM,cAAc,YAAA,CAAa,SAAA,CAAU,IAAA,EAAM,OAAA,EAAS,QAAQ,OAAO,CAAA;AAEzE,EAAA,MAAM,mBACH,WAAA,CAAY,CAAC,CAAA,IAAK,CAAA,IAAK,MACvB,WAAA,CAAY,CAAC,CAAA,KAAM,EAAA,IAAA,CAAO,YAAY,CAAC,CAAA,IAAK,CAAA,KAAM,CAAA,IAClD,YAAY,CAAC,CAAA,KAAM,EAAA,IAAA,CAAO,WAAA,CAAY,CAAC,CAAA,IAAK,CAAA,KAAM,EAAA,IAAA,CAClD,WAAA,CAAY,CAAC,CAAA,IAAK,CAAA,IAAK,CAAA,IACvB,WAAA,CAAY,CAAC,CAAA,KAAM,CAAA,IAAA,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J,oHAAA;AAAA,MAEA;AAAA,KACF;AACF,IAAA;AAAA,EACF;AAEA,EAAA,CAAA,CAAE,OAAA,GAAU,IAAA;AACd;;;;"}
1
+ {"version":3,"file":"register.js","sources":["../../../../src/orchestrion/runtime/register.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport { createRequire } from 'node:module';\nimport * as Module from 'node:module';\nimport { pathToFileURL } from 'node:url';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { SENTRY_INSTRUMENTATIONS } from '../config';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __SENTRY_ORCHESTRION__: { runtime?: boolean; bundler?: boolean } | undefined;\n}\n\n/**\n * Synchronously register the diagnostics-channel injection module hooks.\n *\n * This is the single source of truth for the registration logic. It is used by:\n * - `Sentry.init()` (the Node SDK calls it directly — that's why this module\n * must be CJS-compatible / dual-built, so it can be `require()`d synchronously\n * before the app's `import`s resolve), and\n * - `import-hook.mjs`, the side-effecting `--import` entry, which just calls it.\n *\n * Libraries imported *after* this call publish the `tracingChannel` events that\n * the channel-based integrations subscribe to.\n *\n * Idempotent via `globalThis.__SENTRY_ORCHESTRION__` — a no-op if the runtime\n * `--import` hook or a bundler plugin already injected the channels.\n */\nexport function registerDiagnosticsChannelInjection(): void {\n const g = (globalThis.__SENTRY_ORCHESTRION__ ??= {});\n\n // Already injected (runtime --import hook or bundler plugin) — nothing to do.\n if (g.runtime || g.bundler) {\n return;\n }\n\n const globalAny = globalThis as { Bun?: unknown; Deno?: { version?: { deno?: string } } };\n const parseVersion = (v: string): number[] => v.split('.').map(n => parseInt(n, 10));\n const nodeVersion = parseVersion(process.versions.node ?? '0.0.0');\n const denoVersion = parseVersion(globalAny.Deno?.version?.deno ?? '0.0.0');\n // `Module.registerHooks` only became stable in Node 24.13 / 25.1 and Deno 2.8.\n const stableSyncHooks =\n (nodeVersion[0] ?? 0) > 25 ||\n (nodeVersion[0] === 25 && (nodeVersion[1] ?? 0) >= 1) ||\n (nodeVersion[0] === 24 && (nodeVersion[1] ?? 0) >= 13) ||\n (denoVersion[0] ?? 0) > 2 ||\n (denoVersion[0] === 2 && (denoVersion[1] ?? 0) >= 8);\n\n let nodeRequire: (specifier: string) => unknown;\n /*! rollup-include-cjs-only */\n nodeRequire = require;\n /*! rollup-include-cjs-only-end */\n /*! rollup-include-esm-only */\n nodeRequire = createRequire(import.meta.url);\n /*! rollup-include-esm-only-end */\n\n // `Module.registerHooks` / `Module.register` are newer than the @types/node\n // we build against, hence the cast.\n const mod = Module as unknown as {\n registerHooks?: (hooks: unknown) => void;\n register?: (specifier: string, options: unknown) => void;\n };\n\n // runs both at `--import` time and (synchronously) inside `Sentry.init()`,\n // so an unguarded throw would either abort startup or make `init()` throw.\n // On any failure (e.g. dep resolution, `require(esm)` / Node-compat\n // incompatibility) we warn (DEBUG only) and continue without channel\n // injection\n try {\n if (typeof mod.registerHooks === 'function' && stableSyncHooks) {\n // Sync hooks cover CJS and ESM, no separate `_compile` patch needed.\n // We require() the module here so that we can synchronously load it,\n // including from a CommonJS Sentry build, without bundlers pulling in.\n // All versions in stableSyncHooks support this.\n const { initialize, resolve, load } = nodeRequire('@apm-js-collab/tracing-hooks/hook-sync.mjs') as {\n initialize: (opts: { instrumentations: unknown }) => void;\n resolve: unknown;\n load: unknown;\n };\n initialize({ instrumentations: SENTRY_INSTRUMENTATIONS });\n mod.registerHooks({ resolve, load });\n DEBUG_BUILD && debug.log('[orchestrion] registered diagnostics-channel injection via Module.registerHooks()');\n } else if (typeof mod.register === 'function' && !globalAny.Bun && !globalAny.Deno) {\n // `Module.register` + the `_compile` patch is Node 18.19–24.12 / 25.0\n // path. Bun/Deno are excluded: they don't support this combination and\n // must use the stable `registerHooks` path above (or none at all).\n let parentURL: string;\n /*! rollup-include-cjs-only */\n parentURL = pathToFileURL(__filename).href;\n /*! rollup-include-cjs-only-end */\n /*! rollup-include-esm-only */\n parentURL = import.meta.url;\n /*! rollup-include-esm-only-end */\n\n mod.register('@apm-js-collab/tracing-hooks/hook.mjs', {\n parentURL,\n data: { instrumentations: SENTRY_INSTRUMENTATIONS },\n });\n\n // ALSO patch `Module.prototype._compile` for the CJS side: when an ESM\n // file `import`s a CJS package, the package's internal `require()` calls\n // are resolved through the CJS machinery and never reach the ESM\n // register hook, so without this patch the file we want to instrument\n // loads untransformed.\n const ModulePatch = nodeRequire('@apm-js-collab/tracing-hooks') as new (opts: { instrumentations: unknown }) => {\n patch: () => void;\n };\n new ModulePatch({ instrumentations: SENTRY_INSTRUMENTATIONS }).patch();\n DEBUG_BUILD && debug.log('[orchestrion] registered diagnostics-channel injection via Module.register()');\n } else {\n DEBUG_BUILD &&\n debug.warn('[Sentry] No available Node API to register diagnostics-channel injection hooks; skipping.');\n return;\n }\n } catch (error) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] Failed to register diagnostics-channel injection hooks; channel-based integrations ' +\n 'will not record spans.',\n error,\n );\n return;\n }\n\n g.runtime = true;\n}\n"],"names":["SENTRY_INSTRUMENTATIONS","DEBUG_BUILD","debug","pathToFileURL"],"mappings":";;;;;;;;AA2BO,SAAS,mCAAA,GAA4C;AAC1D,EAAA,MAAM,CAAA,GAAK,UAAA,CAAW,sBAAA,KAAX,UAAA,CAAW,yBAA2B,EAAC,CAAA;AAGlD,EAAA,IAAI,CAAA,CAAE,OAAA,IAAW,CAAA,CAAE,OAAA,EAAS;AAC1B,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,UAAA;AAClB,EAAA,MAAM,YAAA,GAAe,CAAC,CAAA,KAAwB,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA,CAAE,GAAA,CAAI,CAAA,CAAA,KAAK,QAAA,CAAS,CAAA,EAAG,EAAE,CAAC,CAAA;AACnF,EAAA,MAAM,WAAA,GAAc,YAAA,CAAa,OAAA,CAAQ,QAAA,CAAS,QAAQ,OAAO,CAAA;AACjE,EAAA,MAAM,cAAc,YAAA,CAAa,SAAA,CAAU,IAAA,EAAM,OAAA,EAAS,QAAQ,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D,OAAA,CAAA;AAAI,MACJ,MAAA,WAAA,GAAA,WAAA,CAAA,8BAAA,CAAA;AACA,MAAA,IAAA,WAAY,CAAA,EAAA,kBAAwBA,6BAAE,EAAA,CAAA,CAAA,KAAA,EAAA;AAAA,MACtCC,sBAAA,IAAAC,UAAA,CAAA,GAAA,CAAA,8EAAA,CAAA;AAAA,IAAA,CAAA,MACA;AACA,MAAAD,sBAAA,IAAYC,UAAA,CAAA,IAAY,CAAA,2FAAA,CAAA;AAAA,MACxB;AAEA,IAAA;AAAsD,EAAA,CAAA,CAAA,OACpD,KAAA,EAAA;AAAA,IAAAD,sBACM,IAAEC,UAAA,CAAA,IAAA;AAA0C,MACpD,oHAAC;AAOD,MAAA;AAGA,KAAA;AACA,IAAA;AAAuG,EAAA;AAEvG,EAAA,CAAA,CAAA,OAAA,GAAA,IAAA;AAEA;;;;"}
@@ -0,0 +1,23 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const diagnosticsChannel = require('node:diagnostics_channel');
5
+ const redisDcSubscriber = require('./redis-dc-subscriber.js');
6
+
7
+ const _redisIntegration = ((options = {}) => {
8
+ return {
9
+ name: "Redis",
10
+ setupOnce() {
11
+ if (!diagnosticsChannel.tracingChannel) {
12
+ return;
13
+ }
14
+ core.waitForTracingChannelBinding(() => {
15
+ redisDcSubscriber.subscribeRedisDiagnosticChannels(diagnosticsChannel.tracingChannel, options.responseHook);
16
+ });
17
+ }
18
+ };
19
+ });
20
+ const redisIntegration = core.defineIntegration(_redisIntegration);
21
+
22
+ exports.redisIntegration = redisIntegration;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/redis/index.ts"],"sourcesContent":["import { defineIntegration, type IntegrationFn, waitForTracingChannelBinding } from '@sentry/core';\nimport * as dc from 'node:diagnostics_channel';\nimport { type RedisDiagnosticChannelResponseHook, subscribeRedisDiagnosticChannels } from './redis-dc-subscriber';\n\n/** Options controlling the redis diagnostics-channel subscription. */\nexport interface RedisDiagnosticChannelsOptions {\n /**\n * Optional hook invoked once the redis command response arrives. Useful for attaching\n * response-derived attributes (e.g. cache hit/miss, payload size).\n */\n responseHook?: RedisDiagnosticChannelResponseHook;\n}\n\nconst _redisIntegration = ((options: RedisDiagnosticChannelsOptions = {}) => {\n return {\n name: 'Redis',\n setupOnce() {\n // Bail on runtimes without `tracingChannel` (Node <= 18.18.0).\n if (!dc.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n subscribeRedisDiagnosticChannels(dc.tracingChannel, options.responseHook);\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Auto-instrument the [redis](https://www.npmjs.com/package/redis) and\n * [ioredis](https://www.npmjs.com/package/ioredis) libraries via their native\n * `node:diagnostics_channel` tracing channels (node-redis >= 5.12.0, ioredis >= 5.11.0).\n */\nexport const redisIntegration = defineIntegration(_redisIntegration);\n"],"names":["dc","waitForTracingChannelBinding","subscribeRedisDiagnosticChannels","defineIntegration"],"mappings":";;;;;;AAaA,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAA0C,EAAC,KAAM;AAC3E,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAACA,mBAAG,cAAA,EAAgB;AACtB,QAAA;AAAA,MACF;AAEA,MAAAC,iCAAA,CAA6B,MAAM;AACjC,QAAAC,kDAAA,CAAiCF,kBAAA,CAAG,cAAA,EAAgB,OAAA,CAAQ,YAAY,CAAA;AAAA,MAC1E,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAOO,MAAM,gBAAA,GAAmBG,uBAAkB,iBAAiB;;;;"}
@@ -2,7 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const attributes = require('@sentry/conventions/attributes');
4
4
  const core = require('@sentry/core');
5
- const debugBuild = require('../debug-build.js');
6
5
  const tracingChannel = require('../tracing-channel.js');
7
6
 
8
7
  const REDIS_DC_CHANNEL_COMMAND = "node-redis:command";
@@ -12,34 +11,24 @@ const IOREDIS_DC_CHANNEL_COMMAND = "ioredis:command";
12
11
  const IOREDIS_DC_CHANNEL_CONNECT = "ioredis:connect";
13
12
  const ORIGIN = "auto.db.redis.diagnostic_channel";
14
13
  const DB_SYSTEM_NAME_VALUE_REDIS = "redis";
15
- let subscribed = false;
16
- let currentResponseHook;
17
- let activeUnbinds = [];
18
14
  function subscribeRedisDiagnosticChannels(tracingChannel, responseHook) {
19
- currentResponseHook = responseHook;
20
- if (subscribed) return;
21
- subscribed = true;
22
- try {
23
- activeUnbinds.push(
24
- setupCommandChannel(tracingChannel, REDIS_DC_CHANNEL_COMMAND, (data) => data.args.slice(1)),
25
- setupBatchChannel(
26
- tracingChannel,
27
- REDIS_DC_CHANNEL_BATCH,
28
- (data) => data.batchMode === "PIPELINE" ? "PIPELINE" : "MULTI"
29
- ),
30
- setupConnectChannel(tracingChannel, REDIS_DC_CHANNEL_CONNECT),
31
- // ioredis: args already exclude the command name; no slicing needed. And
32
- // ioredis has no separate batch channel — pipeline/MULTI metadata rides
33
- // on the per-command payload via `batchMode`/`batchSize`.
34
- setupCommandChannel(tracingChannel, IOREDIS_DC_CHANNEL_COMMAND, (data) => data.args),
35
- setupConnectChannel(tracingChannel, IOREDIS_DC_CHANNEL_CONNECT)
36
- );
37
- } catch {
38
- debugBuild.DEBUG_BUILD && core.debug.log("Redis node:diagnostics_channel subscription failed.");
39
- }
15
+ setupCommandChannel(
16
+ tracingChannel,
17
+ REDIS_DC_CHANNEL_COMMAND,
18
+ (data) => data.args.slice(1),
19
+ responseHook
20
+ );
21
+ setupBatchChannel(
22
+ tracingChannel,
23
+ REDIS_DC_CHANNEL_BATCH,
24
+ (data) => data.batchMode === "PIPELINE" ? "PIPELINE" : "MULTI"
25
+ );
26
+ setupConnectChannel(tracingChannel, REDIS_DC_CHANNEL_CONNECT);
27
+ setupCommandChannel(tracingChannel, IOREDIS_DC_CHANNEL_COMMAND, (data) => data.args, responseHook);
28
+ setupConnectChannel(tracingChannel, IOREDIS_DC_CHANNEL_CONNECT);
40
29
  }
41
- function setupCommandChannel(tracingChannel$1, channelName, getCommandArgs) {
42
- return tracingChannel.bindTracingChannelToSpan(
30
+ function setupCommandChannel(tracingChannel$1, channelName, getCommandArgs, responseHook) {
31
+ tracingChannel.bindTracingChannelToSpan(
43
32
  tracingChannel$1(channelName),
44
33
  (data) => {
45
34
  const args = getCommandArgs(data);
@@ -62,13 +51,13 @@ function setupCommandChannel(tracingChannel$1, channelName, getCommandArgs) {
62
51
  captureError: false,
63
52
  beforeSpanEnd(span, data) {
64
53
  if ("error" in data) return;
65
- runResponseHook(span, data.command, getCommandArgs(data), data.result);
54
+ runResponseHook(responseHook, span, data.command, getCommandArgs(data), data.result);
66
55
  }
67
56
  }
68
- ).unbind;
57
+ );
69
58
  }
70
59
  function setupBatchChannel(tracingChannel$1, channelName, getOperationName) {
71
- return tracingChannel.bindTracingChannelToSpan(
60
+ tracingChannel.bindTracingChannelToSpan(
72
61
  tracingChannel$1(channelName),
73
62
  (data) => {
74
63
  return core.startInactiveSpan({
@@ -86,10 +75,10 @@ function setupBatchChannel(tracingChannel$1, channelName, getOperationName) {
86
75
  });
87
76
  },
88
77
  { captureError: false }
89
- ).unbind;
78
+ );
90
79
  }
91
80
  function setupConnectChannel(tracingChannel$1, channelName) {
92
- return tracingChannel.bindTracingChannelToSpan(
81
+ tracingChannel.bindTracingChannelToSpan(
93
82
  tracingChannel$1(channelName),
94
83
  (data) => {
95
84
  return core.startInactiveSpan({
@@ -104,10 +93,9 @@ function setupConnectChannel(tracingChannel$1, channelName) {
104
93
  });
105
94
  },
106
95
  { captureError: false }
107
- ).unbind;
96
+ );
108
97
  }
109
- function runResponseHook(span, command, args, result) {
110
- const hook = currentResponseHook;
98
+ function runResponseHook(hook, span, command, args, result) {
111
99
  if (!hook) return;
112
100
  try {
113
101
  hook(span, command, args, result);
@@ -1 +1 @@
1
- {"version":3,"file":"redis-dc-subscriber.js","sources":["../../../src/redis/redis-dc-subscriber.ts"],"sourcesContent":["import type { TracingChannel } from 'node:diagnostics_channel';\nimport {\n DB_OPERATION_BATCH_SIZE,\n DB_QUERY_TEXT,\n DB_SYSTEM_NAME,\n SERVER_ADDRESS,\n SERVER_PORT,\n} from '@sentry/conventions/attributes';\nimport type { Span } from '@sentry/core';\nimport { debug, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startInactiveSpan } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { bindTracingChannelToSpan } from '../tracing-channel';\n\n// Channel names published by node-redis >= 5.12.0 and ioredis >= 5.11.0.\n// Hardcoded so the subscriber does not have to import either library — the\n// channels just have to be subscribed to before the user's redis code\n// publishes.\nexport const REDIS_DC_CHANNEL_COMMAND = 'node-redis:command';\nexport const REDIS_DC_CHANNEL_BATCH = 'node-redis:batch';\nexport const REDIS_DC_CHANNEL_CONNECT = 'node-redis:connect';\nexport const IOREDIS_DC_CHANNEL_COMMAND = 'ioredis:command';\nexport const IOREDIS_DC_CHANNEL_CONNECT = 'ioredis:connect';\n\nconst ORIGIN = 'auto.db.redis.diagnostic_channel';\nconst DB_SYSTEM_NAME_VALUE_REDIS = 'redis';\n\n/**\n * Shape of the `node-redis:command` channel payload published by node-redis.\n *\n * Both `command` and `args` are already redacted by node-redis itself (see\n * `sanitizeArgs` in @redis/client) using the OTel `redis-common` rules. The\n * arg array is `[<command>, <safe arg>, ..., '?', ...]` — `?` replaces any\n * value the library considers sensitive. Subscribers can emit `args` directly\n * as `db.query.text` without further serialization.\n */\nexport interface RedisCommandData {\n command: string;\n /** First arg is the command name itself; consumers should slice it off. */\n args: string[];\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/**\n * Shape of the `ioredis:command` channel payload published by ioredis >= 5.11.0.\n *\n * As with node-redis, args are already sanitized by ioredis (`sanitizeArgs` in\n * `lib/tracing.ts`) before publishing. Unlike node-redis, the command name is\n * NOT prepended to `args`.\n */\nexport interface IORedisCommandData {\n command: string;\n args: string[];\n batchMode?: 'MULTI';\n batchSize?: number;\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/** Shape of the `node-redis:batch` channel payload published by node-redis. */\nexport interface RedisBatchData {\n batchMode?: 'MULTI' | 'PIPELINE';\n batchSize?: number;\n database?: number;\n clientId?: string | number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown[];\n error?: Error;\n}\n\n/** Shape of the `*:connect` channel payload published by node-redis and ioredis. */\nexport interface RedisConnectData {\n serverAddress?: string;\n serverPort?: number;\n url?: string;\n error?: Error;\n}\n\n/**\n * Optional callback invoked once the redis command response arrives. Useful\n * for attaching response-derived attributes (e.g. cache hit/miss, payload size).\n *\n * Mirrors `@opentelemetry/instrumentation-ioredis`' response hook so existing\n * Sentry node code (`cacheResponseHook`) can be reused unchanged.\n */\nexport type RedisDiagnosticChannelResponseHook = (\n span: Span,\n cmdName: string,\n cmdArgs: string[],\n result: unknown,\n) => void;\n\n/**\n * Platform-provided factory that creates a native tracing channel for the given name. The\n * subscriber binds the span and its lifecycle onto the channel via `bindTracingChannelToSpan`,\n * which propagates the active span through the runtime's async context.\n *\n * Both Node and Deno pass `node:diagnostics_channel`'s `tracingChannel` directly.\n */\nexport type RedisTracingChannelFactory = <T extends object>(name: string) => TracingChannel<T, T>;\n\nlet subscribed = false;\nlet currentResponseHook: RedisDiagnosticChannelResponseHook | undefined;\nlet activeUnbinds: Array<() => void> = [];\n\n/**\n * Subscribe Sentry span handlers to node-redis and ioredis diagnostics-channel\n * events: `node-redis:command`/`:batch`/`:connect` (published by node-redis\n * >= 5.12.0) and `ioredis:command`/`:connect` (published by ioredis >= 5.11.0).\n *\n * On older client versions the channels are never published to, so subscribers\n * are inert — there is no double-instrumentation against any IITM-based\n * patcher gated to those older versions.\n *\n * Idempotent: subsequent calls update the response hook but do not\n * re-subscribe.\n */\nexport function subscribeRedisDiagnosticChannels(\n tracingChannel: RedisTracingChannelFactory,\n responseHook?: RedisDiagnosticChannelResponseHook,\n): void {\n currentResponseHook = responseHook;\n if (subscribed) return;\n subscribed = true;\n\n try {\n // node-redis: command name appears as args[0] in the channel payload, so\n // strip it before the statement and response hook see it.\n activeUnbinds.push(\n setupCommandChannel<RedisCommandData>(tracingChannel, REDIS_DC_CHANNEL_COMMAND, data => data.args.slice(1)),\n setupBatchChannel(tracingChannel, REDIS_DC_CHANNEL_BATCH, data =>\n data.batchMode === 'PIPELINE' ? 'PIPELINE' : 'MULTI',\n ),\n setupConnectChannel(tracingChannel, REDIS_DC_CHANNEL_CONNECT),\n // ioredis: args already exclude the command name; no slicing needed. And\n // ioredis has no separate batch channel — pipeline/MULTI metadata rides\n // on the per-command payload via `batchMode`/`batchSize`.\n setupCommandChannel<IORedisCommandData>(tracingChannel, IOREDIS_DC_CHANNEL_COMMAND, data => data.args),\n setupConnectChannel(tracingChannel, IOREDIS_DC_CHANNEL_CONNECT),\n );\n } catch {\n // The factory may rely on `node:diagnostics_channel`, which isn't always\n // available. Fail closed; the SDK simply won't emit redis spans here.\n DEBUG_BUILD && debug.log('Redis node:diagnostics_channel subscription failed.');\n }\n}\n\nfunction setupCommandChannel<T extends RedisCommandData | IORedisCommandData>(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getCommandArgs: (data: T) => string[],\n): () => void {\n return bindTracingChannelToSpan(\n tracingChannel<T>(channelName),\n data => {\n // `args` is already sanitized by the publishing library (node-redis /\n // ioredis call their own `sanitizeArgs` before publishing). Join with\n // spaces to mirror the format the libraries themselves intend.\n const args = getCommandArgs(data);\n const statement = args.length ? `${data.command} ${args.join(' ')}` : data.command;\n return startInactiveSpan({\n name: `redis-${data.command}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n [DB_QUERY_TEXT]: statement,\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n {\n // Command failures are surfaced to (and usually handled by) the caller; only annotate the\n // span so we don't emit a duplicate error event for every failed command.\n captureError: false,\n beforeSpanEnd(span, data) {\n if ('error' in data) return;\n runResponseHook(span, data.command, getCommandArgs(data), data.result);\n },\n },\n ).unbind;\n}\n\nfunction setupBatchChannel(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getOperationName: (data: RedisBatchData) => string,\n): () => void {\n return bindTracingChannelToSpan(\n tracingChannel<RedisBatchData>(channelName),\n data => {\n return startInactiveSpan({\n name: getOperationName(data),\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n // should only include batch size greater than 1,\n // or else it isn't properly considered a \"batch\"\n ...(Number(data.batchSize) > 1 ? { [DB_OPERATION_BATCH_SIZE]: data.batchSize } : {}),\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n { captureError: false },\n ).unbind;\n}\n\nfunction setupConnectChannel(tracingChannel: RedisTracingChannelFactory, channelName: string): () => void {\n return bindTracingChannelToSpan(\n tracingChannel<RedisConnectData>(channelName),\n data => {\n return startInactiveSpan({\n name: 'redis-connect',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis.connect',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n { captureError: false },\n ).unbind;\n}\n\nfunction runResponseHook(span: Span, command: string, args: string[], result: unknown): void {\n const hook = currentResponseHook;\n if (!hook) return;\n try {\n hook(span, command, args, result);\n } catch {\n // never let user hooks break instrumentation\n }\n}\n\n/** Test-only: detach all channel bindings and reset module-local subscribe state. */\nexport function _resetRedisDiagnosticChannelsForTesting(): void {\n activeUnbinds.forEach(unbind => unbind());\n activeUnbinds = [];\n subscribed = false;\n currentResponseHook = undefined;\n}\n"],"names":["DEBUG_BUILD","debug","tracingChannel","bindTracingChannelToSpan","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","DB_SYSTEM_NAME","DB_QUERY_TEXT","SERVER_ADDRESS","SERVER_PORT","DB_OPERATION_BATCH_SIZE"],"mappings":";;;;;;;AAiBO,MAAM,wBAAA,GAA2B;AACjC,MAAM,sBAAA,GAAyB;AAC/B,MAAM,wBAAA,GAA2B;AACjC,MAAM,0BAAA,GAA6B;AACnC,MAAM,0BAAA,GAA6B;AAE1C,MAAM,MAAA,GAAS,kCAAA;AACf,MAAM,0BAAA,GAA6B,OAAA;AAoFnC,IAAI,UAAA,GAAa,KAAA;AACjB,IAAI,mBAAA;AACJ,IAAI,gBAAmC,EAAC;AAcjC,SAAS,gCAAA,CACd,gBACA,YAAA,EACM;AACN,EAAA,mBAAA,GAAsB,YAAA;AACtB,EAAA,IAAI,UAAA,EAAY;AAChB,EAAA,UAAA,GAAa,IAAA;AAEb,EAAA,IAAI;AAGF,IAAA,aAAA,CAAc,IAAA;AAAA,MACZ,mBAAA,CAAsC,gBAAgB,wBAAA,EAA0B,CAAA,IAAA,KAAQ,KAAK,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA;A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cAAc,KAAA;AAAM,GACxB,CAAE,MAAA;AACJ;AAEA,SAAS,mBAAA,CAAoBR,kBAA4C,WAAA,EAAiC;AACxG,EAAA,OAAOC,uCAAA;AAAA,IACLD,iBAAiC,WAAW,CAAA;AAAA,IAC5C,CAAA,IAAA,KAAQ;AACN,MAAA,OAAOE,sBAAA,CAAkB;AAAA,QACvB,IAAA,EAAM,eAAA;AAAA,QACN,UAAA,EAAY;AAAA,UACV,CAACC,qCAAgC,GAAG,MAAA;AAAA,UACpC,CAACC,iCAA4B,GAAG,kBAAA;AAAA,UAChC,CAACC,yBAAc,GAAG,0BAAA;AAAA,UAClB,GAAI,IAAA,CAAK,aAAA,IAAiB,IAAA,GAAO,EAAE,CAACE,yBAAc,GAAG,IAAA,CAAK,aAAA,EAAc,GAAI,EAAC;AAAA,UAC7E,GAAI,IAAA,CAAK,UAAA,IAAc,IAAA,GAAO,EAAE,CAACC,sBAAW,GAAG,IAAA,CAAK,UAAA,EAAW,GAAI;AAAC;AACtE,OACD,CAAA;AAAA,IACH,CAAA;AAAA,IACA,EAAE,cAAc,KAAA;AAAM,GACxB,CAAE,MAAA;AACJ;AAEA,SAAS,eAAA,CAAgB,IAAA,EAAY,OAAA,EAAiB,IAAA,EAAgB,MAAA,EAAuB;AAC3F,EAAA,MAAM,IAAA,GAAO,mBAAA;AACb,EAAA,IAAI,CAAC,IAAA,EAAM;AACX,EAAA,IAAI;AACF,IAAA,IAAA,CAAK,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,MAAM,CAAA;AAAA,EAClC,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;;;;;;;;;"}
1
+ {"version":3,"file":"redis-dc-subscriber.js","sources":["../../../src/redis/redis-dc-subscriber.ts"],"sourcesContent":["import type { TracingChannel } from 'node:diagnostics_channel';\nimport {\n DB_OPERATION_BATCH_SIZE,\n DB_QUERY_TEXT,\n DB_SYSTEM_NAME,\n SERVER_ADDRESS,\n SERVER_PORT,\n} from '@sentry/conventions/attributes';\nimport type { Span } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startInactiveSpan } from '@sentry/core';\nimport { bindTracingChannelToSpan } from '../tracing-channel';\n\n// Channel names published by node-redis >= 5.12.0 and ioredis >= 5.11.0.\n// Hardcoded so the subscriber does not have to import either library — the\n// channels just have to be subscribed to before the user's redis code\n// publishes.\nexport const REDIS_DC_CHANNEL_COMMAND = 'node-redis:command';\nexport const REDIS_DC_CHANNEL_BATCH = 'node-redis:batch';\nexport const REDIS_DC_CHANNEL_CONNECT = 'node-redis:connect';\nexport const IOREDIS_DC_CHANNEL_COMMAND = 'ioredis:command';\nexport const IOREDIS_DC_CHANNEL_CONNECT = 'ioredis:connect';\n\nconst ORIGIN = 'auto.db.redis.diagnostic_channel';\nconst DB_SYSTEM_NAME_VALUE_REDIS = 'redis';\n\n/**\n * Shape of the `node-redis:command` channel payload published by node-redis.\n *\n * Both `command` and `args` are already redacted by node-redis itself (see\n * `sanitizeArgs` in @redis/client) using the OTel `redis-common` rules. The\n * arg array is `[<command>, <safe arg>, ..., '?', ...]` — `?` replaces any\n * value the library considers sensitive. Subscribers can emit `args` directly\n * as `db.query.text` without further serialization.\n */\nexport interface RedisCommandData {\n command: string;\n /** First arg is the command name itself; consumers should slice it off. */\n args: string[];\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/**\n * Shape of the `ioredis:command` channel payload published by ioredis >= 5.11.0.\n *\n * As with node-redis, args are already sanitized by ioredis (`sanitizeArgs` in\n * `lib/tracing.ts`) before publishing. Unlike node-redis, the command name is\n * NOT prepended to `args`.\n */\nexport interface IORedisCommandData {\n command: string;\n args: string[];\n batchMode?: 'MULTI';\n batchSize?: number;\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/** Shape of the `node-redis:batch` channel payload published by node-redis. */\nexport interface RedisBatchData {\n batchMode?: 'MULTI' | 'PIPELINE';\n batchSize?: number;\n database?: number;\n clientId?: string | number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown[];\n error?: Error;\n}\n\n/** Shape of the `*:connect` channel payload published by node-redis and ioredis. */\nexport interface RedisConnectData {\n serverAddress?: string;\n serverPort?: number;\n url?: string;\n error?: Error;\n}\n\n/**\n * Optional callback invoked once the redis command response arrives. Useful\n * for attaching response-derived attributes (e.g. cache hit/miss, payload size).\n *\n * Mirrors `@opentelemetry/instrumentation-ioredis`' response hook so existing\n * Sentry node code (`cacheResponseHook`) can be reused unchanged.\n */\nexport type RedisDiagnosticChannelResponseHook = (\n span: Span,\n cmdName: string,\n cmdArgs: string[],\n result: unknown,\n) => void;\n\n/**\n * Platform-provided factory that creates a native tracing channel for the given name. The\n * subscriber binds the span and its lifecycle onto the channel via `bindTracingChannelToSpan`,\n * which propagates the active span through the runtime's async context.\n *\n * Both Node and Deno pass `node:diagnostics_channel`'s `tracingChannel` directly.\n */\nexport type RedisTracingChannelFactory = <T extends object>(name: string) => TracingChannel<T, T>;\n\n/**\n * Subscribe Sentry span handlers to node-redis and ioredis diagnostics-channel\n * events: `node-redis:command`/`:batch`/`:connect` (published by node-redis\n * >= 5.12.0) and `ioredis:command`/`:connect` (published by ioredis >= 5.11.0).\n *\n * On older client versions the channels are never published to, so subscribers\n * are inert — there is no double-instrumentation against any IITM-based\n * patcher gated to those older versions.\n */\nexport function subscribeRedisDiagnosticChannels(\n tracingChannel: RedisTracingChannelFactory,\n responseHook?: RedisDiagnosticChannelResponseHook,\n): void {\n // node-redis: command name appears as args[0] in the channel payload, so\n // strip it before the statement and response hook see it.\n setupCommandChannel<RedisCommandData>(\n tracingChannel,\n REDIS_DC_CHANNEL_COMMAND,\n data => data.args.slice(1),\n responseHook,\n );\n setupBatchChannel(tracingChannel, REDIS_DC_CHANNEL_BATCH, data =>\n data.batchMode === 'PIPELINE' ? 'PIPELINE' : 'MULTI',\n );\n setupConnectChannel(tracingChannel, REDIS_DC_CHANNEL_CONNECT);\n // ioredis: args already exclude the command name; no slicing needed. And\n // ioredis has no separate batch channel — pipeline/MULTI metadata rides\n // on the per-command payload via `batchMode`/`batchSize`.\n setupCommandChannel<IORedisCommandData>(tracingChannel, IOREDIS_DC_CHANNEL_COMMAND, data => data.args, responseHook);\n setupConnectChannel(tracingChannel, IOREDIS_DC_CHANNEL_CONNECT);\n}\n\nfunction setupCommandChannel<T extends RedisCommandData | IORedisCommandData>(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getCommandArgs: (data: T) => string[],\n responseHook?: RedisDiagnosticChannelResponseHook,\n): void {\n bindTracingChannelToSpan(\n tracingChannel<T>(channelName),\n data => {\n // `args` is already sanitized by the publishing library (node-redis /\n // ioredis call their own `sanitizeArgs` before publishing). Join with\n // spaces to mirror the format the libraries themselves intend.\n const args = getCommandArgs(data);\n const statement = args.length ? `${data.command} ${args.join(' ')}` : data.command;\n return startInactiveSpan({\n name: `redis-${data.command}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n [DB_QUERY_TEXT]: statement,\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n {\n // Command failures are surfaced to (and usually handled by) the caller; only annotate the\n // span so we don't emit a duplicate error event for every failed command.\n captureError: false,\n beforeSpanEnd(span, data) {\n if ('error' in data) return;\n runResponseHook(responseHook, span, data.command, getCommandArgs(data), data.result);\n },\n },\n );\n}\n\nfunction setupBatchChannel(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getOperationName: (data: RedisBatchData) => string,\n): void {\n bindTracingChannelToSpan(\n tracingChannel<RedisBatchData>(channelName),\n data => {\n return startInactiveSpan({\n name: getOperationName(data),\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n // should only include batch size greater than 1,\n // or else it isn't properly considered a \"batch\"\n ...(Number(data.batchSize) > 1 ? { [DB_OPERATION_BATCH_SIZE]: data.batchSize } : {}),\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n { captureError: false },\n );\n}\n\nfunction setupConnectChannel(tracingChannel: RedisTracingChannelFactory, channelName: string): void {\n bindTracingChannelToSpan(\n tracingChannel<RedisConnectData>(channelName),\n data => {\n return startInactiveSpan({\n name: 'redis-connect',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis.connect',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n });\n },\n { captureError: false },\n );\n}\n\nfunction runResponseHook(\n hook: RedisDiagnosticChannelResponseHook | undefined,\n span: Span,\n command: string,\n args: string[],\n result: unknown,\n): void {\n if (!hook) return;\n try {\n hook(span, command, args, result);\n } catch {\n // never let user hooks break instrumentation\n }\n}\n"],"names":["tracingChannel","bindTracingChannelToSpan","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","DB_SYSTEM_NAME","DB_QUERY_TEXT","SERVER_ADDRESS","SERVER_PORT","DB_OPERATION_BATCH_SIZE"],"mappings":";;;;;;AAgBO,MAAM,wBAAA,GAA2B;AACjC,MAAM,sBAAA,GAAyB;AAC/B,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
+ {
5
+ regex: /^ECHO/i,
6
+ args: 0
7
+ },
8
+ {
9
+ regex: /^(LPUSH|MSET|PFA|PUBLISH|RPUSH|SADD|SET|SPUBLISH|XADD|ZADD)/i,
10
+ args: 1
11
+ },
12
+ {
13
+ regex: /^(HSET|HMSET|LSET|LINSERT)/i,
14
+ args: 2
15
+ },
16
+ {
17
+ regex: /^(ACL|BIT|B[LRZ]|CLIENT|CLUSTER|CONFIG|COMMAND|DECR|DEL|EVAL|EX|FUNCTION|GEO|GET|HINCR|HMGET|HSCAN|INCR|L[TRLM]|MEMORY|P[EFISTU]|RPOP|S[CDIMORSU]|XACK|X[CDGILPRT]|Z[CDILMPRS])/i,
18
+ args: -1
19
+ }
20
+ ];
21
+ const defaultDbStatementSerializer = (cmdName, cmdArgs) => {
22
+ if (Array.isArray(cmdArgs) && cmdArgs.length) {
23
+ const nArgsToSerialize = serializationSubsets.find(({ regex }) => regex.test(cmdName))?.args ?? 0;
24
+ const argsToSerialize = nArgsToSerialize >= 0 ? cmdArgs.slice(0, nArgsToSerialize) : cmdArgs.slice();
25
+ if (cmdArgs.length > argsToSerialize.length) {
26
+ argsToSerialize.push(`[${cmdArgs.length - nArgsToSerialize} other arguments]`);
27
+ }
28
+ return `${cmdName} ${argsToSerialize.join(" ")}`;
29
+ }
30
+ return cmdName;
31
+ };
32
+
33
+ exports.defaultDbStatementSerializer = defaultDbStatementSerializer;
34
+ //# sourceMappingURL=redis-statement-serializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-statement-serializer.js","sources":["../../../src/redis/redis-statement-serializer.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/instrumentation-redis-v0.62.0/packages/redis-common\n * - Upstream version: @opentelemetry/redis-common@0.38.2\n *\n * Single canonical copy, shared by the orchestrion ioredis subscriber here and\n * the node SDK's vendored redis/ioredis instrumentations (which re-export it via\n * `packages/node/src/integrations/tracing/redis/vendored/redis-common.ts`).\n */\n/* eslint-disable -- vendored @opentelemetry/redis-common */\n\n/**\n * List of regexes and the number of arguments that should be serialized for matching commands.\n * For example, HSET should serialize which key and field it's operating on, but not its value.\n * Setting the subset to -1 will serialize all arguments.\n * Commands without a match will have their first argument serialized.\n *\n * Refer to https://redis.io/commands/ for the full list.\n */\nconst serializationSubsets = [\n {\n regex: /^ECHO/i,\n args: 0,\n },\n {\n regex: /^(LPUSH|MSET|PFA|PUBLISH|RPUSH|SADD|SET|SPUBLISH|XADD|ZADD)/i,\n args: 1,\n },\n {\n regex: /^(HSET|HMSET|LSET|LINSERT)/i,\n args: 2,\n },\n {\n regex:\n /^(ACL|BIT|B[LRZ]|CLIENT|CLUSTER|CONFIG|COMMAND|DECR|DEL|EVAL|EX|FUNCTION|GEO|GET|HINCR|HMGET|HSCAN|INCR|L[TRLM]|MEMORY|P[EFISTU]|RPOP|S[CDIMORSU]|XACK|X[CDGILPRT]|Z[CDILMPRS])/i,\n args: -1,\n },\n];\n\n/**\n * Given the redis command name and arguments, return a combination of the\n * command name + the allowed arguments according to `serializationSubsets`.\n */\nexport const defaultDbStatementSerializer = (\n cmdName: string,\n cmdArgs: Array<string | Buffer | number | unknown[]>,\n): string => {\n if (Array.isArray(cmdArgs) && cmdArgs.length) {\n const nArgsToSerialize = serializationSubsets.find(({ regex }) => regex.test(cmdName))?.args ?? 0;\n const argsToSerialize: Array<string | Buffer | number | unknown[]> =\n nArgsToSerialize >= 0 ? cmdArgs.slice(0, nArgsToSerialize) : cmdArgs.slice();\n if (cmdArgs.length > argsToSerialize.length) {\n argsToSerialize.push(`[${cmdArgs.length - nArgsToSerialize} other arguments]`);\n }\n return `${cmdName} ${argsToSerialize.join(' ')}`;\n }\n return cmdName;\n};\n"],"names":[],"mappings":";;AAsBA,MAAM,oBAAA,GAAuB;AAAA,EAC3B;AAAA,IACE,KAAA,EAAO,QAAA;AAAA,IACP,IAAA,EAAM;AAAA,GACR;AAAA,EACA;AAAA,IACE,KAAA,EAAO,8DAAA;AAAA,IACP,IAAA,EAAM;AAAA,GACR;AAAA,EACA;AAAA,IACE,KAAA,EAAO,6BAAA;AAAA,IACP,IAAA,EAAM;AAAA,GACR;AAAA,EACA;AAAA,IACE,KAAA,EACE,kLAAA;AAAA,IACF,IAAA,EAAM;AAAA;AAEV,CAAA;AAMO,MAAM,4BAAA,GAA+B,CAC1C,OAAA,EACA,OAAA,KACW;AACX,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,IAAK,QAAQ,MAAA,EAAQ;AAC5C,IAAA,MAAM,gBAAA,GAAmB,oBAAA,CAAqB,IAAA,CAAK,CAAC,EAAE,KAAA,EAAM,KAAM,KAAA,CAAM,IAAA,CAAK,OAAO,CAAC,CAAA,EAAG,IAAA,IAAQ,CAAA;AAChG,IAAA,MAAM,eAAA,GACJ,oBAAoB,CAAA,GAAI,OAAA,CAAQ,MAAM,CAAA,EAAG,gBAAgB,CAAA,GAAI,OAAA,CAAQ,KAAA,EAAM;AAC7E,IAAA,IAAI,OAAA,CAAQ,MAAA,GAAS,eAAA,CAAgB,MAAA,EAAQ;AAC3C,MAAA,eAAA,CAAgB,IAAA,CAAK,CAAA,CAAA,EAAI,OAAA,CAAQ,MAAA,GAAS,gBAAgB,CAAA,iBAAA,CAAmB,CAAA;AAAA,IAC/E;AACA,IAAA,OAAO,GAAG,OAAO,CAAA,CAAA,EAAI,eAAA,CAAgB,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AAAA,EAChD;AACA,EAAA,OAAO,OAAA;AACT;;;;"}
@@ -7,7 +7,7 @@ const attributes = require('@sentry/conventions/attributes');
7
7
  const NOOP = () => {
8
8
  };
9
9
  function bindTracingChannelToSpan(channel, getSpan, opts) {
10
- const handle = bindSpanToChannelStore(channel, getSpan);
10
+ const handle = bindSpanToChannelStore(channel, getSpan, opts);
11
11
  const beforeSpanEnd = opts?.beforeSpanEnd;
12
12
  const deferSpanEnd = opts?.deferSpanEnd;
13
13
  const getErrorHint = (e) => {
@@ -78,7 +78,7 @@ function bindTracingChannelToSpan(channel, getSpan, opts) {
78
78
  }
79
79
  };
80
80
  }
81
- function bindSpanToChannelStore(channel, getSpan) {
81
+ function bindSpanToChannelStore(channel, getSpan, opts) {
82
82
  const binding = core.getAsyncContextStrategy(core.getMainCarrier()).getTracingChannelBinding?.();
83
83
  if (!binding) {
84
84
  debugBuild.DEBUG_BUILD && core.debug.log("[TracingChannel] Could not access async context binding.");
@@ -90,7 +90,8 @@ function bindSpanToChannelStore(channel, getSpan) {
90
90
  const asyncLocalStorage = binding.asyncLocalStorage;
91
91
  channel.start.bindStore(asyncLocalStorage, (data) => {
92
92
  data._sentryCallerStore = asyncLocalStorage.getStore();
93
- const span = getSpan(data);
93
+ const shouldGetSpan = !opts?.requiresParentSpan || core.getActiveSpan();
94
+ const span = shouldGetSpan ? getSpan(data) : void 0;
94
95
  if (!span) {
95
96
  return data._sentryCallerStore;
96
97
  }
@@ -117,10 +118,10 @@ function endBoundSpan(data, beforeSpanEnd) {
117
118
  span.end();
118
119
  }
119
120
  function getErrorInfo(error) {
120
- const isObject = !!error && typeof error === "object";
121
- const raw = isObject ? "message" in error ? error.message : void 0 : error;
122
- const message = raw ? String(raw) : "unknown_error";
123
- const type = isObject && "name" in error ? String(error.name) : "unknown";
121
+ const errorIsObject = core.isObjectLike(error);
122
+ const raw = errorIsObject ? "message" in error ? error.message : void 0 : error;
123
+ const message = raw ? String(raw) : void 0;
124
+ const type = errorIsObject && "name" in error ? String(error.name) : "unknown";
124
125
  return {
125
126
  message,
126
127
  attributes: {
@@ -1 +1 @@
1
- {"version":3,"file":"tracing-channel.js","sources":["../../src/tracing-channel.ts"],"sourcesContent":["import type { TracingChannel, TracingChannelSubscribers } from 'node:diagnostics_channel';\nimport type { AsyncLocalStorage } from 'node:async_hooks';\nimport type { ExclusiveEventHintOrCaptureContext, Span } from '@sentry/core';\nimport { debug, captureException, SPAN_STATUS_ERROR, getAsyncContextStrategy, getMainCarrier } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\nimport { ERROR_TYPE } from '@sentry/conventions/attributes';\n\nexport type TracingChannelPayloadWithSpan<TData extends object> = TData & {\n /**\n * The current active span for the traced call.\n */\n _sentrySpan?: Span;\n\n /**\n * The context's active store value, used to restore the context for asyncStart continuations for callback-based tracing.\n */\n _sentryCallerStore?: unknown;\n};\n\n/*\n * A type patch so that we don't have to handle all subscription types.\n */\nexport interface SentryTracingChannel<TData extends object = object> extends Omit<\n TracingChannel<TData, TracingChannelPayloadWithSpan<TData>>,\n 'subscribe' | 'unsubscribe'\n> {\n subscribe(subscribers: Partial<TracingChannelSubscribers<TracingChannelPayloadWithSpan<TData>>>): void;\n unsubscribe(subscribers: Partial<TracingChannelSubscribers<TracingChannelPayloadWithSpan<TData>>>): void;\n}\n\nexport interface TracingChannelLifeCycleOptions<TData extends object = object> {\n /**\n * Invoked with the span and the channel context object once the traced operation completes\n * Use it to enrich the span from the result/error (branch on `'error' in data` / `'result' in data`) or to run cleanup.\n */\n beforeSpanEnd?: (span: Span, data: TracingChannelPayloadWithSpan<TData>) => void;\n\n /**\n * Whether a thrown error is captured as a Sentry event. The span is always marked with error status regardless. Defaults to `false`.\n * You can alternatively pass a function that sets the ExclusiveEventHintOrCaptureContext on the captured error.\n * Set `true` for instrumentations that own the error boundary, (e.g: route handlers)\n * For database drivers, it is not recommended to set this at all.\n */\n captureError?: boolean | ((e: unknown) => ExclusiveEventHintOrCaptureContext);\n\n /**\n * Take ownership of *when* the span ends: return `true` and the helper won't end it on\n * `end`/`asyncEnd`. For results that settle out-of-band — e.g. a streamed `EventEmitter` that\n * completes via its own `'end'`/`'error'` events.\n *\n * Call `end` when it settles — `end()` on success, `end(error)` on failure. `end` owns *how* the span\n * ends (error status/attributes, `captureError`, `beforeSpanEnd`) and is idempotent. Default `false`\n * lets the helper end the span as usual.\n */\n deferSpanEnd?: (args: {\n span: Span;\n data: TracingChannelPayloadWithSpan<TData>;\n /** Ends the span: `end()` on success, `end(error)` on failure. Idempotent. */\n end: (error?: unknown) => void;\n }) => boolean;\n}\n\n/** Returned by {@link bindTracingChannelToSpan}: the bound channel plus a teardown handle. */\nexport interface TracingChannelBindingHandle<TData extends object = object> {\n /**\n * The tracing channel with the span bound into async context.\n */\n channel: SentryTracingChannel<TData>;\n\n /**\n * Tears down the binding: unsubscribes lifecycle handlers, when present, and unbinds the start store.\n * Idempotent, and a no-op when no async context binding was available.\n */\n unbind: () => void;\n}\n\nconst NOOP = (): void => {};\n\n/**\n * Bind a span and its lifecycle to a tracing channel so the span becomes the active async context\n * for the traced operation and is ended when the operation completes.\n *\n * `getSpan` may return `undefined` to opt a payload out entirely: nothing is bound, no span is\n * tracked, and the active context is left untouched. Use it for events that ride the same channel\n * but should reuse the enclosing span instead of opening (and ending) their own — e.g. an agent\n * loop's per-step events, where ending a freshly opened span would close the parent prematurely.\n */\nexport function bindTracingChannelToSpan<TData extends object>(\n channel: TracingChannel<TData, TData>,\n getSpan: (data: TracingChannelPayloadWithSpan<TData>) => Span | undefined,\n opts?: TracingChannelLifeCycleOptions<TData>,\n): TracingChannelBindingHandle<TData> {\n const handle = bindSpanToChannelStore(channel, getSpan);\n\n const beforeSpanEnd = opts?.beforeSpanEnd;\n const deferSpanEnd = opts?.deferSpanEnd;\n const getErrorHint = (e: unknown): ExclusiveEventHintOrCaptureContext => {\n if (typeof opts?.captureError === 'function') {\n return opts.captureError(e);\n }\n\n return {\n mechanism: {\n type: 'auto.diagnostic_channels.bind_span',\n handled: false,\n },\n };\n };\n\n // Apply Sentry error status + attributes (and capture, if configured) to a span. Shared by the\n // channel `error` lifecycle and the deferred `end` util so the two can't drift.\n const annotateSpanError = (span: Span, error: unknown): void => {\n if (opts?.captureError) {\n captureException(error, getErrorHint(error));\n }\n\n const { message, attributes } = getErrorInfo(error);\n span.setStatus({ code: SPAN_STATUS_ERROR, message });\n span.setAttributes(attributes);\n };\n\n // Creates an end fn for deferred handlers to use, ensures consistent span end behavior\n const makeDeferredEnd = (span: Span, data: TracingChannelPayloadWithSpan<TData>) => {\n let ended = false;\n\n return (error?: unknown): void => {\n if (ended) {\n return;\n }\n\n ended = true;\n if (error !== undefined) {\n annotateSpanError(span, error);\n }\n\n endBoundSpan(data, beforeSpanEnd);\n };\n };\n\n const subscribers: Partial<TracingChannelSubscribers<TracingChannelPayloadWithSpan<TData>>> = {\n start: NOOP,\n asyncStart: NOOP,\n end(data) {\n // The operation settled synchronously (returned or threw)\n // Presence checks because caller can return `undefined` result or throw a falsy value.\n if ('error' in data || 'result' in data) {\n const span = data._sentrySpan;\n if (span && deferSpanEnd?.({ span, data, end: makeDeferredEnd(span, data) })) {\n return;\n }\n endBoundSpan(data, beforeSpanEnd);\n }\n },\n error(data) {\n // No span was bound for this payload (`getSpan` returned undefined), so there is nothing to\n // annotate and no instrumentation that owns capturing this error.\n const span = data._sentrySpan;\n if (!span) {\n return;\n }\n\n annotateSpanError(span, data.error);\n },\n asyncEnd(data) {\n const span = data._sentrySpan;\n if (span && deferSpanEnd?.({ span, data, end: makeDeferredEnd(span, data) })) {\n return;\n }\n endBoundSpan(data, beforeSpanEnd);\n },\n };\n\n handle.channel.subscribe(subscribers);\n\n return {\n channel: handle.channel,\n unbind: () => {\n handle.channel.unsubscribe(subscribers);\n handle.unbind();\n },\n };\n}\n\n/**\n * Bind a span into the channel's async context so it becomes active for the traced operation,\n * without managing its lifecycle. The primitive behind {@link bindTracingChannelToSpan}, which\n * layers span-ending and error handling on top.\n *\n * `getSpan` may return `undefined` to leave the active context untouched for that payload.\n */\nfunction bindSpanToChannelStore<TData extends object>(\n channel: TracingChannel<TData, TData>,\n getSpan: (data: TracingChannelPayloadWithSpan<TData>) => Span | undefined,\n): TracingChannelBindingHandle<TData> {\n // Grabs the tracing channel binding defined by the AsyncContext strategy implementation\n const binding = getAsyncContextStrategy(getMainCarrier()).getTracingChannelBinding?.();\n\n // If no binding, then either the implementer doesn't support tracing channels or there is no active strategy\n // Failure mode here means we would still access the channel and potentially subscribe to it, but parenting will be off.\n if (!binding) {\n DEBUG_BUILD && debug.log('[TracingChannel] Could not access async context binding.');\n\n return {\n channel,\n unbind: NOOP,\n };\n }\n\n // Grab the ALS instance, we don't really care what is in it as long as the AsyncContext strategy can use its value to figure out parenting.\n const asyncLocalStorage = binding.asyncLocalStorage as AsyncLocalStorage<TData>;\n\n // bindStore activates the ALS for the traced call; any getStore() inside it returns the value bound for that context.\n // 1. Produce: getStoreWithActiveSpan(span) clones the current scope, plants the span via _INTERNAL_setSpanForScope, and returns { scope, isolationScope }, the active context carrying our span.\n // 2. Bind: the courier hands that opaque value to channel.start.bindStore(asyncLocalStorage, producer), which runs the traced op inside asyncLocalStorage.run(value, …); it never inspects the value.\n // 3. Read: inside the op, Sentry's scope machinery calls getScopes() → asyncStorage.getStore() on that same ALS, so getCurrentScope/getIsolationScope/getActiveSpan resolve to the scope carrying our span.\n // 4. Nest: any child span started in the traced op parents to that active span.\n channel.start.bindStore(asyncLocalStorage, (data: TracingChannelPayloadWithSpan<TData>) => {\n // Stash the caller's store before we swap in the span store, so `asyncStart` can restore it for\n // callback-style channels (see `_sentryCallerStore`).\n data._sentryCallerStore = asyncLocalStorage.getStore();\n\n const span = getSpan(data);\n if (!span) {\n // Leave the active context untouched so nested operations keep parenting to the enclosing span.\n return data._sentryCallerStore as TData;\n }\n data._sentrySpan = span;\n\n return binding.getStoreWithActiveSpan(span) as TData;\n });\n\n // Restore the caller's context for the async continuation. Only callback-style channels `runStores`\n // `asyncStart` (so the callback runs inside this store). promise channels `publish` it, leaving this\n // inert, their continuation already inherits the caller's context natively.\n channel.asyncStart.bindStore(asyncLocalStorage, (data: TracingChannelPayloadWithSpan<TData>) => {\n return data._sentryCallerStore as TData;\n });\n\n return {\n channel,\n unbind: () => {\n // Removes the stores\n channel.start.unbindStore(asyncLocalStorage);\n channel.asyncStart.unbindStore(asyncLocalStorage);\n },\n };\n}\n\nfunction endBoundSpan<TData extends object>(\n data: TracingChannelPayloadWithSpan<TData>,\n beforeSpanEnd: TracingChannelLifeCycleOptions<TData>['beforeSpanEnd'],\n): void {\n const span = data._sentrySpan;\n if (!span) {\n return;\n }\n beforeSpanEnd?.(span, data);\n span.end();\n}\n\ntype ErrorInfo = {\n message: string;\n attributes: Record<string, string>;\n};\n\n/**\n * Best-effort message and attribute extraction for thrown/rejected values.\n */\nfunction getErrorInfo(error: unknown): ErrorInfo {\n const isObject = !!error && typeof error === 'object';\n const raw = isObject ? ('message' in error ? error.message : undefined) : error;\n\n const message = raw ? String(raw) : 'unknown_error';\n const type = isObject && 'name' in error ? String(error.name) : 'unknown';\n\n return {\n message,\n attributes: {\n [ERROR_TYPE]: type,\n },\n };\n}\n"],"names":["captureException","SPAN_STATUS_ERROR","getAsyncContextStrategy","getMainCarrier","DEBUG_BUILD","debug","ERROR_TYPE"],"mappings":";;;;;;AA4EA,MAAM,OAAO,MAAY;AAAC,CAAA;AAWnB,SAAS,wBAAA,CACd,OAAA,EACA,OAAA,EACA,IAAA,EACoC;AACpC,EAAA,MAAM,MAAA,GAAS,sBAAA,CAAuB,OAAA,EAAS,OAAO,CAAA;AAEtD,EAAA,MAAM,gBAAgB,IAAA,EAAM,aAAA;AAC5B,EAAA,MAAM,eAAe,IAAA,EAAM,YAAA;AAC3B,EAAA,MAAM,YAAA,GAAe,CAAC,CAAA,KAAmD;AACvE,IAAA,IAAI,OAAO,IAAA,EAAM,YAAA,KAAiB,UAAA,EAAY;AAC5C,MAAA,OAAO,IAAA,CAAK,aAAa,CAAC,CAAA;AAAA,IAC5B;AAEA,IAAA,OAAO;AAAA,MACL,SAAA,EAAW;AAAA,QACT,IAAA,EAAM,oCAAA;AAAA,QACN,OAAA,EAAS;AAAA;AACX,KACF;AAAA,EACF,CAAA;AAIA,EAAA,MAAM,iBAAA,GAAoB,CAAC,IAAA,EAAY,KAAA,KAAyB;AAC9D,IAAA,IAAI,MAAM,YAAA,EAAc;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AU,GAAG;AAAA;AAChB,GACF;AACF;;;;"}
1
+ {"version":3,"file":"tracing-channel.js","sources":["../../src/tracing-channel.ts"],"sourcesContent":["import type { TracingChannel, TracingChannelSubscribers } from 'node:diagnostics_channel';\nimport type { AsyncLocalStorage } from 'node:async_hooks';\nimport type { ExclusiveEventHintOrCaptureContext, Span } from '@sentry/core';\nimport {\n debug,\n captureException,\n isObjectLike,\n SPAN_STATUS_ERROR,\n getAsyncContextStrategy,\n getMainCarrier,\n getActiveSpan,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\nimport { ERROR_TYPE } from '@sentry/conventions/attributes';\n\nexport type TracingChannelPayloadWithSpan<TData extends object> = TData & {\n /**\n * The current active span for the traced call.\n */\n _sentrySpan?: Span;\n\n /**\n * The context's active store value, used to restore the context for asyncStart continuations for callback-based tracing.\n */\n _sentryCallerStore?: unknown;\n};\n\n/*\n * A type patch so that we don't have to handle all subscription types.\n */\nexport interface SentryTracingChannel<TData extends object = object> extends Omit<\n TracingChannel<TData, TracingChannelPayloadWithSpan<TData>>,\n 'subscribe' | 'unsubscribe'\n> {\n subscribe(subscribers: Partial<TracingChannelSubscribers<TracingChannelPayloadWithSpan<TData>>>): void;\n unsubscribe(subscribers: Partial<TracingChannelSubscribers<TracingChannelPayloadWithSpan<TData>>>): void;\n}\n\nexport interface TracingChannelLifeCycleOptions<TData extends object = object> {\n /**\n * Invoked with the span and the channel context object once the traced operation completes\n * Use it to enrich the span from the result/error (branch on `'error' in data` / `'result' in data`) or to run cleanup.\n */\n beforeSpanEnd?: (span: Span, data: TracingChannelPayloadWithSpan<TData>) => void;\n\n /**\n * Whether a thrown error is captured as a Sentry event. The span is always marked with error status regardless. Defaults to `false`.\n * You can alternatively pass a function that sets the ExclusiveEventHintOrCaptureContext on the captured error.\n * Set `true` for instrumentations that own the error boundary, (e.g: route handlers)\n * For database drivers, it is not recommended to set this at all.\n */\n captureError?: boolean | ((e: unknown) => ExclusiveEventHintOrCaptureContext);\n\n /**\n * Take ownership of *when* the span ends: return `true` and the helper won't end it on\n * `end`/`asyncEnd`. For results that settle out-of-band — e.g. a streamed `EventEmitter` that\n * completes via its own `'end'`/`'error'` events.\n *\n * Call `end` when it settles — `end()` on success, `end(error)` on failure. `end` owns *how* the span\n * ends (error status/attributes, `captureError`, `beforeSpanEnd`) and is idempotent. Default `false`\n * lets the helper end the span as usual.\n */\n deferSpanEnd?: (args: {\n span: Span;\n data: TracingChannelPayloadWithSpan<TData>;\n /** Ends the span: `end()` on success, `end(error)` on failure. Idempotent. */\n end: (error?: unknown) => void;\n }) => boolean;\n\n /**\n * Apply span/scope binding only if there is a parent span, similar to returning `undefined` in the `getSpan` callback.\n * If you need to perform some conditional checking on the parent span before deciding, do it in the `getSpan` callback.\n */\n requiresParentSpan?: boolean;\n}\n\n/** Returned by {@link bindTracingChannelToSpan}: the bound channel plus a teardown handle. */\nexport interface TracingChannelBindingHandle<TData extends object = object> {\n /**\n * The tracing channel with the span bound into async context.\n */\n channel: SentryTracingChannel<TData>;\n\n /**\n * Tears down the binding: unsubscribes lifecycle handlers, when present, and unbinds the start store.\n * Idempotent, and a no-op when no async context binding was available.\n */\n unbind: () => void;\n}\n\nconst NOOP = (): void => {};\n\n/**\n * Bind a span and its lifecycle to a tracing channel so the span becomes the active async context\n * for the traced operation and is ended when the operation completes.\n *\n * `getSpan` may return `undefined` to opt a payload out entirely: nothing is bound, no span is\n * tracked, and the active context is left untouched. Use it for events that ride the same channel\n * but should reuse the enclosing span instead of opening (and ending) their own — e.g. an agent\n * loop's per-step events, where ending a freshly opened span would close the parent prematurely.\n */\nexport function bindTracingChannelToSpan<TData extends object>(\n channel: TracingChannel<TData, TData>,\n getSpan: (data: TracingChannelPayloadWithSpan<TData>) => Span | undefined,\n opts?: TracingChannelLifeCycleOptions<TData>,\n): TracingChannelBindingHandle<TData> {\n const handle = bindSpanToChannelStore(channel, getSpan, opts);\n\n const beforeSpanEnd = opts?.beforeSpanEnd;\n const deferSpanEnd = opts?.deferSpanEnd;\n const getErrorHint = (e: unknown): ExclusiveEventHintOrCaptureContext => {\n if (typeof opts?.captureError === 'function') {\n return opts.captureError(e);\n }\n\n return {\n mechanism: {\n type: 'auto.diagnostic_channels.bind_span',\n handled: false,\n },\n };\n };\n\n // Apply Sentry error status + attributes (and capture, if configured) to a span. Shared by the\n // channel `error` lifecycle and the deferred `end` util so the two can't drift.\n const annotateSpanError = (span: Span, error: unknown): void => {\n if (opts?.captureError) {\n captureException(error, getErrorHint(error));\n }\n\n const { message, attributes } = getErrorInfo(error);\n span.setStatus({ code: SPAN_STATUS_ERROR, message });\n span.setAttributes(attributes);\n };\n\n // Creates an end fn for deferred handlers to use, ensures consistent span end behavior\n const makeDeferredEnd = (span: Span, data: TracingChannelPayloadWithSpan<TData>) => {\n let ended = false;\n\n return (error?: unknown): void => {\n if (ended) {\n return;\n }\n\n ended = true;\n if (error !== undefined) {\n annotateSpanError(span, error);\n }\n\n endBoundSpan(data, beforeSpanEnd);\n };\n };\n\n const subscribers: Partial<TracingChannelSubscribers<TracingChannelPayloadWithSpan<TData>>> = {\n start: NOOP,\n asyncStart: NOOP,\n end(data) {\n // The operation settled synchronously (returned or threw)\n // Presence checks because caller can return `undefined` result or throw a falsy value.\n if ('error' in data || 'result' in data) {\n const span = data._sentrySpan;\n if (span && deferSpanEnd?.({ span, data, end: makeDeferredEnd(span, data) })) {\n return;\n }\n endBoundSpan(data, beforeSpanEnd);\n }\n },\n error(data) {\n // No span was bound for this payload (`getSpan` returned undefined), so there is nothing to\n // annotate and no instrumentation that owns capturing this error.\n const span = data._sentrySpan;\n if (!span) {\n return;\n }\n\n annotateSpanError(span, data.error);\n },\n asyncEnd(data) {\n const span = data._sentrySpan;\n if (span && deferSpanEnd?.({ span, data, end: makeDeferredEnd(span, data) })) {\n return;\n }\n endBoundSpan(data, beforeSpanEnd);\n },\n };\n\n handle.channel.subscribe(subscribers);\n\n return {\n channel: handle.channel,\n unbind: () => {\n handle.channel.unsubscribe(subscribers);\n handle.unbind();\n },\n };\n}\n\n/**\n * Bind a span into the channel's async context so it becomes active for the traced operation,\n * without managing its lifecycle. The primitive behind {@link bindTracingChannelToSpan}, which\n * layers span-ending and error handling on top.\n *\n * `getSpan` may return `undefined` to leave the active context untouched for that payload.\n */\nfunction bindSpanToChannelStore<TData extends object>(\n channel: TracingChannel<TData, TData>,\n getSpan: (data: TracingChannelPayloadWithSpan<TData>) => Span | undefined,\n opts?: Pick<TracingChannelLifeCycleOptions, 'requiresParentSpan'>,\n): TracingChannelBindingHandle<TData> {\n // Grabs the tracing channel binding defined by the AsyncContext strategy implementation\n const binding = getAsyncContextStrategy(getMainCarrier()).getTracingChannelBinding?.();\n\n // If no binding, then either the implementer doesn't support tracing channels or there is no active strategy\n // Failure mode here means we would still access the channel and potentially subscribe to it, but parenting will be off.\n if (!binding) {\n DEBUG_BUILD && debug.log('[TracingChannel] Could not access async context binding.');\n\n return {\n channel,\n unbind: NOOP,\n };\n }\n\n // Grab the ALS instance, we don't really care what is in it as long as the AsyncContext strategy can use its value to figure out parenting.\n const asyncLocalStorage = binding.asyncLocalStorage as AsyncLocalStorage<TData>;\n\n // bindStore activates the ALS for the traced call; any getStore() inside it returns the value bound for that context.\n // 1. Produce: getStoreWithActiveSpan(span) clones the current scope, plants the span via _INTERNAL_setSpanForScope, and returns { scope, isolationScope }, the active context carrying our span.\n // 2. Bind: the courier hands that opaque value to channel.start.bindStore(asyncLocalStorage, producer), which runs the traced op inside asyncLocalStorage.run(value, …); it never inspects the value.\n // 3. Read: inside the op, Sentry's scope machinery calls getScopes() → asyncStorage.getStore() on that same ALS, so getCurrentScope/getIsolationScope/getActiveSpan resolve to the scope carrying our span.\n // 4. Nest: any child span started in the traced op parents to that active span.\n channel.start.bindStore(asyncLocalStorage, (data: TracingChannelPayloadWithSpan<TData>) => {\n // Stash the caller's store before we swap in the span store, so `asyncStart` can restore it for\n // callback-style channels (see `_sentryCallerStore`).\n data._sentryCallerStore = asyncLocalStorage.getStore();\n\n const shouldGetSpan = !opts?.requiresParentSpan || getActiveSpan();\n const span = shouldGetSpan ? getSpan(data) : undefined;\n if (!span) {\n // Leave the active context untouched so nested operations keep parenting to the enclosing span.\n return data._sentryCallerStore as TData;\n }\n data._sentrySpan = span;\n\n return binding.getStoreWithActiveSpan(span) as TData;\n });\n\n // Restore the caller's context for the async continuation. Only callback-style channels `runStores`\n // `asyncStart` (so the callback runs inside this store). promise channels `publish` it, leaving this\n // inert, their continuation already inherits the caller's context natively.\n channel.asyncStart.bindStore(asyncLocalStorage, (data: TracingChannelPayloadWithSpan<TData>) => {\n return data._sentryCallerStore as TData;\n });\n\n return {\n channel,\n unbind: () => {\n // Removes the stores\n channel.start.unbindStore(asyncLocalStorage);\n channel.asyncStart.unbindStore(asyncLocalStorage);\n },\n };\n}\n\nfunction endBoundSpan<TData extends object>(\n data: TracingChannelPayloadWithSpan<TData>,\n beforeSpanEnd: TracingChannelLifeCycleOptions<TData>['beforeSpanEnd'],\n): void {\n const span = data._sentrySpan;\n if (!span) {\n return;\n }\n beforeSpanEnd?.(span, data);\n span.end();\n}\n\ntype ErrorInfo = {\n message: string | undefined;\n attributes: Record<string, string>;\n};\n\n/**\n * Best-effort message and attribute extraction for thrown/rejected values.\n */\nfunction getErrorInfo(error: unknown): ErrorInfo {\n const errorIsObject = isObjectLike(error);\n const raw = errorIsObject ? ('message' in error ? error.message : undefined) : error;\n\n // Leave the status message unset if not set (e.g. an `AggregateError` from\n // ECONNREFUSED, whose `.message` is empty). Otherwise cast to string.\n const message = raw ? String(raw) : undefined;\n const type = errorIsObject && 'name' in error ? String(error.name) : 'unknown';\n\n return {\n message,\n attributes: {\n [ERROR_TYPE]: type,\n },\n };\n}\n"],"names":["captureException","SPAN_STATUS_ERROR","getAsyncContextStrategy","getMainCarrier","DEBUG_BUILD","debug","getActiveSpan","isObjectLike","ERROR_TYPE"],"mappings":";;;;;;AA0FA,MAAM,OAAO,MAAY;AAAC,CAAA;AAWnB,SAAS,wBAAA,CACd,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