@sentry/server-utils 10.65.0 → 10.67.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 (557) hide show
  1. package/build/cjs/graphql/graphql-dc-subscriber.js +2 -4
  2. package/build/cjs/graphql/graphql-dc-subscriber.js.map +1 -1
  3. package/build/cjs/graphql/utils.js +7 -1
  4. package/build/cjs/graphql/utils.js.map +1 -1
  5. package/build/cjs/index.js +18 -8
  6. package/build/cjs/index.js.map +1 -1
  7. package/build/cjs/integrations/tracing-channel/aws-sdk/constants.js +16 -0
  8. package/build/cjs/integrations/tracing-channel/aws-sdk/constants.js.map +1 -0
  9. package/build/cjs/integrations/tracing-channel/aws-sdk/index.js +154 -0
  10. package/build/cjs/integrations/tracing-channel/aws-sdk/index.js.map +1 -0
  11. package/build/cjs/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js +46 -0
  12. package/build/cjs/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js.map +1 -0
  13. package/build/cjs/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js +47 -0
  14. package/build/cjs/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js.map +1 -0
  15. package/build/cjs/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js +419 -0
  16. package/build/cjs/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js.map +1 -0
  17. package/build/cjs/integrations/tracing-channel/aws-sdk/services/dynamodb.js +131 -0
  18. package/build/cjs/integrations/tracing-channel/aws-sdk/services/dynamodb.js.map +1 -0
  19. package/build/cjs/integrations/tracing-channel/aws-sdk/services/kinesis.js +21 -0
  20. package/build/cjs/integrations/tracing-channel/aws-sdk/services/kinesis.js.map +1 -0
  21. package/build/cjs/integrations/tracing-channel/aws-sdk/services/lambda.js +64 -0
  22. package/build/cjs/integrations/tracing-channel/aws-sdk/services/lambda.js.map +1 -0
  23. package/build/cjs/integrations/tracing-channel/aws-sdk/services/s3.js +21 -0
  24. package/build/cjs/integrations/tracing-channel/aws-sdk/services/s3.js.map +1 -0
  25. package/build/cjs/integrations/tracing-channel/aws-sdk/services/secretsmanager.js +27 -0
  26. package/build/cjs/integrations/tracing-channel/aws-sdk/services/secretsmanager.js.map +1 -0
  27. package/build/cjs/integrations/tracing-channel/aws-sdk/services/sns.js +63 -0
  28. package/build/cjs/integrations/tracing-channel/aws-sdk/services/sns.js.map +1 -0
  29. package/build/cjs/integrations/tracing-channel/aws-sdk/services/sqs.js +116 -0
  30. package/build/cjs/integrations/tracing-channel/aws-sdk/services/sqs.js.map +1 -0
  31. package/build/cjs/integrations/tracing-channel/aws-sdk/services/stepfunctions.js +25 -0
  32. package/build/cjs/integrations/tracing-channel/aws-sdk/services/stepfunctions.js.map +1 -0
  33. package/build/cjs/integrations/tracing-channel/aws-sdk/utils.js +30 -0
  34. package/build/cjs/integrations/tracing-channel/aws-sdk/utils.js.map +1 -0
  35. package/build/cjs/integrations/tracing-channel/dataloader.js +95 -0
  36. package/build/cjs/integrations/tracing-channel/dataloader.js.map +1 -0
  37. package/build/cjs/integrations/tracing-channel/express/instrumentation.js +1 -6
  38. package/build/cjs/integrations/tracing-channel/express/instrumentation.js.map +1 -1
  39. package/build/cjs/integrations/tracing-channel/generic-pool.js +34 -0
  40. package/build/cjs/integrations/tracing-channel/generic-pool.js.map +1 -0
  41. package/build/cjs/integrations/tracing-channel/graphql/spans.js +2 -2
  42. package/build/cjs/integrations/tracing-channel/graphql/spans.js.map +1 -1
  43. package/build/cjs/integrations/tracing-channel/ioredis.js +29 -26
  44. package/build/cjs/integrations/tracing-channel/ioredis.js.map +1 -1
  45. package/build/cjs/integrations/tracing-channel/kafkajs/consumer.js +71 -0
  46. package/build/cjs/integrations/tracing-channel/kafkajs/consumer.js.map +1 -0
  47. package/build/cjs/integrations/tracing-channel/kafkajs/index.js +70 -0
  48. package/build/cjs/integrations/tracing-channel/kafkajs/index.js.map +1 -0
  49. package/build/cjs/integrations/tracing-channel/kafkajs/semconv.js +22 -0
  50. package/build/cjs/integrations/tracing-channel/kafkajs/semconv.js.map +1 -0
  51. package/build/cjs/integrations/tracing-channel/kafkajs/spans.js +119 -0
  52. package/build/cjs/integrations/tracing-channel/kafkajs/spans.js.map +1 -0
  53. package/build/cjs/integrations/tracing-channel/knex.js +188 -0
  54. package/build/cjs/integrations/tracing-channel/knex.js.map +1 -0
  55. package/build/cjs/integrations/tracing-channel/koa.js +146 -0
  56. package/build/cjs/integrations/tracing-channel/koa.js.map +1 -0
  57. package/build/cjs/integrations/tracing-channel/langchain.js +63 -0
  58. package/build/cjs/integrations/tracing-channel/langchain.js.map +1 -0
  59. package/build/cjs/integrations/tracing-channel/langgraph.js +100 -0
  60. package/build/cjs/integrations/tracing-channel/langgraph.js.map +1 -0
  61. package/build/cjs/integrations/tracing-channel/mongodb.js +104 -0
  62. package/build/cjs/integrations/tracing-channel/mongodb.js.map +1 -0
  63. package/build/cjs/integrations/tracing-channel/mongoose.js +110 -0
  64. package/build/cjs/integrations/tracing-channel/mongoose.js.map +1 -0
  65. package/build/cjs/integrations/tracing-channel/mysql2.js +83 -0
  66. package/build/cjs/integrations/tracing-channel/mysql2.js.map +1 -0
  67. package/build/cjs/integrations/tracing-channel/openai.js +1 -3
  68. package/build/cjs/integrations/tracing-channel/openai.js.map +1 -1
  69. package/build/cjs/integrations/tracing-channel/redis.js +25 -34
  70. package/build/cjs/integrations/tracing-channel/redis.js.map +1 -1
  71. package/build/cjs/integrations/tracing-channel/tedious.js +145 -0
  72. package/build/cjs/integrations/tracing-channel/tedious.js.map +1 -0
  73. package/build/cjs/mongodb/mongodb-span.js +133 -0
  74. package/build/cjs/mongodb/mongodb-span.js.map +1 -0
  75. package/build/cjs/mongoose/index.js.map +1 -1
  76. package/build/cjs/mongoose/mongoose-legacy-span.js +40 -0
  77. package/build/cjs/mongoose/mongoose-legacy-span.js.map +1 -0
  78. package/build/cjs/orchestrion/bundler/esbuild.js +15 -0
  79. package/build/cjs/orchestrion/bundler/esbuild.js.map +1 -0
  80. package/build/cjs/orchestrion/bundler/options.js +24 -0
  81. package/build/cjs/orchestrion/bundler/options.js.map +1 -0
  82. package/build/cjs/orchestrion/bundler/rollup.js +15 -0
  83. package/build/cjs/orchestrion/bundler/rollup.js.map +1 -0
  84. package/build/cjs/orchestrion/bundler/vite.js +8 -21
  85. package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
  86. package/build/cjs/orchestrion/bundler/webpack.js +36 -0
  87. package/build/cjs/orchestrion/bundler/webpack.js.map +1 -0
  88. package/build/cjs/orchestrion/channels.js +54 -20
  89. package/build/cjs/orchestrion/channels.js.map +1 -1
  90. package/build/cjs/orchestrion/config/amqplib.js.map +1 -1
  91. package/build/cjs/orchestrion/config/anthropic-ai.js.map +1 -1
  92. package/build/cjs/orchestrion/config/aws-sdk.js +28 -0
  93. package/build/cjs/orchestrion/config/aws-sdk.js.map +1 -0
  94. package/build/cjs/orchestrion/config/dataloader.js +53 -0
  95. package/build/cjs/orchestrion/config/dataloader.js.map +1 -0
  96. package/build/cjs/orchestrion/config/express.js +9 -8
  97. package/build/cjs/orchestrion/config/express.js.map +1 -1
  98. package/build/cjs/orchestrion/config/firebase.js +8 -0
  99. package/build/cjs/orchestrion/config/firebase.js.map +1 -0
  100. package/build/cjs/orchestrion/config/generic-pool.js +21 -0
  101. package/build/cjs/orchestrion/config/generic-pool.js.map +1 -0
  102. package/build/cjs/orchestrion/config/google-genai.js.map +1 -1
  103. package/build/cjs/orchestrion/config/graphql.js.map +1 -1
  104. package/build/cjs/orchestrion/config/hapi.js.map +1 -1
  105. package/build/cjs/orchestrion/config/index.js +64 -23
  106. package/build/cjs/orchestrion/config/index.js.map +1 -1
  107. package/build/cjs/orchestrion/config/ioredis.js.map +1 -1
  108. package/build/cjs/orchestrion/config/kafkajs.js +30 -0
  109. package/build/cjs/orchestrion/config/kafkajs.js.map +1 -0
  110. package/build/cjs/orchestrion/config/knex.js +43 -0
  111. package/build/cjs/orchestrion/config/knex.js.map +1 -0
  112. package/build/cjs/orchestrion/config/koa.js +16 -0
  113. package/build/cjs/orchestrion/config/koa.js.map +1 -0
  114. package/build/cjs/orchestrion/config/langchain.js +52 -0
  115. package/build/cjs/orchestrion/config/langchain.js.map +1 -0
  116. package/build/cjs/orchestrion/config/langgraph.js +28 -0
  117. package/build/cjs/orchestrion/config/langgraph.js.map +1 -0
  118. package/build/cjs/orchestrion/config/lru-memoizer.js.map +1 -1
  119. package/build/cjs/orchestrion/config/mongodb.js +67 -0
  120. package/build/cjs/orchestrion/config/mongodb.js.map +1 -0
  121. package/build/cjs/orchestrion/config/mongoose.js +107 -0
  122. package/build/cjs/orchestrion/config/mongoose.js.map +1 -0
  123. package/build/cjs/orchestrion/config/mysql.js.map +1 -1
  124. package/build/cjs/orchestrion/config/mysql2.js +32 -0
  125. package/build/cjs/orchestrion/config/mysql2.js.map +1 -0
  126. package/build/cjs/orchestrion/config/nestjs.js +122 -0
  127. package/build/cjs/orchestrion/config/nestjs.js.map +1 -0
  128. package/build/cjs/orchestrion/config/openai.js +5 -5
  129. package/build/cjs/orchestrion/config/openai.js.map +1 -1
  130. package/build/cjs/orchestrion/config/pg.js.map +1 -1
  131. package/build/cjs/orchestrion/config/postgres.js.map +1 -1
  132. package/build/cjs/orchestrion/config/prisma.js +8 -0
  133. package/build/cjs/orchestrion/config/prisma.js.map +1 -0
  134. package/build/cjs/orchestrion/config/react-router.js +8 -0
  135. package/build/cjs/orchestrion/config/react-router.js.map +1 -0
  136. package/build/cjs/orchestrion/config/redis.js.map +1 -1
  137. package/build/cjs/orchestrion/config/remix.js +54 -0
  138. package/build/cjs/orchestrion/config/remix.js.map +1 -0
  139. package/build/cjs/orchestrion/config/tedious.js +24 -0
  140. package/build/cjs/orchestrion/config/tedious.js.map +1 -0
  141. package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -1
  142. package/build/cjs/orchestrion/detect.js +12 -11
  143. package/build/cjs/orchestrion/detect.js.map +1 -1
  144. package/build/cjs/orchestrion/index.js +44 -6
  145. package/build/cjs/orchestrion/index.js.map +1 -1
  146. package/build/cjs/orchestrion/runtime/register.js +45 -21
  147. package/build/cjs/orchestrion/runtime/register.js.map +1 -1
  148. package/build/cjs/prisma/global.js +14 -0
  149. package/build/cjs/prisma/global.js.map +1 -0
  150. package/build/cjs/prisma/index.js +27 -0
  151. package/build/cjs/prisma/index.js.map +1 -0
  152. package/build/cjs/prisma/tracing-helper.js +211 -0
  153. package/build/cjs/prisma/tracing-helper.js.map +1 -0
  154. package/build/cjs/redis/redis-dc-subscriber.js +27 -38
  155. package/build/cjs/redis/redis-dc-subscriber.js.map +1 -1
  156. package/build/cjs/vercel-ai/util.js +0 -11
  157. package/build/cjs/vercel-ai/util.js.map +1 -1
  158. package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js +9 -9
  159. package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  160. package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js +16 -3
  161. package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -1
  162. package/build/esm/graphql/graphql-dc-subscriber.js +3 -5
  163. package/build/esm/graphql/graphql-dc-subscriber.js.map +1 -1
  164. package/build/esm/graphql/utils.js +8 -2
  165. package/build/esm/graphql/utils.js.map +1 -1
  166. package/build/esm/index.js +3 -0
  167. package/build/esm/index.js.map +1 -1
  168. package/build/esm/integrations/tracing-channel/aws-sdk/constants.js +9 -0
  169. package/build/esm/integrations/tracing-channel/aws-sdk/constants.js.map +1 -0
  170. package/build/esm/integrations/tracing-channel/aws-sdk/index.js +152 -0
  171. package/build/esm/integrations/tracing-channel/aws-sdk/index.js.map +1 -0
  172. package/build/esm/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js +41 -0
  173. package/build/esm/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js.map +1 -0
  174. package/build/esm/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js +45 -0
  175. package/build/esm/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js.map +1 -0
  176. package/build/esm/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js +417 -0
  177. package/build/esm/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js.map +1 -0
  178. package/build/esm/integrations/tracing-channel/aws-sdk/services/dynamodb.js +129 -0
  179. package/build/esm/integrations/tracing-channel/aws-sdk/services/dynamodb.js.map +1 -0
  180. package/build/esm/integrations/tracing-channel/aws-sdk/services/kinesis.js +19 -0
  181. package/build/esm/integrations/tracing-channel/aws-sdk/services/kinesis.js.map +1 -0
  182. package/build/esm/integrations/tracing-channel/aws-sdk/services/lambda.js +62 -0
  183. package/build/esm/integrations/tracing-channel/aws-sdk/services/lambda.js.map +1 -0
  184. package/build/esm/integrations/tracing-channel/aws-sdk/services/s3.js +19 -0
  185. package/build/esm/integrations/tracing-channel/aws-sdk/services/s3.js.map +1 -0
  186. package/build/esm/integrations/tracing-channel/aws-sdk/services/secretsmanager.js +25 -0
  187. package/build/esm/integrations/tracing-channel/aws-sdk/services/secretsmanager.js.map +1 -0
  188. package/build/esm/integrations/tracing-channel/aws-sdk/services/sns.js +61 -0
  189. package/build/esm/integrations/tracing-channel/aws-sdk/services/sns.js.map +1 -0
  190. package/build/esm/integrations/tracing-channel/aws-sdk/services/sqs.js +114 -0
  191. package/build/esm/integrations/tracing-channel/aws-sdk/services/sqs.js.map +1 -0
  192. package/build/esm/integrations/tracing-channel/aws-sdk/services/stepfunctions.js +23 -0
  193. package/build/esm/integrations/tracing-channel/aws-sdk/services/stepfunctions.js.map +1 -0
  194. package/build/esm/integrations/tracing-channel/aws-sdk/utils.js +26 -0
  195. package/build/esm/integrations/tracing-channel/aws-sdk/utils.js.map +1 -0
  196. package/build/esm/integrations/tracing-channel/dataloader.js +93 -0
  197. package/build/esm/integrations/tracing-channel/dataloader.js.map +1 -0
  198. package/build/esm/integrations/tracing-channel/express/instrumentation.js +1 -6
  199. package/build/esm/integrations/tracing-channel/express/instrumentation.js.map +1 -1
  200. package/build/esm/integrations/tracing-channel/generic-pool.js +32 -0
  201. package/build/esm/integrations/tracing-channel/generic-pool.js.map +1 -0
  202. package/build/esm/integrations/tracing-channel/graphql/spans.js +3 -3
  203. package/build/esm/integrations/tracing-channel/graphql/spans.js.map +1 -1
  204. package/build/esm/integrations/tracing-channel/ioredis.js +29 -27
  205. package/build/esm/integrations/tracing-channel/ioredis.js.map +1 -1
  206. package/build/esm/integrations/tracing-channel/kafkajs/consumer.js +67 -0
  207. package/build/esm/integrations/tracing-channel/kafkajs/consumer.js.map +1 -0
  208. package/build/esm/integrations/tracing-channel/kafkajs/index.js +68 -0
  209. package/build/esm/integrations/tracing-channel/kafkajs/index.js.map +1 -0
  210. package/build/esm/integrations/tracing-channel/kafkajs/semconv.js +12 -0
  211. package/build/esm/integrations/tracing-channel/kafkajs/semconv.js.map +1 -0
  212. package/build/esm/integrations/tracing-channel/kafkajs/spans.js +112 -0
  213. package/build/esm/integrations/tracing-channel/kafkajs/spans.js.map +1 -0
  214. package/build/esm/integrations/tracing-channel/knex.js +186 -0
  215. package/build/esm/integrations/tracing-channel/knex.js.map +1 -0
  216. package/build/esm/integrations/tracing-channel/koa.js +144 -0
  217. package/build/esm/integrations/tracing-channel/koa.js.map +1 -0
  218. package/build/esm/integrations/tracing-channel/langchain.js +61 -0
  219. package/build/esm/integrations/tracing-channel/langchain.js.map +1 -0
  220. package/build/esm/integrations/tracing-channel/langgraph.js +98 -0
  221. package/build/esm/integrations/tracing-channel/langgraph.js.map +1 -0
  222. package/build/esm/integrations/tracing-channel/mongodb.js +102 -0
  223. package/build/esm/integrations/tracing-channel/mongodb.js.map +1 -0
  224. package/build/esm/integrations/tracing-channel/mongoose.js +108 -0
  225. package/build/esm/integrations/tracing-channel/mongoose.js.map +1 -0
  226. package/build/esm/integrations/tracing-channel/mysql2.js +81 -0
  227. package/build/esm/integrations/tracing-channel/mysql2.js.map +1 -0
  228. package/build/esm/integrations/tracing-channel/openai.js +1 -3
  229. package/build/esm/integrations/tracing-channel/openai.js.map +1 -1
  230. package/build/esm/integrations/tracing-channel/redis.js +25 -34
  231. package/build/esm/integrations/tracing-channel/redis.js.map +1 -1
  232. package/build/esm/integrations/tracing-channel/tedious.js +143 -0
  233. package/build/esm/integrations/tracing-channel/tedious.js.map +1 -0
  234. package/build/esm/mongodb/mongodb-span.js +126 -0
  235. package/build/esm/mongodb/mongodb-span.js.map +1 -0
  236. package/build/esm/mongoose/index.js.map +1 -1
  237. package/build/esm/mongoose/mongoose-legacy-span.js +38 -0
  238. package/build/esm/mongoose/mongoose-legacy-span.js.map +1 -0
  239. package/build/esm/orchestrion/bundler/esbuild.js +9 -0
  240. package/build/esm/orchestrion/bundler/esbuild.js.map +1 -0
  241. package/build/esm/orchestrion/bundler/options.js +22 -0
  242. package/build/esm/orchestrion/bundler/options.js.map +1 -0
  243. package/build/esm/orchestrion/bundler/rollup.js +9 -0
  244. package/build/esm/orchestrion/bundler/rollup.js.map +1 -0
  245. package/build/esm/orchestrion/bundler/vite.js +5 -22
  246. package/build/esm/orchestrion/bundler/vite.js.map +1 -1
  247. package/build/esm/orchestrion/bundler/webpack.js +27 -0
  248. package/build/esm/orchestrion/bundler/webpack.js.map +1 -0
  249. package/build/esm/orchestrion/channels.js +54 -20
  250. package/build/esm/orchestrion/channels.js.map +1 -1
  251. package/build/esm/orchestrion/config/amqplib.js.map +1 -1
  252. package/build/esm/orchestrion/config/anthropic-ai.js.map +1 -1
  253. package/build/esm/orchestrion/config/aws-sdk.js +25 -0
  254. package/build/esm/orchestrion/config/aws-sdk.js.map +1 -0
  255. package/build/esm/orchestrion/config/dataloader.js +50 -0
  256. package/build/esm/orchestrion/config/dataloader.js.map +1 -0
  257. package/build/esm/orchestrion/config/express.js +9 -8
  258. package/build/esm/orchestrion/config/express.js.map +1 -1
  259. package/build/esm/orchestrion/config/firebase.js +5 -0
  260. package/build/esm/orchestrion/config/firebase.js.map +1 -0
  261. package/build/esm/orchestrion/config/generic-pool.js +18 -0
  262. package/build/esm/orchestrion/config/generic-pool.js.map +1 -0
  263. package/build/esm/orchestrion/config/google-genai.js.map +1 -1
  264. package/build/esm/orchestrion/config/graphql.js.map +1 -1
  265. package/build/esm/orchestrion/config/hapi.js.map +1 -1
  266. package/build/esm/orchestrion/config/index.js +64 -24
  267. package/build/esm/orchestrion/config/index.js.map +1 -1
  268. package/build/esm/orchestrion/config/ioredis.js.map +1 -1
  269. package/build/esm/orchestrion/config/kafkajs.js +27 -0
  270. package/build/esm/orchestrion/config/kafkajs.js.map +1 -0
  271. package/build/esm/orchestrion/config/knex.js +40 -0
  272. package/build/esm/orchestrion/config/knex.js.map +1 -0
  273. package/build/esm/orchestrion/config/koa.js +13 -0
  274. package/build/esm/orchestrion/config/koa.js.map +1 -0
  275. package/build/esm/orchestrion/config/langchain.js +48 -0
  276. package/build/esm/orchestrion/config/langchain.js.map +1 -0
  277. package/build/esm/orchestrion/config/langgraph.js +25 -0
  278. package/build/esm/orchestrion/config/langgraph.js.map +1 -0
  279. package/build/esm/orchestrion/config/lru-memoizer.js.map +1 -1
  280. package/build/esm/orchestrion/config/mongodb.js +64 -0
  281. package/build/esm/orchestrion/config/mongodb.js.map +1 -0
  282. package/build/esm/orchestrion/config/mongoose.js +103 -0
  283. package/build/esm/orchestrion/config/mongoose.js.map +1 -0
  284. package/build/esm/orchestrion/config/mysql.js.map +1 -1
  285. package/build/esm/orchestrion/config/mysql2.js +29 -0
  286. package/build/esm/orchestrion/config/mysql2.js.map +1 -0
  287. package/build/esm/orchestrion/config/nestjs.js +119 -0
  288. package/build/esm/orchestrion/config/nestjs.js.map +1 -0
  289. package/build/esm/orchestrion/config/openai.js +5 -5
  290. package/build/esm/orchestrion/config/openai.js.map +1 -1
  291. package/build/esm/orchestrion/config/pg.js.map +1 -1
  292. package/build/esm/orchestrion/config/postgres.js.map +1 -1
  293. package/build/esm/orchestrion/config/prisma.js +5 -0
  294. package/build/esm/orchestrion/config/prisma.js.map +1 -0
  295. package/build/esm/orchestrion/config/react-router.js +5 -0
  296. package/build/esm/orchestrion/config/react-router.js.map +1 -0
  297. package/build/esm/orchestrion/config/redis.js.map +1 -1
  298. package/build/esm/orchestrion/config/remix.js +51 -0
  299. package/build/esm/orchestrion/config/remix.js.map +1 -0
  300. package/build/esm/orchestrion/config/tedious.js +21 -0
  301. package/build/esm/orchestrion/config/tedious.js.map +1 -0
  302. package/build/esm/orchestrion/config/vercel-ai.js.map +1 -1
  303. package/build/esm/orchestrion/detect.js +13 -12
  304. package/build/esm/orchestrion/detect.js.map +1 -1
  305. package/build/esm/orchestrion/index.js +26 -2
  306. package/build/esm/orchestrion/index.js.map +1 -1
  307. package/build/esm/orchestrion/runtime/register.js +47 -23
  308. package/build/esm/orchestrion/runtime/register.js.map +1 -1
  309. package/build/esm/package.json +1 -1
  310. package/build/esm/prisma/global.js +12 -0
  311. package/build/esm/prisma/global.js.map +1 -0
  312. package/build/esm/prisma/index.js +24 -0
  313. package/build/esm/prisma/index.js.map +1 -0
  314. package/build/esm/prisma/tracing-helper.js +209 -0
  315. package/build/esm/prisma/tracing-helper.js.map +1 -0
  316. package/build/esm/redis/redis-dc-subscriber.js +27 -38
  317. package/build/esm/redis/redis-dc-subscriber.js.map +1 -1
  318. package/build/esm/vercel-ai/util.js +1 -11
  319. package/build/esm/vercel-ai/util.js.map +1 -1
  320. package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js +11 -11
  321. package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  322. package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js +17 -4
  323. package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -1
  324. package/build/types/graphql/utils.d.ts +2 -6
  325. package/build/types/graphql/utils.d.ts.map +1 -1
  326. package/build/types/index.d.ts +7 -1
  327. package/build/types/index.d.ts.map +1 -1
  328. package/build/types/integrations/tracing-channel/aws-sdk/aws-sdk.types.d.ts +43 -0
  329. package/build/types/integrations/tracing-channel/aws-sdk/aws-sdk.types.d.ts.map +1 -0
  330. package/build/types/integrations/tracing-channel/aws-sdk/constants.d.ts +15 -0
  331. package/build/types/integrations/tracing-channel/aws-sdk/constants.d.ts.map +1 -0
  332. package/build/types/integrations/tracing-channel/aws-sdk/index.d.ts +15 -0
  333. package/build/types/integrations/tracing-channel/aws-sdk/index.d.ts.map +1 -0
  334. package/build/types/integrations/tracing-channel/aws-sdk/services/MessageAttributes.d.ts +23 -0
  335. package/build/types/integrations/tracing-channel/aws-sdk/services/MessageAttributes.d.ts.map +1 -0
  336. package/build/types/integrations/tracing-channel/aws-sdk/services/ServiceExtension.d.ts +9 -0
  337. package/build/types/integrations/tracing-channel/aws-sdk/services/ServiceExtension.d.ts.map +1 -0
  338. package/build/types/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.d.ts +10 -0
  339. package/build/types/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.d.ts.map +1 -0
  340. package/build/types/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.d.ts +14 -0
  341. package/build/types/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.d.ts.map +1 -0
  342. package/build/types/integrations/tracing-channel/aws-sdk/services/dynamodb.d.ts +8 -0
  343. package/build/types/integrations/tracing-channel/aws-sdk/services/dynamodb.d.ts.map +1 -0
  344. package/build/types/integrations/tracing-channel/aws-sdk/services/index.d.ts +2 -0
  345. package/build/types/integrations/tracing-channel/aws-sdk/services/index.d.ts.map +1 -0
  346. package/build/types/integrations/tracing-channel/aws-sdk/services/kinesis.d.ts +6 -0
  347. package/build/types/integrations/tracing-channel/aws-sdk/services/kinesis.d.ts.map +1 -0
  348. package/build/types/integrations/tracing-channel/aws-sdk/services/lambda.d.ts +9 -0
  349. package/build/types/integrations/tracing-channel/aws-sdk/services/lambda.d.ts.map +1 -0
  350. package/build/types/integrations/tracing-channel/aws-sdk/services/s3.d.ts +6 -0
  351. package/build/types/integrations/tracing-channel/aws-sdk/services/s3.d.ts.map +1 -0
  352. package/build/types/integrations/tracing-channel/aws-sdk/services/secretsmanager.d.ts +8 -0
  353. package/build/types/integrations/tracing-channel/aws-sdk/services/secretsmanager.d.ts.map +1 -0
  354. package/build/types/integrations/tracing-channel/aws-sdk/services/sns.d.ts +9 -0
  355. package/build/types/integrations/tracing-channel/aws-sdk/services/sns.d.ts.map +1 -0
  356. package/build/types/integrations/tracing-channel/aws-sdk/services/sqs.d.ts +9 -0
  357. package/build/types/integrations/tracing-channel/aws-sdk/services/sqs.d.ts.map +1 -0
  358. package/build/types/integrations/tracing-channel/aws-sdk/services/stepfunctions.d.ts +6 -0
  359. package/build/types/integrations/tracing-channel/aws-sdk/services/stepfunctions.d.ts.map +1 -0
  360. package/build/types/integrations/tracing-channel/aws-sdk/types.d.ts +26 -0
  361. package/build/types/integrations/tracing-channel/aws-sdk/types.d.ts.map +1 -0
  362. package/build/types/integrations/tracing-channel/aws-sdk/utils.d.ts +5 -0
  363. package/build/types/integrations/tracing-channel/aws-sdk/utils.d.ts.map +1 -0
  364. package/build/types/integrations/tracing-channel/dataloader.d.ts +11 -0
  365. package/build/types/integrations/tracing-channel/dataloader.d.ts.map +1 -0
  366. package/build/types/integrations/tracing-channel/express/instrumentation.d.ts.map +1 -1
  367. package/build/types/integrations/tracing-channel/generic-pool.d.ts +10 -0
  368. package/build/types/integrations/tracing-channel/generic-pool.d.ts.map +1 -0
  369. package/build/types/integrations/tracing-channel/ioredis.d.ts +20 -0
  370. package/build/types/integrations/tracing-channel/ioredis.d.ts.map +1 -1
  371. package/build/types/integrations/tracing-channel/kafkajs/consumer.d.ts +8 -0
  372. package/build/types/integrations/tracing-channel/kafkajs/consumer.d.ts.map +1 -0
  373. package/build/types/integrations/tracing-channel/kafkajs/index.d.ts +17 -0
  374. package/build/types/integrations/tracing-channel/kafkajs/index.d.ts.map +1 -0
  375. package/build/types/integrations/tracing-channel/kafkajs/semconv.d.ts +10 -0
  376. package/build/types/integrations/tracing-channel/kafkajs/semconv.d.ts.map +1 -0
  377. package/build/types/integrations/tracing-channel/kafkajs/spans.d.ts +38 -0
  378. package/build/types/integrations/tracing-channel/kafkajs/spans.d.ts.map +1 -0
  379. package/build/types/integrations/tracing-channel/kafkajs/types.d.ts +40 -0
  380. package/build/types/integrations/tracing-channel/kafkajs/types.d.ts.map +1 -0
  381. package/build/types/integrations/tracing-channel/knex.d.ts +11 -0
  382. package/build/types/integrations/tracing-channel/knex.d.ts.map +1 -0
  383. package/build/types/integrations/tracing-channel/koa.d.ts +14 -0
  384. package/build/types/integrations/tracing-channel/koa.d.ts.map +1 -0
  385. package/build/types/integrations/tracing-channel/langchain.d.ts +10 -0
  386. package/build/types/integrations/tracing-channel/langchain.d.ts.map +1 -0
  387. package/build/types/integrations/tracing-channel/langgraph.d.ts +10 -0
  388. package/build/types/integrations/tracing-channel/langgraph.d.ts.map +1 -0
  389. package/build/types/integrations/tracing-channel/mongodb.d.ts +12 -0
  390. package/build/types/integrations/tracing-channel/mongodb.d.ts.map +1 -0
  391. package/build/types/integrations/tracing-channel/mongoose.d.ts +15 -0
  392. package/build/types/integrations/tracing-channel/mongoose.d.ts.map +1 -0
  393. package/build/types/integrations/tracing-channel/mysql2.d.ts +15 -0
  394. package/build/types/integrations/tracing-channel/mysql2.d.ts.map +1 -0
  395. package/build/types/integrations/tracing-channel/openai.d.ts.map +1 -1
  396. package/build/types/integrations/tracing-channel/redis.d.ts.map +1 -1
  397. package/build/types/integrations/tracing-channel/tedious.d.ts +11 -0
  398. package/build/types/integrations/tracing-channel/tedious.d.ts.map +1 -0
  399. package/build/types/mongodb/mongodb-span.d.ts +66 -0
  400. package/build/types/mongodb/mongodb-span.d.ts.map +1 -0
  401. package/build/types/mongoose/index.d.ts +2 -0
  402. package/build/types/mongoose/index.d.ts.map +1 -1
  403. package/build/types/mongoose/mongoose-legacy-span.d.ts +29 -0
  404. package/build/types/mongoose/mongoose-legacy-span.d.ts.map +1 -0
  405. package/build/types/orchestrion/bundler/esbuild.d.ts +21 -0
  406. package/build/types/orchestrion/bundler/esbuild.d.ts.map +1 -0
  407. package/build/types/orchestrion/bundler/options.d.ts +29 -0
  408. package/build/types/orchestrion/bundler/options.d.ts.map +1 -0
  409. package/build/types/orchestrion/bundler/rollup.d.ts +17 -0
  410. package/build/types/orchestrion/bundler/rollup.d.ts.map +1 -0
  411. package/build/types/orchestrion/bundler/vite.d.ts +4 -17
  412. package/build/types/orchestrion/bundler/vite.d.ts.map +1 -1
  413. package/build/types/orchestrion/bundler/webpack.d.ts +19 -0
  414. package/build/types/orchestrion/bundler/webpack.d.ts.map +1 -0
  415. package/build/types/orchestrion/channels.d.ts +94 -37
  416. package/build/types/orchestrion/channels.d.ts.map +1 -1
  417. package/build/types/orchestrion/config/aws-sdk.d.ts +19 -0
  418. package/build/types/orchestrion/config/aws-sdk.d.ts.map +1 -0
  419. package/build/types/orchestrion/config/dataloader.d.ts +46 -0
  420. package/build/types/orchestrion/config/dataloader.d.ts.map +1 -0
  421. package/build/types/orchestrion/config/express.d.ts +2 -4
  422. package/build/types/orchestrion/config/express.d.ts.map +1 -1
  423. package/build/types/orchestrion/config/firebase.d.ts +4 -0
  424. package/build/types/orchestrion/config/firebase.d.ts.map +1 -0
  425. package/build/types/orchestrion/config/generic-pool.d.ts +31 -0
  426. package/build/types/orchestrion/config/generic-pool.d.ts.map +1 -0
  427. package/build/types/orchestrion/config/index.d.ts +19 -6
  428. package/build/types/orchestrion/config/index.d.ts.map +1 -1
  429. package/build/types/orchestrion/config/ioredis.d.ts +1 -1
  430. package/build/types/orchestrion/config/ioredis.d.ts.map +1 -1
  431. package/build/types/orchestrion/config/kafkajs.d.ts +17 -0
  432. package/build/types/orchestrion/config/kafkajs.d.ts.map +1 -0
  433. package/build/types/orchestrion/config/knex.d.ts +9 -0
  434. package/build/types/orchestrion/config/knex.d.ts.map +1 -0
  435. package/build/types/orchestrion/config/koa.d.ts +17 -0
  436. package/build/types/orchestrion/config/koa.d.ts.map +1 -0
  437. package/build/types/orchestrion/config/langchain.d.ts +18 -0
  438. package/build/types/orchestrion/config/langchain.d.ts.map +1 -0
  439. package/build/types/orchestrion/config/langgraph.d.ts +21 -0
  440. package/build/types/orchestrion/config/langgraph.d.ts.map +1 -0
  441. package/build/types/orchestrion/config/mongodb.d.ts +59 -0
  442. package/build/types/orchestrion/config/mongodb.d.ts.map +1 -0
  443. package/build/types/orchestrion/config/mongoose.d.ts +40 -0
  444. package/build/types/orchestrion/config/mongoose.d.ts.map +1 -0
  445. package/build/types/orchestrion/config/mysql2.d.ts +18 -0
  446. package/build/types/orchestrion/config/mysql2.d.ts.map +1 -0
  447. package/build/types/orchestrion/config/nestjs.d.ts +24 -0
  448. package/build/types/orchestrion/config/nestjs.d.ts.map +1 -0
  449. package/build/types/orchestrion/config/openai.d.ts +0 -2
  450. package/build/types/orchestrion/config/openai.d.ts.map +1 -1
  451. package/build/types/orchestrion/config/postgres.d.ts +1 -1
  452. package/build/types/orchestrion/config/postgres.d.ts.map +1 -1
  453. package/build/types/orchestrion/config/prisma.d.ts +4 -0
  454. package/build/types/orchestrion/config/prisma.d.ts.map +1 -0
  455. package/build/types/orchestrion/config/react-router.d.ts +4 -0
  456. package/build/types/orchestrion/config/react-router.d.ts.map +1 -0
  457. package/build/types/orchestrion/config/remix.d.ts +9 -0
  458. package/build/types/orchestrion/config/remix.d.ts.map +1 -0
  459. package/build/types/orchestrion/config/tedious.d.ts +12 -0
  460. package/build/types/orchestrion/config/tedious.d.ts.map +1 -0
  461. package/build/types/orchestrion/config/vercel-ai.d.ts +1 -1
  462. package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -1
  463. package/build/types/orchestrion/detect.d.ts +3 -10
  464. package/build/types/orchestrion/detect.d.ts.map +1 -1
  465. package/build/types/orchestrion/index.d.ts +56 -1
  466. package/build/types/orchestrion/index.d.ts.map +1 -1
  467. package/build/types/orchestrion/runtime/register.d.ts +11 -9
  468. package/build/types/orchestrion/runtime/register.d.ts.map +1 -1
  469. package/build/types/prisma/global.d.ts +5 -0
  470. package/build/types/prisma/global.d.ts.map +1 -0
  471. package/build/types/prisma/index.d.ts +45 -0
  472. package/build/types/prisma/index.d.ts.map +1 -0
  473. package/build/types/prisma/tracing-helper.d.ts +46 -0
  474. package/build/types/prisma/tracing-helper.d.ts.map +1 -0
  475. package/build/types/prisma/types.d.ts +37 -0
  476. package/build/types/prisma/types.d.ts.map +1 -0
  477. package/build/types/vercel-ai/util.d.ts +0 -2
  478. package/build/types/vercel-ai/util.d.ts.map +1 -1
  479. package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
  480. package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts.map +1 -1
  481. package/build/types-ts3.8/graphql/utils.d.ts +2 -6
  482. package/build/types-ts3.8/index.d.ts +7 -1
  483. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/aws-sdk.types.d.ts +43 -0
  484. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/constants.d.ts +15 -0
  485. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/index.d.ts +15 -0
  486. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/MessageAttributes.d.ts +23 -0
  487. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/ServiceExtension.d.ts +9 -0
  488. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.d.ts +10 -0
  489. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.d.ts +14 -0
  490. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/dynamodb.d.ts +8 -0
  491. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/index.d.ts +2 -0
  492. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/kinesis.d.ts +6 -0
  493. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/lambda.d.ts +9 -0
  494. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/s3.d.ts +6 -0
  495. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/secretsmanager.d.ts +8 -0
  496. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/sns.d.ts +9 -0
  497. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/sqs.d.ts +9 -0
  498. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/stepfunctions.d.ts +6 -0
  499. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/types.d.ts +26 -0
  500. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/utils.d.ts +5 -0
  501. package/build/types-ts3.8/integrations/tracing-channel/dataloader.d.ts +11 -0
  502. package/build/types-ts3.8/integrations/tracing-channel/generic-pool.d.ts +10 -0
  503. package/build/types-ts3.8/integrations/tracing-channel/ioredis.d.ts +20 -0
  504. package/build/types-ts3.8/integrations/tracing-channel/kafkajs/consumer.d.ts +8 -0
  505. package/build/types-ts3.8/integrations/tracing-channel/kafkajs/index.d.ts +17 -0
  506. package/build/types-ts3.8/integrations/tracing-channel/kafkajs/semconv.d.ts +10 -0
  507. package/build/types-ts3.8/integrations/tracing-channel/kafkajs/spans.d.ts +38 -0
  508. package/build/types-ts3.8/integrations/tracing-channel/kafkajs/types.d.ts +40 -0
  509. package/build/types-ts3.8/integrations/tracing-channel/knex.d.ts +11 -0
  510. package/build/types-ts3.8/integrations/tracing-channel/koa.d.ts +14 -0
  511. package/build/types-ts3.8/integrations/tracing-channel/langchain.d.ts +10 -0
  512. package/build/types-ts3.8/integrations/tracing-channel/langgraph.d.ts +10 -0
  513. package/build/types-ts3.8/integrations/tracing-channel/mongodb.d.ts +12 -0
  514. package/build/types-ts3.8/integrations/tracing-channel/mongoose.d.ts +15 -0
  515. package/build/types-ts3.8/integrations/tracing-channel/mysql2.d.ts +15 -0
  516. package/build/types-ts3.8/integrations/tracing-channel/tedious.d.ts +11 -0
  517. package/build/types-ts3.8/mongodb/mongodb-span.d.ts +66 -0
  518. package/build/types-ts3.8/mongoose/index.d.ts +2 -0
  519. package/build/types-ts3.8/mongoose/mongoose-legacy-span.d.ts +29 -0
  520. package/build/types-ts3.8/orchestrion/bundler/esbuild.d.ts +21 -0
  521. package/build/types-ts3.8/orchestrion/bundler/options.d.ts +29 -0
  522. package/build/types-ts3.8/orchestrion/bundler/rollup.d.ts +17 -0
  523. package/build/types-ts3.8/orchestrion/bundler/vite.d.ts +4 -17
  524. package/build/types-ts3.8/orchestrion/bundler/webpack.d.ts +19 -0
  525. package/build/types-ts3.8/orchestrion/channels.d.ts +94 -37
  526. package/build/types-ts3.8/orchestrion/config/aws-sdk.d.ts +19 -0
  527. package/build/types-ts3.8/orchestrion/config/dataloader.d.ts +46 -0
  528. package/build/types-ts3.8/orchestrion/config/express.d.ts +2 -4
  529. package/build/types-ts3.8/orchestrion/config/firebase.d.ts +4 -0
  530. package/build/types-ts3.8/orchestrion/config/generic-pool.d.ts +31 -0
  531. package/build/types-ts3.8/orchestrion/config/index.d.ts +19 -6
  532. package/build/types-ts3.8/orchestrion/config/ioredis.d.ts +1 -1
  533. package/build/types-ts3.8/orchestrion/config/kafkajs.d.ts +17 -0
  534. package/build/types-ts3.8/orchestrion/config/knex.d.ts +9 -0
  535. package/build/types-ts3.8/orchestrion/config/koa.d.ts +17 -0
  536. package/build/types-ts3.8/orchestrion/config/langchain.d.ts +18 -0
  537. package/build/types-ts3.8/orchestrion/config/langgraph.d.ts +21 -0
  538. package/build/types-ts3.8/orchestrion/config/mongodb.d.ts +59 -0
  539. package/build/types-ts3.8/orchestrion/config/mongoose.d.ts +40 -0
  540. package/build/types-ts3.8/orchestrion/config/mysql2.d.ts +18 -0
  541. package/build/types-ts3.8/orchestrion/config/nestjs.d.ts +24 -0
  542. package/build/types-ts3.8/orchestrion/config/openai.d.ts +0 -2
  543. package/build/types-ts3.8/orchestrion/config/postgres.d.ts +1 -1
  544. package/build/types-ts3.8/orchestrion/config/prisma.d.ts +4 -0
  545. package/build/types-ts3.8/orchestrion/config/react-router.d.ts +4 -0
  546. package/build/types-ts3.8/orchestrion/config/remix.d.ts +9 -0
  547. package/build/types-ts3.8/orchestrion/config/tedious.d.ts +12 -0
  548. package/build/types-ts3.8/orchestrion/config/vercel-ai.d.ts +1 -1
  549. package/build/types-ts3.8/orchestrion/detect.d.ts +3 -10
  550. package/build/types-ts3.8/orchestrion/index.d.ts +56 -1
  551. package/build/types-ts3.8/orchestrion/runtime/register.d.ts +11 -9
  552. package/build/types-ts3.8/prisma/global.d.ts +5 -0
  553. package/build/types-ts3.8/prisma/index.d.ts +45 -0
  554. package/build/types-ts3.8/prisma/tracing-helper.d.ts +52 -0
  555. package/build/types-ts3.8/prisma/types.d.ts +40 -0
  556. package/build/types-ts3.8/vercel-ai/util.d.ts +0 -2
  557. package/package.json +40 -8
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing-channel/express/instrumentation.ts"],"sourcesContent":["import type * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { HTTP_ROUTE } from '@sentry/conventions/attributes';\nimport type { Span } from '@sentry/core';\nimport {\n debug,\n getActiveSpan,\n getDefaultIsolationScope,\n getIsolationScope,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n startInactiveSpan,\n stringMatchesSomePattern,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport { CHANNELS } from '../../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../../tracing-channel';\nimport {\n getActualMatchedRoute,\n getConstructedRoute,\n getLayerPath,\n getLayerRegisteredPath,\n popLayerPath,\n pushLayerPath,\n setLayerRegisteredPath,\n} from './route';\nimport type {\n ExpressIntegrationOptions,\n ExpressLayer,\n ExpressLayerType,\n ExpressRequest,\n ExpressResponse,\n HandleChannelContext,\n RegistrationChannelContext,\n} from './types';\n\nconst ORIGIN = 'auto.http.express';\n\n// `express.name`/`express.type` are Sentry-internal Express attributes (not part\n// of `@sentry/conventions`); kept in sync with `@sentry/core`'s OTel-derived\n// Express integration so the emitted spans are identical across both code paths.\nconst ATTR_EXPRESS_NAME = 'express.name';\nconst ATTR_EXPRESS_TYPE = 'express.type';\n\nconst NOOP = (): void => {};\n\nlet _isInstrumented = false;\n\nexport function instrumentExpress(\n options: ExpressIntegrationOptions,\n tracingChannel: typeof diagnosticsChannel.tracingChannel,\n): void {\n if (_isInstrumented) {\n return;\n }\n _isInstrumented = true;\n\n // Record each layer's registered path *pattern* as it is registered, so the\n // matched route can be reconstructed with its parameters intact at request\n // time. Only the `end` event matters (the layer is on the router's stack by\n // then); the others are required by the subscriber type, so no-op them.\n for (const channelName of [\n CHANNELS.EXPRESS_ROUTE,\n CHANNELS.EXPRESS_USE,\n CHANNELS.ROUTER_ROUTE,\n CHANNELS.ROUTER_USE,\n ]) {\n tracingChannel<RegistrationChannelContext>(channelName).subscribe({\n start: NOOP,\n asyncStart: NOOP,\n asyncEnd: NOOP,\n error: NOOP,\n end: captureRegisteredLayerPath,\n });\n }\n\n for (const channelName of [CHANNELS.EXPRESS_HANDLE, CHANNELS.ROUTER_HANDLE]) {\n DEBUG_BUILD && debug.log(`[orchestrion:express] subscribing to channel \"${channelName}\"`);\n\n const channel = tracingChannel<HandleChannelContext>(channelName);\n\n bindTracingChannelToSpan(channel, data => getSpanForLayer(data, options), {\n beforeSpanEnd(_span, data) {\n data._sentryCleanup?.();\n },\n });\n\n // Pop the layer path when the layer hands off via `next`. `asyncStart` fires\n // when `next` is called and *before* the downstream layer runs, so the\n // per-request path chain reflects only the current chain when each layer\n // reconstructs its route. Only `asyncStart` is relevant here.\n channel.subscribe({\n start: NOOP,\n asyncEnd: NOOP,\n end: NOOP,\n error: NOOP,\n asyncStart: popLayerPathForLayer,\n });\n }\n}\n\n/** Record the freshly-registered layer's path pattern from a `route`/`use` call. */\nfunction captureRegisteredLayerPath(data: RegistrationChannelContext): void {\n const stack = data.self?.stack;\n if (!Array.isArray(stack)) {\n return;\n }\n const layer = stack[stack.length - 1];\n if (layer) {\n setLayerRegisteredPath(layer, getLayerPath(data.arguments ?? []));\n }\n}\n\n/** Pop the path a layer pushed once it hands control onward via `next`. */\nfunction popLayerPathForLayer(data: HandleChannelContext): void {\n if (!data._sentryStoredLayer) {\n return;\n }\n // Clear the marker first so a layer that (incorrectly) calls `next` more than\n // once can't pop again and take a parent's entry off the stack with it.\n data._sentryStoredLayer = false;\n const req = data.arguments?.[0] as ExpressRequest | undefined;\n if (req) {\n popLayerPath(req);\n }\n}\n\n/**\n * Open a span for one layer invocation. Returns `undefined` to opt the layer\n * out (error handlers, or a layer with no active parent trace) — the helper\n * then leaves the active context untouched.\n */\nfunction getSpanForLayer(data: HandleChannelContext, options: ExpressIntegrationOptions): Span | undefined {\n const layer = data.self;\n const args = data.arguments;\n if (!layer || !Array.isArray(args)) {\n return undefined;\n }\n\n // Express only treats a 4-arg handler as an error handler and skips it in\n // the normal request pipeline; match the OTel integration and don't trace it.\n if (layer.handle?.length === 4) {\n return undefined;\n }\n\n // A Route dispatches to its handlers via the same `handle_request` method,\n // but those inner layers already run inside the route-dispatch layer's\n // `request_handler` span. They carry `.method` (and no `.route`); skip them\n // so we emit one span per route, matching the OTel Express integration.\n if (layer.method && !layer.route) {\n return undefined;\n }\n\n const req = args[0] as ExpressRequest | undefined;\n const res = args[1] as ExpressResponse | undefined;\n if (!req) {\n return undefined;\n }\n\n // No active parent span means this request is being ignored (unsampled /\n // filtered), so don't open a span\n if (!getActiveSpan()) {\n return undefined;\n }\n\n const type = getLayerType(layer);\n\n // Push this layer's registered path onto the request's chain so a\n // `request_handler` can reconstruct the full route with parameters intact\n // (`req.baseUrl` only exposes the *resolved* mount prefix). The matching pop\n // happens on `asyncStart` when the layer hands off via `next`.\n const registeredPath = getLayerRegisteredPath(layer);\n if (registeredPath != null) {\n pushLayerPath(req, registeredPath);\n data._sentryStoredLayer = true;\n }\n\n // `constructedRoute` (the full registered pattern) names the span/transaction;\n // `matchedRoute` (validated against the request URL) is the `http.route`.\n const constructedRoute = type === 'request_handler' ? getConstructedRoute(req) : undefined;\n const matchedRoute =\n type === 'request_handler' && constructedRoute != null ? getActualMatchedRoute(req, constructedRoute) : undefined;\n\n const name =\n type === 'request_handler'\n ? constructedRoute || 'request handler'\n : type === 'router'\n ? (layer.path ?? '/')\n : (layer.name ?? '<anonymous>');\n\n // Propagate the route to the root `http.server` span *before* the ignore\n // check, so the transaction is still named even when the layer's own span is\n // ignored — matches the OTel Express integration's `onRouteResolved` timing.\n if (matchedRoute) {\n setHttpServerSpanRoute(matchedRoute);\n }\n\n if (type === 'request_handler' && constructedRoute) {\n const isolationScope = getIsolationScope();\n if (isolationScope !== getDefaultIsolationScope()) {\n const method = typeof req.method === 'string' ? req.method.toUpperCase() : 'GET';\n isolationScope.setTransactionName(`${method} ${constructedRoute}`);\n } else {\n DEBUG_BUILD &&\n debug.warn(\n '[orchestrion:express] Isolation scope is still default isolation scope - skipping transaction name',\n );\n }\n }\n\n // Honor `ignoreLayers`/`ignoreLayersType`: skip the span for matching layers.\n // We intentionally do NOT pop the pushed path here (unlike OTel Express, which\n // pops on ignore): the path is still popped on `asyncStart` when the layer\n // calls `next`, so a following sibling isn't polluted, while an ignored\n // *router* keeps its mount prefix on the stack for the sub-stack it dispatches\n // — so routes under an ignored router stay correct. The only entries that\n // never pop come from layers that end the response without `next()`, and those\n // sit on a per-request store that is discarded when the request ends.\n if (isLayerIgnored(name, type, options)) {\n return undefined;\n }\n\n const span = startInactiveSpan({\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.express`,\n [ATTR_EXPRESS_NAME]: name,\n [ATTR_EXPRESS_TYPE]: type,\n ...(matchedRoute ? { [HTTP_ROUTE]: matchedRoute } : {}),\n },\n });\n\n // A layer that sends the response (route handlers, typically) never calls\n // `next`, so the channel's `asyncEnd` never fires. End on the response's\n // `finish` in that case. When `next` *is* called, the helper ends the span\n // (via `asyncEnd`) and `beforeSpanEnd` removes this now-redundant listener.\n if (res && typeof res.once === 'function') {\n const onFinish = (): void => {\n span.end();\n };\n res.once('finish', onFinish);\n data._sentryCleanup = () => res.removeListener('finish', onFinish);\n }\n\n return span;\n}\n\nfunction getLayerType(layer: ExpressLayer): ExpressLayerType {\n if (layer.name === 'router') {\n return 'router';\n }\n // `bound dispatch` (v4) / `handle` — the route-dispatch layer created by `router.route()`.\n if (layer.name === 'bound dispatch' || layer.name === 'handle') {\n return 'request_handler';\n }\n return 'middleware';\n}\n\n/**\n * Propagate the resolved route to the root `http.server` span so the\n * transaction gets a parameterized `http.route`. Mirrors `@sentry/node`'s\n * `setHttpServerSpanRouteAttribute`; inlined to keep this package free of\n * `@sentry/node` deps. No-op unless the root span is an `http.server` span.\n */\nfunction setHttpServerSpanRoute(route: string): void {\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n if (!rootSpan) {\n return;\n }\n if (spanToJSON(rootSpan).data[SEMANTIC_ATTRIBUTE_SENTRY_OP] !== 'http.server') {\n return;\n }\n rootSpan.setAttribute(HTTP_ROUTE, route);\n}\n\n/**\n * Whether a layer should be skipped per the `ignoreLayers`/`ignoreLayersType`\n * options. Matches `@sentry/core`'s Express `isLayerIgnored`: `ignoreLayersType`\n * filters by layer type, `ignoreLayers` matches the layer's name against\n * string/RegExp/predicate patterns (exact string match).\n */\nfunction isLayerIgnored(name: string, type: ExpressLayerType, options: ExpressIntegrationOptions): boolean {\n const { ignoreLayers, ignoreLayersType } = options;\n\n if (Array.isArray(ignoreLayersType) && ignoreLayersType.includes(type)) {\n return true;\n }\n\n if (!Array.isArray(ignoreLayers)) {\n return false;\n }\n\n try {\n return stringMatchesSomePattern(name, ignoreLayers, true);\n } catch {\n return false;\n }\n}\n"],"names":["tracingChannel","CHANNELS","DEBUG_BUILD","debug","bindTracingChannelToSpan","setLayerRegisteredPath","getLayerPath","popLayerPath","getActiveSpan","getLayerRegisteredPath","pushLayerPath","getConstructedRoute","getActualMatchedRoute","getIsolationScope","getDefault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D,EAAA,IAAI,KAAA,CAAM,SAAS,QAAA,EAAU;AAC3B,IAAA,OAAO,QAAA;AAAA,EACT;AAEA,EAAA,IAAI,KAAA,CAAM,IAAA,KAAS,gBAAA,IAAoB,KAAA,CAAM,SAAS,QAAA,EAAU;AAC9D,IAAA,OAAO,iBAAA;AAAA,EACT;AACA,EAAA,OAAO,YAAA;AACT;AAQA,SAAS,uBAAuB,KAAA,EAAqB;AACnD,EAAA,MAAM,aAAaV,kBAAA,EAAc;AACjC,EAAA,MAAM,QAAA,GAAW,UAAA,IAAcW,gBAAA,CAAY,UAAU,CAAA;AACrD,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA;AAAA,EACF;AACA,EAAA,IAAIC,gBAAW,QAAQ,CAAA,CAAE,IAAA,CAAKH,iCAA4B,MAAM,aAAA,EAAe;AAC7E,IAAA;AAAA,EACF;AACA,EAAA,QAAA,CAAS,YAAA,CAAaC,uBAAY,KAAK,CAAA;AACzC;AAQA,SAAS,cAAA,CAAe,IAAA,EAAc,IAAA,EAAwB,OAAA,EAA6C;AACzG,EAAA,MAAM,EAAE,YAAA,EAAc,gBAAA,EAAiB,GAAI,OAAA;AAE3C,EAAA,IAAI,MAAM,OAAA,CAAQ,gBAAgB,KAAK,gBAAA,CAAiB,QAAA,CAAS,IAAI,CAAA,EAAG;AACtE,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,YAAY,CAAA,EAAG;AAChC,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,OAAOG,6BAAA,CAAyB,IAAA,EAAM,YAAA,EAAc,IAAI,CAAA;AAAA,EAC1D,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;;;"}
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing-channel/express/instrumentation.ts"],"sourcesContent":["import type * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { HTTP_ROUTE } from '@sentry/conventions/attributes';\nimport type { Span } from '@sentry/core';\nimport {\n debug,\n getActiveSpan,\n getDefaultIsolationScope,\n getIsolationScope,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n startInactiveSpan,\n stringMatchesSomePattern,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport { CHANNELS } from '../../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../../tracing-channel';\nimport {\n getActualMatchedRoute,\n getConstructedRoute,\n getLayerPath,\n getLayerRegisteredPath,\n popLayerPath,\n pushLayerPath,\n setLayerRegisteredPath,\n} from './route';\nimport type {\n ExpressIntegrationOptions,\n ExpressLayer,\n ExpressLayerType,\n ExpressRequest,\n ExpressResponse,\n HandleChannelContext,\n RegistrationChannelContext,\n} from './types';\n\nconst ORIGIN = 'auto.http.express';\n\n// `express.name`/`express.type` are Sentry-internal Express attributes (not part\n// of `@sentry/conventions`); kept in sync with `@sentry/core`'s OTel-derived\n// Express integration so the emitted spans are identical across both code paths.\nconst ATTR_EXPRESS_NAME = 'express.name';\nconst ATTR_EXPRESS_TYPE = 'express.type';\n\nconst NOOP = (): void => {};\n\nlet _isInstrumented = false;\n\nexport function instrumentExpress(\n options: ExpressIntegrationOptions,\n tracingChannel: typeof diagnosticsChannel.tracingChannel,\n): void {\n if (_isInstrumented) {\n return;\n }\n _isInstrumented = true;\n\n // Record each layer's registered path *pattern* as it is registered, so the\n // matched route can be reconstructed with its parameters intact at request\n // time. Only the `end` event matters (the layer is on the router's stack by\n // then); the others are required by the subscriber type, so no-op them.\n for (const channelName of [CHANNELS.EXPRESS_REGISTER, CHANNELS.ROUTER_REGISTER]) {\n tracingChannel<RegistrationChannelContext>(channelName).subscribe({\n start: NOOP,\n asyncStart: NOOP,\n asyncEnd: NOOP,\n error: NOOP,\n end: captureRegisteredLayerPath,\n });\n }\n\n for (const channelName of [CHANNELS.EXPRESS_HANDLE, CHANNELS.ROUTER_HANDLE]) {\n DEBUG_BUILD && debug.log(`[orchestrion:express] subscribing to channel \"${channelName}\"`);\n\n const channel = tracingChannel<HandleChannelContext>(channelName);\n\n bindTracingChannelToSpan(channel, data => getSpanForLayer(data, options), {\n beforeSpanEnd(_span, data) {\n data._sentryCleanup?.();\n },\n });\n\n // Pop the layer path when the layer hands off via `next`. `asyncStart` fires\n // when `next` is called and *before* the downstream layer runs, so the\n // per-request path chain reflects only the current chain when each layer\n // reconstructs its route. Only `asyncStart` is relevant here.\n channel.subscribe({\n start: NOOP,\n asyncEnd: NOOP,\n end: NOOP,\n error: NOOP,\n asyncStart: popLayerPathForLayer,\n });\n }\n}\n\n/** Record the freshly-registered layer's path pattern from a `route`/`use` call. */\nfunction captureRegisteredLayerPath(data: RegistrationChannelContext): void {\n const stack = data.self?.stack;\n if (!Array.isArray(stack)) {\n return;\n }\n const layer = stack[stack.length - 1];\n if (layer) {\n setLayerRegisteredPath(layer, getLayerPath(data.arguments ?? []));\n }\n}\n\n/** Pop the path a layer pushed once it hands control onward via `next`. */\nfunction popLayerPathForLayer(data: HandleChannelContext): void {\n if (!data._sentryStoredLayer) {\n return;\n }\n // Clear the marker first so a layer that (incorrectly) calls `next` more than\n // once can't pop again and take a parent's entry off the stack with it.\n data._sentryStoredLayer = false;\n const req = data.arguments?.[0] as ExpressRequest | undefined;\n if (req) {\n popLayerPath(req);\n }\n}\n\n/**\n * Open a span for one layer invocation. Returns `undefined` to opt the layer\n * out (error handlers, or a layer with no active parent trace) — the helper\n * then leaves the active context untouched.\n */\nfunction getSpanForLayer(data: HandleChannelContext, options: ExpressIntegrationOptions): Span | undefined {\n const layer = data.self;\n const args = data.arguments;\n if (!layer || !Array.isArray(args)) {\n return undefined;\n }\n\n // Express only treats a 4-arg handler as an error handler and skips it in\n // the normal request pipeline; match the OTel integration and don't trace it.\n if (layer.handle?.length === 4) {\n return undefined;\n }\n\n // A Route dispatches to its handlers via the same `handle_request` method,\n // but those inner layers already run inside the route-dispatch layer's\n // `request_handler` span. They carry `.method` (and no `.route`); skip them\n // so we emit one span per route, matching the OTel Express integration.\n if (layer.method && !layer.route) {\n return undefined;\n }\n\n const req = args[0] as ExpressRequest | undefined;\n const res = args[1] as ExpressResponse | undefined;\n if (!req) {\n return undefined;\n }\n\n // No active parent span means this request is being ignored (unsampled /\n // filtered), so don't open a span\n if (!getActiveSpan()) {\n return undefined;\n }\n\n const type = getLayerType(layer);\n\n // Push this layer's registered path onto the request's chain so a\n // `request_handler` can reconstruct the full route with parameters intact\n // (`req.baseUrl` only exposes the *resolved* mount prefix). The matching pop\n // happens on `asyncStart` when the layer hands off via `next`.\n const registeredPath = getLayerRegisteredPath(layer);\n if (registeredPath != null) {\n pushLayerPath(req, registeredPath);\n data._sentryStoredLayer = true;\n }\n\n // `constructedRoute` (the full registered pattern) names the span/transaction;\n // `matchedRoute` (validated against the request URL) is the `http.route`.\n const constructedRoute = type === 'request_handler' ? getConstructedRoute(req) : undefined;\n const matchedRoute =\n type === 'request_handler' && constructedRoute != null ? getActualMatchedRoute(req, constructedRoute) : undefined;\n\n const name =\n type === 'request_handler'\n ? constructedRoute || 'request handler'\n : type === 'router'\n ? (layer.path ?? '/')\n : (layer.name ?? '<anonymous>');\n\n // Propagate the route to the root `http.server` span *before* the ignore\n // check, so the transaction is still named even when the layer's own span is\n // ignored — matches the OTel Express integration's `onRouteResolved` timing.\n if (matchedRoute) {\n setHttpServerSpanRoute(matchedRoute);\n }\n\n if (type === 'request_handler' && constructedRoute) {\n const isolationScope = getIsolationScope();\n if (isolationScope !== getDefaultIsolationScope()) {\n const method = typeof req.method === 'string' ? req.method.toUpperCase() : 'GET';\n isolationScope.setTransactionName(`${method} ${constructedRoute}`);\n } else {\n DEBUG_BUILD &&\n debug.warn(\n '[orchestrion:express] Isolation scope is still default isolation scope - skipping transaction name',\n );\n }\n }\n\n // Honor `ignoreLayers`/`ignoreLayersType`: skip the span for matching layers.\n // We intentionally do NOT pop the pushed path here (unlike OTel Express, which\n // pops on ignore): the path is still popped on `asyncStart` when the layer\n // calls `next`, so a following sibling isn't polluted, while an ignored\n // *router* keeps its mount prefix on the stack for the sub-stack it dispatches\n // — so routes under an ignored router stay correct. The only entries that\n // never pop come from layers that end the response without `next()`, and those\n // sit on a per-request store that is discarded when the request ends.\n if (isLayerIgnored(name, type, options)) {\n return undefined;\n }\n\n const span = startInactiveSpan({\n name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.express`,\n [ATTR_EXPRESS_NAME]: name,\n [ATTR_EXPRESS_TYPE]: type,\n ...(matchedRoute ? { [HTTP_ROUTE]: matchedRoute } : {}),\n },\n });\n\n // A layer that sends the response (route handlers, typically) never calls\n // `next`, so the channel's `asyncEnd` never fires. End on the response's\n // `finish` in that case. When `next` *is* called, the helper ends the span\n // (via `asyncEnd`) and `beforeSpanEnd` removes this now-redundant listener.\n if (res && typeof res.once === 'function') {\n const onFinish = (): void => {\n span.end();\n };\n res.once('finish', onFinish);\n data._sentryCleanup = () => res.removeListener('finish', onFinish);\n }\n\n return span;\n}\n\nfunction getLayerType(layer: ExpressLayer): ExpressLayerType {\n if (layer.name === 'router') {\n return 'router';\n }\n // `bound dispatch` (v4) / `handle` — the route-dispatch layer created by `router.route()`.\n if (layer.name === 'bound dispatch' || layer.name === 'handle') {\n return 'request_handler';\n }\n return 'middleware';\n}\n\n/**\n * Propagate the resolved route to the root `http.server` span so the\n * transaction gets a parameterized `http.route`. Mirrors `@sentry/node`'s\n * `setHttpServerSpanRouteAttribute`; inlined to keep this package free of\n * `@sentry/node` deps. No-op unless the root span is an `http.server` span.\n */\nfunction setHttpServerSpanRoute(route: string): void {\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n if (!rootSpan) {\n return;\n }\n if (spanToJSON(rootSpan).data[SEMANTIC_ATTRIBUTE_SENTRY_OP] !== 'http.server') {\n return;\n }\n rootSpan.setAttribute(HTTP_ROUTE, route);\n}\n\n/**\n * Whether a layer should be skipped per the `ignoreLayers`/`ignoreLayersType`\n * options. Matches `@sentry/core`'s Express `isLayerIgnored`: `ignoreLayersType`\n * filters by layer type, `ignoreLayers` matches the layer's name against\n * string/RegExp/predicate patterns (exact string match).\n */\nfunction isLayerIgnored(name: string, type: ExpressLayerType, options: ExpressIntegrationOptions): boolean {\n const { ignoreLayers, ignoreLayersType } = options;\n\n if (Array.isArray(ignoreLayersType) && ignoreLayersType.includes(type)) {\n return true;\n }\n\n if (!Array.isArray(ignoreLayers)) {\n return false;\n }\n\n try {\n return stringMatchesSomePattern(name, ignoreLayers, true);\n } catch {\n return false;\n }\n}\n"],"names":["tracingChannel","CHANNELS","DEBUG_BUILD","debug","bindTracingChannelToSpan","setLayerRegisteredPath","getLayerPath","popLayerPath","getActiveSpan","getLayerRegisteredPath","pushLayerPath","getConstructedRoute","getActualMatchedRoute","getIsolationScope","getDefaultIsolationScope","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","HTTP_ROUTE","getRootSpan","spanToJSON","stringMatchesSomePattern"],"mappings":";;;;;;;;;AAqCA,MAAM,MAAA,GAAS,mBAAA;AAKf,MAAM,iBAAA,GAAoB,cAAA;AAC1B,MAAM,iBAAA,GAAoB,cAAA;AAE1B,MAAM,OAAO,MAAY;AAAC,CAAA;AAE1B,IAAI,eAAA,GAAkB,KAAA;AAEf,SAAS,iBAAA,CACd,SACAA,gBAAA,EACM;AACN,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA;AAAA,EACF;AACA,EAAA,eAAA,GAAkB,IAAA;AAMlB,EAAA,KAAA,MAAW,eAAe,CAACC,iBAAA,CAAS,gBAAA,EAAkBA,iBAAA,CAAS,eAAe,CAAA,EAAG;AAC/E,IAAAD,gBAAA,CAA2C,WAAW,EA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,EAA6C;AACzG,EAAA,MAAM,EAAE,YAAA,EAAc,gBAAA,EAAiB,GAAI,OAAA;AAE3C,EAAA,IAAI,MAAM,OAAA,CAAQ,gBAAgB,KAAK,gBAAA,CAAiB,QAAA,CAAS,IAAI,CAAA,EAAG;AACtE,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,YAAY,CAAA,EAAG;AAChC,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,OAAOG,6BAAA,CAAyB,IAAA,EAAM,YAAA,EAAc,IAAI,CAAA;AAAA,EAC1D,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;;;"}
@@ -0,0 +1,34 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const diagnosticsChannel = require('node:diagnostics_channel');
4
+ const core = require('@sentry/core');
5
+ const channels = require('../../orchestrion/channels.js');
6
+ const tracingChannel = require('../../tracing-channel.js');
7
+
8
+ const INTEGRATION_NAME = "GenericPool";
9
+ const _genericPoolChannelIntegration = (() => {
10
+ return {
11
+ name: INTEGRATION_NAME,
12
+ setupOnce() {
13
+ if (!diagnosticsChannel.tracingChannel) {
14
+ return;
15
+ }
16
+ core.waitForTracingChannelBinding(() => instrumentGenericPool());
17
+ }
18
+ };
19
+ });
20
+ const genericPoolChannelIntegration = core.defineIntegration(_genericPoolChannelIntegration);
21
+ function instrumentGenericPool() {
22
+ tracingChannel.bindTracingChannelToSpan(
23
+ diagnosticsChannel.tracingChannel(channels.CHANNELS.GENERIC_POOL_ACQUIRE),
24
+ () => core.startInactiveSpan({
25
+ name: "generic-pool.acquire",
26
+ attributes: {
27
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.db.orchestrion.generic_pool"
28
+ }
29
+ })
30
+ );
31
+ }
32
+
33
+ exports.genericPoolChannelIntegration = genericPoolChannelIntegration;
34
+ //# sourceMappingURL=generic-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic-pool.js","sources":["../../../../src/integrations/tracing-channel/generic-pool.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n defineIntegration,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Same name as the OTel integration by design — when enabled, the OTel\n// 'GenericPool' integration is omitted from the default set.\nconst INTEGRATION_NAME = 'GenericPool' as const;\n\ninterface GenericPoolAcquireContext {\n arguments: unknown[];\n}\n\nconst _genericPoolChannelIntegration = (() => {\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(() => instrumentGenericPool());\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * EXPERIMENTAL — orchestrion-driven generic-pool integration. Subscribes to\n * `orchestrion:generic-pool:acquire` (injected into `generic-pool/lib/Pool.js`'s\n * `Pool.prototype.acquire`). Creates a `generic-pool.acquire` span for each\n * acquisition. Requires the orchestrion runtime hook or bundler plugin.\n */\nexport const genericPoolChannelIntegration = defineIntegration(_genericPoolChannelIntegration);\n\nfunction instrumentGenericPool(): void {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<GenericPoolAcquireContext>(CHANNELS.GENERIC_POOL_ACQUIRE),\n () =>\n startInactiveSpan({\n name: 'generic-pool.acquire',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.orchestrion.generic_pool',\n },\n }),\n );\n}\n"],"names":["waitForTracingChannelBinding","defineIntegration","bindTracingChannelToSpan","CHANNELS","startInactiveSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;;AAaA,MAAM,gBAAA,GAAmB,aAAA;AAMzB,MAAM,kCAAkC,MAAM;AAC5C,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAAC,mBAAmB,cAAA,EAAgB;AACtC,QAAA;AAAA,MACF;AAEA,MAAAA,iCAAA,CAA6B,MAAM,uBAAuB,CAAA;AAAA,IAC5D;AAAA,GACF;AACF,CAAA,CAAA;AAQO,MAAM,6BAAA,GAAgCC,uBAAkB,8BAA8B;AAE7F,SAAS,qBAAA,GAA8B;AACrC,EAAAC,uCAAA;AAAA,IACE,kBAAA,CAAmB,cAAA,CAA0CC,iBAAA,CAAS,oBAAoB,CAAA;AAAA,IAC1F,MACEC,sBAAA,CAAkB;AAAA,MAChB,IAAA,EAAM,sBAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,CAACC,qCAAgC,GAAG;AAAA;AACtC,KACD;AAAA,GACL;AACF;;;;"}
@@ -17,7 +17,7 @@ function startParseSpan() {
17
17
  function startValidateSpan(documentAST) {
18
18
  return core.startInactiveSpan({
19
19
  name: constants.SPAN_NAME_VALIDATE,
20
- attributes: { ...BASE_ATTRIBUTES, [attributes.GRAPHQL_DOCUMENT]: utils.redactGraphqlDocument(documentAST) }
20
+ attributes: { ...BASE_ATTRIBUTES, [attributes.GRAPHQL_DOCUMENT]: utils.collectGraphqlDocument(documentAST) }
21
21
  });
22
22
  }
23
23
  function finalizeValidateSpan(span, result) {
@@ -78,7 +78,7 @@ function startExecuteSpan(argsArray, self, config, getConfig) {
78
78
  ...BASE_ATTRIBUTES,
79
79
  [attributes.GRAPHQL_OPERATION_TYPE]: operationType,
80
80
  [attributes.GRAPHQL_OPERATION_NAME]: operationName || void 0,
81
- [attributes.GRAPHQL_DOCUMENT]: utils.redactGraphqlDocument(document)
81
+ [attributes.GRAPHQL_DOCUMENT]: utils.collectGraphqlDocument(document)
82
82
  }
83
83
  });
84
84
  if (config.useOperationNameForRootSpan && operationType) {
@@ -1 +1 @@
1
- {"version":3,"file":"spans.js","sources":["../../../../../src/integrations/tracing-channel/graphql/spans.ts"],"sourcesContent":["/*\n * Span builders for the orchestrion graphql channels (v14–16). They emit the same spans as the native\n * `diagnostics_channel` subscriber (`../../../graphql/graphql-dc-subscriber.ts`, graphql >= 17) by\n * reusing its `utils` and conventions — only the data source differs: here the payloads are the raw\n * arguments of the injected `parse`/`validate`/`execute` calls rather than graphql's native events.\n */\n\nimport { GRAPHQL_DOCUMENT, GRAPHQL_OPERATION_NAME, GRAPHQL_OPERATION_TYPE } from '@sentry/conventions/attributes';\nimport { WEB_SERVER_GRAPHQL_SPAN_OP } from '@sentry/conventions/op';\nimport type { Span } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n} from '@sentry/core';\nimport type { GraphqlDocumentNode } from '../../../graphql/utils';\nimport {\n getOperationSpanName,\n hasResultErrors,\n redactGraphqlDocument,\n renameRootSpanWithOperation,\n} from '../../../graphql/utils';\nimport { GRAPHQL_DATA_SYMBOL, ORIGIN, SPAN_NAME_EXECUTE, SPAN_NAME_PARSE, SPAN_NAME_VALIDATE } from './constants';\nimport { getOperation, wrapFields, wrapFieldResolver } from './resolvers';\nimport type {\n DocumentNode,\n GraphQLFieldResolver,\n GraphQLSchema,\n GraphqlResolvedConfig,\n Maybe,\n ObjectWithGraphQLData,\n} from './types';\n\nconst BASE_ATTRIBUTES = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: WEB_SERVER_GRAPHQL_SPAN_OP,\n} as const;\n\nexport function startParseSpan(): Span {\n return startInactiveSpan({ name: SPAN_NAME_PARSE, attributes: { ...BASE_ATTRIBUTES } });\n}\n\n/** `documentAST` is the 2nd argument to `validate(schema, documentAST, …)`. */\nexport function startValidateSpan(documentAST: unknown): Span {\n return startInactiveSpan({\n name: SPAN_NAME_VALIDATE,\n attributes: { ...BASE_ATTRIBUTES, [GRAPHQL_DOCUMENT]: redactGraphqlDocument(documentAST as GraphqlDocumentNode) },\n });\n}\n\n/** `result` is validation's return value: a (possibly empty) array of errors. */\nexport function finalizeValidateSpan(span: Span, result: unknown): void {\n if (Array.isArray(result) && result.length > 0) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'invalid_argument' });\n }\n}\n\n/** Positional slots of a `graphql.execute(schema, document, …)` call (v14/v15 legacy signature). */\nconst enum ExecuteArg {\n SCHEMA = 0,\n DOCUMENT = 1,\n CONTEXT_VALUE = 3,\n OPERATION_NAME = 5,\n FIELD_RESOLVER = 6,\n}\n\ninterface NormalizedExecuteArgs {\n schema?: GraphQLSchema;\n document?: DocumentNode;\n contextValue: ObjectWithGraphQLData;\n operationName?: Maybe<string>;\n fieldResolver?: Maybe<GraphQLFieldResolver>;\n /** Writes `contextValue`/`fieldResolver` mutations back to the live channel `arguments`. */\n writeBack: (contextValue: ObjectWithGraphQLData, fieldResolver: Maybe<GraphQLFieldResolver>) => void;\n}\n\n/**\n * `execute` accepts either a single `ExecutionArgs` object (modern callers, always in v16) or\n * positional args (v14/v15). Both are normalized here; `writeBack` puts mutations onto the correct\n * slot so they reach the real call.\n */\nfunction normalizeExecuteArgs(argsArray: unknown[]): NormalizedExecuteArgs {\n if (argsArray.length >= 2) {\n return {\n schema: argsArray[ExecuteArg.SCHEMA] as GraphQLSchema | undefined,\n document: argsArray[ExecuteArg.DOCUMENT] as DocumentNode | undefined,\n contextValue: (argsArray[ExecuteArg.CONTEXT_VALUE] ?? {}) as ObjectWithGraphQLData,\n operationName: argsArray[ExecuteArg.OPERATION_NAME] as Maybe<string>,\n fieldResolver: argsArray[ExecuteArg.FIELD_RESOLVER] as Maybe<GraphQLFieldResolver>,\n writeBack: (contextValue, fieldResolver) => {\n argsArray[ExecuteArg.CONTEXT_VALUE] = contextValue;\n argsArray[ExecuteArg.FIELD_RESOLVER] = fieldResolver;\n },\n };\n }\n\n const obj = (argsArray[0] ?? {}) as {\n schema?: GraphQLSchema;\n document?: DocumentNode;\n contextValue?: unknown;\n operationName?: Maybe<string>;\n fieldResolver?: Maybe<GraphQLFieldResolver>;\n };\n return {\n schema: obj.schema,\n document: obj.document,\n contextValue: (obj.contextValue ?? {}) as ObjectWithGraphQLData,\n operationName: obj.operationName,\n fieldResolver: obj.fieldResolver,\n writeBack: (contextValue, fieldResolver) => {\n obj.contextValue = contextValue;\n obj.fieldResolver = fieldResolver;\n },\n };\n}\n\n/**\n * Opens the execute span and, unless resolver spans are disabled, swaps the schema's field resolvers\n * (and the default field resolver) for span-creating proxies — mutating the live `arguments` in place\n * so the wrapped `execute` call runs with them. Always returns a span; the caller guards against\n * throws (see `safe` in `index.ts`).\n */\nexport function startExecuteSpan(\n argsArray: unknown[],\n self: unknown,\n config: GraphqlResolvedConfig,\n getConfig: () => GraphqlResolvedConfig,\n): Span {\n const args = normalizeExecuteArgs(argsArray);\n const { schema, document } = args;\n let { contextValue, fieldResolver } = args;\n\n // Skip resolver wrapping when disabled or when a parent execute already set up this context\n // (nested execute reusing the same contextValue).\n const alreadyInstrumented = !!contextValue[GRAPHQL_DATA_SYMBOL];\n if (!config.ignoreResolveSpans && !alreadyInstrumented) {\n const isUsingDefaultResolver = fieldResolver == null;\n const defaultFieldResolver = (self as { defaultFieldResolver?: GraphQLFieldResolver } | undefined)\n ?.defaultFieldResolver;\n const fieldResolverForExecute = fieldResolver ?? defaultFieldResolver;\n if (fieldResolverForExecute) {\n fieldResolver = wrapFieldResolver(getConfig, fieldResolverForExecute, isUsingDefaultResolver);\n }\n\n if (schema) {\n wrapFields(schema.getQueryType(), getConfig);\n wrapFields(schema.getMutationType(), getConfig);\n }\n }\n\n // v14–16 channels carry only the raw args, so derive the operation from the document (native v17\n // provides `operationType`/`operationName` on the event directly).\n const operation = getOperation(document as DocumentNode, args.operationName);\n const operationType = operation?.operation;\n const operationName = operation?.name?.value ?? args.operationName ?? undefined;\n\n const span = startInactiveSpan({\n name: getOperationSpanName(operationType, operationName || undefined, SPAN_NAME_EXECUTE),\n attributes: {\n ...BASE_ATTRIBUTES,\n [GRAPHQL_OPERATION_TYPE]: operationType,\n [GRAPHQL_OPERATION_NAME]: operationName || undefined,\n [GRAPHQL_DOCUMENT]: redactGraphqlDocument(document as GraphqlDocumentNode | undefined),\n },\n });\n\n if (config.useOperationNameForRootSpan && operationType) {\n renameRootSpanWithOperation(span, operationType, operationName || undefined);\n }\n\n // The resolver proxies read the execute span (and their own bookkeeping) off this symbol.\n contextValue[GRAPHQL_DATA_SYMBOL] = { source: document, span, fields: {} };\n args.writeBack(contextValue, fieldResolver);\n\n return span;\n}\n\n/** `result` is the settled `ExecutionResult`; GraphQL errors surface on `result.errors`, not a throw. */\nexport function finalizeExecuteSpan(span: Span, result: unknown): void {\n if (hasResultErrors(result)) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","WEB_SERVER_GRAPHQL_SPAN_OP","startInactiveSpan","SPAN_NAME_PARSE","SPAN_NAME_VALIDATE","GRAPHQL_DOCUMENT","redactGraphqlDocument","SPAN_STATUS_ERROR","GRAPHQL_DATA_SYMBOL","wrapFieldResolver","wrapFields","getOperation","getOperationSpanName","SPAN_NAME_EXECUTE","GRAPHQL_OPERATION_TYPE","GRAPHQL_OPERATION_NAME","renameRootSpanWithOperation","hasResultErrors"],"mappings":";;;;;;;;;AAkCA,MAAM,eAAA,GAAkB;AAAA,EACtB,CAACA,qCAAgC,GAAGC,gBAAA;AAAA,EACpC,CAACC,iCAA4B,GAAGC;AAClC,CAAA;AAEO,SAAS,cAAA,GAAuB;AACrC,EAAA,OAAOC,sBAAA,CAAkB,EAAE,I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SAAA,EAAW,SAAA;AACjC,EAAA,MAAM,aAAA,GAAgB,SAAA,EAAW,IAAA,EAAM,KAAA,IAAS,KAAK,aAAA,IAAiB,MAAA;AAEtE,EAAA,MAAM,OAAOT,sBAAA,CAAkB;AAAA,IAC7B,IAAA,EAAMU,0BAAA,CAAqB,aAAA,EAAe,aAAA,IAAiB,QAAWC,2BAAiB,CAAA;AAAA,IACvF,UAAA,EAAY;AAAA,MACV,GAAG,eAAA;AAAA,MACH,CAACC,iCAAsB,GAAG,aAAA;AAAA,MAC1B,CAACC,iCAAsB,GAAG,aAAA,IAAiB,MAAA;AAAA,MAC3C,CAACV,2BAAgB,GAAGC,2BAAA,CAAsB,QAA2C;AAAA;AACvF,GACD,CAAA;AAED,EAAA,IAAI,MAAA,CAAO,+BAA+B,aAAA,EAAe;AACvD,IAAAU,iCAAA,CAA4B,IAAA,EAAM,aAAA,EAAe,aAAA,IAAiB,MAAS,CAAA;AAAA,EAC7E;AAGA,EAAA,YAAA,CAAaR,6BAAmB,IAAI,EAAE,MAAA,EAAQ,UAAU,IAAA,EAAM,MAAA,EAAQ,EAAC,EAAE;AACzE,EAAA,IAAA,CAAK,SAAA,CAAU,cAAc,aAAa,CAAA;AAE1C,EAAA,OAAO,IAAA;AACT;AAGO,SAAS,mBAAA,CAAoB,MAAY,MAAA,EAAuB;AACrE,EAAA,IAAIS,qBAAA,CAAgB,MAAM,CAAA,EAAG;AAC3B,IAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAMV,sBAAA,EAAmB,OAAA,EAAS,kBAAkB,CAAA;AAAA,EACvE;AACF;;;;;;;;"}
1
+ {"version":3,"file":"spans.js","sources":["../../../../../src/integrations/tracing-channel/graphql/spans.ts"],"sourcesContent":["/*\n * Span builders for the orchestrion graphql channels (v14–16). They emit the same spans as the native\n * `diagnostics_channel` subscriber (`../../../graphql/graphql-dc-subscriber.ts`, graphql >= 17) by\n * reusing its `utils` and conventions — only the data source differs: here the payloads are the raw\n * arguments of the injected `parse`/`validate`/`execute` calls rather than graphql's native events.\n */\n\nimport { GRAPHQL_DOCUMENT, GRAPHQL_OPERATION_NAME, GRAPHQL_OPERATION_TYPE } from '@sentry/conventions/attributes';\nimport { WEB_SERVER_GRAPHQL_SPAN_OP } from '@sentry/conventions/op';\nimport type { Span } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n} from '@sentry/core';\nimport type { GraphqlDocumentNode } from '../../../graphql/utils';\nimport {\n collectGraphqlDocument,\n getOperationSpanName,\n hasResultErrors,\n renameRootSpanWithOperation,\n} from '../../../graphql/utils';\nimport { GRAPHQL_DATA_SYMBOL, ORIGIN, SPAN_NAME_EXECUTE, SPAN_NAME_PARSE, SPAN_NAME_VALIDATE } from './constants';\nimport { getOperation, wrapFields, wrapFieldResolver } from './resolvers';\nimport type {\n DocumentNode,\n GraphQLFieldResolver,\n GraphQLSchema,\n GraphqlResolvedConfig,\n Maybe,\n ObjectWithGraphQLData,\n} from './types';\n\nconst BASE_ATTRIBUTES = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: WEB_SERVER_GRAPHQL_SPAN_OP,\n} as const;\n\nexport function startParseSpan(): Span {\n return startInactiveSpan({ name: SPAN_NAME_PARSE, attributes: { ...BASE_ATTRIBUTES } });\n}\n\n/** `documentAST` is the 2nd argument to `validate(schema, documentAST, …)`. */\nexport function startValidateSpan(documentAST: unknown): Span {\n return startInactiveSpan({\n name: SPAN_NAME_VALIDATE,\n attributes: { ...BASE_ATTRIBUTES, [GRAPHQL_DOCUMENT]: collectGraphqlDocument(documentAST as GraphqlDocumentNode) },\n });\n}\n\n/** `result` is validation's return value: a (possibly empty) array of errors. */\nexport function finalizeValidateSpan(span: Span, result: unknown): void {\n if (Array.isArray(result) && result.length > 0) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'invalid_argument' });\n }\n}\n\n/** Positional slots of a `graphql.execute(schema, document, …)` call (v14/v15 legacy signature). */\nconst enum ExecuteArg {\n SCHEMA = 0,\n DOCUMENT = 1,\n CONTEXT_VALUE = 3,\n OPERATION_NAME = 5,\n FIELD_RESOLVER = 6,\n}\n\ninterface NormalizedExecuteArgs {\n schema?: GraphQLSchema;\n document?: DocumentNode;\n contextValue: ObjectWithGraphQLData;\n operationName?: Maybe<string>;\n fieldResolver?: Maybe<GraphQLFieldResolver>;\n /** Writes `contextValue`/`fieldResolver` mutations back to the live channel `arguments`. */\n writeBack: (contextValue: ObjectWithGraphQLData, fieldResolver: Maybe<GraphQLFieldResolver>) => void;\n}\n\n/**\n * `execute` accepts either a single `ExecutionArgs` object (modern callers, always in v16) or\n * positional args (v14/v15). Both are normalized here; `writeBack` puts mutations onto the correct\n * slot so they reach the real call.\n */\nfunction normalizeExecuteArgs(argsArray: unknown[]): NormalizedExecuteArgs {\n if (argsArray.length >= 2) {\n return {\n schema: argsArray[ExecuteArg.SCHEMA] as GraphQLSchema | undefined,\n document: argsArray[ExecuteArg.DOCUMENT] as DocumentNode | undefined,\n contextValue: (argsArray[ExecuteArg.CONTEXT_VALUE] ?? {}) as ObjectWithGraphQLData,\n operationName: argsArray[ExecuteArg.OPERATION_NAME] as Maybe<string>,\n fieldResolver: argsArray[ExecuteArg.FIELD_RESOLVER] as Maybe<GraphQLFieldResolver>,\n writeBack: (contextValue, fieldResolver) => {\n argsArray[ExecuteArg.CONTEXT_VALUE] = contextValue;\n argsArray[ExecuteArg.FIELD_RESOLVER] = fieldResolver;\n },\n };\n }\n\n const obj = (argsArray[0] ?? {}) as {\n schema?: GraphQLSchema;\n document?: DocumentNode;\n contextValue?: unknown;\n operationName?: Maybe<string>;\n fieldResolver?: Maybe<GraphQLFieldResolver>;\n };\n return {\n schema: obj.schema,\n document: obj.document,\n contextValue: (obj.contextValue ?? {}) as ObjectWithGraphQLData,\n operationName: obj.operationName,\n fieldResolver: obj.fieldResolver,\n writeBack: (contextValue, fieldResolver) => {\n obj.contextValue = contextValue;\n obj.fieldResolver = fieldResolver;\n },\n };\n}\n\n/**\n * Opens the execute span and, unless resolver spans are disabled, swaps the schema's field resolvers\n * (and the default field resolver) for span-creating proxies — mutating the live `arguments` in place\n * so the wrapped `execute` call runs with them. Always returns a span; the caller guards against\n * throws (see `safe` in `index.ts`).\n */\nexport function startExecuteSpan(\n argsArray: unknown[],\n self: unknown,\n config: GraphqlResolvedConfig,\n getConfig: () => GraphqlResolvedConfig,\n): Span {\n const args = normalizeExecuteArgs(argsArray);\n const { schema, document } = args;\n let { contextValue, fieldResolver } = args;\n\n // Skip resolver wrapping when disabled or when a parent execute already set up this context\n // (nested execute reusing the same contextValue).\n const alreadyInstrumented = !!contextValue[GRAPHQL_DATA_SYMBOL];\n if (!config.ignoreResolveSpans && !alreadyInstrumented) {\n const isUsingDefaultResolver = fieldResolver == null;\n const defaultFieldResolver = (self as { defaultFieldResolver?: GraphQLFieldResolver } | undefined)\n ?.defaultFieldResolver;\n const fieldResolverForExecute = fieldResolver ?? defaultFieldResolver;\n if (fieldResolverForExecute) {\n fieldResolver = wrapFieldResolver(getConfig, fieldResolverForExecute, isUsingDefaultResolver);\n }\n\n if (schema) {\n wrapFields(schema.getQueryType(), getConfig);\n wrapFields(schema.getMutationType(), getConfig);\n }\n }\n\n // v14–16 channels carry only the raw args, so derive the operation from the document (native v17\n // provides `operationType`/`operationName` on the event directly).\n const operation = getOperation(document as DocumentNode, args.operationName);\n const operationType = operation?.operation;\n const operationName = operation?.name?.value ?? args.operationName ?? undefined;\n\n const span = startInactiveSpan({\n name: getOperationSpanName(operationType, operationName || undefined, SPAN_NAME_EXECUTE),\n attributes: {\n ...BASE_ATTRIBUTES,\n [GRAPHQL_OPERATION_TYPE]: operationType,\n [GRAPHQL_OPERATION_NAME]: operationName || undefined,\n [GRAPHQL_DOCUMENT]: collectGraphqlDocument(document as GraphqlDocumentNode | undefined),\n },\n });\n\n if (config.useOperationNameForRootSpan && operationType) {\n renameRootSpanWithOperation(span, operationType, operationName || undefined);\n }\n\n // The resolver proxies read the execute span (and their own bookkeeping) off this symbol.\n contextValue[GRAPHQL_DATA_SYMBOL] = { source: document, span, fields: {} };\n args.writeBack(contextValue, fieldResolver);\n\n return span;\n}\n\n/** `result` is the settled `ExecutionResult`; GraphQL errors surface on `result.errors`, not a throw. */\nexport function finalizeExecuteSpan(span: Span, result: unknown): void {\n if (hasResultErrors(result)) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","WEB_SERVER_GRAPHQL_SPAN_OP","startInactiveSpan","SPAN_NAME_PARSE","SPAN_NAME_VALIDATE","GRAPHQL_DOCUMENT","collectGraphqlDocument","SPAN_STATUS_ERROR","GRAPHQL_DATA_SYMBOL","wrapFieldResolver","wrapFields","getOperation","getOperationSpanName","SPAN_NAME_EXECUTE","GRAPHQL_OPERATION_TYPE","GRAPHQL_OPERATION_NAME","renameRootSpanWithOperation","hasResultErrors"],"mappings":";;;;;;;;;AAkCA,MAAM,eAAA,GAAkB;AAAA,EACtB,CAACA,qCAAgC,GAAGC,gBAAA;AAAA,EACpC,CAACC,iCAA4B,GAAGC;AAClC,CAAA;AAEO,SAAS,cAAA,GAAuB;AACrC,EAAA,OAAOC,sBAAA,CAAkB,EAAE,IAAA,EAAMC,yBAAA,EAAiB,YAAY,EAAE,GAAG,eAAA,EAAgB,EAAG,CAAA;AACxF;AAGO,SAAS,kBAAkB,WAAA,EAA4B;AAC5D,EAAA,OAAOD,sBAAA,CAAkB;AAAA,IACvB,IAAA,EAAME,4BAAA;AAAA,IACN,UAAA,EAAY,EAAE,GAAG,eAAA,EAAiB,CAACC,2BAAgB,GAAGC,4BAAA,CAAuB,WAAkC,CAAA;AAAE,GAClH,CAAA;AACH;A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CAACC,iCAAsB,GAAG,aAAA;AAAA,MAC1B,CAACC,iCAAsB,GAAG,aAAA,IAAiB,MAAA;AAAA,MAC3C,CAACV,2BAAgB,GAAGC,4BAAA,CAAuB,QAA2C;AAAA;AACxF,GACD,CAAA;AAED,EAAA,IAAI,MAAA,CAAO,+BAA+B,aAAA,EAAe;AACvD,IAAAU,iCAAA,CAA4B,IAAA,EAAM,aAAA,EAAe,aAAA,IAAiB,MAAS,CAAA;AAAA,EAC7E;AAGA,EAAA,YAAA,CAAaR,6BAAmB,IAAI,EAAE,MAAA,EAAQ,UAAU,IAAA,EAAM,MAAA,EAAQ,EAAC,EAAE;AACzE,EAAA,IAAA,CAAK,SAAA,CAAU,cAAc,aAAa,CAAA;AAE1C,EAAA,OAAO,IAAA;AACT;AAGO,SAAS,mBAAA,CAAoB,MAAY,MAAA,EAAuB;AACrE,EAAA,IAAIS,qBAAA,CAAgB,MAAM,CAAA,EAAG;AAC3B,IAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAMV,sBAAA,EAAmB,OAAA,EAAS,kBAAkB,CAAA;AAAA,EACvE;AACF;;;;;;;;"}
@@ -23,6 +23,24 @@ function connectionAttributes(host, port) {
23
23
  [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN
24
24
  };
25
25
  }
26
+ const tracedCommands = /* @__PURE__ */ new WeakSet();
27
+ function startIORedisCommandSpan(data) {
28
+ const command = data.arguments?.[0];
29
+ if (!command || typeof command !== "object") {
30
+ return void 0;
31
+ }
32
+ if (tracedCommands.has(command)) {
33
+ return void 0;
34
+ }
35
+ tracedCommands.add(command);
36
+ const { host, port } = getConnectionOptions(data.self);
37
+ const statement = redisStatementSerializer.defaultDbStatementSerializer(command.name, command.args ?? []);
38
+ return core.startInactiveSpan({
39
+ name: statement,
40
+ op: "db",
41
+ attributes: { ...connectionAttributes(host, port), [attributes.DB_STATEMENT]: statement }
42
+ });
43
+ }
26
44
  const _ioredisChannelIntegration = ((options = {}) => {
27
45
  const responseHook = options.responseHook;
28
46
  return {
@@ -39,35 +57,19 @@ const _ioredisChannelIntegration = ((options = {}) => {
39
57
  channels.CHANNELS.IOREDIS_CONNECT
40
58
  );
41
59
  core.waitForTracingChannelBinding(() => {
42
- tracingChannel.bindTracingChannelToSpan(
43
- commandChannel,
44
- (data) => {
45
- const command = data.arguments?.[0];
46
- if (!command || typeof command !== "object") {
47
- return void 0;
60
+ tracingChannel.bindTracingChannelToSpan(commandChannel, startIORedisCommandSpan, {
61
+ // ioredis' `requireParentSpan` default: only create a span under an active span.
62
+ requiresParentSpan: true,
63
+ beforeSpanEnd(span, data) {
64
+ if ("error" in data || !responseHook) {
65
+ return;
48
66
  }
49
- const { host, port } = getConnectionOptions(data.self);
50
- const statement = redisStatementSerializer.defaultDbStatementSerializer(command.name, command.args ?? []);
51
- return core.startInactiveSpan({
52
- name: statement,
53
- op: "db",
54
- attributes: { ...connectionAttributes(host, port), [attributes.DB_STATEMENT]: statement }
55
- });
56
- },
57
- {
58
- // ioredis' `requireParentSpan` default: only create a span under an active span.
59
- requiresParentSpan: true,
60
- beforeSpanEnd(span, data) {
61
- if ("error" in data || !responseHook) {
62
- return;
63
- }
64
- const command = data.arguments?.[0];
65
- if (command) {
66
- runResponseHook(responseHook, span, command, data.result);
67
- }
67
+ const command = data.arguments?.[0];
68
+ if (command) {
69
+ runResponseHook(responseHook, span, command, data.result);
68
70
  }
69
71
  }
70
- );
72
+ });
71
73
  tracingChannel.bindTracingChannelToSpan(
72
74
  connectChannel,
73
75
  (data) => {
@@ -93,4 +95,5 @@ function runResponseHook(hook, span, command, result) {
93
95
  const ioredisChannelIntegration = core.defineIntegration(_ioredisChannelIntegration);
94
96
 
95
97
  exports.ioredisChannelIntegration = ioredisChannelIntegration;
98
+ exports.startIORedisCommandSpan = startIORedisCommandSpan;
96
99
  //# sourceMappingURL=ioredis.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ioredis.js","sources":["../../../../src/integrations/tracing-channel/ioredis.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated -- we intentionally emit the OLD db/net semconv\n to match `@opentelemetry/instrumentation-ioredis` (and Sentry's `inferDbSpanData`, which keys off\n `db.statement`). TODO(v11): switch to the non-deprecated `db.system.name`/`db.query.text`/\n `server.address`/`server.port` conventions and drop this disable. */\nimport * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { DB_STATEMENT, DB_SYSTEM, NET_PEER_NAME, NET_PEER_PORT } from '@sentry/conventions/attributes';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { defaultDbStatementSerializer } from '../../redis/redis-statement-serializer';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Distinct from the OTel `Redis` integration, which is composite (node-redis +\n// ioredis + the >=5.11.0 diagnostics_channel subscriber) and stays in the set;\n// only its ioredis monkey-patch is gated off in the node SDK when this is active.\nconst INTEGRATION_NAME = 'IORedis' as const;\n\nconst ORIGIN = 'auto.db.orchestrion.redis';\n\n// todo(v11): Let's drop this as this is already covered with host and port\nconst ATTR_DB_CONNECTION_STRING = 'db.connection_string';\n\n/** Mirrors `@opentelemetry/instrumentation-ioredis`' response hook. Not called for failed commands. */\nexport type IORedisResponseHook = (span: Span, command: string, args: Array<string | Buffer>, result: unknown) => void;\n\nexport interface IORedisChannelIntegrationOptions {\n responseHook?: IORedisResponseHook;\n}\n\n/** Structural type for the command object ioredis passes to `sendCommand`. */\ninterface RedisCommand {\n name: string;\n args: Array<string | Buffer>;\n}\n\ninterface RedisClientLike {\n options?: { host?: string; port?: number };\n}\n\ninterface IORedisCommandContext {\n arguments?: unknown[];\n self?: RedisClientLike;\n result?: unknown;\n error?: unknown;\n}\n\ntype IORedisConnectContext = Omit<IORedisCommandContext, 'arguments'>;\n\nfunction getConnectionOptions(self: RedisClientLike | undefined): { host?: string; port?: number } {\n return { host: self?.options?.host, port: self?.options?.port };\n}\n\nfunction connectionAttributes(host: string | undefined, port: number | undefined): Record<string, unknown> {\n return {\n [DB_SYSTEM]: 'redis',\n [ATTR_DB_CONNECTION_STRING]: `redis://${host}:${port}`,\n [NET_PEER_NAME]: host,\n [NET_PEER_PORT]: port,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n}\n\nconst _ioredisChannelIntegration = ((options: IORedisChannelIntegrationOptions = {}) => {\n const responseHook = options.responseHook;\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19.\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(`[orchestrion:ioredis] subscribing to \"${CHANNELS.IOREDIS_COMMAND}\"/\"${CHANNELS.IOREDIS_CONNECT}\"`);\n\n const commandChannel = diagnosticsChannel.tracingChannel<IORedisCommandContext, IORedisCommandContext>(\n CHANNELS.IOREDIS_COMMAND,\n );\n const connectChannel = diagnosticsChannel.tracingChannel<IORedisConnectContext, IORedisConnectContext>(\n CHANNELS.IOREDIS_CONNECT,\n );\n\n // `bindTracingChannelToSpan` uses `bindStore`, which needs the async-context\n // binding that `initOpenTelemetry()` registers after integration `setupOnce` —\n // defer until it's available (matches the native redis diagnostics-channel subscriber).\n waitForTracingChannelBinding(() => {\n bindTracingChannelToSpan(\n commandChannel,\n data => {\n const command = data.arguments?.[0] as RedisCommand | undefined;\n if (!command || typeof command !== 'object') {\n return undefined;\n }\n const { host, port } = getConnectionOptions(data.self);\n const statement = defaultDbStatementSerializer(command.name, command.args ?? []);\n return startInactiveSpan({\n name: statement,\n op: 'db',\n attributes: { ...connectionAttributes(host, port), [DB_STATEMENT]: statement },\n });\n },\n {\n // ioredis' `requireParentSpan` default: only create a span under an active span.\n requiresParentSpan: true,\n beforeSpanEnd(span, data) {\n if ('error' in data || !responseHook) {\n return;\n }\n const command = data.arguments?.[0] as RedisCommand | undefined;\n if (command) {\n runResponseHook(responseHook, span, command, data.result);\n }\n },\n },\n );\n\n bindTracingChannelToSpan(\n connectChannel,\n data => {\n const { host, port } = getConnectionOptions(data.self);\n return startInactiveSpan({\n name: 'connect',\n op: 'db',\n attributes: { ...connectionAttributes(host, port), [DB_STATEMENT]: 'connect' },\n });\n },\n { requiresParentSpan: true },\n );\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction runResponseHook(hook: IORedisResponseHook, span: Span, command: RedisCommand, result: unknown): void {\n try {\n hook(span, command.name, command.args, result);\n } catch {\n // never let a user-provided response hook break instrumentation\n }\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven ioredis integration. Subscribes to\n * `orchestrion:ioredis:command` / `:connect` (injected into ioredis' `<5.11.0`\n * `sendCommand`/`connect`) and creates db spans matching\n * `@opentelemetry/instrumentation-ioredis`. Requires the orchestrion runtime hook\n * or bundler plugin.\n */\nexport const ioredisChannelIntegration = defineIntegration(_ioredisChannelIntegration);\n"],"names":["DB_SYSTEM","NET_PEER_NAME","NET_PEER_PORT","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","DEBUG_BUILD","debug","CHANNELS","waitForTracingChannelBinding","bindTracingChannelToSpan","defaultDbStatementSerializer","startInactiveSpan","DB_STATEMENT","defineIntegration"],"mappings":";;;;;;;;;;AAsBA,MAAM,gBAAA,GAAmB,SAAA;AAEzB,MAAM,MAAA,GAAS,2BAAA;AAGf,MAAM,yBAAA,GAA4B,sBAAA;AA4BlC,SAAS,qBAAqB,IAAA,EAAqE;AACjG,EAAA,OAAO,EAAE,MAAM,IAAA,EAAM,OAAA,EAAS,MAAM,IAAA,EAAM,IAAA,EAAM,SAAS,IAAA,EAAK;AAChE;AAEA,SAAS,oBAAA,CAAqB,MAA0B,IAAA,EAAmD;AACzG,EAAA,OAAO;AAAA,IACL,CAACA,oBAAS,GAAG,OAAA;AAAA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,OAAA,CAAQ,IAAA,EAAM,OAAA,CAAQ,MAAM,MAAM,CAAA;AAAA,EAC/C,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AASO,MAAM,yBAAA,GAA4BC,uBAAkB,0BAA0B;;;;"}
1
+ {"version":3,"file":"ioredis.js","sources":["../../../../src/integrations/tracing-channel/ioredis.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated -- we intentionally emit the OLD db/net semconv\n to match `@opentelemetry/instrumentation-ioredis` (and Sentry's `inferDbSpanData`, which keys off\n `db.statement`). TODO(v11): switch to the non-deprecated `db.system.name`/`db.query.text`/\n `server.address`/`server.port` conventions and drop this disable. */\nimport * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { DB_STATEMENT, DB_SYSTEM, NET_PEER_NAME, NET_PEER_PORT } from '@sentry/conventions/attributes';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { defaultDbStatementSerializer } from '../../redis/redis-statement-serializer';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Distinct from the OTel `Redis` integration, which is composite (node-redis +\n// ioredis + the >=5.11.0 diagnostics_channel subscriber) and stays in the set;\n// only its ioredis monkey-patch is gated off in the node SDK when this is active.\nconst INTEGRATION_NAME = 'IORedis' as const;\n\nconst ORIGIN = 'auto.db.orchestrion.redis';\n\n// todo(v11): Let's drop this as this is already covered with host and port\nconst ATTR_DB_CONNECTION_STRING = 'db.connection_string';\n\n/** Mirrors `@opentelemetry/instrumentation-ioredis`' response hook. Not called for failed commands. */\nexport type IORedisResponseHook = (span: Span, command: string, args: Array<string | Buffer>, result: unknown) => void;\n\nexport interface IORedisChannelIntegrationOptions {\n responseHook?: IORedisResponseHook;\n}\n\n/** Structural type for the command object ioredis passes to `sendCommand`. */\ninterface RedisCommand {\n name: string;\n args: Array<string | Buffer>;\n}\n\ninterface RedisClientLike {\n options?: { host?: string; port?: number };\n}\n\ninterface IORedisCommandContext {\n arguments?: unknown[];\n self?: RedisClientLike;\n result?: unknown;\n error?: unknown;\n}\n\ntype IORedisConnectContext = Omit<IORedisCommandContext, 'arguments'>;\n\nfunction getConnectionOptions(self: RedisClientLike | undefined): { host?: string; port?: number } {\n return { host: self?.options?.host, port: self?.options?.port };\n}\n\nfunction connectionAttributes(host: string | undefined, port: number | undefined): Record<string, unknown> {\n return {\n [DB_SYSTEM]: 'redis',\n [ATTR_DB_CONNECTION_STRING]: `redis://${host}:${port}`,\n [NET_PEER_NAME]: host,\n [NET_PEER_PORT]: port,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n}\n\n// ioredis re-enters `sendCommand` with the same command object when it drains\n// the offline queue on connect which leads to duplicate spans.\n// Track commands we've already traced so each logical command produces one span.\nconst tracedCommands = new WeakSet<object>();\n\n/**\n * Builds the db span for an `orchestrion:ioredis:command` payload, or returns `undefined` to skip\n * it: for a non-command payload, or the offline-queue re-send of an already-traced command.\n *\n * Exported for unit testing.\n */\nexport function startIORedisCommandSpan(data: IORedisCommandContext): Span | undefined {\n const command = data.arguments?.[0] as RedisCommand | undefined;\n if (!command || typeof command !== 'object') {\n return undefined;\n }\n // guard against duplicate spans\n if (tracedCommands.has(command)) {\n return undefined;\n }\n tracedCommands.add(command);\n const { host, port } = getConnectionOptions(data.self);\n const statement = defaultDbStatementSerializer(command.name, command.args ?? []);\n return startInactiveSpan({\n name: statement,\n op: 'db',\n attributes: { ...connectionAttributes(host, port), [DB_STATEMENT]: statement },\n });\n}\n\nconst _ioredisChannelIntegration = ((options: IORedisChannelIntegrationOptions = {}) => {\n const responseHook = options.responseHook;\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19.\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(`[orchestrion:ioredis] subscribing to \"${CHANNELS.IOREDIS_COMMAND}\"/\"${CHANNELS.IOREDIS_CONNECT}\"`);\n\n const commandChannel = diagnosticsChannel.tracingChannel<IORedisCommandContext, IORedisCommandContext>(\n CHANNELS.IOREDIS_COMMAND,\n );\n const connectChannel = diagnosticsChannel.tracingChannel<IORedisConnectContext, IORedisConnectContext>(\n CHANNELS.IOREDIS_CONNECT,\n );\n\n // `bindTracingChannelToSpan` uses `bindStore`, which needs the async-context\n // binding that `initOpenTelemetry()` registers after integration `setupOnce` —\n // defer until it's available (matches the native redis diagnostics-channel subscriber).\n waitForTracingChannelBinding(() => {\n bindTracingChannelToSpan(commandChannel, startIORedisCommandSpan, {\n // ioredis' `requireParentSpan` default: only create a span under an active span.\n requiresParentSpan: true,\n beforeSpanEnd(span, data) {\n if ('error' in data || !responseHook) {\n return;\n }\n const command = data.arguments?.[0] as RedisCommand | undefined;\n if (command) {\n runResponseHook(responseHook, span, command, data.result);\n }\n },\n });\n\n bindTracingChannelToSpan(\n connectChannel,\n data => {\n const { host, port } = getConnectionOptions(data.self);\n return startInactiveSpan({\n name: 'connect',\n op: 'db',\n attributes: { ...connectionAttributes(host, port), [DB_STATEMENT]: 'connect' },\n });\n },\n { requiresParentSpan: true },\n );\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction runResponseHook(hook: IORedisResponseHook, span: Span, command: RedisCommand, result: unknown): void {\n try {\n hook(span, command.name, command.args, result);\n } catch {\n // never let a user-provided response hook break instrumentation\n }\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven ioredis integration. Subscribes to\n * `orchestrion:ioredis:command` / `:connect` (injected into ioredis' `<5.11.0`\n * `sendCommand`/`connect`) and creates db spans matching\n * `@opentelemetry/instrumentation-ioredis`. Requires the orchestrion runtime hook\n * or bundler plugin.\n */\nexport const ioredisChannelIntegration = defineIntegration(_ioredisChannelIntegration);\n"],"names":["DB_SYSTEM","NET_PEER_NAME","NET_PEER_PORT","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","defaultDbStatementSerializer","startInactiveSpan","DB_STATEMENT","DEBUG_BUILD","debug","CHANNELS","waitForTracingChannelBinding","bindTracingChannelToSpan","defineIntegration"],"mappings":";;;;;;;;;;AAsBA,MAAM,gBAAA,GAAmB,SAAA;AAEzB,MAAM,MAAA,GAAS,2BAAA;AAGf,MAAM,yBAAA,GAA4B,sBAAA;AA4BlC,SAAS,qBAAqB,IAAA,EAAqE;AACjG,EAAA,OAAO,EAAE,MAAM,IAAA,EAAM,OAAA,EAAS,MAAM,IAAA,EAAM,IAAA,EAAM,SAAS,IAAA,EAAK;AAChE;AAEA,SAAS,oBAAA,CAAqB,MAA0B,IAAA,EAAmD;AACzG,EAAA,OAAO;AAAA,IACL,CAACA,oBAAS,GAAG,OAAA;AAAA,IACb,CAAC,yBAAyB,GAAG,CAAA,QAAA,EAAW,IAAI,IAAI,IAAI,CAAA,CAAA;AAAA,IACpD,CAACC,wBAAa,GAAG,IAAA;AAAA,IACjB,CAACC,wBAAa,GAAG,IAAA;AAAA,IACjB,CAACC,qCAAgC,GAAG;AAAA,GACtC;AACF;AAKA,MAAM,cAAA,uBAAqB,OAAA,EAAgB;AAQpC,SAAS,wBAAwB,IAAA,EAA+C;AACrF,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,SAAA,GAAY,CAAC,CAAA;AAClC,EAAA,IAAI,CAAC,OAAA,IAAW,OAAO,OAAA,KAAY,QAAA,EAAU;AAC3C,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI,cAAA,CAAe,GAAA,CAAI,OAAO,CAAA,EAAG;AAC/B,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,cAAA,CAAe,IAAI,OAAO,CAAA;AAC1B,EAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAK,GAAI,oBAAA,CAAqB,KAAK,IAAI,CAAA;AACrD,EAAA,MAAM,Y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AA,EAAc,IAAA,EAAM,OAAA,EAAS,IAAA,CAAK,MAAM,CAAA;AAAA,YAC1D;AAAA,UACF;AAAA,SACD,CAAA;AAED,QAAAA,uCAAA;AAAA,UACE,cAAA;AAAA,UACA,CAAA,IAAA,KAAQ;AACN,YAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAK,GAAI,oBAAA,CAAqB,KAAK,IAAI,CAAA;AACrD,YAAA,OAAON,sBAAA,CAAkB;AAAA,cACvB,IAAA,EAAM,SAAA;AAAA,cACN,EAAA,EAAI,IAAA;AAAA,cACJ,UAAA,EAAY,EAAE,GAAG,oBAAA,CAAqB,IAAA,EAAM,IAAI,CAAA,EAAG,CAACC,uBAAY,GAAG,SAAA;AAAU,aAC9E,CAAA;AAAA,UACH,CAAA;AAAA,UACA,EAAE,oBAAoB,IAAA;AAAK,SAC7B;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAEA,SAAS,eAAA,CAAgB,IAAA,EAA2B,IAAA,EAAY,OAAA,EAAuB,MAAA,EAAuB;AAC5G,EAAA,IAAI;AACF,IAAA,IAAA,CAAK,IAAA,EAAM,OAAA,CAAQ,IAAA,EAAM,OAAA,CAAQ,MAAM,MAAM,CAAA;AAAA,EAC/C,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AASO,MAAM,yBAAA,GAA4BM,uBAAkB,0BAA0B;;;;;"}
@@ -0,0 +1,71 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const attributes = require('@sentry/conventions/attributes');
4
+ const core = require('@sentry/core');
5
+ const semconv = require('./semconv.js');
6
+ const spans = require('./spans.js');
7
+
8
+ const consumerCallbackWrapped = /* @__PURE__ */ Symbol("sentry-kafkajs-consumer-callback-wrapped");
9
+ function isWrappedConsumerCallback(fn) {
10
+ return typeof fn === "function" && fn[consumerCallbackWrapped] === true;
11
+ }
12
+ function wrapEachMessage(original) {
13
+ const wrapped = function eachMessage(payload) {
14
+ const sentryTrace = spans.getHeaderAsString(payload.message.headers, "sentry-trace");
15
+ const baggage = spans.getHeaderAsString(payload.message.headers, "baggage");
16
+ return core.continueTrace({ sentryTrace, baggage }, () => {
17
+ const span = spans.startConsumerSpan({
18
+ topic: payload.topic,
19
+ message: payload.message,
20
+ operationType: semconv.MESSAGING_OPERATION_TYPE_VALUE_PROCESS,
21
+ attributes: {
22
+ [semconv.ATTR_MESSAGING_DESTINATION_PARTITION_ID]: String(payload.partition)
23
+ }
24
+ });
25
+ const promise = core.withActiveSpan(span, () => original.call(this, payload));
26
+ return spans.endSpansOnPromise([span], promise);
27
+ });
28
+ };
29
+ wrapped[consumerCallbackWrapped] = true;
30
+ return wrapped;
31
+ }
32
+ function wrapEachBatch(original) {
33
+ const wrapped = function eachBatch(payload) {
34
+ const receivingSpan = core.startNewTrace(
35
+ () => spans.startConsumerSpan({
36
+ topic: payload.batch.topic,
37
+ message: void 0,
38
+ operationType: semconv.MESSAGING_OPERATION_TYPE_VALUE_RECEIVE,
39
+ attributes: {
40
+ [attributes.MESSAGING_BATCH_MESSAGE_COUNT]: payload.batch.messages.length,
41
+ [semconv.ATTR_MESSAGING_DESTINATION_PARTITION_ID]: String(payload.batch.partition)
42
+ }
43
+ })
44
+ );
45
+ return core.withActiveSpan(receivingSpan, () => {
46
+ const spans$1 = [receivingSpan];
47
+ payload.batch.messages.forEach((message) => {
48
+ spans$1.push(
49
+ spans.startConsumerSpan({
50
+ topic: payload.batch.topic,
51
+ message,
52
+ operationType: semconv.MESSAGING_OPERATION_TYPE_VALUE_PROCESS,
53
+ links: spans.getLinksFromHeaders(message.headers),
54
+ attributes: {
55
+ [semconv.ATTR_MESSAGING_DESTINATION_PARTITION_ID]: String(payload.batch.partition)
56
+ }
57
+ })
58
+ );
59
+ });
60
+ const promise = original.call(this, payload);
61
+ return spans.endSpansOnPromise(spans$1, promise);
62
+ });
63
+ };
64
+ wrapped[consumerCallbackWrapped] = true;
65
+ return wrapped;
66
+ }
67
+
68
+ exports.isWrappedConsumerCallback = isWrappedConsumerCallback;
69
+ exports.wrapEachBatch = wrapEachBatch;
70
+ exports.wrapEachMessage = wrapEachMessage;
71
+ //# sourceMappingURL=consumer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer.js","sources":["../../../../../src/integrations/tracing-channel/kafkajs/consumer.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors, Aspecto\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/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-kafkajs\n * - Upstream version: @opentelemetry/instrumentation-kafkajs@0.27.0\n * - Span-creating wrappers for the consumer callbacks (`_getConsumerEachMessagePatch`/\n * `_getConsumerEachBatchPatch`), migrated to the `@sentry/core` span API. The `run` channel's `start`\n * subscriber swaps the user's `eachMessage`/`eachBatch` for these before the original runs.\n */\n\nimport { MESSAGING_BATCH_MESSAGE_COUNT } from '@sentry/conventions/attributes';\nimport type { Span } from '@sentry/core';\nimport { continueTrace, startNewTrace, withActiveSpan } from '@sentry/core';\nimport {\n ATTR_MESSAGING_DESTINATION_PARTITION_ID,\n MESSAGING_OPERATION_TYPE_VALUE_PROCESS,\n MESSAGING_OPERATION_TYPE_VALUE_RECEIVE,\n} from './semconv';\nimport { endSpansOnPromise, getHeaderAsString, getLinksFromHeaders, startConsumerSpan } from './spans';\nimport type { EachBatchHandler, EachMessageHandler, KafkaMessage } from './types';\n\n// Marks a callback we've already wrapped. A user can reuse one config object across multiple\n// `consumer.run(config)` calls (e.g. a second consumer); without this guard the second `start` would\n// wrap the wrapper and emit duplicate spans per message.\nconst consumerCallbackWrapped: unique symbol = Symbol('sentry-kafkajs-consumer-callback-wrapped');\n\ntype MaybeWrapped = { [consumerCallbackWrapped]?: true };\n\n/** Whether `fn` is a callback this module already wrapped, so callers skip re-wrapping it. */\nexport function isWrappedConsumerCallback(fn: unknown): boolean {\n return typeof fn === 'function' && (fn as MaybeWrapped)[consumerCallbackWrapped] === true;\n}\n\n/** Wraps `eachMessage` so each processed message becomes a consumer span parented to the message's producer. */\nexport function wrapEachMessage(original: EachMessageHandler): EachMessageHandler {\n const wrapped: EachMessageHandler & MaybeWrapped = function eachMessage(this: unknown, payload) {\n const sentryTrace = getHeaderAsString(payload.message.headers, 'sentry-trace');\n const baggage = getHeaderAsString(payload.message.headers, 'baggage');\n\n // Continue the producer's trace so the consumer span is parented to the message's producer.\n return continueTrace({ sentryTrace, baggage }, () => {\n const span = startConsumerSpan({\n topic: payload.topic,\n message: payload.message,\n operationType: MESSAGING_OPERATION_TYPE_VALUE_PROCESS,\n attributes: {\n [ATTR_MESSAGING_DESTINATION_PARTITION_ID]: String(payload.partition),\n },\n });\n\n const promise = withActiveSpan(span, () => original.call(this, payload));\n return endSpansOnPromise([span], promise);\n });\n };\n wrapped[consumerCallbackWrapped] = true;\n return wrapped;\n}\n\n/** Wraps `eachBatch` so the batch pull becomes a fresh-root receiving span with a process span per message. */\nexport function wrapEachBatch(original: EachBatchHandler): EachBatchHandler {\n const wrapped: EachBatchHandler & MaybeWrapped = function eachBatch(this: unknown, payload) {\n // A batch pull aggregates messages from many producers, so the receiving span is a fresh root\n // trace and each processed message links back to its own producer span. Mirrors the OTel messaging\n // semantic conventions for a topic with multiple consumers.\n const receivingSpan = startNewTrace(() =>\n startConsumerSpan({\n topic: payload.batch.topic,\n message: undefined,\n operationType: MESSAGING_OPERATION_TYPE_VALUE_RECEIVE,\n attributes: {\n [MESSAGING_BATCH_MESSAGE_COUNT]: payload.batch.messages.length,\n [ATTR_MESSAGING_DESTINATION_PARTITION_ID]: String(payload.batch.partition),\n },\n }),\n );\n\n return withActiveSpan(receivingSpan, () => {\n const spans: Span[] = [receivingSpan];\n payload.batch.messages.forEach((message: KafkaMessage) => {\n spans.push(\n startConsumerSpan({\n topic: payload.batch.topic,\n message,\n operationType: MESSAGING_OPERATION_TYPE_VALUE_PROCESS,\n links: getLinksFromHeaders(message.headers),\n attributes: {\n [ATTR_MESSAGING_DESTINATION_PARTITION_ID]: String(payload.batch.partition),\n },\n }),\n );\n });\n const promise = original.call(this, payload);\n return endSpansOnPromise(spans, promise);\n });\n };\n wrapped[consumerCallbackWrapped] = true;\n return wrapped;\n}\n"],"names":["getHeaderAsString","continueTrace","startConsumerSpan","MESSAGING_OPERATION_TYPE_VALUE_PROCESS","ATTR_MESSAGING_DESTINATION_PARTITION_ID","withActiveSpan","endSpansOnPromise","startNewTrace","MESSAGING_OPERATION_TYPE_VALUE_RECEIVE","MESSAGING_BATCH_MESSAGE_COUNT","spans","getLinksFromHeaders"],"mappings":";;;;;;;AA0BA,MAAM,uBAAA,0BAAgD,0CAA0C,CAAA;AAKzF,SAAS,0BAA0B,EAAA,EAAsB;AAC9D,EAAA,OAAO,OAAO,EAAA,KAAO,UAAA,IAAe,EAAA,CAAoB,uBAAuB,CAAA,KAAM,IAAA;AACvF;AAGO,SAAS,gBAAgB,QAAA,EAAkD;AAChF,EAAA,MAAM,OAAA,GAA6C,SAAS,WAAA,CAA2B,OAAA,EAAS;AAC9F,IAAA,MAAM,WAAA,GAAcA,uBAAA,CAAkB,OAAA,CAAQ,OAAA,CAAQ,SAAS,cAAc,CAAA;AAC7E,IAAA,MAAM,OAAA,GAAUA,uBAAA,CAAkB,OAAA,CAAQ,OAAA,CAAQ,SAAS,SAAS,CAAA;AAGpE,IAAA,OAAOC,kBAAA,CAAc,EAAE,WAAA,EAAa,OAAA,IAAW,MAAM;AACnD,MAAA,MAAM,OAAOC,uBAAA,CAAkB;AAAA,QAC7B,OAAO,OAAA,CAAQ,KAAA;AAAA,QACf,SAAS,OAAA,CAAQ,OAAA;AAAA,QACjB,aAAA,EAAeC,8CAAA;AAAA,QACf,UAAA,EAAY;AAAA,UACV,CAACC,+CAAuC,GAAG,MAAA,CAAO,QAAQ,SAAS;AAAA;AACrE,OACD,CAAA;AAED,MAAA,MAAM,OAAA,GAAUC,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;AAC3E,WACD;AAAA,SACH;AAAA,MACF,CAAC,CAAA;AACD,MAAA,MAAM,OAAA,GAAU,QAAA,CAAS,IAAA,CAAK,IAAA,EAAM,OAAO,CAAA;AAC3C,MAAA,OAAOE,uBAAA,CAAkBI,SAAO,OAAO,CAAA;AAAA,IACzC,CAAC,CAAA;AAAA,EACH,CAAA;AACA,EAAA,OAAA,CAAQ,uBAAuB,CAAA,GAAI,IAAA;AACnC,EAAA,OAAO,OAAA;AACT;;;;;;"}
@@ -0,0 +1,70 @@
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 consumer = require('./consumer.js');
8
+ const spans = require('./spans.js');
9
+
10
+ const INTEGRATION_NAME = "Kafka";
11
+ function subscribeToProducer() {
12
+ const channel = diagnosticsChannel.tracingChannel(channels.CHANNELS.KAFKAJS_SEND_BATCH);
13
+ const subscribers = {
14
+ start(ctx) {
15
+ const spans$1 = [];
16
+ (ctx.arguments[0]?.topicMessages ?? []).forEach((topicMessage) => {
17
+ topicMessage.messages.forEach((message) => {
18
+ spans$1.push(spans.startProducerSpan(topicMessage.topic, message));
19
+ });
20
+ });
21
+ ctx._sentrySpans = spans$1;
22
+ },
23
+ error(ctx) {
24
+ if (ctx._sentrySpans) {
25
+ spans.applyErrorToSpans(ctx._sentrySpans, ctx.error);
26
+ }
27
+ },
28
+ asyncEnd(ctx) {
29
+ ctx._sentrySpans?.forEach((span) => span.end());
30
+ }
31
+ };
32
+ channel.subscribe(subscribers);
33
+ }
34
+ function subscribeToConsumer() {
35
+ const channel = diagnosticsChannel.tracingChannel(channels.CHANNELS.KAFKAJS_CONSUMER_RUN);
36
+ const subscribers = {
37
+ start(ctx) {
38
+ const config = ctx.arguments[0];
39
+ if (!config || typeof config !== "object") {
40
+ return;
41
+ }
42
+ if (typeof config.eachMessage === "function" && !consumer.isWrappedConsumerCallback(config.eachMessage)) {
43
+ config.eachMessage = consumer.wrapEachMessage(config.eachMessage);
44
+ }
45
+ if (typeof config.eachBatch === "function" && !consumer.isWrappedConsumerCallback(config.eachBatch)) {
46
+ config.eachBatch = consumer.wrapEachBatch(config.eachBatch);
47
+ }
48
+ }
49
+ };
50
+ channel.subscribe(subscribers);
51
+ }
52
+ const _kafkajsChannelIntegration = (() => {
53
+ return {
54
+ name: INTEGRATION_NAME,
55
+ setupOnce() {
56
+ if (!diagnosticsChannel.tracingChannel) {
57
+ return;
58
+ }
59
+ debugBuild.DEBUG_BUILD && core.debug.log(
60
+ `[orchestrion:kafkajs] subscribing to channels "${channels.CHANNELS.KAFKAJS_SEND_BATCH}", "${channels.CHANNELS.KAFKAJS_CONSUMER_RUN}"`
61
+ );
62
+ subscribeToProducer();
63
+ subscribeToConsumer();
64
+ }
65
+ };
66
+ });
67
+ const kafkajsChannelIntegration = core.defineIntegration(_kafkajsChannelIntegration);
68
+
69
+ exports.kafkajsChannelIntegration = kafkajsChannelIntegration;
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing-channel/kafkajs/index.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { TracingChannelSubscribers } from 'node:diagnostics_channel';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport { debug, defineIntegration } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport { CHANNELS } from '../../../orchestrion/channels';\nimport { isWrappedConsumerCallback, wrapEachBatch, wrapEachMessage } from './consumer';\nimport { applyErrorToSpans, startProducerSpan } from './spans';\nimport type { ConsumerRunConfig, ProducerBatch } from './types';\n\n// NOTE: this uses the same name as the OTel `Kafka` integration by design. When enabled, the OTel\n// integration is omitted from the default set (see `experimentalUseDiagnosticsChannelInjection`).\nconst INTEGRATION_NAME = 'Kafka' as const;\n\n/** The tracing-channel context the transform attaches around `messageProducer.js`'s `sendBatch`. */\ninterface SendBatchChannelContext {\n // `arguments[0]` is the `{ topicMessages }` batch (kafkajs normalizes `send` into `sendBatch`).\n arguments: [ProducerBatch?, ...unknown[]];\n error?: unknown;\n // The producer spans opened at `start`, ended on `asyncEnd` (and marked errored on `error`).\n _sentrySpans?: Span[];\n}\n\n/** The tracing-channel context the transform attaches around `consumer/index.js`'s `run`. */\ninterface ConsumerRunChannelContext {\n // `arguments[0]` is the `run(config)` config whose `eachMessage`/`eachBatch` we swap in place.\n arguments: [ConsumerRunConfig?, ...unknown[]];\n}\n\nfunction subscribeToProducer(): void {\n const channel = diagnosticsChannel.tracingChannel<SendBatchChannelContext>(CHANNELS.KAFKAJS_SEND_BATCH);\n // Node types `subscribe` as requiring every lifecycle handler; runtime accepts a partial set, so we\n // pass only the ones we use (matching `bindTracingChannelToSpan`'s handling in `tracing-channel.ts`).\n const subscribers: Partial<TracingChannelSubscribers<SendBatchChannelContext>> = {\n start(ctx) {\n const spans: Span[] = [];\n // `startProducerSpan` mutates each message's headers; doing it at `start` means the mutation\n // reaches the real call, propagating the producer's trace to consumers.\n (ctx.arguments[0]?.topicMessages ?? []).forEach(topicMessage => {\n topicMessage.messages.forEach(message => {\n spans.push(startProducerSpan(topicMessage.topic, message));\n });\n });\n ctx._sentrySpans = spans;\n },\n error(ctx) {\n if (ctx._sentrySpans) {\n applyErrorToSpans(ctx._sentrySpans, ctx.error);\n }\n },\n asyncEnd(ctx) {\n // `asyncEnd` fires on both success and failure; `error` (above) has already set the status.\n ctx._sentrySpans?.forEach(span => span.end());\n },\n };\n channel.subscribe(subscribers as TracingChannelSubscribers<SendBatchChannelContext>);\n}\n\nfunction subscribeToConsumer(): void {\n const channel = diagnosticsChannel.tracingChannel<ConsumerRunChannelContext>(CHANNELS.KAFKAJS_CONSUMER_RUN);\n const subscribers: Partial<TracingChannelSubscribers<ConsumerRunChannelContext>> = {\n start(ctx) {\n const config = ctx.arguments[0];\n if (!config || typeof config !== 'object') {\n return;\n }\n // Swap the user callbacks for span-creating wrappers before `run` destructures its config. The\n // `isWrappedConsumerCallback` guard keeps this idempotent: a config object reused across another\n // `run` (or a second consumer) must not have its wrapper wrapped again, which would double spans.\n if (typeof config.eachMessage === 'function' && !isWrappedConsumerCallback(config.eachMessage)) {\n config.eachMessage = wrapEachMessage(config.eachMessage);\n }\n if (typeof config.eachBatch === 'function' && !isWrappedConsumerCallback(config.eachBatch)) {\n config.eachBatch = wrapEachBatch(config.eachBatch);\n }\n },\n };\n channel.subscribe(subscribers as TracingChannelSubscribers<ConsumerRunChannelContext>);\n}\n\nconst _kafkajsChannelIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(\n `[orchestrion:kafkajs] subscribing to channels \"${CHANNELS.KAFKAJS_SEND_BATCH}\", \"${CHANNELS.KAFKAJS_CONSUMER_RUN}\"`,\n );\n\n subscribeToProducer();\n subscribeToConsumer();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * EXPERIMENTAL — orchestrion-driven kafkajs integration.\n *\n * Subscribes to the `orchestrion:kafkajs:*` diagnostics_channels that the orchestrion code transform\n * injects into `kafkajs`'s `producer/messageProducer.js` (`sendBatch`) and `consumer/index.js` (`run`).\n * Requires the orchestrion runtime hook or bundler plugin to be active — wire that up via\n * `experimentalUseDiagnosticsChannelInjection`.\n *\n * Known limitation vs. the OTel integration it replaces: the wrapping producer-`transaction` span is\n * not emitted (the transformer can't replace `transaction()`'s return value to patch commit/abort).\n * Transactional `send`/`sendBatch` calls still produce producer spans, since they route through the\n * same instrumented `sendBatch`.\n */\nexport const kafkajsChannelIntegration = defineIntegration(_kafkajsChannelIntegration);\n"],"names":["CHANNELS","spans","startProducerSpan","applyErrorToSpans","isWrappedConsumerCallback","wrapEachMessage","wrapEachBatch","DEBUG_BUILD","debug","defineIntegration"],"mappings":";;;;;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AA,IAAI,CAAC,MAAA,IAAU,OAAO,MAAA,KAAW,QAAA,EAAU;AACzC,QAAA;AAAA,MACF;AAIA,MAAA,IAAI,OAAO,OAAO,WAAA,KAAgB,UAAA,IAAc,CAACI,kCAAA,CAA0B,MAAA,CAAO,WAAW,CAAA,EAAG;AAC9F,QAAA,MAAA,CAAO,WAAA,GAAcC,wBAAA,CAAgB,MAAA,CAAO,WAAW,CAAA;AAAA,MACzD;AACA,MAAA,IAAI,OAAO,OAAO,SAAA,KAAc,UAAA,IAAc,CAACD,kCAAA,CAA0B,MAAA,CAAO,SAAS,CAAA,EAAG;AAC1F,QAAA,MAAA,CAAO,SAAA,GAAYE,sBAAA,CAAc,MAAA,CAAO,SAAS,CAAA;AAAA,MACnD;AAAA,IACF;AAAA,GACF;AACA,EAAA,OAAA,CAAQ,UAAU,WAAmE,CAAA;AACvF;AAEA,MAAM,8BAA8B,MAAM;AACxC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,IAAI,CAAC,mBAAmB,cAAA,EAAgB;AACtC,QAAA;AAAA,MACF;AAEA,MAAAC,sBAAA,IACEC,UAAA,CAAM,GAAA;AAAA,QACJ,CAAA,+CAAA,EAAkDR,iBAAA,CAAS,kBAAkB,CAAA,IAAA,EAAOA,kBAAS,oBAAoB,CAAA,CAAA;AAAA,OACnH;AAEF,MAAA,mBAAA,EAAoB;AACpB,MAAA,mBAAA,EAAoB;AAAA,IACtB;AAAA,GACF;AACF,CAAA,CAAA;AAeO,MAAM,yBAAA,GAA4BS,uBAAkB,0BAA0B;;;;"}
@@ -0,0 +1,22 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const ATTR_MESSAGING_DESTINATION_PARTITION_ID = "messaging.destination.partition.id";
4
+ const ATTR_MESSAGING_KAFKA_MESSAGE_KEY = "messaging.kafka.message.key";
5
+ const ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE = "messaging.kafka.message.tombstone";
6
+ const ATTR_MESSAGING_KAFKA_OFFSET = "messaging.kafka.offset";
7
+ const MESSAGING_OPERATION_TYPE_VALUE_PROCESS = "process";
8
+ const MESSAGING_OPERATION_TYPE_VALUE_RECEIVE = "receive";
9
+ const MESSAGING_OPERATION_TYPE_VALUE_SEND = "send";
10
+ const MESSAGING_SYSTEM_VALUE_KAFKA = "kafka";
11
+ const ERROR_TYPE_VALUE_OTHER = "_OTHER";
12
+
13
+ exports.ATTR_MESSAGING_DESTINATION_PARTITION_ID = ATTR_MESSAGING_DESTINATION_PARTITION_ID;
14
+ exports.ATTR_MESSAGING_KAFKA_MESSAGE_KEY = ATTR_MESSAGING_KAFKA_MESSAGE_KEY;
15
+ exports.ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE = ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE;
16
+ exports.ATTR_MESSAGING_KAFKA_OFFSET = ATTR_MESSAGING_KAFKA_OFFSET;
17
+ exports.ERROR_TYPE_VALUE_OTHER = ERROR_TYPE_VALUE_OTHER;
18
+ exports.MESSAGING_OPERATION_TYPE_VALUE_PROCESS = MESSAGING_OPERATION_TYPE_VALUE_PROCESS;
19
+ exports.MESSAGING_OPERATION_TYPE_VALUE_RECEIVE = MESSAGING_OPERATION_TYPE_VALUE_RECEIVE;
20
+ exports.MESSAGING_OPERATION_TYPE_VALUE_SEND = MESSAGING_OPERATION_TYPE_VALUE_SEND;
21
+ exports.MESSAGING_SYSTEM_VALUE_KAFKA = MESSAGING_SYSTEM_VALUE_KAFKA;
22
+ //# sourceMappingURL=semconv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semconv.js","sources":["../../../../../src/integrations/tracing-channel/kafkajs/semconv.ts"],"sourcesContent":["/*\n * Unstable OTel semantic-convention keys/values without a `@sentry/conventions` constant, inlined to\n * keep this integration free of `@opentelemetry/*` deps. Values are byte-identical to the vendored OTel\n * instrumentation (`@sentry/node`'s `integrations/tracing/kafka/vendored/semconv.ts`) for span parity.\n */\n\nexport const ATTR_MESSAGING_DESTINATION_PARTITION_ID = 'messaging.destination.partition.id' as const;\nexport const ATTR_MESSAGING_KAFKA_MESSAGE_KEY = 'messaging.kafka.message.key' as const;\nexport const ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE = 'messaging.kafka.message.tombstone' as const;\nexport const ATTR_MESSAGING_KAFKA_OFFSET = 'messaging.kafka.offset' as const;\nexport const MESSAGING_OPERATION_TYPE_VALUE_PROCESS = 'process' as const;\nexport const MESSAGING_OPERATION_TYPE_VALUE_RECEIVE = 'receive' as const;\nexport const MESSAGING_OPERATION_TYPE_VALUE_SEND = 'send' as const;\nexport const MESSAGING_SYSTEM_VALUE_KAFKA = 'kafka' as const;\n\n// `_OTHER` is OTel's fallback bucket when no more specific `error.type` is known.\nexport const ERROR_TYPE_VALUE_OTHER = '_OTHER' as const;\n"],"names":[],"mappings":";;AAMO,MAAM,uCAAA,GAA0C;AAChD,MAAM,gCAAA,GAAmC;AACzC,MAAM,sCAAA,GAAyC;AAC/C,MAAM,2BAAA,GAA8B;AACpC,MAAM,sCAAA,GAAyC;AAC/C,MAAM,sCAAA,GAAyC;AAC/C,MAAM,mCAAA,GAAsC;AAC5C,MAAM,4BAAA,GAA+B;AAGrC,MAAM,sBAAA,GAAyB;;;;;;;;;;;;"}