@sentry/server-utils 10.66.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 (386) hide show
  1. package/build/cjs/index.js +7 -0
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/integrations/tracing-channel/aws-sdk/constants.js +16 -0
  4. package/build/cjs/integrations/tracing-channel/aws-sdk/constants.js.map +1 -0
  5. package/build/cjs/integrations/tracing-channel/aws-sdk/index.js +154 -0
  6. package/build/cjs/integrations/tracing-channel/aws-sdk/index.js.map +1 -0
  7. package/build/cjs/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js +46 -0
  8. package/build/cjs/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js.map +1 -0
  9. package/build/cjs/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js +47 -0
  10. package/build/cjs/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js.map +1 -0
  11. package/build/cjs/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js +419 -0
  12. package/build/cjs/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js.map +1 -0
  13. package/build/cjs/integrations/tracing-channel/aws-sdk/services/dynamodb.js +131 -0
  14. package/build/cjs/integrations/tracing-channel/aws-sdk/services/dynamodb.js.map +1 -0
  15. package/build/cjs/integrations/tracing-channel/aws-sdk/services/kinesis.js +21 -0
  16. package/build/cjs/integrations/tracing-channel/aws-sdk/services/kinesis.js.map +1 -0
  17. package/build/cjs/integrations/tracing-channel/aws-sdk/services/lambda.js +64 -0
  18. package/build/cjs/integrations/tracing-channel/aws-sdk/services/lambda.js.map +1 -0
  19. package/build/cjs/integrations/tracing-channel/aws-sdk/services/s3.js +21 -0
  20. package/build/cjs/integrations/tracing-channel/aws-sdk/services/s3.js.map +1 -0
  21. package/build/cjs/integrations/tracing-channel/aws-sdk/services/secretsmanager.js +27 -0
  22. package/build/cjs/integrations/tracing-channel/aws-sdk/services/secretsmanager.js.map +1 -0
  23. package/build/cjs/integrations/tracing-channel/aws-sdk/services/sns.js +63 -0
  24. package/build/cjs/integrations/tracing-channel/aws-sdk/services/sns.js.map +1 -0
  25. package/build/cjs/integrations/tracing-channel/aws-sdk/services/sqs.js +116 -0
  26. package/build/cjs/integrations/tracing-channel/aws-sdk/services/sqs.js.map +1 -0
  27. package/build/cjs/integrations/tracing-channel/aws-sdk/services/stepfunctions.js +25 -0
  28. package/build/cjs/integrations/tracing-channel/aws-sdk/services/stepfunctions.js.map +1 -0
  29. package/build/cjs/integrations/tracing-channel/aws-sdk/utils.js +30 -0
  30. package/build/cjs/integrations/tracing-channel/aws-sdk/utils.js.map +1 -0
  31. package/build/cjs/integrations/tracing-channel/express/instrumentation.js +1 -6
  32. package/build/cjs/integrations/tracing-channel/express/instrumentation.js.map +1 -1
  33. package/build/cjs/integrations/tracing-channel/koa.js +146 -0
  34. package/build/cjs/integrations/tracing-channel/koa.js.map +1 -0
  35. package/build/cjs/integrations/tracing-channel/langchain.js +63 -0
  36. package/build/cjs/integrations/tracing-channel/langchain.js.map +1 -0
  37. package/build/cjs/integrations/tracing-channel/langgraph.js +100 -0
  38. package/build/cjs/integrations/tracing-channel/langgraph.js.map +1 -0
  39. package/build/cjs/integrations/tracing-channel/mongodb.js +104 -0
  40. package/build/cjs/integrations/tracing-channel/mongodb.js.map +1 -0
  41. package/build/cjs/integrations/tracing-channel/mongoose.js +110 -0
  42. package/build/cjs/integrations/tracing-channel/mongoose.js.map +1 -0
  43. package/build/cjs/integrations/tracing-channel/openai.js +1 -3
  44. package/build/cjs/integrations/tracing-channel/openai.js.map +1 -1
  45. package/build/cjs/integrations/tracing-channel/redis.js +25 -34
  46. package/build/cjs/integrations/tracing-channel/redis.js.map +1 -1
  47. package/build/cjs/integrations/tracing-channel/tedious.js +145 -0
  48. package/build/cjs/integrations/tracing-channel/tedious.js.map +1 -0
  49. package/build/cjs/mongodb/mongodb-span.js +133 -0
  50. package/build/cjs/mongodb/mongodb-span.js.map +1 -0
  51. package/build/cjs/mongoose/index.js.map +1 -1
  52. package/build/cjs/mongoose/mongoose-legacy-span.js +40 -0
  53. package/build/cjs/mongoose/mongoose-legacy-span.js.map +1 -0
  54. package/build/cjs/orchestrion/bundler/esbuild.js +5 -1
  55. package/build/cjs/orchestrion/bundler/esbuild.js.map +1 -1
  56. package/build/cjs/orchestrion/bundler/options.js +10 -1
  57. package/build/cjs/orchestrion/bundler/options.js.map +1 -1
  58. package/build/cjs/orchestrion/bundler/rollup.js +5 -1
  59. package/build/cjs/orchestrion/bundler/rollup.js.map +1 -1
  60. package/build/cjs/orchestrion/bundler/vite.js +5 -1
  61. package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
  62. package/build/cjs/orchestrion/bundler/webpack.js +8 -4
  63. package/build/cjs/orchestrion/bundler/webpack.js.map +1 -1
  64. package/build/cjs/orchestrion/channels.js +4 -0
  65. package/build/cjs/orchestrion/channels.js.map +1 -1
  66. package/build/cjs/orchestrion/config/amqplib.js.map +1 -1
  67. package/build/cjs/orchestrion/config/anthropic-ai.js.map +1 -1
  68. package/build/cjs/orchestrion/config/aws-sdk.js +28 -0
  69. package/build/cjs/orchestrion/config/aws-sdk.js.map +1 -0
  70. package/build/cjs/orchestrion/config/dataloader.js.map +1 -1
  71. package/build/cjs/orchestrion/config/express.js +9 -8
  72. package/build/cjs/orchestrion/config/express.js.map +1 -1
  73. package/build/cjs/orchestrion/config/firebase.js.map +1 -1
  74. package/build/cjs/orchestrion/config/generic-pool.js.map +1 -1
  75. package/build/cjs/orchestrion/config/google-genai.js.map +1 -1
  76. package/build/cjs/orchestrion/config/graphql.js.map +1 -1
  77. package/build/cjs/orchestrion/config/hapi.js.map +1 -1
  78. package/build/cjs/orchestrion/config/index.js +10 -1
  79. package/build/cjs/orchestrion/config/index.js.map +1 -1
  80. package/build/cjs/orchestrion/config/ioredis.js.map +1 -1
  81. package/build/cjs/orchestrion/config/kafkajs.js.map +1 -1
  82. package/build/cjs/orchestrion/config/knex.js.map +1 -1
  83. package/build/cjs/orchestrion/config/koa.js +16 -0
  84. package/build/cjs/orchestrion/config/koa.js.map +1 -0
  85. package/build/cjs/orchestrion/config/langchain.js +46 -2
  86. package/build/cjs/orchestrion/config/langchain.js.map +1 -1
  87. package/build/cjs/orchestrion/config/langgraph.js +22 -2
  88. package/build/cjs/orchestrion/config/langgraph.js.map +1 -1
  89. package/build/cjs/orchestrion/config/lru-memoizer.js.map +1 -1
  90. package/build/cjs/orchestrion/config/mongodb.js +61 -2
  91. package/build/cjs/orchestrion/config/mongodb.js.map +1 -1
  92. package/build/cjs/orchestrion/config/mongoose.js +101 -2
  93. package/build/cjs/orchestrion/config/mongoose.js.map +1 -1
  94. package/build/cjs/orchestrion/config/mysql.js.map +1 -1
  95. package/build/cjs/orchestrion/config/mysql2.js.map +1 -1
  96. package/build/cjs/orchestrion/config/nestjs.js.map +1 -1
  97. package/build/cjs/orchestrion/config/openai.js +5 -5
  98. package/build/cjs/orchestrion/config/openai.js.map +1 -1
  99. package/build/cjs/orchestrion/config/pg.js.map +1 -1
  100. package/build/cjs/orchestrion/config/postgres.js.map +1 -1
  101. package/build/cjs/orchestrion/config/prisma.js.map +1 -1
  102. package/build/cjs/orchestrion/config/react-router.js.map +1 -1
  103. package/build/cjs/orchestrion/config/redis.js.map +1 -1
  104. package/build/cjs/orchestrion/config/remix.js +48 -2
  105. package/build/cjs/orchestrion/config/remix.js.map +1 -1
  106. package/build/cjs/orchestrion/config/tedious.js +18 -2
  107. package/build/cjs/orchestrion/config/tedious.js.map +1 -1
  108. package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -1
  109. package/build/cjs/orchestrion/index.js +32 -9
  110. package/build/cjs/orchestrion/index.js.map +1 -1
  111. package/build/cjs/orchestrion/runtime/register.js +25 -12
  112. package/build/cjs/orchestrion/runtime/register.js.map +1 -1
  113. package/build/cjs/redis/redis-dc-subscriber.js +27 -38
  114. package/build/cjs/redis/redis-dc-subscriber.js.map +1 -1
  115. package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js +16 -3
  116. package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -1
  117. package/build/esm/index.js +2 -0
  118. package/build/esm/index.js.map +1 -1
  119. package/build/esm/integrations/tracing-channel/aws-sdk/constants.js +9 -0
  120. package/build/esm/integrations/tracing-channel/aws-sdk/constants.js.map +1 -0
  121. package/build/esm/integrations/tracing-channel/aws-sdk/index.js +152 -0
  122. package/build/esm/integrations/tracing-channel/aws-sdk/index.js.map +1 -0
  123. package/build/esm/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js +41 -0
  124. package/build/esm/integrations/tracing-channel/aws-sdk/services/MessageAttributes.js.map +1 -0
  125. package/build/esm/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js +45 -0
  126. package/build/esm/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.js.map +1 -0
  127. package/build/esm/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js +417 -0
  128. package/build/esm/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.js.map +1 -0
  129. package/build/esm/integrations/tracing-channel/aws-sdk/services/dynamodb.js +129 -0
  130. package/build/esm/integrations/tracing-channel/aws-sdk/services/dynamodb.js.map +1 -0
  131. package/build/esm/integrations/tracing-channel/aws-sdk/services/kinesis.js +19 -0
  132. package/build/esm/integrations/tracing-channel/aws-sdk/services/kinesis.js.map +1 -0
  133. package/build/esm/integrations/tracing-channel/aws-sdk/services/lambda.js +62 -0
  134. package/build/esm/integrations/tracing-channel/aws-sdk/services/lambda.js.map +1 -0
  135. package/build/esm/integrations/tracing-channel/aws-sdk/services/s3.js +19 -0
  136. package/build/esm/integrations/tracing-channel/aws-sdk/services/s3.js.map +1 -0
  137. package/build/esm/integrations/tracing-channel/aws-sdk/services/secretsmanager.js +25 -0
  138. package/build/esm/integrations/tracing-channel/aws-sdk/services/secretsmanager.js.map +1 -0
  139. package/build/esm/integrations/tracing-channel/aws-sdk/services/sns.js +61 -0
  140. package/build/esm/integrations/tracing-channel/aws-sdk/services/sns.js.map +1 -0
  141. package/build/esm/integrations/tracing-channel/aws-sdk/services/sqs.js +114 -0
  142. package/build/esm/integrations/tracing-channel/aws-sdk/services/sqs.js.map +1 -0
  143. package/build/esm/integrations/tracing-channel/aws-sdk/services/stepfunctions.js +23 -0
  144. package/build/esm/integrations/tracing-channel/aws-sdk/services/stepfunctions.js.map +1 -0
  145. package/build/esm/integrations/tracing-channel/aws-sdk/utils.js +26 -0
  146. package/build/esm/integrations/tracing-channel/aws-sdk/utils.js.map +1 -0
  147. package/build/esm/integrations/tracing-channel/express/instrumentation.js +1 -6
  148. package/build/esm/integrations/tracing-channel/express/instrumentation.js.map +1 -1
  149. package/build/esm/integrations/tracing-channel/koa.js +144 -0
  150. package/build/esm/integrations/tracing-channel/koa.js.map +1 -0
  151. package/build/esm/integrations/tracing-channel/langchain.js +61 -0
  152. package/build/esm/integrations/tracing-channel/langchain.js.map +1 -0
  153. package/build/esm/integrations/tracing-channel/langgraph.js +98 -0
  154. package/build/esm/integrations/tracing-channel/langgraph.js.map +1 -0
  155. package/build/esm/integrations/tracing-channel/mongodb.js +102 -0
  156. package/build/esm/integrations/tracing-channel/mongodb.js.map +1 -0
  157. package/build/esm/integrations/tracing-channel/mongoose.js +108 -0
  158. package/build/esm/integrations/tracing-channel/mongoose.js.map +1 -0
  159. package/build/esm/integrations/tracing-channel/openai.js +1 -3
  160. package/build/esm/integrations/tracing-channel/openai.js.map +1 -1
  161. package/build/esm/integrations/tracing-channel/redis.js +25 -34
  162. package/build/esm/integrations/tracing-channel/redis.js.map +1 -1
  163. package/build/esm/integrations/tracing-channel/tedious.js +143 -0
  164. package/build/esm/integrations/tracing-channel/tedious.js.map +1 -0
  165. package/build/esm/mongodb/mongodb-span.js +126 -0
  166. package/build/esm/mongodb/mongodb-span.js.map +1 -0
  167. package/build/esm/mongoose/index.js.map +1 -1
  168. package/build/esm/mongoose/mongoose-legacy-span.js +38 -0
  169. package/build/esm/mongoose/mongoose-legacy-span.js.map +1 -0
  170. package/build/esm/orchestrion/bundler/options.js +10 -1
  171. package/build/esm/orchestrion/bundler/options.js.map +1 -1
  172. package/build/esm/orchestrion/bundler/webpack.js +4 -4
  173. package/build/esm/orchestrion/bundler/webpack.js.map +1 -1
  174. package/build/esm/orchestrion/channels.js +4 -0
  175. package/build/esm/orchestrion/channels.js.map +1 -1
  176. package/build/esm/orchestrion/config/amqplib.js.map +1 -1
  177. package/build/esm/orchestrion/config/anthropic-ai.js.map +1 -1
  178. package/build/esm/orchestrion/config/aws-sdk.js +25 -0
  179. package/build/esm/orchestrion/config/aws-sdk.js.map +1 -0
  180. package/build/esm/orchestrion/config/dataloader.js.map +1 -1
  181. package/build/esm/orchestrion/config/express.js +9 -8
  182. package/build/esm/orchestrion/config/express.js.map +1 -1
  183. package/build/esm/orchestrion/config/firebase.js.map +1 -1
  184. package/build/esm/orchestrion/config/generic-pool.js.map +1 -1
  185. package/build/esm/orchestrion/config/google-genai.js.map +1 -1
  186. package/build/esm/orchestrion/config/graphql.js.map +1 -1
  187. package/build/esm/orchestrion/config/hapi.js.map +1 -1
  188. package/build/esm/orchestrion/config/index.js +10 -1
  189. package/build/esm/orchestrion/config/index.js.map +1 -1
  190. package/build/esm/orchestrion/config/ioredis.js.map +1 -1
  191. package/build/esm/orchestrion/config/kafkajs.js.map +1 -1
  192. package/build/esm/orchestrion/config/knex.js.map +1 -1
  193. package/build/esm/orchestrion/config/koa.js +13 -0
  194. package/build/esm/orchestrion/config/koa.js.map +1 -0
  195. package/build/esm/orchestrion/config/langchain.js +46 -3
  196. package/build/esm/orchestrion/config/langchain.js.map +1 -1
  197. package/build/esm/orchestrion/config/langgraph.js +22 -2
  198. package/build/esm/orchestrion/config/langgraph.js.map +1 -1
  199. package/build/esm/orchestrion/config/lru-memoizer.js.map +1 -1
  200. package/build/esm/orchestrion/config/mongodb.js +61 -2
  201. package/build/esm/orchestrion/config/mongodb.js.map +1 -1
  202. package/build/esm/orchestrion/config/mongoose.js +101 -3
  203. package/build/esm/orchestrion/config/mongoose.js.map +1 -1
  204. package/build/esm/orchestrion/config/mysql.js.map +1 -1
  205. package/build/esm/orchestrion/config/mysql2.js.map +1 -1
  206. package/build/esm/orchestrion/config/nestjs.js.map +1 -1
  207. package/build/esm/orchestrion/config/openai.js +5 -5
  208. package/build/esm/orchestrion/config/openai.js.map +1 -1
  209. package/build/esm/orchestrion/config/pg.js.map +1 -1
  210. package/build/esm/orchestrion/config/postgres.js.map +1 -1
  211. package/build/esm/orchestrion/config/prisma.js.map +1 -1
  212. package/build/esm/orchestrion/config/react-router.js.map +1 -1
  213. package/build/esm/orchestrion/config/redis.js.map +1 -1
  214. package/build/esm/orchestrion/config/remix.js +48 -2
  215. package/build/esm/orchestrion/config/remix.js.map +1 -1
  216. package/build/esm/orchestrion/config/tedious.js +18 -2
  217. package/build/esm/orchestrion/config/tedious.js.map +1 -1
  218. package/build/esm/orchestrion/config/vercel-ai.js.map +1 -1
  219. package/build/esm/orchestrion/index.js +17 -2
  220. package/build/esm/orchestrion/index.js.map +1 -1
  221. package/build/esm/orchestrion/runtime/register.js +25 -12
  222. package/build/esm/orchestrion/runtime/register.js.map +1 -1
  223. package/build/esm/package.json +1 -1
  224. package/build/esm/redis/redis-dc-subscriber.js +27 -38
  225. package/build/esm/redis/redis-dc-subscriber.js.map +1 -1
  226. package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js +17 -4
  227. package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -1
  228. package/build/types/index.d.ts +5 -1
  229. package/build/types/index.d.ts.map +1 -1
  230. package/build/types/integrations/tracing-channel/aws-sdk/aws-sdk.types.d.ts +43 -0
  231. package/build/types/integrations/tracing-channel/aws-sdk/aws-sdk.types.d.ts.map +1 -0
  232. package/build/types/integrations/tracing-channel/aws-sdk/constants.d.ts +15 -0
  233. package/build/types/integrations/tracing-channel/aws-sdk/constants.d.ts.map +1 -0
  234. package/build/types/integrations/tracing-channel/aws-sdk/index.d.ts +15 -0
  235. package/build/types/integrations/tracing-channel/aws-sdk/index.d.ts.map +1 -0
  236. package/build/types/integrations/tracing-channel/aws-sdk/services/MessageAttributes.d.ts +23 -0
  237. package/build/types/integrations/tracing-channel/aws-sdk/services/MessageAttributes.d.ts.map +1 -0
  238. package/build/types/integrations/tracing-channel/aws-sdk/services/ServiceExtension.d.ts +9 -0
  239. package/build/types/integrations/tracing-channel/aws-sdk/services/ServiceExtension.d.ts.map +1 -0
  240. package/build/types/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.d.ts +10 -0
  241. package/build/types/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.d.ts.map +1 -0
  242. package/build/types/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.d.ts +14 -0
  243. package/build/types/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.d.ts.map +1 -0
  244. package/build/types/integrations/tracing-channel/aws-sdk/services/dynamodb.d.ts +8 -0
  245. package/build/types/integrations/tracing-channel/aws-sdk/services/dynamodb.d.ts.map +1 -0
  246. package/build/types/integrations/tracing-channel/aws-sdk/services/index.d.ts +2 -0
  247. package/build/types/integrations/tracing-channel/aws-sdk/services/index.d.ts.map +1 -0
  248. package/build/types/integrations/tracing-channel/aws-sdk/services/kinesis.d.ts +6 -0
  249. package/build/types/integrations/tracing-channel/aws-sdk/services/kinesis.d.ts.map +1 -0
  250. package/build/types/integrations/tracing-channel/aws-sdk/services/lambda.d.ts +9 -0
  251. package/build/types/integrations/tracing-channel/aws-sdk/services/lambda.d.ts.map +1 -0
  252. package/build/types/integrations/tracing-channel/aws-sdk/services/s3.d.ts +6 -0
  253. package/build/types/integrations/tracing-channel/aws-sdk/services/s3.d.ts.map +1 -0
  254. package/build/types/integrations/tracing-channel/aws-sdk/services/secretsmanager.d.ts +8 -0
  255. package/build/types/integrations/tracing-channel/aws-sdk/services/secretsmanager.d.ts.map +1 -0
  256. package/build/types/integrations/tracing-channel/aws-sdk/services/sns.d.ts +9 -0
  257. package/build/types/integrations/tracing-channel/aws-sdk/services/sns.d.ts.map +1 -0
  258. package/build/types/integrations/tracing-channel/aws-sdk/services/sqs.d.ts +9 -0
  259. package/build/types/integrations/tracing-channel/aws-sdk/services/sqs.d.ts.map +1 -0
  260. package/build/types/integrations/tracing-channel/aws-sdk/services/stepfunctions.d.ts +6 -0
  261. package/build/types/integrations/tracing-channel/aws-sdk/services/stepfunctions.d.ts.map +1 -0
  262. package/build/types/integrations/tracing-channel/aws-sdk/types.d.ts +26 -0
  263. package/build/types/integrations/tracing-channel/aws-sdk/types.d.ts.map +1 -0
  264. package/build/types/integrations/tracing-channel/aws-sdk/utils.d.ts +5 -0
  265. package/build/types/integrations/tracing-channel/aws-sdk/utils.d.ts.map +1 -0
  266. package/build/types/integrations/tracing-channel/express/instrumentation.d.ts.map +1 -1
  267. package/build/types/integrations/tracing-channel/koa.d.ts +14 -0
  268. package/build/types/integrations/tracing-channel/koa.d.ts.map +1 -0
  269. package/build/types/integrations/tracing-channel/langchain.d.ts +10 -0
  270. package/build/types/integrations/tracing-channel/langchain.d.ts.map +1 -0
  271. package/build/types/integrations/tracing-channel/langgraph.d.ts +10 -0
  272. package/build/types/integrations/tracing-channel/langgraph.d.ts.map +1 -0
  273. package/build/types/integrations/tracing-channel/mongodb.d.ts +12 -0
  274. package/build/types/integrations/tracing-channel/mongodb.d.ts.map +1 -0
  275. package/build/types/integrations/tracing-channel/mongoose.d.ts +15 -0
  276. package/build/types/integrations/tracing-channel/mongoose.d.ts.map +1 -0
  277. package/build/types/integrations/tracing-channel/openai.d.ts.map +1 -1
  278. package/build/types/integrations/tracing-channel/redis.d.ts.map +1 -1
  279. package/build/types/integrations/tracing-channel/tedious.d.ts +11 -0
  280. package/build/types/integrations/tracing-channel/tedious.d.ts.map +1 -0
  281. package/build/types/mongodb/mongodb-span.d.ts +66 -0
  282. package/build/types/mongodb/mongodb-span.d.ts.map +1 -0
  283. package/build/types/mongoose/index.d.ts +2 -0
  284. package/build/types/mongoose/index.d.ts.map +1 -1
  285. package/build/types/mongoose/mongoose-legacy-span.d.ts +29 -0
  286. package/build/types/mongoose/mongoose-legacy-span.d.ts.map +1 -0
  287. package/build/types/orchestrion/bundler/options.d.ts +13 -3
  288. package/build/types/orchestrion/bundler/options.d.ts.map +1 -1
  289. package/build/types/orchestrion/bundler/webpack.d.ts +5 -5
  290. package/build/types/orchestrion/bundler/webpack.d.ts.map +1 -1
  291. package/build/types/orchestrion/channels.d.ts +36 -6
  292. package/build/types/orchestrion/channels.d.ts.map +1 -1
  293. package/build/types/orchestrion/config/aws-sdk.d.ts +19 -0
  294. package/build/types/orchestrion/config/aws-sdk.d.ts.map +1 -0
  295. package/build/types/orchestrion/config/express.d.ts +2 -4
  296. package/build/types/orchestrion/config/express.d.ts.map +1 -1
  297. package/build/types/orchestrion/config/firebase.d.ts +1 -1
  298. package/build/types/orchestrion/config/firebase.d.ts.map +1 -1
  299. package/build/types/orchestrion/config/index.d.ts +1 -1
  300. package/build/types/orchestrion/config/index.d.ts.map +1 -1
  301. package/build/types/orchestrion/config/ioredis.d.ts +1 -1
  302. package/build/types/orchestrion/config/ioredis.d.ts.map +1 -1
  303. package/build/types/orchestrion/config/knex.d.ts +1 -1
  304. package/build/types/orchestrion/config/knex.d.ts.map +1 -1
  305. package/build/types/orchestrion/config/koa.d.ts +17 -0
  306. package/build/types/orchestrion/config/koa.d.ts.map +1 -0
  307. package/build/types/orchestrion/config/langchain.d.ts +17 -3
  308. package/build/types/orchestrion/config/langchain.d.ts.map +1 -1
  309. package/build/types/orchestrion/config/langgraph.d.ts +20 -3
  310. package/build/types/orchestrion/config/langgraph.d.ts.map +1 -1
  311. package/build/types/orchestrion/config/mongodb.d.ts +58 -3
  312. package/build/types/orchestrion/config/mongodb.d.ts.map +1 -1
  313. package/build/types/orchestrion/config/mongoose.d.ts +39 -3
  314. package/build/types/orchestrion/config/mongoose.d.ts.map +1 -1
  315. package/build/types/orchestrion/config/nestjs.d.ts +1 -1
  316. package/build/types/orchestrion/config/nestjs.d.ts.map +1 -1
  317. package/build/types/orchestrion/config/openai.d.ts +0 -2
  318. package/build/types/orchestrion/config/openai.d.ts.map +1 -1
  319. package/build/types/orchestrion/config/postgres.d.ts +1 -1
  320. package/build/types/orchestrion/config/postgres.d.ts.map +1 -1
  321. package/build/types/orchestrion/config/prisma.d.ts +1 -1
  322. package/build/types/orchestrion/config/prisma.d.ts.map +1 -1
  323. package/build/types/orchestrion/config/react-router.d.ts +1 -1
  324. package/build/types/orchestrion/config/react-router.d.ts.map +1 -1
  325. package/build/types/orchestrion/config/remix.d.ts +7 -2
  326. package/build/types/orchestrion/config/remix.d.ts.map +1 -1
  327. package/build/types/orchestrion/config/tedious.d.ts +10 -2
  328. package/build/types/orchestrion/config/tedious.d.ts.map +1 -1
  329. package/build/types/orchestrion/config/vercel-ai.d.ts +1 -1
  330. package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -1
  331. package/build/types/orchestrion/index.d.ts +32 -1
  332. package/build/types/orchestrion/index.d.ts.map +1 -1
  333. package/build/types/orchestrion/runtime/register.d.ts.map +1 -1
  334. package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts.map +1 -1
  335. package/build/types-ts3.8/index.d.ts +5 -1
  336. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/aws-sdk.types.d.ts +43 -0
  337. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/constants.d.ts +15 -0
  338. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/index.d.ts +15 -0
  339. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/MessageAttributes.d.ts +23 -0
  340. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/ServiceExtension.d.ts +9 -0
  341. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/ServicesExtensions.d.ts +10 -0
  342. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/bedrock-runtime.d.ts +14 -0
  343. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/dynamodb.d.ts +8 -0
  344. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/index.d.ts +2 -0
  345. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/kinesis.d.ts +6 -0
  346. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/lambda.d.ts +9 -0
  347. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/s3.d.ts +6 -0
  348. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/secretsmanager.d.ts +8 -0
  349. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/sns.d.ts +9 -0
  350. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/sqs.d.ts +9 -0
  351. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/services/stepfunctions.d.ts +6 -0
  352. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/types.d.ts +26 -0
  353. package/build/types-ts3.8/integrations/tracing-channel/aws-sdk/utils.d.ts +5 -0
  354. package/build/types-ts3.8/integrations/tracing-channel/koa.d.ts +14 -0
  355. package/build/types-ts3.8/integrations/tracing-channel/langchain.d.ts +10 -0
  356. package/build/types-ts3.8/integrations/tracing-channel/langgraph.d.ts +10 -0
  357. package/build/types-ts3.8/integrations/tracing-channel/mongodb.d.ts +12 -0
  358. package/build/types-ts3.8/integrations/tracing-channel/mongoose.d.ts +15 -0
  359. package/build/types-ts3.8/integrations/tracing-channel/tedious.d.ts +11 -0
  360. package/build/types-ts3.8/mongodb/mongodb-span.d.ts +66 -0
  361. package/build/types-ts3.8/mongoose/index.d.ts +2 -0
  362. package/build/types-ts3.8/mongoose/mongoose-legacy-span.d.ts +29 -0
  363. package/build/types-ts3.8/orchestrion/bundler/options.d.ts +13 -3
  364. package/build/types-ts3.8/orchestrion/bundler/webpack.d.ts +5 -5
  365. package/build/types-ts3.8/orchestrion/channels.d.ts +36 -6
  366. package/build/types-ts3.8/orchestrion/config/aws-sdk.d.ts +19 -0
  367. package/build/types-ts3.8/orchestrion/config/express.d.ts +2 -4
  368. package/build/types-ts3.8/orchestrion/config/firebase.d.ts +1 -1
  369. package/build/types-ts3.8/orchestrion/config/index.d.ts +1 -1
  370. package/build/types-ts3.8/orchestrion/config/ioredis.d.ts +1 -1
  371. package/build/types-ts3.8/orchestrion/config/knex.d.ts +1 -1
  372. package/build/types-ts3.8/orchestrion/config/koa.d.ts +17 -0
  373. package/build/types-ts3.8/orchestrion/config/langchain.d.ts +17 -3
  374. package/build/types-ts3.8/orchestrion/config/langgraph.d.ts +20 -3
  375. package/build/types-ts3.8/orchestrion/config/mongodb.d.ts +58 -3
  376. package/build/types-ts3.8/orchestrion/config/mongoose.d.ts +39 -3
  377. package/build/types-ts3.8/orchestrion/config/nestjs.d.ts +1 -1
  378. package/build/types-ts3.8/orchestrion/config/openai.d.ts +0 -2
  379. package/build/types-ts3.8/orchestrion/config/postgres.d.ts +1 -1
  380. package/build/types-ts3.8/orchestrion/config/prisma.d.ts +1 -1
  381. package/build/types-ts3.8/orchestrion/config/react-router.d.ts +1 -1
  382. package/build/types-ts3.8/orchestrion/config/remix.d.ts +7 -2
  383. package/build/types-ts3.8/orchestrion/config/tedious.d.ts +10 -2
  384. package/build/types-ts3.8/orchestrion/config/vercel-ai.d.ts +1 -1
  385. package/build/types-ts3.8/orchestrion/index.d.ts +32 -1
  386. package/package.json +3 -4
@@ -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":[],"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,SACA,cAAA,EACM;AACN,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA;AAAA,EACF;AACA,EAAA,eAAA,GAAkB,IAAA;AAMlB,EAAA,KAAA,MAAW,WAAA,IAAe;AAAA,IACxB,QAAA,CAAS,aAAA;AAAA,IACT,QAAA,CAAS,WAAA;AAAA,IACT,QAAA,CAAS,YAAA;AAAA,IACT,QAAA,CAAS;AAAA,GACX,EAAG;AACD,IAAA,cAAA,CAA2C,WAAW,EAAE,SAAA,CAAU;AAAA,MAChE,KAAA,EAAO,IAAA;AAAA,MACP,UAAA,EAAY,IAAA;AAAA,MACZ,QAAA,EAAU,IAAA;AAAA,MACV,KAAA,EAAO,IAAA;AAAA,MACP,GAAA,EAAK;AAAA,KACN,CAAA;AAAA,EACH;AAEA,EAAA,KAAA,MAAW,eAAe,CAAC,QAAA,CAAS,cAAA,EAAgB,QAAA,CAAS,aAAa,CAAA,EAAG;AAC3E,IAAA,WAAA,IAAe,KAAA,CAAM,GAAA,CAAI,CAAA,8CAAA,EAAiD,WAAW,CAAA,CAAA,CAAG,CAAA;AAExF,IAAA,MAAM,OAAA,GAAU,eAAqC,WAAW,CAAA;AAEhE,IAAA,wBAAA,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entation.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":[],"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,SACA,cAAA,EACM;AACN,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA;AAAA,EACF;AACA,EAAA,eAAA,GAAkB,IAAA;AAMlB,EAAA,KAAA,MAAW,eAAe,CAAC,QAAA,CAAS,gBAAA,EAAkB,QAAA,CAAS,eAAe,CAAA,EAAG;AAC/E,IAAA,cAAA,CAA2C,WAAW,EAAE,SAAA,CAAU;AAAA,MAChE,KAAA,EAAO,IAAA;AAAA,MACP,UAAA,EAAY,IAAA;AAAA,MACZ,QAAA,EAAU,IAAA;AAAA,MACV,KAAA,EAAO,IAAA;AAAA,MACP,GAAA,EAAK;AAAA,KACN,CAAA;AAAA,EACH;AAEA,EAAA,KAAA,MAAW,eAA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Y,CAAA,EAAG;AAChC,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,OAAO,wBAAA,CAAyB,IAAA,EAAM,YAAA,EAAc,IAAI,CAAA;AAAA,EAC1D,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;;;;"}
@@ -0,0 +1,144 @@
1
+ import * as diagnosticsChannel from 'node:diagnostics_channel';
2
+ import { defineIntegration, debug, getActiveSpan, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getIsolationScope, getDefaultIsolationScope, getRootSpan, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
3
+ import { KOA_NAME, HTTP_ROUTE, KOA_TYPE, CODE_FUNCTION_NAME } from '@sentry/conventions/attributes';
4
+ import { DEBUG_BUILD } from '../../debug-build.js';
5
+ import { CHANNELS } from '../../orchestrion/channels.js';
6
+
7
+ const INTEGRATION_NAME = "Koa";
8
+ const ORIGIN = "auto.http.orchestrion.koa";
9
+ const LAYER_TYPE = {
10
+ ROUTER: "router",
11
+ MIDDLEWARE: "middleware"
12
+ };
13
+ const kLayerPatched = /* @__PURE__ */ Symbol("sentry.koa.layer-patched");
14
+ let subscribed = false;
15
+ const _koaChannelIntegration = ((options = {}) => {
16
+ const ignoreLayersType = options.ignoreLayersType ?? [];
17
+ return {
18
+ name: INTEGRATION_NAME,
19
+ setupOnce() {
20
+ if (!diagnosticsChannel.tracingChannel || subscribed) {
21
+ return;
22
+ }
23
+ subscribed = true;
24
+ DEBUG_BUILD && debug.log(`[orchestrion:koa] subscribing to channel "${CHANNELS.KOA_USE}"`);
25
+ diagnosticsChannel.tracingChannel(CHANNELS.KOA_USE).subscribe({
26
+ start(rawCtx) {
27
+ handleUse(rawCtx, ignoreLayersType);
28
+ },
29
+ end() {
30
+ },
31
+ asyncStart() {
32
+ },
33
+ asyncEnd() {
34
+ },
35
+ error() {
36
+ }
37
+ });
38
+ }
39
+ };
40
+ });
41
+ function handleUse(ctx, ignoreLayersType) {
42
+ const middleware = ctx.arguments[0];
43
+ if (typeof middleware === "function") {
44
+ ctx.arguments[0] = patchUse(middleware, ignoreLayersType);
45
+ }
46
+ }
47
+ function patchUse(middleware, ignoreLayersType) {
48
+ return middleware.router ? patchRouterDispatch(middleware, ignoreLayersType) : patchLayer(middleware, false, ignoreLayersType);
49
+ }
50
+ function patchRouterDispatch(dispatchLayer, ignoreLayersType) {
51
+ const router = dispatchLayer.router;
52
+ const routesStack = router?.stack ?? [];
53
+ for (const pathLayer of routesStack) {
54
+ const path = pathLayer.path;
55
+ const pathStack = pathLayer.stack;
56
+ pathStack.forEach((routedMiddleware, j) => {
57
+ pathStack[j] = patchLayer(routedMiddleware, true, ignoreLayersType, path);
58
+ });
59
+ }
60
+ return dispatchLayer;
61
+ }
62
+ function patchLayer(middlewareLayer, isRouter, ignoreLayersType, layerPath) {
63
+ const layerType = isRouter ? LAYER_TYPE.ROUTER : LAYER_TYPE.MIDDLEWARE;
64
+ if (middlewareLayer[kLayerPatched] === true || ignoreLayersType.includes(layerType)) {
65
+ return middlewareLayer;
66
+ }
67
+ if (middlewareLayer.constructor.name === "GeneratorFunction" || middlewareLayer.constructor.name === "AsyncGeneratorFunction") {
68
+ return middlewareLayer;
69
+ }
70
+ middlewareLayer[kLayerPatched] = true;
71
+ return (context, next) => {
72
+ if (!getActiveSpan()) {
73
+ return middlewareLayer(context, next);
74
+ }
75
+ const metadata = getMiddlewareMetadata(context, middlewareLayer, isRouter, layerPath);
76
+ if (context._matchedRoute) {
77
+ setHttpServerSpanRouteAttribute(context._matchedRoute.toString());
78
+ }
79
+ const koaName = metadata.attributes[KOA_NAME];
80
+ const name = typeof koaName === "string" ? koaName || "< unknown >" : metadata.name;
81
+ return startSpan(
82
+ {
83
+ name,
84
+ op: `${layerType}.koa`,
85
+ attributes: {
86
+ ...metadata.attributes,
87
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN
88
+ }
89
+ },
90
+ () => {
91
+ const route = metadata.attributes[HTTP_ROUTE];
92
+ if (getIsolationScope() === getDefaultIsolationScope()) {
93
+ DEBUG_BUILD && debug.warn("Isolation scope is default isolation scope - skipping setting transactionName");
94
+ } else if (route) {
95
+ const method = context.request?.method?.toUpperCase() || "GET";
96
+ getIsolationScope().setTransactionName(`${method} ${route}`);
97
+ }
98
+ return middlewareLayer(context, next);
99
+ }
100
+ );
101
+ };
102
+ }
103
+ function getMiddlewareMetadata(context, layer, isRouter, layerPath) {
104
+ if (isRouter) {
105
+ return {
106
+ attributes: {
107
+ // oxlint-disable-next-line typescript/no-deprecated
108
+ [KOA_NAME]: layerPath?.toString(),
109
+ // TODO(v11): remove, replaced by http.route
110
+ [KOA_TYPE]: LAYER_TYPE.ROUTER,
111
+ [HTTP_ROUTE]: layerPath?.toString()
112
+ },
113
+ name: context._matchedRouteName || `router - ${layerPath}`
114
+ };
115
+ }
116
+ return {
117
+ attributes: {
118
+ // oxlint-disable-next-line typescript/no-deprecated
119
+ [KOA_NAME]: layer.name || "middleware",
120
+ // TODO(v11): remove, replaced by code.function.name
121
+ [KOA_TYPE]: LAYER_TYPE.MIDDLEWARE,
122
+ [CODE_FUNCTION_NAME]: layer.name || "middleware"
123
+ },
124
+ name: `middleware - ${layer.name}`
125
+ };
126
+ }
127
+ function setHttpServerSpanRouteAttribute(route) {
128
+ const activeSpan = getActiveSpan();
129
+ if (!activeSpan) {
130
+ return;
131
+ }
132
+ const rootSpan = getRootSpan(activeSpan);
133
+ if (!rootSpan) {
134
+ return;
135
+ }
136
+ if (spanToJSON(rootSpan).data[SEMANTIC_ATTRIBUTE_SENTRY_OP] !== "http.server") {
137
+ return;
138
+ }
139
+ rootSpan.setAttribute(HTTP_ROUTE, route);
140
+ }
141
+ const koaChannelIntegration = defineIntegration(_koaChannelIntegration);
142
+
143
+ export { koaChannelIntegration };
144
+ //# sourceMappingURL=koa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"koa.js","sources":["../../../../src/integrations/tracing-channel/koa.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n getActiveSpan,\n getDefaultIsolationScope,\n getIsolationScope,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n startSpan,\n} from '@sentry/core';\n// oxlint-disable-next-line typescript/no-deprecated\nimport { CODE_FUNCTION_NAME, HTTP_ROUTE, KOA_NAME, KOA_TYPE } from '@sentry/conventions/attributes';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\n\n// Same name as the OTel integration. When enabled, the OTel 'Koa' integration is omitted from the default set.\nconst INTEGRATION_NAME = 'Koa' as const;\n\nconst ORIGIN = 'auto.http.orchestrion.koa';\n\nconst LAYER_TYPE = {\n ROUTER: 'router',\n MIDDLEWARE: 'middleware',\n} as const;\ntype KoaLayerType = (typeof LAYER_TYPE)[keyof typeof LAYER_TYPE];\n\n// Keeps wrapping idempotent — the same middleware instance can be registered on\n// multiple routes (mirrors the vendored OTel instrumentation's symbol).\nconst kLayerPatched: unique symbol = Symbol('sentry.koa.layer-patched');\n\n// Core dedupes `setupOnce` by integration name, but the Deno SDK also runs this\n// under the name `DenoKoa` (via `extendIntegration`), so guard against a second\n// subscription here.\nlet subscribed = false;\n\ntype Next = () => Promise<unknown>;\n\ninterface KoaContext {\n [key: string]: unknown;\n _matchedRoute?: string | RegExp;\n _matchedRouteName?: string;\n request?: { method?: string };\n}\n\ninterface Layer {\n path: string | RegExp;\n stack: KoaMiddleware[];\n}\n\ninterface Router {\n stack: Layer[];\n}\n\ntype KoaMiddleware = ((context: KoaContext, next: Next) => unknown) & {\n router?: Router;\n [kLayerPatched]?: boolean;\n};\n\ntype KoaSpanAttributes = Record<string, string | undefined>;\n\ninterface KoaMiddlewareMetadata {\n attributes: KoaSpanAttributes;\n name: string;\n}\n\ninterface KoaUseContext {\n arguments: unknown[];\n}\n\nexport interface KoaChannelIntegrationOptions {\n /** Ignore layers of the specified types (`'middleware'` and/or `'router'`). */\n ignoreLayersType?: Array<'middleware' | 'router'>;\n}\n\nconst _koaChannelIntegration = ((options: KoaChannelIntegrationOptions = {}) => {\n const ignoreLayersType = options.ignoreLayersType ?? [];\n\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 || subscribed) {\n return;\n }\n subscribed = true;\n DEBUG_BUILD && debug.log(`[orchestrion:koa] subscribing to channel \"${CHANNELS.KOA_USE}\"`);\n\n diagnosticsChannel.tracingChannel(CHANNELS.KOA_USE).subscribe({\n start(rawCtx) {\n handleUse(rawCtx as KoaUseContext, ignoreLayersType);\n },\n end() {},\n asyncStart() {},\n asyncEnd() {},\n error() {},\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction handleUse(ctx: KoaUseContext, ignoreLayersType: KoaLayerType[]): void {\n const middleware = ctx.arguments[0];\n if (typeof middleware === 'function') {\n ctx.arguments[0] = patchUse(middleware as KoaMiddleware, ignoreLayersType);\n }\n}\n\n/**\n * Wrap a registered koa middleware. A `@koa/router` dispatch layer\n * (`router.routes()`) exposes a `.router`, in which case we patch each routed\n * middleware in its stack (in place) and leave the dispatch itself unwrapped;\n * everything else is a plain middleware.\n */\nfunction patchUse(middleware: KoaMiddleware, ignoreLayersType: KoaLayerType[]): KoaMiddleware {\n return middleware.router\n ? patchRouterDispatch(middleware, ignoreLayersType)\n : patchLayer(middleware, false, ignoreLayersType);\n}\n\n/**\n * Patches the dispatch function used by `@koa/router`, wrapping each routed\n * middleware in the router's stack so routed spans carry their matched path.\n */\nfunction patchRouterDispatch(dispatchLayer: KoaMiddleware, ignoreLayersType: KoaLayerType[]): KoaMiddleware {\n const router = dispatchLayer.router;\n const routesStack = router?.stack ?? [];\n for (const pathLayer of routesStack) {\n const path = pathLayer.path;\n const pathStack = pathLayer.stack;\n pathStack.forEach((routedMiddleware, j) => {\n pathStack[j] = patchLayer(routedMiddleware, true, ignoreLayersType, path);\n });\n }\n return dispatchLayer;\n}\n\n/**\n * Wraps an individual middleware layer so it opens a span when invoked. No span\n * is created when there is no active (parent) span, matching the vendored OTel\n * instrumentation's `api.trace.getSpan(api.context.active())` guard.\n */\nfunction patchLayer(\n middlewareLayer: KoaMiddleware,\n isRouter: boolean,\n ignoreLayersType: KoaLayerType[],\n layerPath?: string | RegExp,\n): KoaMiddleware {\n const layerType = isRouter ? LAYER_TYPE.ROUTER : LAYER_TYPE.MIDDLEWARE;\n // Skip patching the layer if it's ignored by config or already wrapped.\n if (middlewareLayer[kLayerPatched] === true || ignoreLayersType.includes(layerType)) {\n return middlewareLayer;\n }\n\n if (\n middlewareLayer.constructor.name === 'GeneratorFunction' ||\n middlewareLayer.constructor.name === 'AsyncGeneratorFunction'\n ) {\n return middlewareLayer;\n }\n\n middlewareLayer[kLayerPatched] = true;\n\n return (context: KoaContext, next: Next) => {\n if (!getActiveSpan()) {\n return middlewareLayer(context, next);\n }\n const metadata = getMiddlewareMetadata(context, middlewareLayer, isRouter, layerPath);\n\n if (context._matchedRoute) {\n setHttpServerSpanRouteAttribute(context._matchedRoute.toString());\n }\n\n // oxlint-disable-next-line typescript/no-deprecated\n const koaName = metadata.attributes[KOA_NAME];\n // Somehow, name is sometimes `''` for middleware spans.\n // See: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2220\n const name = typeof koaName === 'string' ? koaName || '< unknown >' : metadata.name;\n\n return startSpan(\n {\n name,\n op: `${layerType}.koa`,\n attributes: {\n ...metadata.attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n },\n },\n () => {\n const route = metadata.attributes[HTTP_ROUTE];\n if (getIsolationScope() === getDefaultIsolationScope()) {\n DEBUG_BUILD && debug.warn('Isolation scope is default isolation scope - skipping setting transactionName');\n } else if (route) {\n const method = context.request?.method?.toUpperCase() || 'GET';\n getIsolationScope().setTransactionName(`${method} ${route}`);\n }\n return middlewareLayer(context, next);\n },\n );\n };\n}\n\nfunction getMiddlewareMetadata(\n context: KoaContext,\n layer: KoaMiddleware,\n isRouter: boolean,\n layerPath?: string | RegExp,\n): KoaMiddlewareMetadata {\n if (isRouter) {\n return {\n attributes: {\n // oxlint-disable-next-line typescript/no-deprecated\n [KOA_NAME]: layerPath?.toString(), // TODO(v11): remove, replaced by http.route\n [KOA_TYPE]: LAYER_TYPE.ROUTER,\n [HTTP_ROUTE]: layerPath?.toString(),\n },\n name: context._matchedRouteName || `router - ${layerPath}`,\n };\n }\n return {\n attributes: {\n // oxlint-disable-next-line typescript/no-deprecated\n [KOA_NAME]: layer.name || 'middleware', // TODO(v11): remove, replaced by code.function.name\n [KOA_TYPE]: LAYER_TYPE.MIDDLEWARE,\n [CODE_FUNCTION_NAME]: layer.name || 'middleware',\n },\n name: `middleware - ${layer.name}`,\n };\n}\n\n/**\n * Set the `http.route` attribute on the root HTTP server span for the current trace.\n *\n * No-op when there is no active span, no root span, or the root span is not an\n * `http.server` span — so this can be called unconditionally without risking\n * attribute pollution on non-HTTP root spans.\n */\nfunction setHttpServerSpanRouteAttribute(route: string): void {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n return;\n }\n const rootSpan = 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 * EXPERIMENTAL — orchestrion-driven koa integration. Subscribes to the\n * `orchestrion:koa:use` channel injected into `Application.prototype.use` and\n * wraps each registered middleware/router layer in a span-creating proxy.\n * Requires the orchestrion runtime hook or bundler plugin.\n */\nexport const koaChannelIntegration = defineIntegration(_koaChannelIntegration);\n"],"names":[],"mappings":";;;;;;AAoBA,MAAM,gBAAA,GAAmB,K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agnostics_channel';
2
+ import { defineIntegration, LANGCHAIN_INTEGRATION_NAME, createLangChainCallbackHandler, debug, waitForTracingChannelBinding, _INTERNAL_mergeLangChainCallbackHandler, startInactiveSpan, _INTERNAL_getLangChainEmbeddingsSpanOptions, _INTERNAL_skipAiProviderWrapping, OPENAI_INTEGRATION_NAME, ANTHROPIC_AI_INTEGRATION_NAME, GOOGLE_GENAI_INTEGRATION_NAME } from '@sentry/core';
3
+ import { DEBUG_BUILD } from '../../debug-build.js';
4
+ import { CHANNELS } from '../../orchestrion/channels.js';
5
+ import { langchainEmbeddingsChannels } from '../../orchestrion/config/langchain.js';
6
+ import { bindTracingChannelToSpan } from '../../tracing-channel.js';
7
+
8
+ const INTEGRATION_NAME = LANGCHAIN_INTEGRATION_NAME;
9
+ const SKIPPED_PROVIDERS = [OPENAI_INTEGRATION_NAME, ANTHROPIC_AI_INTEGRATION_NAME, GOOGLE_GENAI_INTEGRATION_NAME];
10
+ let subscribed = false;
11
+ function markProvidersSkipped() {
12
+ _INTERNAL_skipAiProviderWrapping(SKIPPED_PROVIDERS);
13
+ }
14
+ const _langChainChannelIntegration = ((options = {}) => {
15
+ return {
16
+ name: INTEGRATION_NAME,
17
+ setupOnce() {
18
+ if (!diagnosticsChannel.tracingChannel || subscribed) {
19
+ return;
20
+ }
21
+ subscribed = true;
22
+ const sentryHandler = createLangChainCallbackHandler(options);
23
+ const injectHandler = (message) => {
24
+ markProvidersSkipped();
25
+ const args = message.arguments;
26
+ if (!Array.isArray(args)) {
27
+ return;
28
+ }
29
+ let callOptions = args[1];
30
+ if (!callOptions || typeof callOptions !== "object" || Array.isArray(callOptions)) {
31
+ callOptions = {};
32
+ args[1] = callOptions;
33
+ }
34
+ callOptions.callbacks = _INTERNAL_mergeLangChainCallbackHandler(callOptions.callbacks, sentryHandler);
35
+ };
36
+ for (const channelName of [CHANNELS.LANGCHAIN_CHAT_MODEL_INVOKE, CHANNELS.LANGCHAIN_CHAT_MODEL_STREAM]) {
37
+ DEBUG_BUILD && debug.log(`[orchestrion:langchain] subscribing to channel "${channelName}"`);
38
+ diagnosticsChannel.tracingChannel(channelName).start.subscribe(injectHandler);
39
+ }
40
+ waitForTracingChannelBinding(() => {
41
+ for (const channelName of langchainEmbeddingsChannels) {
42
+ DEBUG_BUILD && debug.log(`[orchestrion:langchain] subscribing to channel "${channelName}"`);
43
+ bindTracingChannelToSpan(
44
+ diagnosticsChannel.tracingChannel(channelName),
45
+ (data) => createEmbeddingsSpan(data, options),
46
+ { captureError: () => ({ mechanism: { handled: false, type: "auto.ai.langchain" } }) }
47
+ );
48
+ }
49
+ });
50
+ }
51
+ };
52
+ });
53
+ function createEmbeddingsSpan(data, options) {
54
+ markProvidersSkipped();
55
+ const input = (data.arguments ?? [])[0];
56
+ return startInactiveSpan(_INTERNAL_getLangChainEmbeddingsSpanOptions(data.self, input, options));
57
+ }
58
+ const langChainChannelIntegration = defineIntegration(_langChainChannelIntegration);
59
+
60
+ export { langChainChannelIntegration };
61
+ //# sourceMappingURL=langchain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langchain.js","sources":["../../../../src/integrations/tracing-channel/langchain.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn, LangChainOptions, Span } from '@sentry/core';\nimport {\n _INTERNAL_getLangChainEmbeddingsSpanOptions,\n _INTERNAL_mergeLangChainCallbackHandler,\n _INTERNAL_skipAiProviderWrapping,\n ANTHROPIC_AI_INTEGRATION_NAME,\n createLangChainCallbackHandler,\n debug,\n defineIntegration,\n GOOGLE_GENAI_INTEGRATION_NAME,\n LANGCHAIN_INTEGRATION_NAME,\n OPENAI_INTEGRATION_NAME,\n startInactiveSpan,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { langchainEmbeddingsChannels } from '../../orchestrion/config/langchain';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Same name as the OTel integration by design: when enabled, the OTel 'LangChain' integration is\n// dropped from the default set (see the Node opt-in loader).\nconst INTEGRATION_NAME = LANGCHAIN_INTEGRATION_NAME;\n\n// LangChain drives the underlying AI provider SDKs itself, so while it's active those providers must\n// not also instrument, or every call would produce two spans (mirrors the OTel path's skip list).\nconst SKIPPED_PROVIDERS = [OPENAI_INTEGRATION_NAME, ANTHROPIC_AI_INTEGRATION_NAME, GOOGLE_GENAI_INTEGRATION_NAME];\n\n// The chat-model channels carry the live args array of `invoke(input, options)` / `_streamIterator(input, options)`.\ninterface RunnableChannelContext {\n arguments: unknown[];\n}\n\n// The embeddings channels carry the instance (`self`) and the `embedQuery(text)` / `embedDocuments(texts)` args.\ninterface EmbeddingsChannelContext {\n self?: unknown;\n arguments: unknown[];\n}\n\nlet subscribed = false;\n\n// Registered lazily on the first LangChain call (not at `setupOnce`) so a direct provider call made\n// before any LangChain call still gets its own span — matches the OTel patch-on-import timing. It\n// also stops the underlying SDK from double-instrumenting embeddings, whose `embedQuery`/\n// `embedDocuments` call the provider SDK (e.g. `openai`) internally.\nfunction markProvidersSkipped(): void {\n _INTERNAL_skipAiProviderWrapping(SKIPPED_PROVIDERS);\n}\n\nconst _langChainChannelIntegration = ((options: LangChainOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19, and a second `init()` would double-subscribe.\n if (!diagnosticsChannel.tracingChannel || subscribed) {\n return;\n }\n subscribed = true;\n\n // One stateful handler tracks spans across the whole run tree, just like the OTel path.\n const sentryHandler = createLangChainCallbackHandler(options);\n\n // Chat models: inject the Sentry callback handler into the call options (arg 1). LangChain's own\n // callback dispatch then creates the spans, exactly as in the OTel path, so no span is opened\n // here — a `start` subscriber (which also makes orchestrion wrap the function) is enough.\n const injectHandler = (message: unknown): void => {\n markProvidersSkipped();\n\n const args = (message as RunnableChannelContext).arguments;\n if (!Array.isArray(args)) {\n return;\n }\n\n let callOptions = args[1] as Record<string, unknown> | undefined;\n if (!callOptions || typeof callOptions !== 'object' || Array.isArray(callOptions)) {\n callOptions = {};\n args[1] = callOptions;\n }\n\n callOptions.callbacks = _INTERNAL_mergeLangChainCallbackHandler(callOptions.callbacks, sentryHandler);\n };\n\n for (const channelName of [CHANNELS.LANGCHAIN_CHAT_MODEL_INVOKE, CHANNELS.LANGCHAIN_CHAT_MODEL_STREAM]) {\n DEBUG_BUILD && debug.log(`[orchestrion:langchain] subscribing to channel \"${channelName}\"`);\n diagnosticsChannel.tracingChannel<RunnableChannelContext>(channelName).start.subscribe(injectHandler);\n }\n\n // Embeddings don't use the callback system — the OTel path wraps the method in its own span, so\n // do the same here. `bindTracingChannelToSpan` needs the async-context binding that\n // `initOpenTelemetry()` registers after `setupOnce`, so wait for it before subscribing.\n waitForTracingChannelBinding(() => {\n for (const channelName of langchainEmbeddingsChannels) {\n DEBUG_BUILD && debug.log(`[orchestrion:langchain] subscribing to channel \"${channelName}\"`);\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<EmbeddingsChannelContext>(channelName),\n data => createEmbeddingsSpan(data, options),\n { captureError: () => ({ mechanism: { handled: false, type: 'auto.ai.langchain' } }) },\n );\n }\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction createEmbeddingsSpan(data: EmbeddingsChannelContext, options: LangChainOptions): Span {\n // `embedQuery`/`embedDocuments` call the provider SDK internally, so skip that SDK's own\n // instrumentation before its channel fires (the producer runs at the embeddings channel's `start`).\n markProvidersSkipped();\n\n const input = (data.arguments ?? [])[0];\n\n return startInactiveSpan(_INTERNAL_getLangChainEmbeddingsSpanOptions(data.self, input, options));\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven LangChain integration. Subscribes to the diagnostics_channels\n * injected into `@langchain/core`'s `BaseChatModel` (to inject the Sentry callback handler) and into\n * `@langchain/openai`'s embedding methods, so it requires the orchestrion runtime hook or bundler plugin.\n */\nexport const langChainChannelIntegration = defineIntegration(_langChainChannelIntegration);\n"],"names":[],"mapp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,EAAmD,WAAW,CAAA,CAAA,CAAG,CAAA;AAC1F,QAAA,kBAAA,CAAmB,cAAA,CAAuC,WAAW,CAAA,CAAE,KAAA,CAAM,UAAU,aAAa,CAAA;AAAA,MACtG;AAKA,MAAA,4BAAA,CAA6B,MAAM;AACjC,QAAA,KAAA,MAAW,eAAe,2BAAA,EAA6B;AACrD,UAAA,WAAA,IAAe,KAAA,CAAM,GAAA,CAAI,CAAA,gDAAA,EAAmD,WAAW,CAAA,CAAA,CAAG,CAAA;AAC1F,UAAA,wBAAA;AAAA,YACE,kBAAA,CAAmB,eAAyC,WAAW,CAAA;AAAA,YACvE,CAAA,IAAA,KAAQ,oBAAA,CAAqB,IAAA,EAAM,OAAO,CAAA;AAAA,YAC1C,EAAE,YAAA,EAAc,OAAO,EAAE,SAAA,EAAW,EAAE,OAAA,EAAS,KAAA,EAAO,IAAA,EAAM,mBAAA,EAAoB,EAAE,CAAA;AAAG,WACvF;AAAA,QACF;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAEA,SAAS,oBAAA,CAAqB,MAAgC,OAAA,EAAiC;AAG7F,EAAA,oBAAA,EAAqB;AAErB,EAAA,MAAM,KAAA,GAAA,CAAS,IAAA,CAAK,SAAA,IAAa,IAAI,CAAC,CAAA;AAEtC,EAAA,OAAO,kBAAkB,2CAAA,CAA4C,IAAA,CAAK,IAAA,EAAM,KAAA,EAAO,OAAO,CAAC,CAAA;AACjG;AAOO,MAAM,2BAAA,GAA8B,kBAAkB,4BAA4B;;;;"}
@@ -0,0 +1,98 @@
1
+ import * as diagnosticsChannel from 'node:diagnostics_channel';
2
+ import { defineIntegration, LANGGRAPH_INTEGRATION_NAME, resolveAIRecordingOptions, createLangChainCallbackHandler, waitForTracingChannelBinding, debug, startInactiveSpan, _INTERNAL_getLangGraphCreateAgentSpanOptions, wrapToolsWithSpans, extractAgentNameFromParams, extractLLMFromParams, instrumentCompiledGraphInvoke } from '@sentry/core';
3
+ import { DEBUG_BUILD } from '../../debug-build.js';
4
+ import { CHANNELS } from '../../orchestrion/channels.js';
5
+ import { bindTracingChannelToSpan } from '../../tracing-channel.js';
6
+
7
+ const INTEGRATION_NAME = LANGGRAPH_INTEGRATION_NAME;
8
+ let subscribed = false;
9
+ let insideCreateReactAgent = false;
10
+ const _langGraphChannelIntegration = ((options = {}) => {
11
+ return {
12
+ name: INTEGRATION_NAME,
13
+ setupOnce() {
14
+ if (!diagnosticsChannel.tracingChannel || subscribed) {
15
+ return;
16
+ }
17
+ subscribed = true;
18
+ const resolvedOptions = resolveAIRecordingOptions(options);
19
+ const sentryHandler = createLangChainCallbackHandler(resolvedOptions);
20
+ waitForTracingChannelBinding(() => {
21
+ DEBUG_BUILD && debug.log(`[orchestrion:langgraph] subscribing to channel "${CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE}"`);
22
+ bindTracingChannelToSpan(
23
+ diagnosticsChannel.tracingChannel(CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE),
24
+ (data) => {
25
+ if (insideCreateReactAgent) {
26
+ return void 0;
27
+ }
28
+ const compileOptions = getFirstArgObject(data.arguments);
29
+ const name = typeof compileOptions?.name === "string" ? compileOptions.name : void 0;
30
+ return startInactiveSpan(_INTERNAL_getLangGraphCreateAgentSpanOptions(name));
31
+ },
32
+ {
33
+ beforeSpanEnd: (_span, data) => {
34
+ wrapCompiledGraphInvoke(
35
+ data.result,
36
+ getFirstArgObject(data.arguments) ?? {},
37
+ resolvedOptions,
38
+ null,
39
+ sentryHandler
40
+ );
41
+ }
42
+ }
43
+ );
44
+ DEBUG_BUILD && debug.log(`[orchestrion:langgraph] subscribing to channel "${CHANNELS.LANGGRAPH_CREATE_REACT_AGENT}"`);
45
+ const reactAgentChannel = diagnosticsChannel.tracingChannel(
46
+ CHANNELS.LANGGRAPH_CREATE_REACT_AGENT
47
+ );
48
+ reactAgentChannel.start.subscribe((message) => {
49
+ insideCreateReactAgent = true;
50
+ try {
51
+ const { arguments: args } = message;
52
+ const params = getFirstArgObject(args);
53
+ if (params && Array.isArray(params.tools) && params.tools.length > 0) {
54
+ wrapToolsWithSpans(params.tools, resolvedOptions, extractAgentNameFromParams(args) ?? void 0);
55
+ }
56
+ } catch (error) {
57
+ DEBUG_BUILD && debug.error("[orchestrion:langgraph] failed to wrap createReactAgent tools", error);
58
+ }
59
+ });
60
+ reactAgentChannel.end.subscribe((message) => {
61
+ insideCreateReactAgent = false;
62
+ const { arguments: args, result } = message;
63
+ const agentName = extractAgentNameFromParams(args) ?? void 0;
64
+ const compileOptions = agentName ? { name: agentName } : {};
65
+ wrapCompiledGraphInvoke(result, compileOptions, resolvedOptions, extractLLMFromParams(args), sentryHandler);
66
+ });
67
+ reactAgentChannel.error.subscribe(() => {
68
+ insideCreateReactAgent = false;
69
+ });
70
+ });
71
+ }
72
+ };
73
+ });
74
+ function getFirstArgObject(args) {
75
+ const first = (args ?? [])[0];
76
+ return typeof first === "object" && first !== null ? first : void 0;
77
+ }
78
+ function wrapCompiledGraphInvoke(graph, compileOptions, options, llm, sentryHandler) {
79
+ if (!graph || typeof graph !== "object") {
80
+ return;
81
+ }
82
+ const compiledGraph = graph;
83
+ const originalInvoke = compiledGraph.invoke;
84
+ if (typeof originalInvoke === "function") {
85
+ compiledGraph.invoke = instrumentCompiledGraphInvoke(
86
+ originalInvoke.bind(compiledGraph),
87
+ compiledGraph,
88
+ compileOptions,
89
+ options,
90
+ llm,
91
+ sentryHandler
92
+ );
93
+ }
94
+ }
95
+ const langGraphChannelIntegration = defineIntegration(_langGraphChannelIntegration);
96
+
97
+ export { langGraphChannelIntegration };
98
+ //# sourceMappingURL=langgraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langgraph.js","sources":["../../../../src/integrations/tracing-channel/langgraph.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { CompiledGraph, IntegrationFn, LangGraphOptions } from '@sentry/core';\nimport {\n _INTERNAL_getLangGraphCreateAgentSpanOptions,\n createLangChainCallbackHandler,\n debug,\n defineIntegration,\n extractAgentNameFromParams,\n extractLLMFromParams,\n instrumentCompiledGraphInvoke,\n LANGGRAPH_INTEGRATION_NAME,\n resolveAIRecordingOptions,\n startInactiveSpan,\n waitForTracingChannelBinding,\n wrapToolsWithSpans,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\n// Same name as the OTel integration by design: when enabled, the OTel 'LangGraph' integration is\n// dropped from the default set (see the Node opt-in loader).\nconst INTEGRATION_NAME = LANGGRAPH_INTEGRATION_NAME;\n\ninterface CompileChannelContext {\n arguments: unknown[];\n result?: unknown;\n}\n\ninterface CreateReactAgentChannelContext {\n arguments: unknown[];\n result?: unknown;\n}\n\nlet subscribed = false;\n\n// `createReactAgent` compiles a `StateGraph` internally; suppress the `create_agent` span for that\n// nested compile so a react agent gets a single `invoke_agent` span, matching the OTel path.\nlet insideCreateReactAgent = false;\n\nconst _langGraphChannelIntegration = ((options: LangGraphOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // `tracingChannel` is unavailable before Node 18.19, and a second `init()` would double-subscribe.\n if (!diagnosticsChannel.tracingChannel || subscribed) {\n return;\n }\n subscribed = true;\n\n const resolvedOptions = resolveAIRecordingOptions(options);\n const sentryHandler = createLangChainCallbackHandler(resolvedOptions);\n\n // `bindTracingChannelToSpan` needs the async-context binding that `initOpenTelemetry()` registers\n // after `setupOnce` runs, so wait for it before subscribing.\n waitForTracingChannelBinding(() => {\n // StateGraph.compile → `create_agent` span, then wrap the returned graph's `invoke`.\n DEBUG_BUILD &&\n debug.log(`[orchestrion:langgraph] subscribing to channel \"${CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE}\"`);\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<CompileChannelContext>(CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE),\n data => {\n if (insideCreateReactAgent) {\n return undefined;\n }\n const compileOptions = getFirstArgObject(data.arguments);\n const name = typeof compileOptions?.name === 'string' ? compileOptions.name : undefined;\n\n return startInactiveSpan(_INTERNAL_getLangGraphCreateAgentSpanOptions(name));\n },\n {\n beforeSpanEnd: (_span, data) => {\n wrapCompiledGraphInvoke(\n data.result,\n getFirstArgObject(data.arguments) ?? {},\n resolvedOptions,\n null,\n sentryHandler,\n );\n },\n },\n );\n\n // createReactAgent has no `create_agent` span of its own; it only wraps tools and the returned\n // graph's `invoke`. Tools are wrapped at `start` (before the agent runs), invoke at `end`.\n DEBUG_BUILD &&\n debug.log(`[orchestrion:langgraph] subscribing to channel \"${CHANNELS.LANGGRAPH_CREATE_REACT_AGENT}\"`);\n const reactAgentChannel = diagnosticsChannel.tracingChannel<CreateReactAgentChannelContext>(\n CHANNELS.LANGGRAPH_CREATE_REACT_AGENT,\n );\n reactAgentChannel.start.subscribe(message => {\n // `createReactAgent` runs synchronously and compiles a `StateGraph` internally, so the flag\n // must be on for the duration and off by `end`. It's set here (never in a branch that can\n // throw) and cleared in both `end` and `error`, so it can neither stick on across calls nor\n // stay off during this call's nested compile. Tool wrapping is guarded for the same reason.\n insideCreateReactAgent = true;\n try {\n const { arguments: args } = message as CreateReactAgentChannelContext;\n const params = getFirstArgObject(args);\n if (params && Array.isArray(params.tools) && params.tools.length > 0) {\n wrapToolsWithSpans(params.tools, resolvedOptions, extractAgentNameFromParams(args) ?? undefined);\n }\n } catch (error) {\n DEBUG_BUILD && debug.error('[orchestrion:langgraph] failed to wrap createReactAgent tools', error);\n }\n });\n reactAgentChannel.end.subscribe(message => {\n insideCreateReactAgent = false;\n const { arguments: args, result } = message as CreateReactAgentChannelContext;\n const agentName = extractAgentNameFromParams(args) ?? undefined;\n const compileOptions = agentName ? { name: agentName } : {};\n wrapCompiledGraphInvoke(result, compileOptions, resolvedOptions, extractLLMFromParams(args), sentryHandler);\n });\n // Make sure a thrown `createReactAgent` doesn't leave the suppression flag stuck on.\n reactAgentChannel.error.subscribe(() => {\n insideCreateReactAgent = false;\n });\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction getFirstArgObject(args: unknown[] | undefined): Record<string, unknown> | undefined {\n const first = (args ?? [])[0];\n\n return typeof first === 'object' && first !== null ? (first as Record<string, unknown>) : undefined;\n}\n\n/**\n * Wrap the compiled graph's `invoke` with the shared `invoke_agent` instrumentation, exactly as the\n * OTel path does on the returned graph.\n */\nfunction wrapCompiledGraphInvoke(\n graph: unknown,\n compileOptions: Record<string, unknown>,\n options: LangGraphOptions,\n llm: ReturnType<typeof extractLLMFromParams>,\n sentryHandler: unknown,\n): void {\n if (!graph || typeof graph !== 'object') {\n return;\n }\n\n const compiledGraph = graph as CompiledGraph;\n const originalInvoke = compiledGraph.invoke;\n if (typeof originalInvoke === 'function') {\n compiledGraph.invoke = instrumentCompiledGraphInvoke(\n originalInvoke.bind(compiledGraph),\n compiledGraph,\n compileOptions,\n options,\n llm,\n sentryHandler,\n );\n }\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven LangGraph integration. Subscribes to the diagnostics_channels\n * injected into `@langchain/langgraph`'s `StateGraph.compile` and `createReactAgent`, so it requires\n * the orchestrion runtime hook or bundler plugin.\n */\nexport const langGraphChannelIntegration = defineIntegration(_langGraphChannelIntegration);\n"],"names":[],"mappings":";;;;;;AAsBA,MAAM,gBAAA,GAAmB,0BAAA;AAYzB,IAAI,UAAA,GAAa,KAAA;AAIjB,IAAI,sBAAA,GAAyB,KAAA;AAE7B,MAAM,4BAAA,IAAgC,CAAC,OAAA,GAA4B,EAAC,KAAM;AACxE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAEV,MAAA,IAAI,CAAC,kBAAA,CAAmB,cAAA,IAAkB,UAAA,EAAY;AACpD,QAAA;AAAA,MACF;AACA,MAAA,UAAA,GAAa,IAAA;AAEb,MAAA,MAAM,eAAA,GAAkB,0BAA0B,OAAO,CAAA;AAC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,KAAA,GAAoC,MAAA;AAC5F;AAMA,SAAS,uBAAA,CACP,KAAA,EACA,cAAA,EACA,OAAA,EACA,KACA,aAAA,EACM;AACN,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACvC,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,aAAA,GAAgB,KAAA;AACtB,EAAA,MAAM,iBAAiB,aAAA,CAAc,MAAA;AACrC,EAAA,IAAI,OAAO,mBAAmB,UAAA,EAAY;AACxC,IAAA,aAAA,CAAc,MAAA,GAAS,6BAAA;AAAA,MACrB,cAAA,CAAe,KAAK,aAAa,CAAA;AAAA,MACjC,aAAA;AAAA,MACA,cAAA;AAAA,MACA,OAAA;AAAA,MACA,GAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF;AAOO,MAAM,2BAAA,GAA8B,kBAAkB,4BAA4B;;;;"}
@@ -0,0 +1,102 @@
1
+ import * as diagnosticsChannel from 'node:diagnostics_channel';
2
+ import { defineIntegration, waitForTracingChannelBinding } from '@sentry/core';
3
+ import { startMongoSpan, getV4SpanAttributes, getV3SpanAttributes, getV3CommandOperation } from '../../mongodb/mongodb-span.js';
4
+ import { CHANNELS } from '../../orchestrion/channels.js';
5
+ import { bindTracingChannelToSpan } from '../../tracing-channel.js';
6
+
7
+ const INTEGRATION_NAME = "Mongo";
8
+ const ORIGIN = "auto.db.orchestrion.mongo";
9
+ const V3_DEDICATED_COMMANDS = /* @__PURE__ */ new Set(["insert", "update", "delete", "find", "getMore", "killCursors"]);
10
+ const _mongodbChannelIntegration = (() => {
11
+ return {
12
+ name: INTEGRATION_NAME,
13
+ setupOnce() {
14
+ if (!diagnosticsChannel.tracingChannel) {
15
+ return;
16
+ }
17
+ waitForTracingChannelBinding(() => {
18
+ subscribeV4Command();
19
+ subscribeV4Checkout();
20
+ subscribeV3Wireprotocol();
21
+ });
22
+ }
23
+ };
24
+ });
25
+ function subscribeV4Command() {
26
+ bindTracingChannelToSpan(
27
+ diagnosticsChannel.tracingChannel(CHANNELS.MONGODB_COMMAND),
28
+ (data) => {
29
+ const args = data.arguments ?? [];
30
+ const ns = args[0];
31
+ const cmd = args[1];
32
+ if (!ns || !cmd || typeof cmd !== "object" || cmd.ismaster || cmd.hello) {
33
+ return void 0;
34
+ }
35
+ const operation = Object.keys(cmd)[0];
36
+ return startMongoSpan(getV4SpanAttributes(data.self, ns, cmd, operation, ORIGIN));
37
+ },
38
+ // Matches otel's `shouldSkipInstrumentation`: only trace when there is
39
+ // an active parent span, to avoid emitting orphaned mongodb spans.
40
+ { requiresParentSpan: true }
41
+ );
42
+ }
43
+ function subscribeV4Checkout() {
44
+ bindTracingChannelToSpan(diagnosticsChannel.tracingChannel(CHANNELS.MONGODB_CHECKOUT), () => void 0);
45
+ }
46
+ function subscribeV3Wireprotocol() {
47
+ for (const operation of ["insert", "update", "remove"]) {
48
+ const channel = operation === "insert" ? CHANNELS.MONGODB_V3_INSERT : operation === "update" ? CHANNELS.MONGODB_V3_UPDATE : CHANNELS.MONGODB_V3_REMOVE;
49
+ bindV3(channel, (args) => ({
50
+ topology: args[0],
51
+ ns: args[1],
52
+ command: args[2]?.[0],
53
+ operation
54
+ }));
55
+ }
56
+ bindV3(CHANNELS.MONGODB_V3_COMMAND, (args) => {
57
+ const command = args[2];
58
+ const type = command ? Object.keys(command)[0] : void 0;
59
+ if (type && V3_DEDICATED_COMMANDS.has(type)) {
60
+ return void 0;
61
+ }
62
+ return {
63
+ topology: args[0],
64
+ ns: args[1],
65
+ command,
66
+ operation: command ? getV3CommandOperation(command) : void 0
67
+ };
68
+ });
69
+ bindV3(CHANNELS.MONGODB_V3_QUERY, (args) => ({
70
+ topology: args[0],
71
+ ns: args[1],
72
+ command: args[2],
73
+ operation: "find"
74
+ }));
75
+ bindV3(CHANNELS.MONGODB_V3_GET_MORE, (args) => ({
76
+ topology: args[0],
77
+ ns: args[1],
78
+ command: args[2]?.cmd,
79
+ operation: "getMore"
80
+ }));
81
+ }
82
+ function bindV3(channelName, extract) {
83
+ bindTracingChannelToSpan(
84
+ diagnosticsChannel.tracingChannel(channelName),
85
+ (data) => {
86
+ const args = data.arguments;
87
+ if (!args) {
88
+ return void 0;
89
+ }
90
+ const info = extract(args);
91
+ if (!info || typeof info.ns !== "string") {
92
+ return void 0;
93
+ }
94
+ return startMongoSpan(getV3SpanAttributes(info.ns, info.topology, info.command, info.operation, ORIGIN));
95
+ },
96
+ { requiresParentSpan: true }
97
+ );
98
+ }
99
+ const mongodbChannelIntegration = defineIntegration(_mongodbChannelIntegration);
100
+
101
+ export { mongodbChannelIntegration };
102
+ //# sourceMappingURL=mongodb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb.js","sources":["../../../../src/integrations/tracing-channel/mongodb.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, waitForTracingChannelBinding } from '@sentry/core';\nimport type { MongodbNamespace, MongoV3Topology } from '../../mongodb/mongodb-span';\nimport {\n getV3CommandOperation,\n getV3SpanAttributes,\n getV4SpanAttributes,\n startMongoSpan,\n} from '../../mongodb/mongodb-span';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\n\nconst INTEGRATION_NAME = 'Mongo' as const;\n\nconst ORIGIN = 'auto.db.orchestrion.mongo';\n\n/**\n * what orchestrion's transform attaches to a channel context:\n * `self` is the `this`, plus args.\n */\ninterface MongoChannelContext {\n self?: { address?: string };\n arguments?: unknown[];\n}\n\n// Details extracted from a v3 wireprotocol call's arguments to build its span.\ninterface V3CallInfo {\n topology: MongoV3Topology | undefined;\n ns: string;\n command: Record<string, unknown> | undefined;\n operation: string | undefined;\n}\n\n// Command doc first-keys whose span the `v3_command` channel must suppress.\n// The `insert`/`update`/`remove`/`query`/`getMore` functions call the shared\n// `command` function internally. Orchestrion transforms the `command` *source*\n// (unlike the vendored OTel patch, which wraps the module's exported reference\n// and misses internal calls), so `v3_command` would double-span the ones that\n// already have their own dedicated channel (`v3_insert`/`update`/`remove`/\n// `query`/`get_more`) without this guard.\n//\n// `killCursors` has no dedicated channel, but is suppressed too for OTel\n// parity: OTel wraps `wireprotocol/index.js`'s `command` property, which never\n// intercepts `kill_cursors.js`'s direct `require('./command')` call — so OTel\n// emits no killCursors span, and neither should we.\nconst V3_DEDICATED_COMMANDS = new Set(['insert', 'update', 'delete', 'find', 'getMore', 'killCursors']);\n\nconst _mongodbChannelIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n subscribeV4Command();\n subscribeV4Checkout();\n subscribeV3Wireprotocol();\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * `Connection.prototype.command` (mongodb >=4.0) one span per command.\n * Handles both the >=6.4 promise form and the >=4.0 <6.4 callback form\n * (both publish to this channel).\n */\nfunction subscribeV4Command(): void {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<MongoChannelContext>(CHANNELS.MONGODB_COMMAND),\n data => {\n const args = data.arguments ?? [];\n const ns = args[0] as MongodbNamespace | undefined;\n const cmd = args[1] as Record<string, unknown> | undefined;\n // Skip handshake/heartbeat commands (matches otel).\n if (!ns || !cmd || typeof cmd !== 'object' || cmd.ismaster || cmd.hello) {\n return undefined;\n }\n const operation = Object.keys(cmd)[0];\n return startMongoSpan(getV4SpanAttributes(data.self, ns, cmd, operation, ORIGIN));\n },\n // Matches otel's `shouldSkipInstrumentation`: only trace when there is\n // an active parent span, to avoid emitting orphaned mongodb spans.\n { requiresParentSpan: true },\n );\n}\n\n/**\n * `ConnectionPool.prototype.checkOut` (mongodb 4.0 - 6.3, callback form).\n * Creates no span (`getSpan` returns `undefined`) but the binding re-runs\n * the checkout callback under the caller's captured context, so the pooled\n * `command()` invoked inside it re-inherits the active span.\n */\nfunction subscribeV4Checkout(): void {\n bindTracingChannelToSpan(diagnosticsChannel.tracingChannel(CHANNELS.MONGODB_CHECKOUT), () => undefined);\n}\n\n/**\n * mongodb >=3.3 <4 had no unified `command`; each operation is a separate\n * `lib/core/wireprotocol` function with its own argument layout, so each\n * channel extracts topology/namespace/command/op differently before building\n * the span.\n */\nfunction subscribeV3Wireprotocol(): void {\n for (const operation of ['insert', 'update', 'remove'] as const) {\n const channel =\n operation === 'insert'\n ? CHANNELS.MONGODB_V3_INSERT\n : operation === 'update'\n ? CHANNELS.MONGODB_V3_UPDATE\n : CHANNELS.MONGODB_V3_REMOVE;\n bindV3(channel, args => ({\n topology: args[0] as MongoV3Topology | undefined,\n ns: args[1] as string,\n command: (args[2] as Record<string, unknown>[] | undefined)?.[0],\n operation,\n }));\n }\n\n // `command`(server, ns, cmd, options, callback) operation derived from the\n // command doc. Skips commands that have a dedicated channel. See set above.\n bindV3(CHANNELS.MONGODB_V3_COMMAND, args => {\n const command = args[2] as Record<string, unknown> | undefined;\n const type = command ? Object.keys(command)[0] : undefined;\n if (type && V3_DEDICATED_COMMANDS.has(type)) {\n return undefined;\n }\n return {\n topology: args[0] as MongoV3Topology | undefined,\n ns: args[1] as string,\n command,\n operation: command ? getV3CommandOperation(command) : undefined,\n };\n });\n\n // `query`(server, ns, cmd, cursorState, options, callback). a find.\n bindV3(CHANNELS.MONGODB_V3_QUERY, args => ({\n topology: args[0] as MongoV3Topology | undefined,\n ns: args[1] as string,\n command: args[2] as Record<string, unknown> | undefined,\n operation: 'find',\n }));\n\n // `getMore`(server, ns, cursorState, batchSize, options, callback)\n // command doc is `cursorState.cmd`.\n bindV3(CHANNELS.MONGODB_V3_GET_MORE, args => ({\n topology: args[0] as MongoV3Topology | undefined,\n ns: args[1] as string,\n command: (args[2] as { cmd?: Record<string, unknown> } | undefined)?.cmd,\n operation: 'getMore',\n }));\n}\n\nfunction bindV3(channelName: string, extract: (args: unknown[]) => V3CallInfo | undefined): void {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<MongoChannelContext>(channelName),\n data => {\n const args = data.arguments;\n if (!args) {\n return undefined;\n }\n const info = extract(args);\n if (!info || typeof info.ns !== 'string') {\n return undefined;\n }\n return startMongoSpan(getV3SpanAttributes(info.ns, info.topology, info.command, info.operation, ORIGIN));\n },\n { requiresParentSpan: true },\n );\n}\n\n/**\n * EXPERIMENTAL: orchestrion-driven mongodb integration.\n *\n * Reproduces the vendored `@opentelemetry/instrumentation-mongodb` span shape\n * (legacy db/net semantic conventions, `mongodb.<op>` names, scrubbed\n * `db.statement`) via the `orchestrion:mongodb:*` diagnostics_channels\n * injected by the orchestrion code transform.\n */\nexport const mongodbChannelIntegration = defineIntegration(_mongodbChannelIntegration);\n"],"names":[],"mappings":";;;;;;AAaA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,MAAA,GAAS,2BAAA;AA+Bf,MAAM,qBAAA,mBAAwB,IAAI,GAAA,CAAI,CAAC,QAAA,EAAU,UAAU,QAAA,EAAU,MAAA,EAAQ,SAAA,EAAW,aAAa,CAAC,CAAA;AAEtG,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,MAAA,4BAAA,CAA6B,MAAM;AACjC,QAAA,kBAAA,EAAmB;AACnB,QAAA,mBAAA,EAAoB;AACpB,QAAA,uBAAA,EAAwB;AAAA,MAC1B,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAOA,SAAS,kBAAA,GAA2B;AAClC,EAAA,wBAAA;AAAA,IACE,kBAAA,CAAmB,cAAA,CAAoC,QAAA,CAAS,eAAe,CAAA;AAAA,IAC/E,CAAA,IAAA,KAAQ;AACN,MAAA,MAAM,IAAA,GAAO,IAAA,CAAK,SAAA,IAAa,EAAC;AAChC,MAAA,MAAM,EAAA,GAAK,KAAK,CAAC,CAAA;AACjB,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