@sentry/server-utils 10.63.0 → 10.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/build/cjs/graphql/graphql-dc-subscriber.js +125 -0
  2. package/build/cjs/graphql/graphql-dc-subscriber.js.map +1 -0
  3. package/build/cjs/graphql/index.js +23 -0
  4. package/build/cjs/graphql/index.js.map +1 -0
  5. package/build/cjs/graphql/utils.js +86 -0
  6. package/build/cjs/graphql/utils.js.map +1 -0
  7. package/build/cjs/index.js +12 -9
  8. package/build/cjs/index.js.map +1 -1
  9. package/build/cjs/integrations/tracing-channel/amqplib.js +420 -0
  10. package/build/cjs/integrations/tracing-channel/amqplib.js.map +1 -0
  11. package/build/cjs/integrations/tracing-channel/anthropic.js +101 -0
  12. package/build/cjs/integrations/tracing-channel/anthropic.js.map +1 -0
  13. package/build/cjs/integrations/tracing-channel/express/index.js +24 -0
  14. package/build/cjs/integrations/tracing-channel/express/index.js.map +1 -0
  15. package/build/cjs/integrations/tracing-channel/express/instrumentation.js +173 -0
  16. package/build/cjs/integrations/tracing-channel/express/instrumentation.js.map +1 -0
  17. package/build/cjs/integrations/tracing-channel/express/route.js +76 -0
  18. package/build/cjs/integrations/tracing-channel/express/route.js.map +1 -0
  19. package/build/cjs/integrations/tracing-channel/fastify/instrumentation.js +1 -1
  20. package/build/cjs/integrations/tracing-channel/fastify/instrumentation.js.map +1 -1
  21. package/build/cjs/integrations/tracing-channel/google-genai.js +96 -0
  22. package/build/cjs/integrations/tracing-channel/google-genai.js.map +1 -0
  23. package/build/cjs/integrations/tracing-channel/graphql/constants.js +26 -0
  24. package/build/cjs/integrations/tracing-channel/graphql/constants.js.map +1 -0
  25. package/build/cjs/integrations/tracing-channel/graphql/index.js +66 -0
  26. package/build/cjs/integrations/tracing-channel/graphql/index.js.map +1 -0
  27. package/build/cjs/integrations/tracing-channel/graphql/resolvers.js +168 -0
  28. package/build/cjs/integrations/tracing-channel/graphql/resolvers.js.map +1 -0
  29. package/build/cjs/integrations/tracing-channel/graphql/spans.js +102 -0
  30. package/build/cjs/integrations/tracing-channel/graphql/spans.js.map +1 -0
  31. package/build/cjs/integrations/tracing-channel/hapi-types.js +30 -0
  32. package/build/cjs/integrations/tracing-channel/hapi-types.js.map +1 -0
  33. package/build/cjs/integrations/tracing-channel/hapi-utils.js +177 -0
  34. package/build/cjs/integrations/tracing-channel/hapi-utils.js.map +1 -0
  35. package/build/cjs/integrations/tracing-channel/hapi.js +52 -0
  36. package/build/cjs/integrations/tracing-channel/hapi.js.map +1 -0
  37. package/build/cjs/integrations/tracing-channel/ioredis.js +96 -0
  38. package/build/cjs/integrations/tracing-channel/ioredis.js.map +1 -0
  39. package/build/cjs/integrations/tracing-channel/mysql.js +2 -1
  40. package/build/cjs/integrations/tracing-channel/mysql.js.map +1 -1
  41. package/build/cjs/integrations/tracing-channel/openai.js +83 -0
  42. package/build/cjs/integrations/tracing-channel/openai.js.map +1 -0
  43. package/build/cjs/integrations/tracing-channel/postgres-js.js +191 -0
  44. package/build/cjs/integrations/tracing-channel/postgres-js.js.map +1 -0
  45. package/build/cjs/integrations/tracing-channel/postgres.js +170 -0
  46. package/build/cjs/integrations/tracing-channel/postgres.js.map +1 -0
  47. package/build/cjs/integrations/tracing-channel/redis.js +227 -0
  48. package/build/cjs/integrations/tracing-channel/redis.js.map +1 -0
  49. package/build/cjs/integrations/tracing-channel/vercel-ai.js +25 -0
  50. package/build/cjs/integrations/tracing-channel/vercel-ai.js.map +1 -0
  51. package/build/cjs/mongoose/index.js +23 -0
  52. package/build/cjs/mongoose/index.js.map +1 -0
  53. package/build/cjs/mongoose/mongoose-dc-subscriber.js +97 -0
  54. package/build/cjs/mongoose/mongoose-dc-subscriber.js.map +1 -0
  55. package/build/cjs/mysql2/index.js +23 -0
  56. package/build/cjs/mysql2/index.js.map +1 -0
  57. package/build/cjs/mysql2/mysql2-dc-subscriber.js +68 -0
  58. package/build/cjs/mysql2/mysql2-dc-subscriber.js.map +1 -0
  59. package/build/cjs/orchestrion/bundler/vite.js +3 -3
  60. package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
  61. package/build/cjs/orchestrion/channels.js +29 -2
  62. package/build/cjs/orchestrion/channels.js.map +1 -1
  63. package/build/cjs/orchestrion/config/amqplib.js +81 -0
  64. package/build/cjs/orchestrion/config/amqplib.js.map +1 -0
  65. package/build/cjs/orchestrion/config/anthropic-ai.js +43 -0
  66. package/build/cjs/orchestrion/config/anthropic-ai.js.map +1 -0
  67. package/build/cjs/orchestrion/config/express.js +76 -0
  68. package/build/cjs/orchestrion/config/express.js.map +1 -0
  69. package/build/cjs/orchestrion/config/google-genai.js +38 -0
  70. package/build/cjs/orchestrion/config/google-genai.js.map +1 -0
  71. package/build/cjs/orchestrion/config/graphql.js +28 -0
  72. package/build/cjs/orchestrion/config/graphql.js.map +1 -0
  73. package/build/cjs/orchestrion/config/hapi.js +26 -0
  74. package/build/cjs/orchestrion/config/hapi.js.map +1 -0
  75. package/build/cjs/orchestrion/config/index.js +48 -0
  76. package/build/cjs/orchestrion/config/index.js.map +1 -0
  77. package/build/cjs/orchestrion/config/ioredis.js +35 -0
  78. package/build/cjs/orchestrion/config/ioredis.js.map +1 -0
  79. package/build/cjs/orchestrion/config/lru-memoizer.js +17 -0
  80. package/build/cjs/orchestrion/config/lru-memoizer.js.map +1 -0
  81. package/build/cjs/orchestrion/config/mysql.js +16 -0
  82. package/build/cjs/orchestrion/config/mysql.js.map +1 -0
  83. package/build/cjs/orchestrion/config/openai.js +40 -0
  84. package/build/cjs/orchestrion/config/openai.js.map +1 -0
  85. package/build/cjs/orchestrion/config/pg.js +51 -0
  86. package/build/cjs/orchestrion/config/pg.js.map +1 -0
  87. package/build/cjs/orchestrion/config/postgres.js +50 -0
  88. package/build/cjs/orchestrion/config/postgres.js.map +1 -0
  89. package/build/cjs/orchestrion/config/redis.js +76 -0
  90. package/build/cjs/orchestrion/config/redis.js.map +1 -0
  91. package/build/cjs/orchestrion/config/vercel-ai.js +48 -0
  92. package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -0
  93. package/build/cjs/orchestrion/detect.js +6 -1
  94. package/build/cjs/orchestrion/detect.js.map +1 -1
  95. package/build/cjs/orchestrion/index.js +44 -5
  96. package/build/cjs/orchestrion/index.js.map +1 -1
  97. package/build/cjs/orchestrion/runtime/register.js +10 -7
  98. package/build/cjs/orchestrion/runtime/register.js.map +1 -1
  99. package/build/cjs/redis/index.js +23 -0
  100. package/build/cjs/redis/index.js.map +1 -0
  101. package/build/cjs/redis/redis-dc-subscriber.js +23 -35
  102. package/build/cjs/redis/redis-dc-subscriber.js.map +1 -1
  103. package/build/cjs/redis/redis-statement-serializer.js +34 -0
  104. package/build/cjs/redis/redis-statement-serializer.js.map +1 -0
  105. package/build/cjs/tracing-channel.js +8 -7
  106. package/build/cjs/tracing-channel.js.map +1 -1
  107. package/build/cjs/vercel-ai/util.js +123 -0
  108. package/build/cjs/vercel-ai/util.js.map +1 -0
  109. package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js +147 -76
  110. package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  111. package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js +386 -0
  112. package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -0
  113. package/build/esm/graphql/graphql-dc-subscriber.js +118 -0
  114. package/build/esm/graphql/graphql-dc-subscriber.js.map +1 -0
  115. package/build/esm/graphql/index.js +21 -0
  116. package/build/esm/graphql/index.js.map +1 -0
  117. package/build/esm/graphql/utils.js +81 -0
  118. package/build/esm/graphql/utils.js.map +1 -0
  119. package/build/esm/index.js +5 -1
  120. package/build/esm/index.js.map +1 -1
  121. package/build/esm/integrations/tracing-channel/amqplib.js +418 -0
  122. package/build/esm/integrations/tracing-channel/amqplib.js.map +1 -0
  123. package/build/esm/integrations/tracing-channel/anthropic.js +99 -0
  124. package/build/esm/integrations/tracing-channel/anthropic.js.map +1 -0
  125. package/build/esm/integrations/tracing-channel/express/index.js +22 -0
  126. package/build/esm/integrations/tracing-channel/express/index.js.map +1 -0
  127. package/build/esm/integrations/tracing-channel/express/instrumentation.js +171 -0
  128. package/build/esm/integrations/tracing-channel/express/instrumentation.js.map +1 -0
  129. package/build/esm/integrations/tracing-channel/express/route.js +68 -0
  130. package/build/esm/integrations/tracing-channel/express/route.js.map +1 -0
  131. package/build/esm/integrations/tracing-channel/fastify/instrumentation.js +2 -2
  132. package/build/esm/integrations/tracing-channel/fastify/instrumentation.js.map +1 -1
  133. package/build/esm/integrations/tracing-channel/google-genai.js +94 -0
  134. package/build/esm/integrations/tracing-channel/google-genai.js.map +1 -0
  135. package/build/esm/integrations/tracing-channel/graphql/constants.js +14 -0
  136. package/build/esm/integrations/tracing-channel/graphql/constants.js.map +1 -0
  137. package/build/esm/integrations/tracing-channel/graphql/index.js +63 -0
  138. package/build/esm/integrations/tracing-channel/graphql/index.js.map +1 -0
  139. package/build/esm/integrations/tracing-channel/graphql/resolvers.js +164 -0
  140. package/build/esm/integrations/tracing-channel/graphql/resolvers.js.map +1 -0
  141. package/build/esm/integrations/tracing-channel/graphql/spans.js +96 -0
  142. package/build/esm/integrations/tracing-channel/graphql/spans.js.map +1 -0
  143. package/build/esm/integrations/tracing-channel/hapi-types.js +25 -0
  144. package/build/esm/integrations/tracing-channel/hapi-types.js.map +1 -0
  145. package/build/esm/integrations/tracing-channel/hapi-utils.js +172 -0
  146. package/build/esm/integrations/tracing-channel/hapi-utils.js.map +1 -0
  147. package/build/esm/integrations/tracing-channel/hapi.js +50 -0
  148. package/build/esm/integrations/tracing-channel/hapi.js.map +1 -0
  149. package/build/esm/integrations/tracing-channel/ioredis.js +94 -0
  150. package/build/esm/integrations/tracing-channel/ioredis.js.map +1 -0
  151. package/build/esm/integrations/tracing-channel/mysql.js +3 -2
  152. package/build/esm/integrations/tracing-channel/mysql.js.map +1 -1
  153. package/build/esm/integrations/tracing-channel/openai.js +81 -0
  154. package/build/esm/integrations/tracing-channel/openai.js.map +1 -0
  155. package/build/esm/integrations/tracing-channel/postgres-js.js +189 -0
  156. package/build/esm/integrations/tracing-channel/postgres-js.js.map +1 -0
  157. package/build/esm/integrations/tracing-channel/postgres.js +168 -0
  158. package/build/esm/integrations/tracing-channel/postgres.js.map +1 -0
  159. package/build/esm/integrations/tracing-channel/redis.js +225 -0
  160. package/build/esm/integrations/tracing-channel/redis.js.map +1 -0
  161. package/build/esm/integrations/tracing-channel/vercel-ai.js +23 -0
  162. package/build/esm/integrations/tracing-channel/vercel-ai.js.map +1 -0
  163. package/build/esm/mongoose/index.js +21 -0
  164. package/build/esm/mongoose/index.js.map +1 -0
  165. package/build/esm/mongoose/mongoose-dc-subscriber.js +89 -0
  166. package/build/esm/mongoose/mongoose-dc-subscriber.js.map +1 -0
  167. package/build/esm/mysql2/index.js +21 -0
  168. package/build/esm/mysql2/index.js.map +1 -0
  169. package/build/esm/mysql2/mysql2-dc-subscriber.js +62 -0
  170. package/build/esm/mysql2/mysql2-dc-subscriber.js.map +1 -0
  171. package/build/esm/orchestrion/bundler/vite.js +1 -1
  172. package/build/esm/orchestrion/channels.js +29 -2
  173. package/build/esm/orchestrion/channels.js.map +1 -1
  174. package/build/esm/orchestrion/config/amqplib.js +78 -0
  175. package/build/esm/orchestrion/config/amqplib.js.map +1 -0
  176. package/build/esm/orchestrion/config/anthropic-ai.js +40 -0
  177. package/build/esm/orchestrion/config/anthropic-ai.js.map +1 -0
  178. package/build/esm/orchestrion/config/express.js +73 -0
  179. package/build/esm/orchestrion/config/express.js.map +1 -0
  180. package/build/esm/orchestrion/config/google-genai.js +35 -0
  181. package/build/esm/orchestrion/config/google-genai.js.map +1 -0
  182. package/build/esm/orchestrion/config/graphql.js +25 -0
  183. package/build/esm/orchestrion/config/graphql.js.map +1 -0
  184. package/build/esm/orchestrion/config/hapi.js +23 -0
  185. package/build/esm/orchestrion/config/hapi.js.map +1 -0
  186. package/build/esm/orchestrion/config/index.js +44 -0
  187. package/build/esm/orchestrion/config/index.js.map +1 -0
  188. package/build/esm/orchestrion/config/ioredis.js +32 -0
  189. package/build/esm/orchestrion/config/ioredis.js.map +1 -0
  190. package/build/esm/orchestrion/config/lru-memoizer.js +14 -0
  191. package/build/esm/orchestrion/config/lru-memoizer.js.map +1 -0
  192. package/build/esm/orchestrion/config/mysql.js +13 -0
  193. package/build/esm/orchestrion/config/mysql.js.map +1 -0
  194. package/build/esm/orchestrion/config/openai.js +37 -0
  195. package/build/esm/orchestrion/config/openai.js.map +1 -0
  196. package/build/esm/orchestrion/config/pg.js +48 -0
  197. package/build/esm/orchestrion/config/pg.js.map +1 -0
  198. package/build/esm/orchestrion/config/postgres.js +47 -0
  199. package/build/esm/orchestrion/config/postgres.js.map +1 -0
  200. package/build/esm/orchestrion/config/redis.js +73 -0
  201. package/build/esm/orchestrion/config/redis.js.map +1 -0
  202. package/build/esm/orchestrion/config/vercel-ai.js +45 -0
  203. package/build/esm/orchestrion/config/vercel-ai.js.map +1 -0
  204. package/build/esm/orchestrion/detect.js +6 -2
  205. package/build/esm/orchestrion/detect.js.map +1 -1
  206. package/build/esm/orchestrion/index.js +33 -3
  207. package/build/esm/orchestrion/index.js.map +1 -1
  208. package/build/esm/orchestrion/runtime/register.js +8 -4
  209. package/build/esm/orchestrion/runtime/register.js.map +1 -1
  210. package/build/esm/package.json +1 -1
  211. package/build/esm/redis/index.js +21 -0
  212. package/build/esm/redis/index.js.map +1 -0
  213. package/build/esm/redis/redis-dc-subscriber.js +24 -36
  214. package/build/esm/redis/redis-dc-subscriber.js.map +1 -1
  215. package/build/esm/redis/redis-statement-serializer.js +32 -0
  216. package/build/esm/redis/redis-statement-serializer.js.map +1 -0
  217. package/build/esm/tracing-channel.js +9 -8
  218. package/build/esm/tracing-channel.js.map +1 -1
  219. package/build/esm/vercel-ai/util.js +116 -0
  220. package/build/esm/vercel-ai/util.js.map +1 -0
  221. package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js +122 -54
  222. package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
  223. package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js +384 -0
  224. package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -0
  225. package/build/types/graphql/graphql-dc-subscriber.d.ts +94 -0
  226. package/build/types/graphql/graphql-dc-subscriber.d.ts.map +1 -0
  227. package/build/types/graphql/index.d.ts +12 -0
  228. package/build/types/graphql/index.d.ts.map +1 -0
  229. package/build/types/graphql/utils.d.ts +40 -0
  230. package/build/types/graphql/utils.d.ts.map +1 -0
  231. package/build/types/index.d.ts +6 -2
  232. package/build/types/index.d.ts.map +1 -1
  233. package/build/types/integrations/tracing-channel/amqplib.d.ts +11 -0
  234. package/build/types/integrations/tracing-channel/amqplib.d.ts.map +1 -0
  235. package/build/types/integrations/tracing-channel/anthropic.d.ts +10 -0
  236. package/build/types/integrations/tracing-channel/anthropic.d.ts.map +1 -0
  237. package/build/types/integrations/tracing-channel/express/index.d.ts +18 -0
  238. package/build/types/integrations/tracing-channel/express/index.d.ts.map +1 -0
  239. package/build/types/integrations/tracing-channel/express/instrumentation.d.ts +4 -0
  240. package/build/types/integrations/tracing-channel/express/instrumentation.d.ts.map +1 -0
  241. package/build/types/integrations/tracing-channel/express/route.d.ts +28 -0
  242. package/build/types/integrations/tracing-channel/express/route.d.ts.map +1 -0
  243. package/build/types/integrations/tracing-channel/express/types.d.ts +64 -0
  244. package/build/types/integrations/tracing-channel/express/types.d.ts.map +1 -0
  245. package/build/types/integrations/tracing-channel/fastify/instrumentation.d.ts.map +1 -1
  246. package/build/types/integrations/tracing-channel/google-genai.d.ts +12 -0
  247. package/build/types/integrations/tracing-channel/google-genai.d.ts.map +1 -0
  248. package/build/types/integrations/tracing-channel/graphql/constants.d.ts +12 -0
  249. package/build/types/integrations/tracing-channel/graphql/constants.d.ts.map +1 -0
  250. package/build/types/integrations/tracing-channel/graphql/graphql-types.d.ts +135 -0
  251. package/build/types/integrations/tracing-channel/graphql/graphql-types.d.ts.map +1 -0
  252. package/build/types/integrations/tracing-channel/graphql/index.d.ts +28 -0
  253. package/build/types/integrations/tracing-channel/graphql/index.d.ts.map +1 -0
  254. package/build/types/integrations/tracing-channel/graphql/resolvers.d.ts +13 -0
  255. package/build/types/integrations/tracing-channel/graphql/resolvers.d.ts.map +1 -0
  256. package/build/types/integrations/tracing-channel/graphql/spans.d.ts +17 -0
  257. package/build/types/integrations/tracing-channel/graphql/spans.d.ts.map +1 -0
  258. package/build/types/integrations/tracing-channel/graphql/types.d.ts +25 -0
  259. package/build/types/integrations/tracing-channel/graphql/types.d.ts.map +1 -0
  260. package/build/types/integrations/tracing-channel/hapi-types.d.ts +53 -0
  261. package/build/types/integrations/tracing-channel/hapi-types.d.ts.map +1 -0
  262. package/build/types/integrations/tracing-channel/hapi-utils.d.ts +25 -0
  263. package/build/types/integrations/tracing-channel/hapi-utils.d.ts.map +1 -0
  264. package/build/types/integrations/tracing-channel/hapi.d.ts +9 -0
  265. package/build/types/integrations/tracing-channel/hapi.d.ts.map +1 -0
  266. package/build/types/integrations/tracing-channel/ioredis.d.ts +17 -0
  267. package/build/types/integrations/tracing-channel/ioredis.d.ts.map +1 -0
  268. package/build/types/integrations/tracing-channel/mysql.d.ts.map +1 -1
  269. package/build/types/integrations/tracing-channel/openai.d.ts +10 -0
  270. package/build/types/integrations/tracing-channel/openai.d.ts.map +1 -0
  271. package/build/types/integrations/tracing-channel/postgres-js.d.ts +26 -0
  272. package/build/types/integrations/tracing-channel/postgres-js.d.ts.map +1 -0
  273. package/build/types/integrations/tracing-channel/postgres.d.ts +15 -0
  274. package/build/types/integrations/tracing-channel/postgres.d.ts.map +1 -0
  275. package/build/types/integrations/tracing-channel/redis.d.ts +16 -0
  276. package/build/types/integrations/tracing-channel/redis.d.ts.map +1 -0
  277. package/build/types/integrations/tracing-channel/vercel-ai.d.ts +13 -0
  278. package/build/types/integrations/tracing-channel/vercel-ai.d.ts.map +1 -0
  279. package/build/types/mongoose/index.d.ts +11 -0
  280. package/build/types/mongoose/index.d.ts.map +1 -0
  281. package/build/types/mongoose/mongoose-dc-subscriber.d.ts +63 -0
  282. package/build/types/mongoose/mongoose-dc-subscriber.d.ts.map +1 -0
  283. package/build/types/mysql2/index.d.ts +11 -0
  284. package/build/types/mysql2/index.d.ts.map +1 -0
  285. package/build/types/mysql2/mysql2-dc-subscriber.d.ts +59 -0
  286. package/build/types/mysql2/mysql2-dc-subscriber.d.ts.map +1 -0
  287. package/build/types/orchestrion/channels.d.ts +55 -1
  288. package/build/types/orchestrion/channels.d.ts.map +1 -1
  289. package/build/types/orchestrion/config/amqplib.d.ts +66 -0
  290. package/build/types/orchestrion/config/amqplib.d.ts.map +1 -0
  291. package/build/types/orchestrion/config/anthropic-ai.d.ts +31 -0
  292. package/build/types/orchestrion/config/anthropic-ai.d.ts.map +1 -0
  293. package/build/types/orchestrion/config/express.d.ts +32 -0
  294. package/build/types/orchestrion/config/express.d.ts.map +1 -0
  295. package/build/types/orchestrion/config/google-genai.d.ts +30 -0
  296. package/build/types/orchestrion/config/google-genai.d.ts.map +1 -0
  297. package/build/types/orchestrion/config/graphql.d.ts +29 -0
  298. package/build/types/orchestrion/config/graphql.d.ts.map +1 -0
  299. package/build/types/orchestrion/config/hapi.d.ts +17 -0
  300. package/build/types/orchestrion/config/hapi.d.ts.map +1 -0
  301. package/build/types/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
  302. package/build/types/orchestrion/config/index.d.ts.map +1 -0
  303. package/build/types/orchestrion/config/ioredis.d.ts +7 -0
  304. package/build/types/orchestrion/config/ioredis.d.ts.map +1 -0
  305. package/build/types/orchestrion/config/lru-memoizer.d.ts +16 -0
  306. package/build/types/orchestrion/config/lru-memoizer.d.ts.map +1 -0
  307. package/build/types/orchestrion/config/mysql.d.ts +16 -0
  308. package/build/types/orchestrion/config/mysql.d.ts.map +1 -0
  309. package/build/types/orchestrion/config/openai.d.ts +20 -0
  310. package/build/types/orchestrion/config/openai.d.ts.map +1 -0
  311. package/build/types/orchestrion/config/pg.d.ts +33 -0
  312. package/build/types/orchestrion/config/pg.d.ts.map +1 -0
  313. package/build/types/orchestrion/config/postgres.d.ts +9 -0
  314. package/build/types/orchestrion/config/postgres.d.ts.map +1 -0
  315. package/build/types/orchestrion/config/redis.d.ts +37 -0
  316. package/build/types/orchestrion/config/redis.d.ts.map +1 -0
  317. package/build/types/orchestrion/config/vercel-ai.d.ts +12 -0
  318. package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -0
  319. package/build/types/orchestrion/detect.d.ts +10 -0
  320. package/build/types/orchestrion/detect.d.ts.map +1 -1
  321. package/build/types/orchestrion/index.d.ts +80 -3
  322. package/build/types/orchestrion/index.d.ts.map +1 -1
  323. package/build/types/orchestrion/runtime/register.d.ts.map +1 -1
  324. package/build/types/redis/index.d.ts +18 -0
  325. package/build/types/redis/index.d.ts.map +1 -0
  326. package/build/types/redis/redis-dc-subscriber.d.ts +0 -5
  327. package/build/types/redis/redis-dc-subscriber.d.ts.map +1 -1
  328. package/build/types/redis/redis-statement-serializer.d.ts +6 -0
  329. package/build/types/redis/redis-statement-serializer.d.ts.map +1 -0
  330. package/build/types/tracing-channel.d.ts +5 -0
  331. package/build/types/tracing-channel.d.ts.map +1 -1
  332. package/build/types/vercel-ai/util.d.ts +32 -0
  333. package/build/types/vercel-ai/util.d.ts.map +1 -0
  334. package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts +15 -5
  335. package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
  336. package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts +12 -0
  337. package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts.map +1 -0
  338. package/build/types-ts3.8/graphql/graphql-dc-subscriber.d.ts +94 -0
  339. package/build/types-ts3.8/graphql/index.d.ts +12 -0
  340. package/build/types-ts3.8/graphql/utils.d.ts +40 -0
  341. package/build/types-ts3.8/index.d.ts +6 -2
  342. package/build/types-ts3.8/integrations/tracing-channel/amqplib.d.ts +11 -0
  343. package/build/types-ts3.8/integrations/tracing-channel/anthropic.d.ts +10 -0
  344. package/build/types-ts3.8/integrations/tracing-channel/express/index.d.ts +18 -0
  345. package/build/types-ts3.8/integrations/tracing-channel/express/instrumentation.d.ts +4 -0
  346. package/build/types-ts3.8/integrations/tracing-channel/express/route.d.ts +28 -0
  347. package/build/types-ts3.8/integrations/tracing-channel/express/types.d.ts +64 -0
  348. package/build/types-ts3.8/integrations/tracing-channel/google-genai.d.ts +12 -0
  349. package/build/types-ts3.8/integrations/tracing-channel/graphql/constants.d.ts +12 -0
  350. package/build/types-ts3.8/integrations/tracing-channel/graphql/graphql-types.d.ts +135 -0
  351. package/build/types-ts3.8/integrations/tracing-channel/graphql/index.d.ts +30 -0
  352. package/build/types-ts3.8/integrations/tracing-channel/graphql/resolvers.d.ts +13 -0
  353. package/build/types-ts3.8/integrations/tracing-channel/graphql/spans.d.ts +17 -0
  354. package/build/types-ts3.8/integrations/tracing-channel/graphql/types.d.ts +25 -0
  355. package/build/types-ts3.8/integrations/tracing-channel/hapi-types.d.ts +65 -0
  356. package/build/types-ts3.8/integrations/tracing-channel/hapi-utils.d.ts +25 -0
  357. package/build/types-ts3.8/integrations/tracing-channel/hapi.d.ts +9 -0
  358. package/build/types-ts3.8/integrations/tracing-channel/ioredis.d.ts +17 -0
  359. package/build/types-ts3.8/integrations/tracing-channel/openai.d.ts +10 -0
  360. package/build/types-ts3.8/integrations/tracing-channel/postgres-js.d.ts +26 -0
  361. package/build/types-ts3.8/integrations/tracing-channel/postgres.d.ts +15 -0
  362. package/build/types-ts3.8/integrations/tracing-channel/redis.d.ts +16 -0
  363. package/build/types-ts3.8/integrations/tracing-channel/vercel-ai.d.ts +13 -0
  364. package/build/types-ts3.8/mongoose/index.d.ts +11 -0
  365. package/build/types-ts3.8/mongoose/mongoose-dc-subscriber.d.ts +63 -0
  366. package/build/types-ts3.8/mysql2/index.d.ts +11 -0
  367. package/build/types-ts3.8/mysql2/mysql2-dc-subscriber.d.ts +59 -0
  368. package/build/types-ts3.8/orchestrion/channels.d.ts +55 -1
  369. package/build/types-ts3.8/orchestrion/config/amqplib.d.ts +66 -0
  370. package/build/types-ts3.8/orchestrion/config/anthropic-ai.d.ts +31 -0
  371. package/build/types-ts3.8/orchestrion/config/express.d.ts +32 -0
  372. package/build/types-ts3.8/orchestrion/config/google-genai.d.ts +30 -0
  373. package/build/types-ts3.8/orchestrion/config/graphql.d.ts +29 -0
  374. package/build/types-ts3.8/orchestrion/config/hapi.d.ts +17 -0
  375. package/build/types-ts3.8/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
  376. package/build/types-ts3.8/orchestrion/config/ioredis.d.ts +7 -0
  377. package/build/types-ts3.8/orchestrion/config/lru-memoizer.d.ts +16 -0
  378. package/build/types-ts3.8/orchestrion/config/mysql.d.ts +16 -0
  379. package/build/types-ts3.8/orchestrion/config/openai.d.ts +20 -0
  380. package/build/types-ts3.8/orchestrion/config/pg.d.ts +33 -0
  381. package/build/types-ts3.8/orchestrion/config/postgres.d.ts +9 -0
  382. package/build/types-ts3.8/orchestrion/config/redis.d.ts +37 -0
  383. package/build/types-ts3.8/orchestrion/config/vercel-ai.d.ts +12 -0
  384. package/build/types-ts3.8/orchestrion/detect.d.ts +10 -0
  385. package/build/types-ts3.8/orchestrion/index.d.ts +82 -3
  386. package/build/types-ts3.8/redis/index.d.ts +18 -0
  387. package/build/types-ts3.8/redis/redis-dc-subscriber.d.ts +0 -5
  388. package/build/types-ts3.8/redis/redis-statement-serializer.d.ts +6 -0
  389. package/build/types-ts3.8/tracing-channel.d.ts +5 -0
  390. package/build/types-ts3.8/vercel-ai/util.d.ts +32 -0
  391. package/build/types-ts3.8/vercel-ai/vercel-ai-dc-subscriber.d.ts +15 -5
  392. package/build/types-ts3.8/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts +12 -0
  393. package/package.json +9 -9
  394. package/build/cjs/orchestrion/config.js +0 -44
  395. package/build/cjs/orchestrion/config.js.map +0 -1
  396. package/build/esm/orchestrion/config.js +0 -40
  397. package/build/esm/orchestrion/config.js.map +0 -1
  398. package/build/types/orchestrion/config.d.ts.map +0 -1
@@ -0,0 +1,66 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const diagnosticsChannel = require('node:diagnostics_channel');
4
+ const core = require('@sentry/core');
5
+ const debugBuild = require('../../../debug-build.js');
6
+ const index = require('../../../graphql/index.js');
7
+ const channels = require('../../../orchestrion/channels.js');
8
+ const tracingChannel = require('../../../tracing-channel.js');
9
+ const spans = require('./spans.js');
10
+
11
+ const INTEGRATION_NAME = "Graphql";
12
+ function getOptionsWithDefaults(options) {
13
+ return {
14
+ ignoreResolveSpans: options.ignoreResolveSpans !== false,
15
+ ignoreTrivialResolveSpans: options.ignoreTrivialResolveSpans !== false,
16
+ useOperationNameForRootSpan: options.useOperationNameForRootSpan !== false
17
+ };
18
+ }
19
+ function safe(fn) {
20
+ try {
21
+ return fn();
22
+ } catch (error) {
23
+ debugBuild.DEBUG_BUILD && core.debug.warn("[orchestrion:graphql] error building span", error);
24
+ return void 0;
25
+ }
26
+ }
27
+ const _graphqlChannelIntegration = ((options = {}) => {
28
+ const config = getOptionsWithDefaults(options);
29
+ const getConfig = () => config;
30
+ return {
31
+ name: INTEGRATION_NAME,
32
+ setupOnce() {
33
+ if (!diagnosticsChannel.tracingChannel) {
34
+ return;
35
+ }
36
+ core.waitForTracingChannelBinding(() => {
37
+ tracingChannel.bindTracingChannelToSpan(
38
+ diagnosticsChannel.tracingChannel(channels.CHANNELS.GRAPHQL_PARSE),
39
+ () => safe(() => spans.startParseSpan())
40
+ );
41
+ tracingChannel.bindTracingChannelToSpan(
42
+ diagnosticsChannel.tracingChannel(channels.CHANNELS.GRAPHQL_VALIDATE),
43
+ (data) => safe(() => spans.startValidateSpan(data.arguments[1])),
44
+ { beforeSpanEnd: (span, data) => void safe(() => spans.finalizeValidateSpan(span, data.result)) }
45
+ );
46
+ tracingChannel.bindTracingChannelToSpan(
47
+ diagnosticsChannel.tracingChannel(channels.CHANNELS.GRAPHQL_EXECUTE),
48
+ (data) => safe(() => spans.startExecuteSpan(data.arguments, data.self, config, getConfig)),
49
+ { beforeSpanEnd: (span, data) => void safe(() => spans.finalizeExecuteSpan(span, data.result)) }
50
+ );
51
+ });
52
+ }
53
+ };
54
+ });
55
+ const graphqlChannelIntegration = core.defineIntegration(_graphqlChannelIntegration);
56
+ const graphqlDiagnosticsChannelIntegration = (options) => {
57
+ const orchestrion = graphqlChannelIntegration(options);
58
+ return core.extendIntegration(index.graphqlIntegration(options), {
59
+ name: INTEGRATION_NAME,
60
+ setupOnce: () => orchestrion.setupOnce?.()
61
+ });
62
+ };
63
+
64
+ exports.graphqlChannelIntegration = graphqlChannelIntegration;
65
+ exports.graphqlDiagnosticsChannelIntegration = graphqlDiagnosticsChannelIntegration;
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing-channel/graphql/index.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn } from '@sentry/core';\nimport { debug, defineIntegration, extendIntegration, waitForTracingChannelBinding } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport { graphqlIntegration as graphqlNativeIntegration } from '../../../graphql';\nimport type { GraphqlDiagnosticChannelsOptions } from '../../../graphql/graphql-dc-subscriber';\nimport { CHANNELS } from '../../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../../tracing-channel';\nimport {\n finalizeExecuteSpan,\n finalizeValidateSpan,\n startExecuteSpan,\n startParseSpan,\n startValidateSpan,\n} from './spans';\nimport type { GraphqlResolvedConfig } from './types';\n\n// Same name as the OTel/native integration by design, so enabling injection swaps this in for it.\nconst INTEGRATION_NAME = 'Graphql' as const;\n\n// The context orchestrion's transform attaches to each channel: `arguments` is the live args of the\n// wrapped call, `result` the settled return value.\ninterface GraphqlChannelContext {\n arguments: unknown[];\n self?: unknown;\n result?: unknown;\n error?: unknown;\n}\n\nfunction getOptionsWithDefaults(options: GraphqlDiagnosticChannelsOptions): GraphqlResolvedConfig {\n return {\n ignoreResolveSpans: options.ignoreResolveSpans !== false,\n ignoreTrivialResolveSpans: options.ignoreTrivialResolveSpans !== false,\n useOperationNameForRootSpan: options.useOperationNameForRootSpan !== false,\n };\n}\n\n/**\n * Runs a span-building callback so a throw inside it can never break the user's graphql call: these\n * run inside the `tracingChannel(...).trace*` machinery wrapping the real function (as the `getSpan`\n * producer / `beforeSpanEnd` handler), where an unguarded throw would propagate into the traced call.\n */\nfunction safe<T>(fn: () => T): T | undefined {\n try {\n return fn();\n } catch (error) {\n DEBUG_BUILD && debug.warn('[orchestrion:graphql] error building span', error);\n return undefined;\n }\n}\n\nconst _graphqlChannelIntegration = ((options: GraphqlDiagnosticChannelsOptions = {}) => {\n const config = getOptionsWithDefaults(options);\n const getConfig = (): GraphqlResolvedConfig => config;\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!diagnosticsChannel.tracingChannel) {\n return;\n }\n\n waitForTracingChannelBinding(() => {\n bindTracingChannelToSpan(diagnosticsChannel.tracingChannel<GraphqlChannelContext>(CHANNELS.GRAPHQL_PARSE), () =>\n safe(() => startParseSpan()),\n );\n\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<GraphqlChannelContext>(CHANNELS.GRAPHQL_VALIDATE),\n data => safe(() => startValidateSpan(data.arguments[1])),\n { beforeSpanEnd: (span, data) => void safe(() => finalizeValidateSpan(span, data.result)) },\n );\n\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<GraphqlChannelContext>(CHANNELS.GRAPHQL_EXECUTE),\n data => safe(() => startExecuteSpan(data.arguments, data.self, config, getConfig)),\n { beforeSpanEnd: (span, data) => void safe(() => finalizeExecuteSpan(span, data.result)) },\n );\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * EXPERIMENTAL — orchestrion-driven graphql integration for graphql v14–16 (v17 publishes native\n * `diagnostics_channel` events handled by `@sentry/server-utils`'s graphql integration instead).\n *\n * Subscribes to the `orchestrion:graphql:{parse,validate,execute}` channels the orchestrion code\n * transform injects into `graphql`'s `language/parser.js`, `validation/validate.js` and\n * `execution/execute.js`, emitting spans identical to the native path. Requires the orchestrion\n * runtime hook or bundler plugin — wire it up via `experimentalUseDiagnosticsChannelInjection()`.\n *\n * @experimental\n */\nexport const graphqlChannelIntegration = defineIntegration(_graphqlChannelIntegration);\n\n/**\n * The complete graphql diagnostics-channel integration: the native subscriber (graphql v17) composed\n * with the orchestrion subscriber (v14–16), so opting into injection instruments every supported\n * version via diagnostics channels without the OTel patcher. Reuses the OTel `Graphql` name so\n * enabling injection swaps this in for it.\n */\nexport const graphqlDiagnosticsChannelIntegration = (options?: GraphqlDiagnosticChannelsOptions) => {\n const orchestrion = graphqlChannelIntegration(options);\n return extendIntegration(graphqlNativeIntegration(options), {\n name: INTEGRATION_NAME,\n setupOnce: () => orchestrion.setupOnce?.(),\n });\n};\n"],"names":["DEBUG_BUILD","debug","waitForTracingChannelBinding","bindTracingChannelToSpan","CHANNELS","startParseSpan","startValidateSpan","finalizeValidateSpan","startExecuteSpan","finalizeExecuteSpan","defineIntegration","extendIntegration","graphqlNativeIntegration"],"mappings":";;;;;;;;;;AAkBA,MAAM,gBAAA,GAAmB,SAAA;AAWzB,SAAS,uBAAuB,OAAA,EAAkE;AAChG,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,QAAQ,kBAAA,KAAuB,KAAA;AAAA,IACnD,yBAAA,EAA2B,QAAQ,yBAAA,KAA8B,KAAA;AAAA,IACjE,2BAAA,EAA6B,QAAQ,2BAAA,KAAgC;AAAA,GACvE;AACF;AAOA,SAAS,KAAQ,EAAA,EAA4B;AAC3C,EAAA,IAAI;AACF,IAAA,OAAO,EAAA,EAAG;AAAA,EACZ,SAAS,KAAA,EAAO;AACd,IAAAA,sBAAA,IAAeC,UAAA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,EAAM,IAAA,CAAK,MAAM,CAAC,CAAA;AAAE,SAC3F;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAA,CAAA;AAaO,MAAM,yBAAA,GAA4BC,uBAAkB,0BAA0B;AAQ9E,MAAM,oCAAA,GAAuC,CAAC,OAAA,KAA+C;AAClG,EAAA,MAAM,WAAA,GAAc,0BAA0B,OAAO,CAAA;AACrD,EAAA,OAAOC,sBAAA,CAAkBC,wBAAA,CAAyB,OAAO,CAAA,EAAG;AAAA,IAC1D,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,EAAW,MAAM,WAAA,CAAY,SAAA;AAAY,GAC1C,CAAA;AACH;;;;;"}
@@ -0,0 +1,168 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const op = require('@sentry/conventions/op');
4
+ const core = require('@sentry/core');
5
+ const constants = require('./constants.js');
6
+
7
+ function isPromise(value) {
8
+ return typeof value?.then === "function";
9
+ }
10
+ function wrapFields(type, getConfig) {
11
+ if (!type || type[constants.GRAPHQL_PATCHED_SYMBOL]) {
12
+ return;
13
+ }
14
+ type[constants.GRAPHQL_PATCHED_SYMBOL] = true;
15
+ const fields = type.getFields();
16
+ Object.keys(fields).forEach((key) => {
17
+ const field = fields[key];
18
+ if (!field) {
19
+ return;
20
+ }
21
+ if (field.resolve) {
22
+ field.resolve = wrapFieldResolver(getConfig, field.resolve);
23
+ }
24
+ if (field.type) {
25
+ for (const unwrappedType of unwrapType(field.type)) {
26
+ wrapFields(unwrappedType, getConfig);
27
+ }
28
+ }
29
+ });
30
+ }
31
+ function wrapFieldResolver(getConfig, fieldResolver, isDefaultResolver = false) {
32
+ if (typeof fieldResolver !== "function" || fieldResolver[constants.GRAPHQL_PATCHED_SYMBOL]) {
33
+ return fieldResolver;
34
+ }
35
+ function wrappedFieldResolver(source, args, rawContextValue, info) {
36
+ if (!fieldResolver) {
37
+ return void 0;
38
+ }
39
+ const contextValue = rawContextValue ?? {};
40
+ const config = getConfig();
41
+ if (config.ignoreTrivialResolveSpans && isDefaultResolver && (core.isObjectLike(source) || typeof source === "function")) {
42
+ const property = source[info.fieldName];
43
+ if (typeof property !== "function") {
44
+ return fieldResolver.call(this, source, args, contextValue, info);
45
+ }
46
+ }
47
+ if (!contextValue[constants.GRAPHQL_DATA_SYMBOL]) {
48
+ return fieldResolver.call(this, source, args, contextValue, info);
49
+ }
50
+ const path = pathToArray(info.path);
51
+ const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path);
52
+ const span = field.span;
53
+ return core.withActiveSpan(span, () => {
54
+ try {
55
+ const res = fieldResolver.call(this, source, args, contextValue, info);
56
+ if (isPromise(res)) {
57
+ return res.then(
58
+ (r) => {
59
+ endResolveSpan(span, spanAdded);
60
+ return r;
61
+ },
62
+ (err) => {
63
+ endResolveSpan(span, spanAdded, err);
64
+ throw err;
65
+ }
66
+ );
67
+ }
68
+ endResolveSpan(span, spanAdded);
69
+ return res;
70
+ } catch (err) {
71
+ endResolveSpan(span, spanAdded, err);
72
+ throw err;
73
+ }
74
+ });
75
+ }
76
+ wrappedFieldResolver[constants.GRAPHQL_PATCHED_SYMBOL] = true;
77
+ return wrappedFieldResolver;
78
+ }
79
+ function endResolveSpan(span, shouldEndSpan, error) {
80
+ if (!shouldEndSpan) {
81
+ return;
82
+ }
83
+ if (error) {
84
+ span.setStatus({ code: core.SPAN_STATUS_ERROR, message: error.message });
85
+ }
86
+ span.end();
87
+ }
88
+ function createFieldIfNotExists(contextValue, info, path) {
89
+ const existing = getField(contextValue, path);
90
+ if (existing) {
91
+ return { field: existing, spanAdded: false };
92
+ }
93
+ const field = { span: createResolverSpan(info, path, getParentFieldSpan(contextValue, path)) };
94
+ addField(contextValue, path, field);
95
+ return { field, spanAdded: true };
96
+ }
97
+ function createResolverSpan(info, path, parentSpan) {
98
+ const attributes = {
99
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: constants.ORIGIN,
100
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: op.WEB_SERVER_GRAPHQL_SPAN_OP,
101
+ [constants.GRAPHQL_FIELD_NAME]: info.fieldName,
102
+ [constants.GRAPHQL_FIELD_PATH]: path.join("."),
103
+ [constants.GRAPHQL_FIELD_TYPE]: info.returnType.toString(),
104
+ [constants.GRAPHQL_PARENT_NAME]: info.parentType.name
105
+ };
106
+ return core.startInactiveSpan({ name: `${constants.SPAN_NAME_RESOLVE} ${path.join(".")}`, attributes, parentSpan });
107
+ }
108
+ function addField(contextValue, path, field) {
109
+ const data = contextValue[constants.GRAPHQL_DATA_SYMBOL];
110
+ if (data) {
111
+ data.fields[path.join(".")] = field;
112
+ }
113
+ }
114
+ function getField(contextValue, path) {
115
+ return contextValue[constants.GRAPHQL_DATA_SYMBOL]?.fields[path.join(".")];
116
+ }
117
+ function getParentFieldSpan(contextValue, path) {
118
+ for (let i = path.length - 1; i > 0; i--) {
119
+ const field = getField(contextValue, path.slice(0, i));
120
+ if (field) {
121
+ return field.span;
122
+ }
123
+ }
124
+ return contextValue[constants.GRAPHQL_DATA_SYMBOL]?.span;
125
+ }
126
+ function pathToArray(path) {
127
+ const flattened = [];
128
+ let curr = path;
129
+ while (curr) {
130
+ flattened.push(String(curr.key));
131
+ curr = curr.prev;
132
+ }
133
+ return flattened.reverse();
134
+ }
135
+ function unwrapType(type) {
136
+ if ("ofType" in type && type.ofType) {
137
+ return unwrapType(type.ofType);
138
+ }
139
+ if (isGraphQLUnionType(type)) {
140
+ return type.getTypes();
141
+ }
142
+ if (isGraphQLObjectType(type)) {
143
+ return [type];
144
+ }
145
+ return [];
146
+ }
147
+ function isGraphQLUnionType(type) {
148
+ return "getTypes" in type && typeof type.getTypes === "function";
149
+ }
150
+ function isGraphQLObjectType(type) {
151
+ return "getFields" in type && typeof type.getFields === "function";
152
+ }
153
+ function getOperation(document, operationName) {
154
+ const definitions = document?.definitions;
155
+ if (!definitions || !Array.isArray(definitions)) {
156
+ return void 0;
157
+ }
158
+ const isOperation = (def) => !!def?.operation && ["query", "mutation", "subscription"].indexOf(def.operation) !== -1;
159
+ if (operationName) {
160
+ return definitions.filter(isOperation).find((def) => operationName === def?.name?.value);
161
+ }
162
+ return definitions.find(isOperation);
163
+ }
164
+
165
+ exports.getOperation = getOperation;
166
+ exports.wrapFieldResolver = wrapFieldResolver;
167
+ exports.wrapFields = wrapFields;
168
+ //# sourceMappingURL=resolvers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvers.js","sources":["../../../../../src/integrations/tracing-channel/graphql/resolvers.ts"],"sourcesContent":["/*\n * Resolver-span wrapping for the orchestrion graphql path. graphql v14–16 publishes no per-field\n * `resolve` channel (unlike v17's native one), so the schema's field resolvers are swapped for\n * span-creating proxies under the execute channel's `start` (the \"consumer trick\" — the transform\n * can't target user resolvers, but `execute` receives the schema, so we mutate it before the wrapped\n * call runs). Resolver spans use the same origin/op/field attributes as the native subscriber.\n */\n\nimport { WEB_SERVER_GRAPHQL_SPAN_OP } from '@sentry/conventions/op';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n isObjectLike,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport {\n GRAPHQL_DATA_SYMBOL,\n GRAPHQL_FIELD_NAME,\n GRAPHQL_FIELD_PATH,\n GRAPHQL_FIELD_TYPE,\n GRAPHQL_PARENT_NAME,\n GRAPHQL_PATCHED_SYMBOL,\n ORIGIN,\n SPAN_NAME_RESOLVE,\n} from './constants';\nimport type {\n DefinitionNode,\n DocumentNode,\n GraphQLFieldResolver,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLPath,\n GraphQLResolveInfo,\n GraphQLType,\n GraphQLUnionType,\n GraphqlResolvedConfig,\n Maybe,\n ObjectWithGraphQLData,\n Patched,\n} from './types';\n\nfunction isPromise(value: unknown): value is Promise<unknown> {\n return typeof (value as { then?: unknown } | undefined)?.then === 'function';\n}\n\n/**\n * Walks the query/mutation type tree and swaps each field's `resolve` for a span-creating proxy.\n * Idempotent per type via {@link GRAPHQL_PATCHED_SYMBOL}.\n */\nexport function wrapFields(type: Maybe<GraphQLObjectType & Patched>, getConfig: () => GraphqlResolvedConfig): void {\n if (!type || type[GRAPHQL_PATCHED_SYMBOL]) {\n return;\n }\n\n type[GRAPHQL_PATCHED_SYMBOL] = true;\n const fields = type.getFields();\n\n Object.keys(fields).forEach(key => {\n const field = fields[key];\n if (!field) {\n return;\n }\n\n if (field.resolve) {\n field.resolve = wrapFieldResolver(getConfig, field.resolve);\n }\n\n if (field.type) {\n for (const unwrappedType of unwrapType(field.type)) {\n wrapFields(unwrappedType, getConfig);\n }\n }\n });\n}\n\nexport function wrapFieldResolver(\n getConfig: () => GraphqlResolvedConfig,\n fieldResolver: Maybe<GraphQLFieldResolver & Patched>,\n isDefaultResolver = false,\n): GraphQLFieldResolver & Patched {\n // Return the resolver untouched if it isn't a function or is already a wrapped one — the wrapper we\n // return is marked with `GRAPHQL_PATCHED_SYMBOL` below precisely so it can be detected here. (The\n // guard must test the incoming `fieldResolver`, not the freshly-hoisted `wrappedFieldResolver`.)\n if (typeof fieldResolver !== 'function' || fieldResolver[GRAPHQL_PATCHED_SYMBOL]) {\n return fieldResolver as GraphQLFieldResolver;\n }\n\n function wrappedFieldResolver(\n this: unknown,\n source: unknown,\n args: unknown,\n rawContextValue: unknown,\n info: GraphQLResolveInfo,\n ): unknown {\n if (!fieldResolver) {\n return undefined;\n }\n\n const contextValue = (rawContextValue ?? {}) as ObjectWithGraphQLData;\n const config = getConfig();\n\n // Mirror graphql's own \"trivial resolver\" check: a default resolver that just reads a\n // non-function property is not worth a span.\n if (\n config.ignoreTrivialResolveSpans &&\n isDefaultResolver &&\n (isObjectLike(source) || typeof source === 'function')\n ) {\n const property = (source as Record<string, unknown>)[info.fieldName];\n if (typeof property !== 'function') {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n }\n\n if (!contextValue[GRAPHQL_DATA_SYMBOL]) {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n\n const path = pathToArray(info.path);\n const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path);\n const span = field.span;\n\n return withActiveSpan(span, () => {\n try {\n const res = fieldResolver.call(this, source, args, contextValue, info);\n if (isPromise(res)) {\n return res.then(\n r => {\n endResolveSpan(span, spanAdded);\n return r;\n },\n (err: Error) => {\n endResolveSpan(span, spanAdded, err);\n throw err;\n },\n );\n }\n endResolveSpan(span, spanAdded);\n return res;\n } catch (err) {\n endResolveSpan(span, spanAdded, err as Error);\n throw err;\n }\n });\n }\n\n (wrappedFieldResolver as Patched)[GRAPHQL_PATCHED_SYMBOL] = true;\n return wrappedFieldResolver;\n}\n\nfunction endResolveSpan(span: Span, shouldEndSpan: boolean, error?: Error): void {\n if (!shouldEndSpan) {\n return;\n }\n if (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n}\n\nfunction createFieldIfNotExists(\n contextValue: ObjectWithGraphQLData,\n info: GraphQLResolveInfo,\n path: string[],\n): { field: { span: Span }; spanAdded: boolean } {\n const existing = getField(contextValue, path);\n if (existing) {\n return { field: existing, spanAdded: false };\n }\n\n const field = { span: createResolverSpan(info, path, getParentFieldSpan(contextValue, path)) };\n addField(contextValue, path, field);\n return { field, spanAdded: true };\n}\n\nfunction createResolverSpan(info: GraphQLResolveInfo, path: string[], parentSpan?: Span): Span {\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: WEB_SERVER_GRAPHQL_SPAN_OP,\n [GRAPHQL_FIELD_NAME]: info.fieldName,\n [GRAPHQL_FIELD_PATH]: path.join('.'),\n [GRAPHQL_FIELD_TYPE]: info.returnType.toString(),\n [GRAPHQL_PARENT_NAME]: info.parentType.name,\n };\n\n return startInactiveSpan({ name: `${SPAN_NAME_RESOLVE} ${path.join('.')}`, attributes, parentSpan });\n}\n\nfunction addField(contextValue: ObjectWithGraphQLData, path: string[], field: { span: Span }): void {\n const data = contextValue[GRAPHQL_DATA_SYMBOL];\n if (data) {\n data.fields[path.join('.')] = field;\n }\n}\n\nfunction getField(contextValue: ObjectWithGraphQLData, path: string[]): { span: Span } | undefined {\n return contextValue[GRAPHQL_DATA_SYMBOL]?.fields[path.join('.')];\n}\n\nfunction getParentFieldSpan(contextValue: ObjectWithGraphQLData, path: string[]): Span | undefined {\n for (let i = path.length - 1; i > 0; i--) {\n const field = getField(contextValue, path.slice(0, i));\n if (field) {\n return field.span;\n }\n }\n return contextValue[GRAPHQL_DATA_SYMBOL]?.span;\n}\n\nfunction pathToArray(path: GraphQLPath): string[] {\n const flattened: string[] = [];\n let curr: GraphQLPath | undefined = path;\n while (curr) {\n flattened.push(String(curr.key));\n curr = curr.prev;\n }\n return flattened.reverse();\n}\n\nfunction unwrapType(type: GraphQLOutputType): readonly (GraphQLObjectType & Patched)[] {\n // The structural index signature widens `ofType` to `unknown`, so narrow it back explicitly.\n if ('ofType' in type && type.ofType) {\n return unwrapType(type.ofType as GraphQLOutputType);\n }\n if (isGraphQLUnionType(type)) {\n return type.getTypes();\n }\n if (isGraphQLObjectType(type)) {\n return [type];\n }\n return [];\n}\n\nfunction isGraphQLUnionType(type: GraphQLType): type is GraphQLUnionType {\n return 'getTypes' in type && typeof type.getTypes === 'function';\n}\n\nfunction isGraphQLObjectType(type: GraphQLType): type is GraphQLObjectType {\n return 'getFields' in type && typeof (type as GraphQLObjectType).getFields === 'function';\n}\n\n/**\n * Returns the operation definition for `operationName` (or the first operation) from a parsed\n * document, or `undefined` for schema documents / when no operation is present.\n */\nexport function getOperation(document: DocumentNode, operationName?: Maybe<string>): DefinitionNode | undefined {\n const definitions: readonly DefinitionNode[] | undefined = document?.definitions;\n if (!definitions || !Array.isArray(definitions)) {\n return undefined;\n }\n\n const isOperation = (def: DefinitionNode): boolean =>\n !!def?.operation && ['query', 'mutation', 'subscription'].indexOf(def.operation) !== -1;\n\n if (operationName) {\n return definitions.filter(isOperation).find((def: DefinitionNode) => operationName === def?.name?.value);\n }\n return definitions.find(isOperation);\n}\n"],"names":["GRAPHQL_PATCHED_SYMBOL","isObjectLike","GRAPHQL_DATA_SYMBOL","withActiveSpan","SPAN_STATUS_ERROR","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","WEB_SERVER_GRAPHQL_SPAN_OP","GRAPHQL_FIELD_NAME","GRAPHQL_FIELD_PATH","GRAPHQL_FIELD_TYPE","GRAPHQL_PARENT_NAME","startInactiveSpan","SPAN_NAME_RESOLVE"],"mappings":";;;;;;AA4CA,SAAS,UAAU,KAAA,EAA2C;AAC5D,EAAA,OAAO,OAAQ,OAA0C,IAAA,KAAS,UAAA;AACpE;AAMO,SAAS,UAAA,CAAW,MAA0C,SAAA,EAA8C;AACjH,EAAA,IAAI,CAAC,IAAA,IAAQ,IAAA,CAAKA,gCAAsB,CAAA,EAAG;AACzC,IAAA;AAAA,EACF;AAEA,EAAA,IAAA,CAAKA,gCAAsB,CAAA,GAAI,IAAA;AAC/B,EAAA,MAAM,MAAA,GAAS,KAAK,SAAA,EAAU;AAE9B,EAAA,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAAE,OAAA,CAAQ,CAAA,GAAA,KAAO;AACjC,IAAA,MAAM,KAAA,GAAQ,OAAO,GAAG,CAAA;AACxB,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,MAAM,OAAA,EAAS;AACjB,MAAA,KAAA,CAAM,OAAA,GAAU,iBAAA,CAAkB,SAAA,EAAW,KAAA,CAAM,OAAO,CAAA;AAAA,IAC5D;AAEA,IAAA,IAAI,MAAM,IAAA,EAAM;AACd,MAAA,KAAA,MAAW,aAAA,IAAiB,UAAA,CAAW,KAAA,CAAM,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AAA,EAA6C;AACvE,EAAA,OAAO,UAAA,IAAc,IAAA,IAAQ,OAAO,IAAA,CAAK,QAAA,KAAa,UAAA;AACxD;AAEA,SAAS,oBAAoB,IAAA,EAA8C;AACzE,EAAA,OAAO,WAAA,IAAe,IAAA,IAAQ,OAAQ,IAAA,CAA2B,SAAA,KAAc,UAAA;AACjF;AAMO,SAAS,YAAA,CAAa,UAAwB,aAAA,EAA2D;AAC9G,EAAA,MAAM,cAAqD,QAAA,EAAU,WAAA;AACrE,EAAA,IAAI,CAAC,WAAA,IAAe,CAAC,KAAA,CAAM,OAAA,CAAQ,WAAW,CAAA,EAAG;AAC/C,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,WAAA,GAAc,CAAC,GAAA,KACnB,CAAC,CAAC,GAAA,EAAK,SAAA,IAAa,CAAC,OAAA,EAAS,YAAY,cAAc,CAAA,CAAE,OAAA,CAAQ,GAAA,CAAI,SAAS,CAAA,KAAM,EAAA;AAEvF,EAAA,IAAI,aAAA,EAAe;AACjB,IAAA,OAAO,WAAA,CAAY,MAAA,CAAO,WAAW,CAAA,CAAE,IAAA,CAAK,CAAC,GAAA,KAAwB,aAAA,KAAkB,GAAA,EAAK,IAAA,EAAM,KAAK,CAAA;AAAA,EACzG;AACA,EAAA,OAAO,WAAA,CAAY,KAAK,WAAW,CAAA;AACrC;;;;;;"}
@@ -0,0 +1,102 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const attributes = require('@sentry/conventions/attributes');
4
+ const op = require('@sentry/conventions/op');
5
+ const core = require('@sentry/core');
6
+ const utils = require('../../../graphql/utils.js');
7
+ const constants = require('./constants.js');
8
+ const resolvers = require('./resolvers.js');
9
+
10
+ const BASE_ATTRIBUTES = {
11
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: constants.ORIGIN,
12
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: op.WEB_SERVER_GRAPHQL_SPAN_OP
13
+ };
14
+ function startParseSpan() {
15
+ return core.startInactiveSpan({ name: constants.SPAN_NAME_PARSE, attributes: { ...BASE_ATTRIBUTES } });
16
+ }
17
+ function startValidateSpan(documentAST) {
18
+ return core.startInactiveSpan({
19
+ name: constants.SPAN_NAME_VALIDATE,
20
+ attributes: { ...BASE_ATTRIBUTES, [attributes.GRAPHQL_DOCUMENT]: utils.redactGraphqlDocument(documentAST) }
21
+ });
22
+ }
23
+ function finalizeValidateSpan(span, result) {
24
+ if (Array.isArray(result) && result.length > 0) {
25
+ span.setStatus({ code: core.SPAN_STATUS_ERROR, message: "invalid_argument" });
26
+ }
27
+ }
28
+ function normalizeExecuteArgs(argsArray) {
29
+ if (argsArray.length >= 2) {
30
+ return {
31
+ schema: argsArray[0 /* SCHEMA */],
32
+ document: argsArray[1 /* DOCUMENT */],
33
+ contextValue: argsArray[3 /* CONTEXT_VALUE */] ?? {},
34
+ operationName: argsArray[5 /* OPERATION_NAME */],
35
+ fieldResolver: argsArray[6 /* FIELD_RESOLVER */],
36
+ writeBack: (contextValue, fieldResolver) => {
37
+ argsArray[3 /* CONTEXT_VALUE */] = contextValue;
38
+ argsArray[6 /* FIELD_RESOLVER */] = fieldResolver;
39
+ }
40
+ };
41
+ }
42
+ const obj = argsArray[0] ?? {};
43
+ return {
44
+ schema: obj.schema,
45
+ document: obj.document,
46
+ contextValue: obj.contextValue ?? {},
47
+ operationName: obj.operationName,
48
+ fieldResolver: obj.fieldResolver,
49
+ writeBack: (contextValue, fieldResolver) => {
50
+ obj.contextValue = contextValue;
51
+ obj.fieldResolver = fieldResolver;
52
+ }
53
+ };
54
+ }
55
+ function startExecuteSpan(argsArray, self, config, getConfig) {
56
+ const args = normalizeExecuteArgs(argsArray);
57
+ const { schema, document } = args;
58
+ let { contextValue, fieldResolver } = args;
59
+ const alreadyInstrumented = !!contextValue[constants.GRAPHQL_DATA_SYMBOL];
60
+ if (!config.ignoreResolveSpans && !alreadyInstrumented) {
61
+ const isUsingDefaultResolver = fieldResolver == null;
62
+ const defaultFieldResolver = self?.defaultFieldResolver;
63
+ const fieldResolverForExecute = fieldResolver ?? defaultFieldResolver;
64
+ if (fieldResolverForExecute) {
65
+ fieldResolver = resolvers.wrapFieldResolver(getConfig, fieldResolverForExecute, isUsingDefaultResolver);
66
+ }
67
+ if (schema) {
68
+ resolvers.wrapFields(schema.getQueryType(), getConfig);
69
+ resolvers.wrapFields(schema.getMutationType(), getConfig);
70
+ }
71
+ }
72
+ const operation = resolvers.getOperation(document, args.operationName);
73
+ const operationType = operation?.operation;
74
+ const operationName = operation?.name?.value ?? args.operationName ?? void 0;
75
+ const span = core.startInactiveSpan({
76
+ name: utils.getOperationSpanName(operationType, operationName || void 0, constants.SPAN_NAME_EXECUTE),
77
+ attributes: {
78
+ ...BASE_ATTRIBUTES,
79
+ [attributes.GRAPHQL_OPERATION_TYPE]: operationType,
80
+ [attributes.GRAPHQL_OPERATION_NAME]: operationName || void 0,
81
+ [attributes.GRAPHQL_DOCUMENT]: utils.redactGraphqlDocument(document)
82
+ }
83
+ });
84
+ if (config.useOperationNameForRootSpan && operationType) {
85
+ utils.renameRootSpanWithOperation(span, operationType, operationName || void 0);
86
+ }
87
+ contextValue[constants.GRAPHQL_DATA_SYMBOL] = { source: document, span, fields: {} };
88
+ args.writeBack(contextValue, fieldResolver);
89
+ return span;
90
+ }
91
+ function finalizeExecuteSpan(span, result) {
92
+ if (utils.hasResultErrors(result)) {
93
+ span.setStatus({ code: core.SPAN_STATUS_ERROR, message: "internal_error" });
94
+ }
95
+ }
96
+
97
+ exports.finalizeExecuteSpan = finalizeExecuteSpan;
98
+ exports.finalizeValidateSpan = finalizeValidateSpan;
99
+ exports.startExecuteSpan = startExecuteSpan;
100
+ exports.startParseSpan = startParseSpan;
101
+ exports.startValidateSpan = startValidateSpan;
102
+ //# sourceMappingURL=spans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spans.js","sources":["../../../../../src/integrations/tracing-channel/graphql/spans.ts"],"sourcesContent":["/*\n * Span builders for the orchestrion graphql channels (v14–16). They emit the same spans as the native\n * `diagnostics_channel` subscriber (`../../../graphql/graphql-dc-subscriber.ts`, graphql >= 17) by\n * reusing its `utils` and conventions — only the data source differs: here the payloads are the raw\n * arguments of the injected `parse`/`validate`/`execute` calls rather than graphql's native events.\n */\n\nimport { GRAPHQL_DOCUMENT, GRAPHQL_OPERATION_NAME, GRAPHQL_OPERATION_TYPE } from '@sentry/conventions/attributes';\nimport { WEB_SERVER_GRAPHQL_SPAN_OP } from '@sentry/conventions/op';\nimport type { Span } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n} from '@sentry/core';\nimport type { GraphqlDocumentNode } from '../../../graphql/utils';\nimport {\n getOperationSpanName,\n hasResultErrors,\n redactGraphqlDocument,\n renameRootSpanWithOperation,\n} from '../../../graphql/utils';\nimport { GRAPHQL_DATA_SYMBOL, ORIGIN, SPAN_NAME_EXECUTE, SPAN_NAME_PARSE, SPAN_NAME_VALIDATE } from './constants';\nimport { getOperation, wrapFields, wrapFieldResolver } from './resolvers';\nimport type {\n DocumentNode,\n GraphQLFieldResolver,\n GraphQLSchema,\n GraphqlResolvedConfig,\n Maybe,\n ObjectWithGraphQLData,\n} from './types';\n\nconst BASE_ATTRIBUTES = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: WEB_SERVER_GRAPHQL_SPAN_OP,\n} as const;\n\nexport function startParseSpan(): Span {\n return startInactiveSpan({ name: SPAN_NAME_PARSE, attributes: { ...BASE_ATTRIBUTES } });\n}\n\n/** `documentAST` is the 2nd argument to `validate(schema, documentAST, …)`. */\nexport function startValidateSpan(documentAST: unknown): Span {\n return startInactiveSpan({\n name: SPAN_NAME_VALIDATE,\n attributes: { ...BASE_ATTRIBUTES, [GRAPHQL_DOCUMENT]: redactGraphqlDocument(documentAST as GraphqlDocumentNode) },\n });\n}\n\n/** `result` is validation's return value: a (possibly empty) array of errors. */\nexport function finalizeValidateSpan(span: Span, result: unknown): void {\n if (Array.isArray(result) && result.length > 0) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'invalid_argument' });\n }\n}\n\n/** Positional slots of a `graphql.execute(schema, document, …)` call (v14/v15 legacy signature). */\nconst enum ExecuteArg {\n SCHEMA = 0,\n DOCUMENT = 1,\n CONTEXT_VALUE = 3,\n OPERATION_NAME = 5,\n FIELD_RESOLVER = 6,\n}\n\ninterface NormalizedExecuteArgs {\n schema?: GraphQLSchema;\n document?: DocumentNode;\n contextValue: ObjectWithGraphQLData;\n operationName?: Maybe<string>;\n fieldResolver?: Maybe<GraphQLFieldResolver>;\n /** Writes `contextValue`/`fieldResolver` mutations back to the live channel `arguments`. */\n writeBack: (contextValue: ObjectWithGraphQLData, fieldResolver: Maybe<GraphQLFieldResolver>) => void;\n}\n\n/**\n * `execute` accepts either a single `ExecutionArgs` object (modern callers, always in v16) or\n * positional args (v14/v15). Both are normalized here; `writeBack` puts mutations onto the correct\n * slot so they reach the real call.\n */\nfunction normalizeExecuteArgs(argsArray: unknown[]): NormalizedExecuteArgs {\n if (argsArray.length >= 2) {\n return {\n schema: argsArray[ExecuteArg.SCHEMA] as GraphQLSchema | undefined,\n document: argsArray[ExecuteArg.DOCUMENT] as DocumentNode | undefined,\n contextValue: (argsArray[ExecuteArg.CONTEXT_VALUE] ?? {}) as ObjectWithGraphQLData,\n operationName: argsArray[ExecuteArg.OPERATION_NAME] as Maybe<string>,\n fieldResolver: argsArray[ExecuteArg.FIELD_RESOLVER] as Maybe<GraphQLFieldResolver>,\n writeBack: (contextValue, fieldResolver) => {\n argsArray[ExecuteArg.CONTEXT_VALUE] = contextValue;\n argsArray[ExecuteArg.FIELD_RESOLVER] = fieldResolver;\n },\n };\n }\n\n const obj = (argsArray[0] ?? {}) as {\n schema?: GraphQLSchema;\n document?: DocumentNode;\n contextValue?: unknown;\n operationName?: Maybe<string>;\n fieldResolver?: Maybe<GraphQLFieldResolver>;\n };\n return {\n schema: obj.schema,\n document: obj.document,\n contextValue: (obj.contextValue ?? {}) as ObjectWithGraphQLData,\n operationName: obj.operationName,\n fieldResolver: obj.fieldResolver,\n writeBack: (contextValue, fieldResolver) => {\n obj.contextValue = contextValue;\n obj.fieldResolver = fieldResolver;\n },\n };\n}\n\n/**\n * Opens the execute span and, unless resolver spans are disabled, swaps the schema's field resolvers\n * (and the default field resolver) for span-creating proxies — mutating the live `arguments` in place\n * so the wrapped `execute` call runs with them. Always returns a span; the caller guards against\n * throws (see `safe` in `index.ts`).\n */\nexport function startExecuteSpan(\n argsArray: unknown[],\n self: unknown,\n config: GraphqlResolvedConfig,\n getConfig: () => GraphqlResolvedConfig,\n): Span {\n const args = normalizeExecuteArgs(argsArray);\n const { schema, document } = args;\n let { contextValue, fieldResolver } = args;\n\n // Skip resolver wrapping when disabled or when a parent execute already set up this context\n // (nested execute reusing the same contextValue).\n const alreadyInstrumented = !!contextValue[GRAPHQL_DATA_SYMBOL];\n if (!config.ignoreResolveSpans && !alreadyInstrumented) {\n const isUsingDefaultResolver = fieldResolver == null;\n const defaultFieldResolver = (self as { defaultFieldResolver?: GraphQLFieldResolver } | undefined)\n ?.defaultFieldResolver;\n const fieldResolverForExecute = fieldResolver ?? defaultFieldResolver;\n if (fieldResolverForExecute) {\n fieldResolver = wrapFieldResolver(getConfig, fieldResolverForExecute, isUsingDefaultResolver);\n }\n\n if (schema) {\n wrapFields(schema.getQueryType(), getConfig);\n wrapFields(schema.getMutationType(), getConfig);\n }\n }\n\n // v14–16 channels carry only the raw args, so derive the operation from the document (native v17\n // provides `operationType`/`operationName` on the event directly).\n const operation = getOperation(document as DocumentNode, args.operationName);\n const operationType = operation?.operation;\n const operationName = operation?.name?.value ?? args.operationName ?? undefined;\n\n const span = startInactiveSpan({\n name: getOperationSpanName(operationType, operationName || undefined, SPAN_NAME_EXECUTE),\n attributes: {\n ...BASE_ATTRIBUTES,\n [GRAPHQL_OPERATION_TYPE]: operationType,\n [GRAPHQL_OPERATION_NAME]: operationName || undefined,\n [GRAPHQL_DOCUMENT]: redactGraphqlDocument(document as GraphqlDocumentNode | undefined),\n },\n });\n\n if (config.useOperationNameForRootSpan && operationType) {\n renameRootSpanWithOperation(span, operationType, operationName || undefined);\n }\n\n // The resolver proxies read the execute span (and their own bookkeeping) off this symbol.\n contextValue[GRAPHQL_DATA_SYMBOL] = { source: document, span, fields: {} };\n args.writeBack(contextValue, fieldResolver);\n\n return span;\n}\n\n/** `result` is the settled `ExecutionResult`; GraphQL errors surface on `result.errors`, not a throw. */\nexport function finalizeExecuteSpan(span: Span, result: unknown): void {\n if (hasResultErrors(result)) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","WEB_SERVER_GRAPHQL_SPAN_OP","startInactiveSpan","SPAN_NAME_PARSE","SPAN_NAME_VALIDATE","GRAPHQL_DOCUMENT","redactGraphqlDocument","SPAN_STATUS_ERROR","GRAPHQL_DATA_SYMBOL","wrapFieldResolver","wrapFields","getOperation","getOperationSpanName","SPAN_NAME_EXECUTE","GRAPHQL_OPERATION_TYPE","GRAPHQL_OPERATION_NAME","renameRootSpanWithOperation","hasResultErrors"],"mappings":";;;;;;;;;AAkCA,MAAM,eAAA,GAAkB;AAAA,EACtB,CAACA,qCAAgC,GAAGC,gBAAA;AAAA,EACpC,CAACC,iCAA4B,GAAGC;AAClC,CAAA;AAEO,SAAS,cAAA,GAAuB;AACrC,EAAA,OAAOC,sBAAA,CAAkB,EAAE,IAAA,EAAMC,yBAAA,EAAiB,YAAY,EAAE,GAAG,eAAA,EAAgB,EAAG,CAAA;AACxF;AAGO,SAAS,kBAAkB,WAAA,EAA4B;AAC5D,EAAA,OAAOD,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OAAOT,sBAAA,CAAkB;AAAA,IAC7B,IAAA,EAAMU,0BAAA,CAAqB,aAAA,EAAe,aAAA,IAAiB,QAAWC,2BAAiB,CAAA;AAAA,IACvF,UAAA,EAAY;AAAA,MACV,GAAG,eAAA;AAAA,MACH,CAACC,iCAAsB,GAAG,aAAA;AAAA,MAC1B,CAACC,iCAAsB,GAAG,aAAA,IAAiB,MAAA;AAAA,MAC3C,CAACV,2BAAgB,GAAGC,2BAAA,CAAsB,QAA2C;AAAA;AACvF,GACD,CAAA;AAED,EAAA,IAAI,MAAA,CAAO,+BAA+B,aAAA,EAAe;AACvD,IAAAU,iCAAA,CAA4B,IAAA,EAAM,aAAA,EAAe,aAAA,IAAiB,MAAS,CAAA;AAAA,EAC7E;AAGA,EAAA,YAAA,CAAaR,6BAAmB,IAAI,EAAE,MAAA,EAAQ,UAAU,IAAA,EAAM,MAAA,EAAQ,EAAC,EAAE;AACzE,EAAA,IAAA,CAAK,SAAA,CAAU,cAAc,aAAa,CAAA;AAE1C,EAAA,OAAO,IAAA;AACT;AAGO,SAAS,mBAAA,CAAoB,MAAY,MAAA,EAAuB;AACrE,EAAA,IAAIS,qBAAA,CAAgB,MAAM,CAAA,EAAG;AAC3B,IAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAMV,sBAAA,EAAmB,OAAA,EAAS,kBAAkB,CAAA;AAAA,EACvE;AACF;;;;;;;;"}
@@ -0,0 +1,30 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const LIFECYCLE_EXT_POINTS = [
4
+ "onPreAuth",
5
+ "onCredentials",
6
+ "onPostAuth",
7
+ "onPreHandler",
8
+ "onPostHandler",
9
+ "onPreResponse",
10
+ "onRequest"
11
+ ];
12
+ const handlerPatched = /* @__PURE__ */ Symbol("hapi-handler-patched");
13
+ const HapiLayerType = {
14
+ ROUTER: "router",
15
+ PLUGIN: "plugin",
16
+ EXT: "server.ext"
17
+ };
18
+ const HapiLifecycleMethodNames = new Set(LIFECYCLE_EXT_POINTS);
19
+ var AttributeNames = /* @__PURE__ */ ((AttributeNames2) => {
20
+ AttributeNames2["HAPI_TYPE"] = "hapi.type";
21
+ AttributeNames2["PLUGIN_NAME"] = "hapi.plugin.name";
22
+ AttributeNames2["EXT_TYPE"] = "server.ext.type";
23
+ return AttributeNames2;
24
+ })(AttributeNames || {});
25
+
26
+ exports.AttributeNames = AttributeNames;
27
+ exports.HapiLayerType = HapiLayerType;
28
+ exports.HapiLifecycleMethodNames = HapiLifecycleMethodNames;
29
+ exports.handlerPatched = handlerPatched;
30
+ //# sourceMappingURL=hapi-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hapi-types.js","sources":["../../../../src/integrations/tracing-channel/hapi-types.ts"],"sourcesContent":["/*\n * Structural type definitions and constants ported from the vendored\n * `@opentelemetry/instrumentation-hapi` types, with all `@hapi/*` and\n * `@opentelemetry/*` dependencies removed. Only the shapes actually accessed by\n * the orchestrion hapi subscriber are kept.\n */\n\n// Single source of truth for the request lifecycle extension points, so the\n// `ServerRequestExtType` union and the runtime `HapiLifecycleMethodNames` set\n// below can't drift apart.\nconst LIFECYCLE_EXT_POINTS = [\n 'onPreAuth',\n 'onCredentials',\n 'onPostAuth',\n 'onPreHandler',\n 'onPostHandler',\n 'onPreResponse',\n 'onRequest',\n] as const;\n\nexport type ServerRequestExtType = (typeof LIFECYCLE_EXT_POINTS)[number];\n\nexport type LifecycleMethod = (request: unknown, h: unknown, err?: Error) => unknown;\n\nexport interface ServerRouteOptions {\n handler?: LifecycleMethod | unknown;\n [key: string]: unknown;\n}\n\nexport interface ServerRoute {\n path: string;\n method: string;\n handler?: LifecycleMethod | unknown;\n options?: ((server: unknown) => ServerRouteOptions) | ServerRouteOptions;\n [key: string]: unknown;\n}\n\nexport interface ServerExtEventsObject {\n type: string;\n [key: string]: unknown;\n}\n\nexport interface ServerExtEventsRequestObject {\n type: ServerRequestExtType;\n method: LifecycleMethod;\n [key: string]: unknown;\n}\n\nexport interface ServerExtOptions {\n [key: string]: unknown;\n}\n\n/**\n * This symbol is used to mark a Hapi route handler or server extension handler as\n * already patched, since it's possible to use these handlers multiple times\n * i.e. when allowing multiple versions of one plugin, or when registering a plugin\n * multiple times on different servers.\n */\nexport const handlerPatched: unique symbol = Symbol('hapi-handler-patched');\n\nexport type PatchableServerRoute = ServerRoute & {\n [handlerPatched]?: boolean;\n};\n\nexport type PatchableExtMethod = LifecycleMethod & {\n [handlerPatched]?: boolean;\n};\n\nexport type ServerExtDirectInput = [ServerRequestExtType, LifecycleMethod, (ServerExtOptions | undefined)?];\n\nexport const HapiLayerType = {\n ROUTER: 'router',\n PLUGIN: 'plugin',\n EXT: 'server.ext',\n} as const;\n\nexport const HapiLifecycleMethodNames = new Set<string>(LIFECYCLE_EXT_POINTS);\n\nexport enum AttributeNames {\n HAPI_TYPE = 'hapi.type',\n PLUGIN_NAME = 'hapi.plugin.name',\n EXT_TYPE = 'server.ext.type',\n}\n"],"names":["AttributeNames"],"mappings":";;AAUA,MAAM,oBAAA,GAAuB;AAAA,EAC3B,WAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAA;AAwCO,MAAM,cAAA,0BAAuC,sBAAsB;AAYnE,MAAM,aAAA,GAAgB;AAAA,EAC3B,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,GAAA,EAAK;AACP;AAEO,MAAM,wBAAA,GAA2B,IAAI,GAAA,CAAY,oBAAoB;AAErE,IAAK,cAAA,qBAAAA,eAAAA,KAAL;AACL,EAAAA,gBAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,gBAAA,aAAA,CAAA,GAAc,kBAAA;AACd,EAAAA,gBAAA,UAAA,CAAA,GAAW,iBAAA;AAHD,EAAA,OAAAA,eAAAA;AAAA,CAAA,EAAA,cAAA,IAAA,EAAA;;;;;;;"}
@@ -0,0 +1,177 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const attributes = require('@sentry/conventions/attributes');
5
+ const hapiTypes = require('./hapi-types.js');
6
+
7
+ function setHttpServerSpanRouteAttribute(route) {
8
+ const activeSpan = core.getActiveSpan();
9
+ if (!activeSpan) {
10
+ return;
11
+ }
12
+ const rootSpan = core.getRootSpan(activeSpan);
13
+ if (!rootSpan) {
14
+ return;
15
+ }
16
+ if (core.spanToJSON(rootSpan).data[core.SEMANTIC_ATTRIBUTE_SENTRY_OP] !== "http.server") {
17
+ return;
18
+ }
19
+ rootSpan.setAttribute(attributes.HTTP_ROUTE, route);
20
+ }
21
+ const isLifecycleExtType = (variableToCheck) => {
22
+ return typeof variableToCheck === "string" && hapiTypes.HapiLifecycleMethodNames.has(variableToCheck);
23
+ };
24
+ const isLifecycleExtEventObj = (variableToCheck) => {
25
+ const event = variableToCheck?.type;
26
+ return event !== void 0 && isLifecycleExtType(event);
27
+ };
28
+ const isDirectExtInput = (variableToCheck) => {
29
+ return Array.isArray(variableToCheck) && variableToCheck.length <= 3 && isLifecycleExtType(variableToCheck[0]) && typeof variableToCheck[1] === "function";
30
+ };
31
+ const isPatchableExtMethod = (variableToCheck) => {
32
+ return !Array.isArray(variableToCheck);
33
+ };
34
+ const getRouteMetadata = (route, pluginName) => {
35
+ const attributes$1 = {
36
+ [attributes.HTTP_ROUTE]: route.path,
37
+ // eslint-disable-next-line typescript/no-deprecated -- TODO(v11): Replace deprecated attributes
38
+ [attributes.HTTP_METHOD]: route.method
39
+ };
40
+ let name;
41
+ if (pluginName) {
42
+ attributes$1[hapiTypes.AttributeNames.HAPI_TYPE] = hapiTypes.HapiLayerType.PLUGIN;
43
+ attributes$1[hapiTypes.AttributeNames.PLUGIN_NAME] = pluginName;
44
+ name = `${pluginName}: route - ${route.path}`;
45
+ } else {
46
+ attributes$1[hapiTypes.AttributeNames.HAPI_TYPE] = hapiTypes.HapiLayerType.ROUTER;
47
+ name = `route - ${route.path}`;
48
+ }
49
+ return { attributes: attributes$1, name };
50
+ };
51
+ const getExtMetadata = (extPoint, pluginName, methodName) => {
52
+ let baseName = `ext - ${extPoint}`;
53
+ if (methodName && methodName !== "method") {
54
+ baseName = `ext - ${extPoint} - ${methodName}`;
55
+ }
56
+ if (pluginName) {
57
+ return {
58
+ attributes: {
59
+ [hapiTypes.AttributeNames.EXT_TYPE]: extPoint,
60
+ [hapiTypes.AttributeNames.HAPI_TYPE]: hapiTypes.HapiLayerType.EXT,
61
+ [hapiTypes.AttributeNames.PLUGIN_NAME]: pluginName
62
+ },
63
+ name: `${pluginName}: ${baseName}`
64
+ };
65
+ }
66
+ return {
67
+ attributes: {
68
+ [hapiTypes.AttributeNames.EXT_TYPE]: extPoint,
69
+ [hapiTypes.AttributeNames.HAPI_TYPE]: hapiTypes.HapiLayerType.EXT
70
+ },
71
+ name: baseName
72
+ };
73
+ };
74
+ function startMetadataSpan(metadata, original) {
75
+ return core.startSpan(
76
+ {
77
+ name: metadata.name,
78
+ op: `${metadata.attributes[hapiTypes.AttributeNames.HAPI_TYPE]}.hapi`,
79
+ attributes: {
80
+ ...metadata.attributes,
81
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.http.orchestrion.hapi"
82
+ }
83
+ },
84
+ original
85
+ );
86
+ }
87
+ function wrapRouteHandler(route, pluginName) {
88
+ if (route[hapiTypes.handlerPatched] === true) return route;
89
+ route[hapiTypes.handlerPatched] = true;
90
+ const wrapHandler = (oldHandler) => {
91
+ return function(...params) {
92
+ if (!core.getActiveSpan()) {
93
+ return oldHandler.call(this, ...params);
94
+ }
95
+ setHttpServerSpanRouteAttribute(route.path);
96
+ const metadata = getRouteMetadata(route, pluginName);
97
+ return startMetadataSpan(metadata, () => oldHandler.call(this, ...params));
98
+ };
99
+ };
100
+ if (typeof route.handler === "function") {
101
+ route.handler = wrapHandler(route.handler);
102
+ } else if (typeof route.options === "function") {
103
+ const oldOptions = route.options;
104
+ route.options = function(server) {
105
+ const options = oldOptions(server);
106
+ if (typeof options.handler === "function") {
107
+ options.handler = wrapHandler(options.handler);
108
+ }
109
+ return options;
110
+ };
111
+ } else if (typeof route.options?.handler === "function") {
112
+ route.options.handler = wrapHandler(route.options.handler);
113
+ }
114
+ return route;
115
+ }
116
+ function wrapExtMethods(method, extPoint, pluginName) {
117
+ if (Array.isArray(method)) {
118
+ for (let i = 0; i < method.length; i++) {
119
+ method[i] = wrapExtMethods(method[i], extPoint);
120
+ }
121
+ return method;
122
+ } else if (isPatchableExtMethod(method)) {
123
+ if (method[hapiTypes.handlerPatched] === true) return method;
124
+ method[hapiTypes.handlerPatched] = true;
125
+ const newHandler = function(...params) {
126
+ if (!core.getActiveSpan()) {
127
+ return method.apply(this, params);
128
+ }
129
+ const metadata = getExtMetadata(extPoint, pluginName, method.name);
130
+ return startMetadataSpan(metadata, () => method.apply(void 0, params));
131
+ };
132
+ newHandler[hapiTypes.handlerPatched] = true;
133
+ return newHandler;
134
+ }
135
+ return method;
136
+ }
137
+ function wrapRouteArguments(args, pluginName) {
138
+ const route = args[0];
139
+ if (Array.isArray(route)) {
140
+ for (let i = 0; i < route.length; i++) {
141
+ route[i] = wrapRouteHandler(route[i], pluginName);
142
+ }
143
+ } else {
144
+ args[0] = wrapRouteHandler(route, pluginName);
145
+ }
146
+ }
147
+ function wrapExtArguments(args, pluginName) {
148
+ if (Array.isArray(args[0])) {
149
+ const eventsList = args[0];
150
+ for (let i = 0; i < eventsList.length; i++) {
151
+ const eventObj = eventsList[i];
152
+ if (isLifecycleExtType(eventObj.type)) {
153
+ const lifecycleEventObj = eventObj;
154
+ const handler = wrapExtMethods(lifecycleEventObj.method, eventObj.type, pluginName);
155
+ lifecycleEventObj.method = handler;
156
+ eventsList[i] = lifecycleEventObj;
157
+ }
158
+ }
159
+ return;
160
+ } else if (isDirectExtInput(args)) {
161
+ const extInput = args;
162
+ const method = extInput[1];
163
+ const handler = wrapExtMethods(method, extInput[0], pluginName);
164
+ args[1] = handler;
165
+ return;
166
+ } else if (isLifecycleExtEventObj(args[0])) {
167
+ const lifecycleEventObj = args[0];
168
+ const handler = wrapExtMethods(lifecycleEventObj.method, lifecycleEventObj.type, pluginName);
169
+ lifecycleEventObj.method = handler;
170
+ }
171
+ }
172
+
173
+ exports.getExtMetadata = getExtMetadata;
174
+ exports.getRouteMetadata = getRouteMetadata;
175
+ exports.wrapExtArguments = wrapExtArguments;
176
+ exports.wrapRouteArguments = wrapRouteArguments;
177
+ //# sourceMappingURL=hapi-utils.js.map