@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-js.js","sources":["../../../../src/integrations/tracing-channel/postgres-js.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { DB_QUERY_TEXT, DB_SYSTEM_NAME, ERROR_TYPE } from '@sentry/conventions/attributes';\nimport type { IntegrationFn, PostgresConnectionContext, Span } from '@sentry/core';\nimport {\n _INTERNAL_buildPostgresConnectionContext,\n _INTERNAL_reconstructPostgresQuery,\n _INTERNAL_sanitizeSqlQuery,\n _INTERNAL_setPostgresConnectionAttributes,\n _INTERNAL_setPostgresOperationName,\n debug,\n defineIntegration,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Same name as the OTel `PostgresJs` integration by design: when this is\n// enabled, the OTel integration of the same name is dropped from the default\n// set (see `experimentalUseDiagnosticsChannelInjection`).\nconst INTEGRATION_NAME = 'PostgresJs' as const;\n\nconst ORIGIN = 'auto.db.orchestrion.postgresjs';\n\n// Not part of `@sentry/conventions`, so we keep it inline (matches the OTel `PostgresJsInstrumentation`).\nconst DB_RESPONSE_STATUS_CODE = 'db.response.status_code';\n\nconst NOOP = (): void => {};\n\n// Same `Symbol.for()` marker the core `instrumentPostgresJsSql` wrapper sets on\n// queries it manually instruments, so we skip them there and never double-span.\nconst QUERY_FROM_INSTRUMENTED_SQL = Symbol.for('sentry.query.from.instrumented.sql');\n// The query span, stashed on the `Query` so the `execute`/`connect` channels can\n// attach connection attributes to it.\nconst QUERY_SPAN = Symbol('sentryPostgresJsSpan');\n// Set once connection attributes are on the span, so the fallback and the\n// `execute`/`connect` channels don't both write them.\nconst CONNECTION_ATTRS_SET = Symbol('sentryPostgresJsConnectionAttrsSet');\n// Set on the channel context once the resolve/reject wrappers have ended the\n// span, so `deferSpanEnd` knows the wrappers own the lifecycle.\nconst SPAN_ENDED = Symbol('sentryPostgresJsSpanEnded');\n\nexport interface PostgresJsChannelIntegrationOptions {\n /**\n * Only create spans when there's already an active parent span. Defaults to\n * `true`, matching the OTel `postgresJsIntegration`.\n */\n requireParentSpan?: boolean;\n /**\n * Hook to modify the query span before the query runs. Receives the span, the\n * sanitized SQL, and (when resolvable) the connection context.\n */\n requestHook?: (span: Span, sanitizedSqlQuery: string, postgresConnectionContext?: PostgresConnectionContext) => void;\n}\n\n/** The `Query` instance postgres.js passes as `self` to `Query.prototype.handle`. */\ninterface PostgresQuery {\n strings?: string[];\n executed?: boolean;\n resolve?: (...args: unknown[]) => unknown;\n reject?: (...args: unknown[]) => unknown;\n}\n\ninterface PostgresJsQueryContext {\n arguments?: unknown[];\n self?: PostgresQuery;\n result?: unknown;\n error?: unknown;\n}\n\n// A connection object -> its resolved context, populated on the `connection`\n// channel and read on the `execute`/`connect` channels (keyed by the same object).\nconst connectionContexts = new WeakMap<object, PostgresConnectionContext>();\n// Distinct endpoints seen so far (value-compared, so N connections to one DB\n// count once). When exactly one endpoint exists — the common case, and the only\n// one the tests exercise — every query resolves to it at handle-start.\nconst endpointRegistry: PostgresConnectionContext[] = [];\n\nfunction registerEndpoint(context: PostgresConnectionContext): void {\n const alreadyKnown = endpointRegistry.some(\n e =>\n e.ATTR_SERVER_ADDRESS === context.ATTR_SERVER_ADDRESS &&\n e.ATTR_SERVER_PORT === context.ATTR_SERVER_PORT &&\n e.ATTR_DB_NAMESPACE === context.ATTR_DB_NAMESPACE,\n );\n if (!alreadyKnown) {\n endpointRegistry.push(context);\n }\n}\n\n/** The single known endpoint, or `undefined` when zero or multiple are known. */\nfunction resolveSingleEndpoint(): PostgresConnectionContext | undefined {\n return endpointRegistry.length === 1 ? endpointRegistry[0] : undefined;\n}\n\n/**\n * Record a connection from the `connection` channel `end` (`result` is the\n * connection object, `arguments[0]` the parsed options), keying its resolved\n * context by the connection object and tracking its endpoint.\n */\nfunction recordConnectionFromChannel(message: PostgresJsQueryContext): void {\n const connection = message.result;\n const options = message.arguments?.[0] as { host?: string[]; port?: number[]; database?: string } | undefined;\n if (!connection || typeof connection !== 'object' || !options) {\n return;\n }\n const context = _INTERNAL_buildPostgresConnectionContext(options);\n connectionContexts.set(connection, context);\n registerEndpoint(context);\n}\n\nfunction setConnectionAttributes(span: Span, query: PostgresQuery, context: PostgresConnectionContext): void {\n const queryRecord = query as Record<symbol, unknown>;\n if (queryRecord[CONNECTION_ATTRS_SET]) {\n return;\n }\n queryRecord[CONNECTION_ATTRS_SET] = true;\n _INTERNAL_setPostgresConnectionAttributes(span, context);\n}\n\n/**\n * Backfill connection attributes onto a query's span from a channel whose `self`\n * is the connection object and `arguments[0]` the query. Shared by the `execute`\n * and `connect` channels; both carry that shape and both resolve the context via\n * the `connectionContexts` WeakMap. Idempotent (guarded inside `setConnectionAttributes`).\n */\nfunction attachConnectionAttributesFromChannel(message: PostgresJsQueryContext): void {\n const connection = message.self as object | undefined;\n const query = message.arguments?.[0] as PostgresQuery | undefined;\n if (!connection || !query) {\n return;\n }\n const span = (query as Record<symbol, unknown>)[QUERY_SPAN] as Span | undefined;\n const context = connectionContexts.get(connection);\n if (span && context) {\n setConnectionAttributes(span, query, context);\n }\n}\n\n/**\n * Wrap `query.resolve`/`query.reject` so the span ends when the query settles.\n *\n * `Query extends Promise` and `async handle()` only dispatches — its promise\n * resolves immediately, long before the query completes. postgres.js signals\n * completion by calling `this.resolve`/`this.reject`, so we own the span end\n * there. Wrapping happens at handle-start because `reject` can fire\n * synchronously during dispatch and `cursor()` reassigns both before executing.\n */\nfunction wrapQuerySettlement(data: PostgresJsQueryContext, span: Span, sanitizedSqlQuery: string): void {\n const query = data.self;\n if (!query) {\n return;\n }\n\n // Claim ownership of ending the span up front, so `deferSpanEnd` defers to the\n // wrapper even if `span.end()` below throws.\n const markEnded = (): void => {\n (data as Record<symbol, unknown>)[SPAN_ENDED] = true;\n };\n\n const originalResolve = query.resolve;\n if (typeof originalResolve === 'function') {\n query.resolve = function (this: unknown, ...resolveArgs: unknown[]): unknown {\n markEnded();\n try {\n const command = (resolveArgs[0] as { command?: string } | undefined)?.command;\n _INTERNAL_setPostgresOperationName(span, sanitizedSqlQuery, command);\n span.end();\n } catch (e) {\n DEBUG_BUILD && debug.error('[orchestrion:postgresjs] error ending span in resolve:', e);\n }\n return originalResolve.apply(this, resolveArgs);\n };\n }\n\n const originalReject = query.reject;\n if (typeof originalReject === 'function') {\n query.reject = function (this: unknown, ...rejectArgs: unknown[]): unknown {\n markEnded();\n try {\n const err = rejectArgs[0] as { message?: string; code?: string; name?: string } | undefined;\n span.setStatus({ code: SPAN_STATUS_ERROR, message: err?.message || 'unknown_error' });\n span.setAttribute(DB_RESPONSE_STATUS_CODE, err?.code || 'unknown');\n span.setAttribute(ERROR_TYPE, err?.name || 'unknown');\n _INTERNAL_setPostgresOperationName(span, sanitizedSqlQuery);\n span.end();\n } catch (e) {\n DEBUG_BUILD && debug.error('[orchestrion:postgresjs] error ending span in reject:', e);\n }\n return originalReject.apply(this, rejectArgs);\n };\n }\n}\n\nconst _postgresJsChannelIntegration = ((options: PostgresJsChannelIntegrationOptions = {}) => {\n const { requireParentSpan, requestHook } = options;\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19.\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD && debug.log(`[orchestrion:postgresjs] subscribing to \"${CHANNELS.POSTGRESJS_HANDLE}\"`);\n\n // Connection + execute are pure observers (no span, no async binding), so\n // subscribe immediately — factory-time `Connection()` calls happen before\n // `waitForTracingChannelBinding` resolves and must still be recorded.\n diagnosticsChannel.tracingChannel<PostgresJsQueryContext>(CHANNELS.POSTGRESJS_CONNECTION).subscribe({\n start: NOOP,\n asyncStart: NOOP,\n asyncEnd: NOOP,\n error: NOOP,\n end: recordConnectionFromChannel,\n });\n\n // Per-connection attributes for queries reusing an already-open connection\n // (`c.execute(q)`, `self === c`). `execute` is also called bare\n // (`self === undefined`) for the first query on each connection, `fetchState`\n // and `retry`; those miss here (the `connect` channel below covers the first\n // user query, and the single-endpoint fallback covers the common case).\n diagnosticsChannel.tracingChannel<PostgresJsQueryContext>(CHANNELS.POSTGRESJS_EXECUTE).subscribe({\n end: NOOP,\n asyncStart: NOOP,\n asyncEnd: NOOP,\n error: NOOP,\n start: attachConnectionAttributesFromChannel,\n });\n\n // The connection's `connect(query)` method (`self === c`, `arguments[0]` the\n // query) fires when a fresh connection is opened for a query. That first query\n // is later dispatched via a bare `execute` (no `self`), so this is where it\n // gets its connection attributes in multi-endpoint apps.\n diagnosticsChannel.tracingChannel<PostgresJsQueryContext>(CHANNELS.POSTGRESJS_CONNECT).subscribe({\n end: NOOP,\n asyncStart: NOOP,\n asyncEnd: NOOP,\n error: NOOP,\n start: attachConnectionAttributesFromChannel,\n });\n\n // The span-creating `handle` subscription needs the async-context binding\n // that `initOpenTelemetry()` registers after integration setup.\n waitForTracingChannelBinding(() => {\n bindTracingChannelToSpan<PostgresJsQueryContext>(\n diagnosticsChannel.tracingChannel<PostgresJsQueryContext>(CHANNELS.POSTGRESJS_HANDLE),\n data => {\n const query = data.self;\n if (!query) {\n return undefined;\n }\n\n // Opt out of re-entrant `handle()` calls (then/catch/finally re-invoke it, guarded by\n // `executed`) and queries already wrapped by the portable `instrumentPostgresJsSql`. The\n // parent-span requirement is applied via `requiresParentSpan` below.\n if (query.executed === true || (query as Record<symbol, unknown>)[QUERY_FROM_INSTRUMENTED_SQL]) {\n return undefined;\n }\n\n const fullQuery = _INTERNAL_reconstructPostgresQuery(query.strings);\n const sanitizedSqlQuery = _INTERNAL_sanitizeSqlQuery(fullQuery);\n\n // `kind: CLIENT` matches the mysql/pg channel subscribers.\n const span = startInactiveSpan({\n name: sanitizedSqlQuery || 'postgresjs.query',\n op: 'db',\n kind: SPAN_KIND.CLIENT,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [DB_SYSTEM_NAME]: 'postgres',\n [DB_QUERY_TEXT]: sanitizedSqlQuery,\n },\n });\n\n // Stash for the `execute`/`connect` channels to attach per-connection attributes.\n (query as Record<symbol, unknown>)[QUERY_SPAN] = span;\n\n // Single-endpoint fallback: resolve context now so `requestHook` has it\n // and the first-query-per-connection (bare `execute`) path still gets attrs.\n const context = resolveSingleEndpoint();\n if (context) {\n setConnectionAttributes(span, query, context);\n }\n\n if (requestHook) {\n try {\n requestHook(span, sanitizedSqlQuery, context);\n } catch (e) {\n span.setAttribute('sentry.hook.error', 'requestHook failed');\n DEBUG_BUILD && debug.error('[orchestrion:postgresjs] error in requestHook:', e);\n }\n }\n\n wrapQuerySettlement(data, span, sanitizedSqlQuery);\n\n return span;\n },\n {\n requiresParentSpan: requireParentSpan !== false,\n deferSpanEnd({ data }) {\n // `handle` is async: its promise settles on dispatch (asyncEnd), long\n // before the query does. The resolve/reject wrappers own the ending.\n if ((data as Record<symbol, unknown>)[SPAN_ENDED]) {\n return true; // wrappers already ended it\n }\n if ('error' in data) {\n return false; // `handle()` itself threw; the error subscriber annotated the span, let the helper end it\n }\n // NOTE: for a cursor consumed as an async iterator, only the first batch\n // reaches `handle` (the `executed` guard blocks the rest), so the span\n // ends on the first batch — a pre-existing flaw kept for parity.\n return true; // query in flight; the wrappers will end the span when it settles\n },\n },\n );\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * EXPERIMENTAL — orchestrion-driven postgres.js (`postgres` v3.x) integration.\n *\n * Subscribes to the `orchestrion:postgres:handle` / `:connection` / `:execute` /\n * `:connect` diagnostics channels injected into postgres.js' `Query.prototype.handle`\n * and `Connection`/`execute`/`connect` (in `src/*` and `cjs/src/*`) and creates db\n * spans matching the OTel `postgresJsIntegration`. Requires the orchestrion runtime\n * hook or bundler plugin.\n */\nexport const postgresJsChannelIntegration = defineIntegration(_postgresJsChannelIntegration);\n"],"names":["_INTERNAL_buildPostgresConnectionContext","_INTERNAL_setPostgresConnectionAttributes","_INTERNAL_setPostgresOperationName","DEBUG_BUILD","debug","SPAN_STATUS_ERROR","ERROR_TYPE","CHANNELS","waitForTracingChannelBinding","bindTracingChannelToSpan","_INTERNAL_reconstructPostgresQuery","_INTERNAL_sanitizeSqlQuery","startInactiveSpan","SPAN_KIND","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","DB_SYSTEM_NAME","DB_QUERY_TEXT","defineIntegration"],"mappings":";;;;;;;;;AAwBA,MAAM,gBAAA,GAAmB,YAAA;AAEzB,MAAM,MAAA,GAAS,gCAAA;AAGf,MAAM,uBAAA,GAA0B,yBAAA;AAEhC,MAAM,OAAO,MAAY;AAAC,CAAA;AAI1B,MAAM,2BAAA,mBAA8B,MAAA,CAAO,GAAA,CAAI,oCAAoC,CAAA;AAGnF,MAAM,UAAA,0BAAoB,sBAAsB,CAAA;AAGhD,MAAM,oBAAA,0BAA8B,oCAAoC,CAAA;AAGxE,MAAM,UAAA,0BAAoB,2BAA2B,CAAA;AAgCrD,MAAM,kBAAA,uBAAyB,OAAA,EAA2C;AAI1E,MAAM,mBAAgD,EAAC;AAEvD,SAAS,iBAAiB,OAAA,EAA0C;AAClE,EAAA,MAAM,eAAe,gBAAA,CAAiB,IAAA;AAAA,IACpC,CAAA,CAAA,KACE,CAAA,CAAE,mBAAA,KAAwB,OAAA,CAAQ,mBAAA,IAClC,CAAA,CAAE,gBAAA,KAAqB,OAAA,CAAQ,gBAAA,IAC/B,CAAA,CAAE,iBAAA,KAAsB,OAAA,CAAQ;AAAA,GACpC;AACA,EAAA,IAAI,CAAC,YAAA,EAAc;AACjB,IAAA,gBAAA,CAAiB,KAAK,OAAO,CAAA;AAAA,EAC/B;AACF;AAGA,SAAS,qBA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A,EAAsB;AACtC,YAAA,IAAI,OAAA,EAAS;AACX,cAAA,uBAAA,CAAwB,IAAA,EAAM,OAAO,OAAO,CAAA;AAAA,YAC9C;AAEA,YAAA,IAAI,WAAA,EAAa;AACf,cAAA,IAAI;AACF,gBAAA,WAAA,CAAY,IAAA,EAAM,mBAAmB,OAAO,CAAA;AAAA,cAC9C,SAAS,CAAA,EAAG;AACV,gBAAA,IAAA,CAAK,YAAA,CAAa,qBAAqB,oBAAoB,CAAA;AAC3D,gBAAAb,sBAAA,IAAeC,UAAA,CAAM,KAAA,CAAM,gDAAA,EAAkD,CAAC,CAAA;AAAA,cAChF;AAAA,YACF;AAEA,YAAA,mBAAA,CAAoB,IAAA,EAAM,MAAM,iBAAiB,CAAA;AAEjD,YAAA,OAAO,IAAA;AAAA,UACT,CAAA;AAAA,UACA;AAAA,YACE,oBAAoB,iBAAA,KAAsB,KAAA;AAAA,YAC1C,YAAA,CAAa,EAAE,IAAA,EAAK,EAAG;AAGrB,cAAA,IAAK,IAAA,CAAiC,UAAU,CAAA,EAAG;AACjD,gBAAA,OAAO,IAAA;AAAA,cACT;AACA,cAAA,IAAI,WAAW,IAAA,EAAM;AACnB,gBAAA,OAAO,KAAA;AAAA,cACT;AAIA,cAAA,OAAO,IAAA;AAAA,YACT;AAAA;AACF,SACF;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAWO,MAAM,4BAAA,GAA+Ba,uBAAkB,6BAA6B;;;;"}
@@ -0,0 +1,170 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const diagnosticsChannel = require('node:diagnostics_channel');
4
+ const core = require('@sentry/core');
5
+ const debugBuild = require('../../debug-build.js');
6
+ const channels = require('../../orchestrion/channels.js');
7
+ const tracingChannel = require('../../tracing-channel.js');
8
+
9
+ const INTEGRATION_NAME = "Postgres";
10
+ const ORIGIN = "auto.db.orchestrion.postgres";
11
+ const ATTR_DB_SYSTEM = "db.system";
12
+ const ATTR_DB_NAME = "db.name";
13
+ const ATTR_DB_CONNECTION_STRING = "db.connection_string";
14
+ const ATTR_DB_USER = "db.user";
15
+ const ATTR_DB_STATEMENT = "db.statement";
16
+ const ATTR_NET_PEER_NAME = "net.peer.name";
17
+ const ATTR_NET_PEER_PORT = "net.peer.port";
18
+ const ATTR_PG_PLAN = "db.postgresql.plan";
19
+ const ATTR_PG_IDLE_TIMEOUT = "db.postgresql.idle.timeout.millis";
20
+ const ATTR_PG_MAX_CLIENT = "db.postgresql.max.client";
21
+ const DB_SYSTEM_POSTGRESQL = "postgresql";
22
+ const SPAN_QUERY_FALLBACK = "pg.query";
23
+ const SPAN_CONNECT = "pg.connect";
24
+ const SPAN_POOL_CONNECT = "pg-pool.connect";
25
+ const _postgresChannelIntegration = ((options = {}) => {
26
+ return {
27
+ name: INTEGRATION_NAME,
28
+ setupOnce() {
29
+ if (!diagnosticsChannel.tracingChannel) {
30
+ return;
31
+ }
32
+ core.waitForTracingChannelBinding(() => {
33
+ subscribeQueryLikeChannel(channels.CHANNELS.PG_QUERY, querySpanOptions, { deferStreamedResult: true });
34
+ if (!options.ignoreConnectSpans) {
35
+ subscribeQueryLikeChannel(channels.CHANNELS.PG_CONNECT, connectSpanOptions);
36
+ subscribeQueryLikeChannel(channels.CHANNELS.PGPOOL_CONNECT, poolConnectSpanOptions);
37
+ }
38
+ });
39
+ }
40
+ };
41
+ });
42
+ function subscribeQueryLikeChannel(channelName, getSpanOptions, { deferStreamedResult = false } = {}) {
43
+ debugBuild.DEBUG_BUILD && core.debug.log(`[orchestrion:pg] subscribing to channel "${channelName}"`);
44
+ tracingChannel.bindTracingChannelToSpan(
45
+ diagnosticsChannel.tracingChannel(channelName),
46
+ (data) => {
47
+ data._sentryCallerScope = core.getCurrentScope();
48
+ return core.startInactiveSpan({ ...getSpanOptions(data), kind: core.SPAN_KIND.CLIENT });
49
+ },
50
+ // `connect`/`pool-connect` resolve with a persistent `Client` (itself an
51
+ // `EventEmitter`), which is NOT a streamed result. Deferring their span
52
+ // to that emitter's `'end'`/`'error'` would keep it open for the whole
53
+ // connection lifetime, so it never ends in time and is dropped. Only
54
+ // `query` can return a streamable `Submittable`, so only it defers.
55
+ deferStreamedResult ? {
56
+ // Only instrument under an active span, leaving the context untouched otherwise
57
+ // (e.g. connects issued during app startup).
58
+ requiresParentSpan: true,
59
+ // Streamable `Submittable` (e.g. `client.query(new Query())`)
60
+ // returns an emitter that orchestrion stores on `ctx.result` while
61
+ // firing no async events; the query isn't done until the emitter
62
+ // emits `'end'`/`'error'`. Defer ending to those events for that
63
+ // path; the callback, promise, and sync-throw paths carry no
64
+ // emitter, so the helper ends the span as usual.
65
+ deferSpanEnd({ data, end }) {
66
+ const result = data.result;
67
+ if (!result || typeof result !== "object" || !hasOnMethod(result)) {
68
+ return false;
69
+ }
70
+ const callerScope = data._sentryCallerScope;
71
+ if (callerScope) {
72
+ core.bindScopeToEmitter(result, callerScope);
73
+ }
74
+ result.on("error", (err) => end(err));
75
+ result.on("end", () => end());
76
+ return true;
77
+ }
78
+ } : { requiresParentSpan: true }
79
+ );
80
+ }
81
+ function querySpanOptions(ctx) {
82
+ const params = ctx.self?.connectionParameters ?? {};
83
+ const queryConfig = extractQueryConfig(ctx.arguments);
84
+ return {
85
+ // The description is the SQL statement
86
+ name: queryConfig?.text ?? SPAN_QUERY_FALLBACK,
87
+ op: "db",
88
+ attributes: {
89
+ ...getConnectionAttributes(params),
90
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
91
+ [ATTR_DB_STATEMENT]: queryConfig?.text || void 0,
92
+ [ATTR_PG_PLAN]: typeof queryConfig?.name === "string" ? queryConfig.name : void 0
93
+ }
94
+ };
95
+ }
96
+ function connectSpanOptions(ctx) {
97
+ const params = ctx.self?.connectionParameters ?? {};
98
+ return { name: SPAN_CONNECT, op: "db", attributes: getConnectionAttributes(params) };
99
+ }
100
+ function poolConnectSpanOptions(ctx) {
101
+ const opts = ctx.self?.options ?? {};
102
+ return { name: SPAN_POOL_CONNECT, op: "db", attributes: getPoolConnectionAttributes(opts) };
103
+ }
104
+ function hasOnMethod(obj) {
105
+ return "on" in obj && typeof obj.on === "function";
106
+ }
107
+ function extractQueryConfig(args) {
108
+ const arg0 = args[0];
109
+ if (typeof arg0 === "string") {
110
+ return { text: arg0 };
111
+ }
112
+ if (core.isObjectLike(arg0) && typeof arg0.text === "string") {
113
+ const obj = arg0;
114
+ return { text: obj.text, name: obj.name };
115
+ }
116
+ return void 0;
117
+ }
118
+ function getConnectionAttributes(params) {
119
+ return {
120
+ [ATTR_DB_SYSTEM]: DB_SYSTEM_POSTGRESQL,
121
+ [ATTR_DB_CONNECTION_STRING]: getConnectionString(params),
122
+ [ATTR_DB_NAME]: params.database,
123
+ [ATTR_DB_USER]: params.user,
124
+ [ATTR_NET_PEER_NAME]: params.host,
125
+ [ATTR_NET_PEER_PORT]: Number.isInteger(params.port) ? params.port : void 0
126
+ };
127
+ }
128
+ function getPoolConnectionAttributes(opts) {
129
+ let url;
130
+ try {
131
+ url = opts.connectionString ? new URL(opts.connectionString) : void 0;
132
+ } catch {
133
+ url = void 0;
134
+ }
135
+ const database = url?.pathname.slice(1) || opts.database;
136
+ const host = url?.hostname || opts.host;
137
+ const port = Number(url?.port) || (Number.isInteger(opts.port) ? opts.port : void 0);
138
+ const user = url?.username || opts.user;
139
+ return {
140
+ [ATTR_DB_SYSTEM]: DB_SYSTEM_POSTGRESQL,
141
+ [ATTR_DB_CONNECTION_STRING]: getConnectionString(opts),
142
+ [ATTR_PG_IDLE_TIMEOUT]: opts.idleTimeoutMillis,
143
+ [ATTR_PG_MAX_CLIENT]: opts.max,
144
+ [ATTR_DB_NAME]: database,
145
+ [ATTR_NET_PEER_PORT]: port,
146
+ // these two come from a url parse and slice, can be ''
147
+ [ATTR_NET_PEER_NAME]: host || void 0,
148
+ [ATTR_DB_USER]: user || void 0
149
+ };
150
+ }
151
+ function getConnectionString(params) {
152
+ if (params.connectionString) {
153
+ try {
154
+ const url = new URL(params.connectionString);
155
+ url.username = "";
156
+ url.password = "";
157
+ return url.toString();
158
+ } catch {
159
+ return "postgresql://localhost:5432/";
160
+ }
161
+ }
162
+ const host = params.host || "localhost";
163
+ const port = params.port || 5432;
164
+ const database = params.database || "";
165
+ return `postgresql://${host}:${port}/${database}`;
166
+ }
167
+ const postgresChannelIntegration = core.defineIntegration(_postgresChannelIntegration);
168
+
169
+ exports.postgresChannelIntegration = postgresChannelIntegration;
170
+ //# sourceMappingURL=postgres.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres.js","sources":["../../../../src/integrations/tracing-channel/postgres.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn, Scope, SpanAttributes } from '@sentry/core';\nimport {\n isObjectLike,\n bindScopeToEmitter,\n debug,\n defineIntegration,\n getCurrentScope,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// NOTE: this uses the same name as the OTel integration by design.\n// When enabled, the OTel 'Postgres' integration is omitted from the default set.\nconst INTEGRATION_NAME = 'Postgres' as const;\n\n// Only the query span carries an origin (the connect/pool-connect spans don't,\n// so they default to 'manual').\nconst ORIGIN = 'auto.db.orchestrion.postgres';\n\n// OpenTelemetry \"OLD\" db/net semantic-conventions, inlined to keep this\n// integration free of `@opentelemetry/*` deps.\nconst ATTR_DB_SYSTEM = 'db.system';\nconst ATTR_DB_NAME = 'db.name';\nconst ATTR_DB_CONNECTION_STRING = 'db.connection_string';\nconst ATTR_DB_USER = 'db.user';\nconst ATTR_DB_STATEMENT = 'db.statement';\nconst ATTR_NET_PEER_NAME = 'net.peer.name';\nconst ATTR_NET_PEER_PORT = 'net.peer.port';\nconst ATTR_PG_PLAN = 'db.postgresql.plan';\nconst ATTR_PG_IDLE_TIMEOUT = 'db.postgresql.idle.timeout.millis';\nconst ATTR_PG_MAX_CLIENT = 'db.postgresql.max.client';\nconst DB_SYSTEM_POSTGRESQL = 'postgresql';\n\n// We set `op: 'db'` and the SQL description directly here (same as mysql\n// orchestrion) rather than relying on the OTel pipeline's `inferDbSpanData`\n// processor, which only runs in the node SDK, so setting them here is what\n// makes the spans correct on the other runtimes\n//\n// The user-visible span is identical to OTel: query spans are named after\n// `db.statement`; connect/pool-connect spans keep these names.\nconst SPAN_QUERY_FALLBACK = 'pg.query';\nconst SPAN_CONNECT = 'pg.connect';\nconst SPAN_POOL_CONNECT = 'pg-pool.connect';\n\n/**\n * The shape orchestrion's transform attaches to the tracing-channel `context`. Documented here rather\n * than imported because orchestrion's runtime doesn't export it.\n */\ninterface PgChannelContext {\n // The live args array passed to the wrapped `query`/`connect` call.\n arguments: unknown[];\n self?: unknown;\n result?: unknown;\n error?: unknown;\n // The caller's scope, captured at `start` and replayed onto a streamed `Submittable` emitter (see below).\n _sentryCallerScope?: Scope;\n}\n\ninterface PgConnectionParams {\n database?: string;\n host?: string;\n port?: number;\n user?: string;\n connectionString?: string;\n}\n\ninterface PgPoolOptions extends PgConnectionParams {\n idleTimeoutMillis?: number;\n // pg-pool stores the max pool size as `max` (defaulting it to 10 in its\n // constructor). The OTel pg instrumentation reads a `maxClient` field that\n // pg-pool never sets, so its `db.postgresql.max.client` attribute is always\n // dropped; we read the real `max` so the attribute is actually populated.\n max?: number;\n}\n\nconst _postgresChannelIntegration = ((options: { ignoreConnectSpans?: boolean } = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19 so do nothing in that case.\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n // Query spans: `pg`/native `Client.prototype.query`. Only this channel can return a streamable\n // `Submittable` result, so it's the only one that defers span-ending to the emitter (see below).\n subscribeQueryLikeChannel(CHANNELS.PG_QUERY, querySpanOptions, { deferStreamedResult: true });\n\n // Connect spans, gated by `ignoreConnectSpans` (same as OTel pg).\n // `Client.prototype.connect` (pg + native)\n // and `Pool.prototype.connect` (pg-pool).\n if (!options.ignoreConnectSpans) {\n subscribeQueryLikeChannel(CHANNELS.PG_CONNECT, connectSpanOptions);\n subscribeQueryLikeChannel(CHANNELS.PGPOOL_CONNECT, poolConnectSpanOptions);\n }\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Subscribe to a pg tracing-channel and manage a span across its lifecycle.\n * Shared by the query/connect/pool-connect channels. They differ only in how\n * the span's name + attributes are built (`getSpanOptions`), and whether the\n * result can be a streamable emitter (`deferStreamedResult`, query-only).\n */\nfunction subscribeQueryLikeChannel(\n channelName: string,\n getSpanOptions: (ctx: PgChannelContext) => { name: string; op: string; attributes: SpanAttributes },\n { deferStreamedResult = false }: { deferStreamedResult?: boolean } = {},\n): void {\n DEBUG_BUILD && debug.log(`[orchestrion:pg] subscribing to channel \"${channelName}\"`);\n\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<PgChannelContext>(channelName),\n data => {\n // Capture the caller's scope while still synchronously inside the call, for the streamed path:\n // pg dispatches a `Submittable` emitter's events outside the original async scope, so `deferSpanEnd`\n // replays this scope onto that emitter.\n data._sentryCallerScope = getCurrentScope();\n\n // `kind: CLIENT` mirrors the OTel pg instrumentation, so the emitted\n // `otel.kind` matches across the OTel and diagnostics-channel paths.\n return startInactiveSpan({ ...getSpanOptions(data), kind: SPAN_KIND.CLIENT });\n },\n // `connect`/`pool-connect` resolve with a persistent `Client` (itself an\n // `EventEmitter`), which is NOT a streamed result. Deferring their span\n // to that emitter's `'end'`/`'error'` would keep it open for the whole\n // connection lifetime, so it never ends in time and is dropped. Only\n // `query` can return a streamable `Submittable`, so only it defers.\n deferStreamedResult\n ? {\n // Only instrument under an active span, leaving the context untouched otherwise\n // (e.g. connects issued during app startup).\n requiresParentSpan: true,\n // Streamable `Submittable` (e.g. `client.query(new Query())`)\n // returns an emitter that orchestrion stores on `ctx.result` while\n // firing no async events; the query isn't done until the emitter\n // emits `'end'`/`'error'`. Defer ending to those events for that\n // path; the callback, promise, and sync-throw paths carry no\n // emitter, so the helper ends the span as usual.\n deferSpanEnd({ data, end }) {\n const result = data.result;\n if (!result || typeof result !== 'object' || !hasOnMethod(result)) {\n return false;\n }\n\n // Replay the caller's scope onto the emitter so listeners theu\n // user attaches after the call returns (and any spans they start)\n // nest under the caller, not a fresh root trace.\n const callerScope = data._sentryCallerScope;\n if (callerScope) {\n bindScopeToEmitter(result, callerScope);\n }\n\n result.on('error', err => end(err));\n result.on('end', () => end());\n\n return true;\n },\n }\n : { requiresParentSpan: true },\n );\n}\n\nfunction querySpanOptions(ctx: PgChannelContext): { name: string; op: string; attributes: SpanAttributes } {\n const params = (ctx.self as { connectionParameters?: PgConnectionParams } | undefined)?.connectionParameters ?? {};\n const queryConfig = extractQueryConfig(ctx.arguments);\n return {\n // The description is the SQL statement\n name: queryConfig?.text ?? SPAN_QUERY_FALLBACK,\n op: 'db',\n attributes: {\n ...getConnectionAttributes(params),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [ATTR_DB_STATEMENT]: queryConfig?.text || undefined,\n [ATTR_PG_PLAN]: typeof queryConfig?.name === 'string' ? queryConfig.name : undefined,\n },\n };\n}\n\nfunction connectSpanOptions(ctx: PgChannelContext): { name: string; op: string; attributes: SpanAttributes } {\n const params = (ctx.self as { connectionParameters?: PgConnectionParams } | undefined)?.connectionParameters ?? {};\n // No origin set -> defaults to 'manual'\n return { name: SPAN_CONNECT, op: 'db', attributes: getConnectionAttributes(params) };\n}\n\nfunction poolConnectSpanOptions(ctx: PgChannelContext): { name: string; op: string; attributes: SpanAttributes } {\n const opts = (ctx.self as { options?: PgPoolOptions } | undefined)?.options ?? {};\n return { name: SPAN_POOL_CONNECT, op: 'db', attributes: getPoolConnectionAttributes(opts) };\n}\n\nfunction hasOnMethod(obj: object): obj is { on: (event: string, listener: (arg?: unknown) => void) => unknown } {\n return 'on' in obj && typeof (obj as { on?: unknown }).on === 'function';\n}\n\n// `client.query(text, cb?)`, `client.query(text, values, cb?)`, and\n// `client.query(configObj, cb?)` are all valid; normalize to `{ text, name }`\n// (the only fields the span needs). Returns undefined for invalid args.\nfunction extractQueryConfig(args: unknown[]): { text: string; name?: unknown } | undefined {\n const arg0 = args[0];\n if (typeof arg0 === 'string') {\n return { text: arg0 };\n }\n if (isObjectLike(arg0) && typeof (arg0 as { text?: unknown }).text === 'string') {\n const obj = arg0 as { text: string; name?: unknown };\n return { text: obj.text, name: obj.name };\n }\n return undefined;\n}\n\nfunction getConnectionAttributes(params: PgConnectionParams): SpanAttributes {\n return {\n [ATTR_DB_SYSTEM]: DB_SYSTEM_POSTGRESQL,\n [ATTR_DB_CONNECTION_STRING]: getConnectionString(params),\n [ATTR_DB_NAME]: params.database,\n [ATTR_DB_USER]: params.user,\n [ATTR_NET_PEER_NAME]: params.host,\n [ATTR_NET_PEER_PORT]: Number.isInteger(params.port) ? params.port : undefined,\n };\n}\n\nfunction getPoolConnectionAttributes(opts: PgPoolOptions): SpanAttributes {\n let url: URL | undefined;\n try {\n url = opts.connectionString ? new URL(opts.connectionString) : undefined;\n } catch {\n url = undefined;\n }\n const database = url?.pathname.slice(1) || opts.database;\n const host = url?.hostname || opts.host;\n // Mirror OTel's `getSemanticAttributesFromPoolConnection`: prefer the URL's\n // port, but fall back to an explicit `opts.port` when the connection string\n // omits it (`Number('')` / `Number(undefined)` -> falsy).\n const port = Number(url?.port) || (Number.isInteger(opts.port) ? opts.port : undefined);\n const user = url?.username || opts.user;\n return {\n [ATTR_DB_SYSTEM]: DB_SYSTEM_POSTGRESQL,\n [ATTR_DB_CONNECTION_STRING]: getConnectionString(opts),\n [ATTR_PG_IDLE_TIMEOUT]: opts.idleTimeoutMillis,\n [ATTR_PG_MAX_CLIENT]: opts.max,\n [ATTR_DB_NAME]: database,\n [ATTR_NET_PEER_PORT]: port,\n // these two come from a url parse and slice, can be ''\n [ATTR_NET_PEER_NAME]: host || undefined,\n [ATTR_DB_USER]: user || undefined,\n };\n}\n\n// Builds `postgresql://host:port/database`, masking credentials when a raw\n// connection string was provided.\nfunction getConnectionString(params: PgConnectionParams): string {\n if (params.connectionString) {\n try {\n const url = new URL(params.connectionString);\n url.username = '';\n url.password = '';\n return url.toString();\n } catch {\n return 'postgresql://localhost:5432/';\n }\n }\n const host = params.host || 'localhost';\n const port = params.port || 5432;\n const database = params.database || '';\n return `postgresql://${host}:${port}/${database}`;\n}\n\n/**\n * EXPERIMENTAL: orchestrion-driven `pg` (node-postgres) integration.\n *\n * Subscribes to the `orchestrion:pg:query`/`:connect` and\n * `orchestrion:pg-pool:connect` diagnostics_channels that the orchestrion code\n * transform injects into `pg`'s `Client.prototype.query`/`connect`\n * and `pg-pool`'s `Pool.prototype.connect`. Requires the orchestrion runtime\n * hook or bundler plugin to be active.\n */\nexport const postgresChannelIntegration = defineIntegration(_postgresChannelIntegration);\n"],"names":["waitForTracingChannelBinding","CHANNELS","DEBUG_BUILD","debug","bindTracingChannelToSpan","getCurrentScope","startInactiveSpan","SPAN_KIND","bindScopeToEmitter","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","isObjectLike","defineIntegration"],"mappings":";;;;;;;;AAmBA,MAAM,gBAAA,GAAmB,UAAA;AAIzB,MAAM,MAAA,GAAS,8BAAA;AAIf,MAAM,cAAA,GAAiB,WAAA;AACvB,MAAM,YAAA,GAAe,SAAA;AACrB,MAAM,yBAAA,GAA4B,sBAAA;AAClC,MAAM,YAAA,GAAe,SAAA;AACrB,MAAM,iBAAA,GAAoB,cAAA;AAC1B,MAAM,kBAAA,GAAqB,eAAA;AAC3B,MAAM,kBAAA,GAAqB,eAAA;AAC3B,MAAM,YAAA,GAAe,oBAAA;AACrB,MAAM,oBAAA,GAAuB,mCAAA;AAC7B,MAAM,kBAAA,GAAqB,0BAAA;AAC3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AAY,GAAG,IAAA,IAAQ;AAAA,GAC1B;AACF;AAIA,SAAS,oBAAoB,MAAA,EAAoC;AAC/D,EAAA,IAAI,OAAO,gBAAA,EAAkB;AAC3B,IAAA,IAAI;AACF,MAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,MAAA,CAAO,gBAAgB,CAAA;AAC3C,MAAA,GAAA,CAAI,QAAA,GAAW,EAAA;AACf,MAAA,GAAA,CAAI,QAAA,GAAW,EAAA;AACf,MAAA,OAAO,IAAI,QAAA,EAAS;AAAA,IACtB,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,8BAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,MAAM,IAAA,GAAO,OAAO,IAAA,IAAQ,WAAA;AAC5B,EAAA,MAAM,IAAA,GAAO,OAAO,IAAA,IAAQ,IAAA;AAC5B,EAAA,MAAM,QAAA,GAAW,OAAO,QAAA,IAAY,EAAA;AACpC,EAAA,OAAO,CAAA,aAAA,EAAgB,IAAI,CAAA,CAAA,EAAI,IAAI,IAAI,QAAQ,CAAA,CAAA;AACjD;AAWO,MAAM,0BAAA,GAA6BC,uBAAkB,2BAA2B;;;;"}
@@ -0,0 +1,227 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const diagnosticsChannel = require('node:diagnostics_channel');
4
+ const attributes = require('@sentry/conventions/attributes');
5
+ const core = require('@sentry/core');
6
+ const debugBuild = require('../../debug-build.js');
7
+ const channels = require('../../orchestrion/channels.js');
8
+ const redisStatementSerializer = require('../../redis/redis-statement-serializer.js');
9
+ const tracingChannel = require('../../tracing-channel.js');
10
+
11
+ const INTEGRATION_NAME = "RedisChannel";
12
+ const ORIGIN = "auto.db.orchestrion.redis";
13
+ const ATTR_DB_CONNECTION_STRING = "db.connection_string";
14
+ const DB_SYSTEM_VALUE_REDIS = "redis";
15
+ function endSpan(span, err) {
16
+ if (err) {
17
+ span.setStatus({ code: core.SPAN_STATUS_ERROR, message: err instanceof Error ? err.message : String(err) });
18
+ }
19
+ span.end();
20
+ }
21
+ function runResponseHook(hook, span, command, args, result) {
22
+ if (!hook) {
23
+ return;
24
+ }
25
+ try {
26
+ hook(span, command, args, result);
27
+ } catch {
28
+ }
29
+ }
30
+ function stripCommandOptions(args) {
31
+ const first = args[0];
32
+ if (core.isObjectLike(first) && Object.getOwnPropertySymbols(first).length > 0) {
33
+ return args.slice(1);
34
+ }
35
+ return args;
36
+ }
37
+ function removeCredentialsFromConnectionString(url) {
38
+ if (typeof url !== "string" || !url) {
39
+ return void 0;
40
+ }
41
+ try {
42
+ const parsed = new URL(url);
43
+ parsed.searchParams.delete("user_pwd");
44
+ parsed.username = "";
45
+ parsed.password = "";
46
+ return parsed.href;
47
+ } catch {
48
+ return void 0;
49
+ }
50
+ }
51
+ function nodeRedisAttributes(options) {
52
+ return {
53
+ [attributes.DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS,
54
+ [attributes.NET_PEER_NAME]: options?.socket?.host,
55
+ [attributes.NET_PEER_PORT]: options?.socket?.port,
56
+ [ATTR_DB_CONNECTION_STRING]: removeCredentialsFromConnectionString(options?.url),
57
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN
58
+ };
59
+ }
60
+ function startCommandSpan(commandName, commandArgs, attributes$1) {
61
+ return core.startInactiveSpan({
62
+ name: `redis-${commandName}`,
63
+ kind: core.SPAN_KIND.CLIENT,
64
+ attributes: {
65
+ ...attributes$1,
66
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db",
67
+ [attributes.DB_STATEMENT]: redisStatementSerializer.defaultDbStatementSerializer(commandName, commandArgs)
68
+ }
69
+ });
70
+ }
71
+ function subscribeLegacyRedisCommand(responseHook) {
72
+ const channel = diagnosticsChannel.tracingChannel(channels.CHANNELS.REDIS_COMMAND);
73
+ const noop = () => {
74
+ };
75
+ channel.subscribe({
76
+ end: noop,
77
+ asyncStart: noop,
78
+ asyncEnd: noop,
79
+ start(data) {
80
+ const command = data.arguments?.[0];
81
+ if (!command || typeof command !== "object") {
82
+ return;
83
+ }
84
+ const originalCallback = command.callback;
85
+ if (typeof originalCallback !== "function") {
86
+ return;
87
+ }
88
+ const client = data.self;
89
+ const attributes$1 = {
90
+ [attributes.DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS,
91
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN
92
+ };
93
+ attributes$1[attributes.NET_PEER_NAME] = client?.connection_options?.host;
94
+ attributes$1[attributes.NET_PEER_PORT] = client?.connection_options?.port;
95
+ if (client?.address) {
96
+ attributes$1[ATTR_DB_CONNECTION_STRING] = `redis://${client.address}`;
97
+ }
98
+ const span = startCommandSpan(command.command, command.args ?? [], attributes$1);
99
+ data._sentrySpan = span;
100
+ const parentSpan = core.getActiveSpan();
101
+ command.callback = function(err, reply) {
102
+ if (!err) {
103
+ runResponseHook(responseHook, span, command.command, command.args ?? [], reply);
104
+ }
105
+ endSpan(span, err);
106
+ const args = arguments;
107
+ return core.withActiveSpan(parentSpan ?? null, () => originalCallback.apply(this, args));
108
+ };
109
+ },
110
+ error(data) {
111
+ const span = data._sentrySpan;
112
+ if (span) {
113
+ endSpan(span, data.error);
114
+ }
115
+ }
116
+ });
117
+ }
118
+ function bindNodeRedisCommandChannel(channelName, getWireArgs, responseHook) {
119
+ const channel = diagnosticsChannel.tracingChannel(channelName);
120
+ tracingChannel.bindTracingChannelToSpan(
121
+ channel,
122
+ (data) => {
123
+ const wireArgs = getWireArgs(data);
124
+ if (!wireArgs?.length) {
125
+ return void 0;
126
+ }
127
+ const commandName = String(wireArgs[0]);
128
+ const options = data.self?.options;
129
+ return startCommandSpan(commandName, wireArgs.slice(1), nodeRedisAttributes(options));
130
+ },
131
+ {
132
+ captureError: false,
133
+ beforeSpanEnd(span, data) {
134
+ if ("error" in data || !responseHook) {
135
+ return;
136
+ }
137
+ const wireArgs = getWireArgs(data);
138
+ if (wireArgs?.length) {
139
+ runResponseHook(responseHook, span, String(wireArgs[0]), wireArgs.slice(1), data.result);
140
+ }
141
+ }
142
+ }
143
+ );
144
+ }
145
+ function getSendCommandArgs(data) {
146
+ const args = data.arguments?.[0];
147
+ return Array.isArray(args) ? args : void 0;
148
+ }
149
+ function getExecutorArgs(data) {
150
+ const command = data.arguments?.[0];
151
+ const jsArgs = data.arguments?.[1];
152
+ if (typeof command?.transformArguments !== "function" || !Array.isArray(jsArgs)) {
153
+ return void 0;
154
+ }
155
+ try {
156
+ return command.transformArguments(...stripCommandOptions(jsArgs));
157
+ } catch {
158
+ return void 0;
159
+ }
160
+ }
161
+ function bindNodeRedisConnectChannel() {
162
+ const channel = diagnosticsChannel.tracingChannel(channels.CHANNELS.NODE_REDIS_CONNECT);
163
+ tracingChannel.bindTracingChannelToSpan(
164
+ channel,
165
+ (data) => {
166
+ const options = data.self?.options;
167
+ return core.startInactiveSpan({
168
+ name: "redis-connect",
169
+ kind: core.SPAN_KIND.CLIENT,
170
+ attributes: { ...nodeRedisAttributes(options), [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db" }
171
+ });
172
+ },
173
+ { captureError: false }
174
+ );
175
+ }
176
+ function bindNodeRedisBatchChannel(channelName, getOperation) {
177
+ const channel = diagnosticsChannel.tracingChannel(channelName);
178
+ tracingChannel.bindTracingChannelToSpan(
179
+ channel,
180
+ (data) => {
181
+ const commands = data.arguments?.[0];
182
+ const size = Array.isArray(commands) ? commands.length : void 0;
183
+ const socket = data.self?.options?.socket;
184
+ return core.startInactiveSpan({
185
+ name: getOperation(data),
186
+ kind: core.SPAN_KIND.CLIENT,
187
+ attributes: {
188
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
189
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db.redis",
190
+ [attributes.DB_SYSTEM_NAME]: DB_SYSTEM_VALUE_REDIS,
191
+ ...size && size > 1 ? { [attributes.DB_OPERATION_BATCH_SIZE]: size } : {},
192
+ ...socket?.host != null ? { [attributes.SERVER_ADDRESS]: socket.host } : {},
193
+ ...socket?.port != null ? { [attributes.SERVER_PORT]: socket.port } : {}
194
+ }
195
+ });
196
+ },
197
+ { captureError: false }
198
+ );
199
+ }
200
+ const _redisChannelIntegration = ((options = {}) => {
201
+ const responseHook = options.responseHook;
202
+ return {
203
+ name: INTEGRATION_NAME,
204
+ setupOnce() {
205
+ if (!diagnosticsChannel.tracingChannel) {
206
+ return;
207
+ }
208
+ debugBuild.DEBUG_BUILD && core.debug.log(`[orchestrion:redis] subscribing to "${channels.CHANNELS.REDIS_COMMAND}" and node-redis channels`);
209
+ subscribeLegacyRedisCommand(responseHook);
210
+ core.waitForTracingChannelBinding(() => {
211
+ bindNodeRedisCommandChannel(channels.CHANNELS.NODE_REDIS_COMMAND, getSendCommandArgs, responseHook);
212
+ bindNodeRedisCommandChannel(channels.CHANNELS.NODE_REDIS_EXECUTOR, getExecutorArgs, responseHook);
213
+ bindNodeRedisConnectChannel();
214
+ bindNodeRedisBatchChannel(channels.CHANNELS.NODE_REDIS_MULTI, () => "MULTI");
215
+ bindNodeRedisBatchChannel(channels.CHANNELS.NODE_REDIS_PIPELINE, () => "PIPELINE");
216
+ bindNodeRedisBatchChannel(
217
+ channels.CHANNELS.NODE_REDIS_BATCH,
218
+ (data) => data.arguments?.[2] !== void 0 ? "MULTI" : "PIPELINE"
219
+ );
220
+ });
221
+ }
222
+ };
223
+ });
224
+ const redisChannelIntegration = core.defineIntegration(_redisChannelIntegration);
225
+
226
+ exports.redisChannelIntegration = redisChannelIntegration;
227
+ //# sourceMappingURL=redis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.js","sources":["../../../../src/integrations/tracing-channel/redis.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated -- we intentionally emit the OLD db/net semconv\n to match `@opentelemetry/instrumentation-redis`. TODO(v11): switch to the non-deprecated\n `db.system.name`/`db.query.text`/`server.address`/`server.port` conventions and drop this disable. */\nimport * as diagnosticsChannel from 'node:diagnostics_channel';\nimport {\n DB_OPERATION_BATCH_SIZE,\n DB_STATEMENT,\n DB_SYSTEM,\n DB_SYSTEM_NAME,\n NET_PEER_NAME,\n NET_PEER_PORT,\n SERVER_ADDRESS,\n SERVER_PORT,\n} from '@sentry/conventions/attributes';\nimport type { IntegrationFn, Span, SpanAttributes } from '@sentry/core';\nimport {\n isObjectLike,\n debug,\n defineIntegration,\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n waitForTracingChannelBinding,\n withActiveSpan,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { defaultDbStatementSerializer } from '../../redis/redis-statement-serializer';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// A distinct name from the composite OTel `Redis` integration — they can't share one, and\n// `Redis` stays in the set for its native diagnostics_channel subscriber (node-redis >=5.12 /\n// ioredis >=5.11). When this integration is active, the OTel `RedisInstrumentation` monkey-patch\n// is fully gated off in the node SDK.\nconst INTEGRATION_NAME = 'RedisChannel' as const;\n\nconst ORIGIN = 'auto.db.orchestrion.redis';\n\n// todo(v11): drop this — it is already covered by host and port.\nconst ATTR_DB_CONNECTION_STRING = 'db.connection_string';\nconst DB_SYSTEM_VALUE_REDIS = 'redis';\n\n/** Mirrors `@opentelemetry/instrumentation-redis`' response hook. Not called for failed commands. */\nexport type RedisResponseHook = (span: Span, command: string, args: Array<string | Buffer>, result: unknown) => void;\n\nexport interface RedisChannelIntegrationOptions {\n responseHook?: RedisResponseHook;\n}\n\n/** Structural type for a node-redis (`@redis/client`) command definition. */\ninterface RedisCommandDefinition {\n transformArguments?: (...args: unknown[]) => Array<string | Buffer>;\n}\n\n/** Structural type for the `command_obj` `redis` v2-v3 passes to `internal_send_command`. */\ninterface LegacyRedisCommand {\n command: string;\n args: Array<string | Buffer>;\n callback?: (err: Error | null | undefined, reply: unknown) => unknown;\n}\n\ninterface LegacyRedisClient {\n connection_options?: { host?: string; port?: number };\n address?: string;\n}\n\ninterface NodeRedisClientOptions {\n socket?: { host?: string; port?: number };\n url?: string;\n}\n\ninterface NodeRedisClient {\n options?: NodeRedisClientOptions;\n}\n\ninterface CommandContext {\n arguments?: unknown[];\n self?: unknown;\n result?: unknown;\n error?: unknown;\n}\n\nfunction endSpan(span: Span, err: unknown): void {\n if (err) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: err instanceof Error ? err.message : String(err) });\n }\n span.end();\n}\n\nfunction runResponseHook(\n hook: RedisResponseHook | undefined,\n span: Span,\n command: string,\n args: Array<string | Buffer>,\n result: unknown,\n): void {\n if (!hook) {\n return;\n }\n try {\n hook(span, command, args, result);\n } catch {\n // never let a user-provided response hook break instrumentation\n }\n}\n\n// Strip a leading `commandOptions(...)` object (tagged with a `Symbol`) before\n// deriving the wire arguments, mirroring `@redis/client`'s `transformCommandArguments`.\nfunction stripCommandOptions(args: unknown[]): unknown[] {\n const first = args[0];\n if (isObjectLike(first) && Object.getOwnPropertySymbols(first).length > 0) {\n return args.slice(1);\n }\n return args;\n}\n\nfunction removeCredentialsFromConnectionString(url: string | undefined): string | undefined {\n if (typeof url !== 'string' || !url) {\n return undefined;\n }\n try {\n const parsed = new URL(url);\n parsed.searchParams.delete('user_pwd');\n parsed.username = '';\n parsed.password = '';\n return parsed.href;\n } catch {\n return undefined;\n }\n}\n\nfunction nodeRedisAttributes(options: NodeRedisClientOptions | undefined): SpanAttributes {\n return {\n [DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS,\n [NET_PEER_NAME]: options?.socket?.host,\n [NET_PEER_PORT]: options?.socket?.port,\n [ATTR_DB_CONNECTION_STRING]: removeCredentialsFromConnectionString(options?.url),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n}\n\nfunction startCommandSpan(commandName: string, commandArgs: Array<string | Buffer>, attributes: SpanAttributes): Span {\n return startInactiveSpan({\n name: `redis-${commandName}`,\n kind: SPAN_KIND.CLIENT,\n attributes: {\n ...attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',\n [DB_STATEMENT]: defaultDbStatementSerializer(commandName, commandArgs),\n },\n });\n}\n\n// --- redis v2-v3: `RedisClient.prototype.internal_send_command(command_obj)` ---\n\n// Settles via `command_obj.callback`, not the sync return — so instead of\n// `bindTracingChannelToSpan` we open the span in `start`, wrap the callback to end it, and end on `error` for sync throws.\nfunction subscribeLegacyRedisCommand(responseHook: RedisResponseHook | undefined): void {\n const channel = diagnosticsChannel.tracingChannel<CommandContext>(CHANNELS.REDIS_COMMAND);\n const noop = (): void => {};\n channel.subscribe({\n end: noop,\n asyncStart: noop,\n asyncEnd: noop,\n start(data) {\n const command = data.arguments?.[0] as LegacyRedisCommand | undefined;\n if (!command || typeof command !== 'object') {\n return;\n }\n // The span is ended via the wrapped callback (or the sync-throw `error` path). A\n // command with no callback has no completion signal to end it on, so don't open one.\n const originalCallback = command.callback;\n if (typeof originalCallback !== 'function') {\n return;\n }\n const client = data.self as LegacyRedisClient | undefined;\n const attributes: SpanAttributes = {\n [DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n\n attributes[NET_PEER_NAME] = client?.connection_options?.host;\n attributes[NET_PEER_PORT] = client?.connection_options?.port;\n\n if (client?.address) {\n attributes[ATTR_DB_CONNECTION_STRING] = `redis://${client.address}`;\n }\n const span = startCommandSpan(command.command, command.args ?? [], attributes);\n (data as CommandContext & { _sentrySpan?: Span })._sentrySpan = span;\n\n const parentSpan = getActiveSpan();\n command.callback = function (this: unknown, err: Error | null | undefined, reply: unknown) {\n if (!err) {\n runResponseHook(responseHook, span, command.command, command.args ?? [], reply);\n }\n endSpan(span, err);\n // eslint-disable-next-line prefer-rest-params\n const args = arguments as unknown as [Error | null | undefined, unknown];\n return withActiveSpan(parentSpan ?? null, () => originalCallback.apply(this, args));\n };\n },\n error(data) {\n // Synchronous throw: the wrapped callback never fires, so end here instead.\n const span = (data as CommandContext & { _sentrySpan?: Span })._sentrySpan;\n if (span) {\n endSpan(span, data.error);\n }\n },\n });\n}\n\n// --- node-redis v4/v5 (`@redis/client`) ---\n\nfunction bindNodeRedisCommandChannel(\n channelName: string,\n getWireArgs: (data: CommandContext) => Array<string | Buffer> | undefined,\n responseHook: RedisResponseHook | undefined,\n): void {\n const channel = diagnosticsChannel.tracingChannel<CommandContext, CommandContext>(channelName);\n bindTracingChannelToSpan(\n channel,\n data => {\n const wireArgs = getWireArgs(data);\n if (!wireArgs?.length) {\n return undefined;\n }\n const commandName = String(wireArgs[0]);\n const options = (data.self as NodeRedisClient | undefined)?.options;\n return startCommandSpan(commandName, wireArgs.slice(1), nodeRedisAttributes(options));\n },\n {\n captureError: false,\n beforeSpanEnd(span, data) {\n if ('error' in data || !responseHook) {\n return;\n }\n const wireArgs = getWireArgs(data);\n if (wireArgs?.length) {\n runResponseHook(responseHook, span, String(wireArgs[0]), wireArgs.slice(1), data.result);\n }\n },\n },\n );\n}\n\n// `sendCommand(args, options)` — `args` are already the wire arguments.\nfunction getSendCommandArgs(data: CommandContext): Array<string | Buffer> | undefined {\n const args = data.arguments?.[0];\n return Array.isArray(args) ? (args as Array<string | Buffer>) : undefined;\n}\n\n// `commandsExecutor(command, jsArgs)` — derive the wire arguments the same way\n// `@redis/client` does internally, via `command.transformArguments`.\nfunction getExecutorArgs(data: CommandContext): Array<string | Buffer> | undefined {\n const command = data.arguments?.[0] as RedisCommandDefinition | undefined;\n const jsArgs = data.arguments?.[1];\n if (typeof command?.transformArguments !== 'function' || !Array.isArray(jsArgs)) {\n return undefined;\n }\n try {\n return command.transformArguments(...stripCommandOptions(jsArgs));\n } catch {\n return undefined;\n }\n}\n\nfunction bindNodeRedisConnectChannel(): void {\n const channel = diagnosticsChannel.tracingChannel<CommandContext, CommandContext>(CHANNELS.NODE_REDIS_CONNECT);\n bindTracingChannelToSpan(\n channel,\n data => {\n const options = (data.self as NodeRedisClient | undefined)?.options;\n return startInactiveSpan({\n name: 'redis-connect',\n kind: SPAN_KIND.CLIENT,\n attributes: { ...nodeRedisAttributes(options), [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db' },\n });\n },\n { captureError: false },\n );\n}\n\n// Batch (multi/pipeline): one span per `exec`. Batched commands bypass `sendCommand`, so\n// the executor's `ctx.arguments[0]` (the queued commands) gives the batch size. Span shape\n// mirrors the native `node-redis:batch` span (see `redis-dc-subscriber.ts`).\nfunction bindNodeRedisBatchChannel(channelName: string, getOperation: (data: CommandContext) => string): void {\n const channel = diagnosticsChannel.tracingChannel<CommandContext, CommandContext>(channelName);\n bindTracingChannelToSpan(\n channel,\n data => {\n const commands = data.arguments?.[0];\n const size = Array.isArray(commands) ? commands.length : undefined;\n const socket = (data.self as NodeRedisClient | undefined)?.options?.socket;\n return startInactiveSpan({\n name: getOperation(data),\n kind: SPAN_KIND.CLIENT,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_VALUE_REDIS,\n ...(size && size > 1 ? { [DB_OPERATION_BATCH_SIZE]: size } : {}),\n ...(socket?.host != null ? { [SERVER_ADDRESS]: socket.host } : {}),\n ...(socket?.port != null ? { [SERVER_PORT]: socket.port } : {}),\n },\n });\n },\n { captureError: false },\n );\n}\n\nconst _redisChannelIntegration = ((options: RedisChannelIntegrationOptions = {}) => {\n const responseHook = options.responseHook;\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(`[orchestrion:redis] subscribing to \"${CHANNELS.REDIS_COMMAND}\" and node-redis channels`);\n\n // redis v2-v3 uses a nested callback rather than `bindStore`, so it can be\n // subscribed synchronously here.\n subscribeLegacyRedisCommand(responseHook);\n\n waitForTracingChannelBinding(() => {\n bindNodeRedisCommandChannel(CHANNELS.NODE_REDIS_COMMAND, getSendCommandArgs, responseHook);\n bindNodeRedisCommandChannel(CHANNELS.NODE_REDIS_EXECUTOR, getExecutorArgs, responseHook);\n bindNodeRedisConnectChannel();\n bindNodeRedisBatchChannel(CHANNELS.NODE_REDIS_MULTI, () => 'MULTI');\n bindNodeRedisBatchChannel(CHANNELS.NODE_REDIS_PIPELINE, () => 'PIPELINE');\n bindNodeRedisBatchChannel(CHANNELS.NODE_REDIS_BATCH, data =>\n data.arguments?.[2] !== undefined ? 'MULTI' : 'PIPELINE',\n );\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * EXPERIMENTAL — orchestrion-driven redis integration for `redis` v2-v3 and\n * node-redis v4/v5 `<5.12.0` (`@redis/client`). Covers single commands, `connect`,\n * and multi/pipeline batches, fully replacing `@opentelemetry/instrumentation-redis`.\n * Requires the orchestrion runtime hook or bundler plugin.\n */\nexport const redisChannelIntegration = defineIntegration(_redisChannelIntegration);\n"],"names":["SPAN_STATUS_ERROR","isObjectLike","DB_SYSTEM","NET_PEER_NAME","NET_PEER_PORT","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","attributes","startInactiveSpan","SPAN_KIND","SEMANTIC_ATTRIBUTE_SENTRY_OP","DB_STATEMENT","defaultDbStatementSerializer","CHANNELS","getActiveSpan","withActiveSpan","bindTracingChannelToSpan","DB_SYSTEM_NAME","DB_OPERATION_BATCH_SIZE","SERVER_ADDRESS","SERVER_PORT","DEBUG_BUILD","debug","waitForTracingChannelBinding","defineIntegration"],"mappings":";;;;;;;;;;AAqCA,MAAM,gBAAA,GAAmB,cAAA;AAEzB,MAAM,MAAA,GAAS,2BAAA;AAGf,MAAM,yBAAA,GAA4B,sBAAA;AAClC,MAAM,qBAAA,GAAwB,OAAA;AA0C9B,SAAS,OAAA,CAAQ,MAAY,GAAA,EAA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UAAA,CAAM,GAAA,CAAI,CAAA,oCAAA,EAAuCT,iBAAA,CAAS,aAAa,CAAA,yBAAA,CAA2B,CAAA;AAIpG,MAAA,2BAAA,CAA4B,YAAY,CAAA;AAExC,MAAAU,iCAAA,CAA6B,MAAM;AACjC,QAAA,2BAAA,CAA4BV,iBAAA,CAAS,kBAAA,EAAoB,kBAAA,EAAoB,YAAY,CAAA;AACzF,QAAA,2BAAA,CAA4BA,iBAAA,CAAS,mBAAA,EAAqB,eAAA,EAAiB,YAAY,CAAA;AACvF,QAAA,2BAAA,EAA4B;AAC5B,QAAA,yBAAA,CAA0BA,iBAAA,CAAS,gBAAA,EAAkB,MAAM,OAAO,CAAA;AAClE,QAAA,yBAAA,CAA0BA,iBAAA,CAAS,mBAAA,EAAqB,MAAM,UAAU,CAAA;AACxE,QAAA,yBAAA;AAAA,UAA0BA,iBAAA,CAAS,gBAAA;AAAA,UAAkB,UACnD,IAAA,CAAK,SAAA,GAAY,CAAC,CAAA,KAAM,SAAY,OAAA,GAAU;AAAA,SAChD;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAQO,MAAM,uBAAA,GAA0BW,uBAAkB,wBAAwB;;;;"}
@@ -0,0 +1,25 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const index = require('../../vercel-ai/index.js');
5
+ const diagnosticsChannel = require('node:diagnostics_channel');
6
+ const vercelAiOrchestrionSubscriber = require('../../vercel-ai/vercel-ai-orchestrion-subscriber.js');
7
+
8
+ const _vercelAiChannelIntegration = ((options = {}) => {
9
+ const parentIntegration = index.vercelAiIntegration(options);
10
+ return core.extendIntegration(parentIntegration, {
11
+ options,
12
+ setupOnce() {
13
+ if (!diagnosticsChannel.tracingChannel) {
14
+ return;
15
+ }
16
+ core.waitForTracingChannelBinding(() => {
17
+ vercelAiOrchestrionSubscriber.subscribeVercelAiOrchestrionChannels(diagnosticsChannel.tracingChannel, options);
18
+ });
19
+ }
20
+ });
21
+ });
22
+ const vercelAiChannelIntegration = core.defineIntegration(_vercelAiChannelIntegration);
23
+
24
+ exports.vercelAiChannelIntegration = vercelAiChannelIntegration;
25
+ //# sourceMappingURL=vercel-ai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel-ai.js","sources":["../../../../src/integrations/tracing-channel/vercel-ai.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, extendIntegration, waitForTracingChannelBinding } from '@sentry/core';\nimport { vercelAiIntegration as baseVercelAiIntegration } from '../../vercel-ai';\nimport * as dc from 'node:diagnostics_channel';\nimport { subscribeVercelAiOrchestrionChannels } from '../../vercel-ai/vercel-ai-orchestrion-subscriber';\n\ntype VercelAiOptions = Parameters<typeof baseVercelAiIntegration>[0];\n\n// In channel-based (orchestrion) mode we emit our own `gen_ai.*` spans from the\n// diagnostics channels. The `ai` SDK would otherwise emit its own native\n// OpenTelemetry spans whenever the user enables `experimental_telemetry`, which\n// would be duplicates. Rather than dropping those after the fact, the v6\n// subscriber suppresses them at the source: it flips the wrapped call's\n// `experimental_telemetry.isEnabled` to `false`, so `ai` falls back to its\n// internal no-op tracer and never creates the native spans in the first place.\n// See `subscribeVercelAiOrchestrionChannels`.\nconst _vercelAiChannelIntegration = ((options: VercelAiOptions = {}) => {\n const parentIntegration = baseVercelAiIntegration(options);\n\n return extendIntegration(parentIntegration, {\n options,\n setupOnce() {\n // Bail if this is not available\n if (!dc.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n subscribeVercelAiOrchestrionChannels(dc.tracingChannel, options);\n });\n },\n });\n}) satisfies IntegrationFn;\n\n/**\n * Auto-instrument the `ai` SDK. Supported are:\n * - v7 via native `ai:telemetry` tracing channel\n * - v4, v5 & v6 via orchestrion `orchestrion:ai:*` channels\n */\nexport const vercelAiChannelIntegration = defineIntegration(_vercelAiChannelIntegration);\n"],"names":["baseVercelAiIntegration","extendIntegration","dc","waitForTracingChannelBinding","subscribeVercelAiOrchestrionChannels","defineIntegration"],"mappings":";;;;;;;AAgBA,MAAM,2BAAA,IAA+B,CAAC,OAAA,GAA2B,EAAC,KAAM;AACtE,EAAA,MAAM,iBAAA,GAAoBA,0BAAwB,OAAO,CAAA;AAEzD,EAAA,OAAOC,uBAAkB,iBAAA,EAAmB;AAAA,IAC1C,OAAA;AAAA,IACA,SAAA,GAAY;AAEV,MAAA,IAAI,CAACC,mBAAG,cAAA,EAAgB;AACtB,QAAA;AAAA,MACF;AAEA,MAAAC,iCAAA,CAA6B,MAAM;AACjC,QAAAC,kEAAA,CAAqCF,kBAAA,CAAG,gBAAgB,OAAO,CAAA;AAAA,MACjE,CAAC,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAOO,MAAM,0BAAA,GAA6BG,uBAAkB,2BAA2B;;;;"}
@@ -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 mongooseDcSubscriber = require('./mongoose-dc-subscriber.js');
6
+
7
+ const _mongooseIntegration = (() => {
8
+ return {
9
+ name: "Mongoose",
10
+ setupOnce() {
11
+ if (!diagnosticsChannel.tracingChannel) {
12
+ return;
13
+ }
14
+ core.waitForTracingChannelBinding(() => {
15
+ mongooseDcSubscriber.subscribeMongooseDiagnosticChannels(diagnosticsChannel.tracingChannel);
16
+ });
17
+ }
18
+ };
19
+ });
20
+ const mongooseIntegration = core.defineIntegration(_mongooseIntegration);
21
+
22
+ exports.mongooseIntegration = mongooseIntegration;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/mongoose/index.ts"],"sourcesContent":["import { defineIntegration, type IntegrationFn, waitForTracingChannelBinding } from '@sentry/core';\nimport * as dc from 'node:diagnostics_channel';\nimport { subscribeMongooseDiagnosticChannels } from './mongoose-dc-subscriber';\n\nconst _mongooseIntegration = (() => {\n return {\n name: 'Mongoose',\n setupOnce() {\n // Bail on Node <= 18.18.0, where `tracingChannel` does not exist.\n if (!dc.tracingChannel) {\n return;\n }\n\n // Subscribe to mongoose's native tracing channels (mongoose >= 9.7).\n // This is a no-op on versions that don't publish to the channels, so it is always safe to call.\n waitForTracingChannelBinding(() => {\n subscribeMongooseDiagnosticChannels(dc.tracingChannel);\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Auto-instrument the [mongoose](https://www.npmjs.com/package/mongoose) library via its native\n * `node:diagnostics_channel` tracing channels (mongoose >= 9.7).\n *\n * On older mongoose versions the channels are never published to, so this integration is inert and\n * the IITM-based patcher (gated to `< 9.7.0`) handles instrumentation instead.\n */\nexport const mongooseIntegration = defineIntegration(_mongooseIntegration);\n"],"names":["dc","waitForTracingChannelBinding","subscribeMongooseDiagnosticChannels","defineIntegration"],"mappings":";;;;;;AAIA,MAAM,wBAAwB,MAAM;AAClC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,UAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAACA,mBAAG,cAAA,EAAgB;AACtB,QAAA;AAAA,MACF;AAIA,MAAAC,iCAAA,CAA6B,MAAM;AACjC,QAAAC,wDAAA,CAAoCF,mBAAG,cAAc,CAAA;AAAA,MACvD,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AASO,MAAM,mBAAA,GAAsBG,uBAAkB,oBAAoB;;;;"}