@sentry/node 10.61.0 → 10.63.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 (385) hide show
  1. package/build/cjs/integrations/featureFlagShims/launchDarkly.js.map +1 -1
  2. package/build/cjs/integrations/featureFlagShims/openFeature.js.map +1 -1
  3. package/build/cjs/integrations/featureFlagShims/statsig.js.map +1 -1
  4. package/build/cjs/integrations/featureFlagShims/unleash.js.map +1 -1
  5. package/build/cjs/integrations/fs/index.js.map +1 -1
  6. package/build/cjs/integrations/http.js.map +1 -1
  7. package/build/cjs/integrations/node-fetch/index.js +7 -49
  8. package/build/cjs/integrations/node-fetch/index.js.map +1 -1
  9. package/build/cjs/integrations/node-fetch/undici-instrumentation.js +266 -0
  10. package/build/cjs/integrations/node-fetch/undici-instrumentation.js.map +1 -0
  11. package/build/cjs/integrations/tracing/amqplib/index.js +2 -10
  12. package/build/cjs/integrations/tracing/amqplib/index.js.map +1 -1
  13. package/build/cjs/integrations/tracing/amqplib/vendored/instrumentation.js +117 -0
  14. package/build/cjs/integrations/tracing/amqplib/vendored/instrumentation.js.map +1 -0
  15. package/build/cjs/integrations/tracing/amqplib/vendored/patches.js +185 -0
  16. package/build/cjs/integrations/tracing/amqplib/vendored/patches.js.map +1 -0
  17. package/build/cjs/integrations/tracing/amqplib/vendored/semconv.js +21 -1
  18. package/build/cjs/integrations/tracing/amqplib/vendored/semconv.js.map +1 -1
  19. package/build/cjs/integrations/tracing/amqplib/vendored/types.js +0 -6
  20. package/build/cjs/integrations/tracing/amqplib/vendored/types.js.map +1 -1
  21. package/build/cjs/integrations/tracing/amqplib/vendored/utils.js +71 -80
  22. package/build/cjs/integrations/tracing/amqplib/vendored/utils.js.map +1 -1
  23. package/build/cjs/integrations/tracing/connect/index.js.map +1 -1
  24. package/build/cjs/integrations/tracing/dataloader/index.js.map +1 -1
  25. package/build/cjs/integrations/tracing/express.js.map +1 -1
  26. package/build/cjs/integrations/tracing/fastify/index.js +7 -103
  27. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
  28. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js +2 -3
  29. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js.map +1 -1
  30. package/build/cjs/integrations/tracing/firebase/firebase.js +1 -24
  31. package/build/cjs/integrations/tracing/firebase/firebase.js.map +1 -1
  32. package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js +3 -11
  33. package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -1
  34. package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js +33 -72
  35. package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -1
  36. package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js +46 -105
  37. package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js.map +1 -1
  38. package/build/cjs/integrations/tracing/genericPool/index.js.map +1 -1
  39. package/build/cjs/integrations/tracing/graphql/index.js.map +1 -1
  40. package/build/cjs/integrations/tracing/hapi/index.js.map +1 -1
  41. package/build/cjs/integrations/tracing/hono/index.js.map +1 -1
  42. package/build/cjs/integrations/tracing/index.js +0 -1
  43. package/build/cjs/integrations/tracing/index.js.map +1 -1
  44. package/build/cjs/integrations/tracing/kafka/index.js.map +1 -1
  45. package/build/cjs/integrations/tracing/knex/index.js.map +1 -1
  46. package/build/cjs/integrations/tracing/koa/index.js.map +1 -1
  47. package/build/cjs/integrations/tracing/lrumemoizer/index.js.map +1 -1
  48. package/build/cjs/integrations/tracing/lrumemoizer/vendored/instrumentation.js +4 -2
  49. package/build/cjs/integrations/tracing/lrumemoizer/vendored/instrumentation.js.map +1 -1
  50. package/build/cjs/integrations/tracing/mongo/index.js.map +1 -1
  51. package/build/cjs/integrations/tracing/mongoose/index.js.map +1 -1
  52. package/build/cjs/integrations/tracing/mysql/index.js.map +1 -1
  53. package/build/cjs/integrations/tracing/mysql/vendored/instrumentation.js +34 -128
  54. package/build/cjs/integrations/tracing/mysql/vendored/instrumentation.js.map +1 -1
  55. package/build/cjs/integrations/tracing/mysql/vendored/semconv.js +0 -2
  56. package/build/cjs/integrations/tracing/mysql/vendored/semconv.js.map +1 -1
  57. package/build/cjs/integrations/tracing/mysql/vendored/utils.js +2 -27
  58. package/build/cjs/integrations/tracing/mysql/vendored/utils.js.map +1 -1
  59. package/build/cjs/integrations/tracing/mysql2/index.js.map +1 -1
  60. package/build/cjs/integrations/tracing/postgres/index.js.map +1 -1
  61. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
  62. package/build/cjs/integrations/tracing/prisma/index.js +1 -10
  63. package/build/cjs/integrations/tracing/prisma/index.js.map +1 -1
  64. package/build/cjs/integrations/tracing/prisma/vendored/active-tracing-helper.js +83 -57
  65. package/build/cjs/integrations/tracing/prisma/vendored/active-tracing-helper.js.map +1 -1
  66. package/build/cjs/integrations/tracing/prisma/vendored/constants.js.map +1 -1
  67. package/build/cjs/integrations/tracing/prisma/vendored/global.js +2 -2
  68. package/build/cjs/integrations/tracing/prisma/vendored/global.js.map +1 -1
  69. package/build/cjs/integrations/tracing/prisma/vendored/instrumentation.js +1 -6
  70. package/build/cjs/integrations/tracing/prisma/vendored/instrumentation.js.map +1 -1
  71. package/build/cjs/integrations/tracing/redis/index.js +5 -3
  72. package/build/cjs/integrations/tracing/redis/index.js.map +1 -1
  73. package/build/cjs/integrations/tracing/tedious/index.js.map +1 -1
  74. package/build/cjs/integrations/tracing/vercelai/constants.js.map +1 -1
  75. package/build/cjs/integrations/tracing/vercelai/index.js +4 -3
  76. package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -1
  77. package/build/cjs/sdk/diagnosticsChannelInjection.js.map +1 -1
  78. package/build/cjs/sdk/experimentalUseDiagnosticsChannelInjection.js +8 -6
  79. package/build/cjs/sdk/experimentalUseDiagnosticsChannelInjection.js.map +1 -1
  80. package/build/esm/integrations/featureFlagShims/launchDarkly.js.map +1 -1
  81. package/build/esm/integrations/featureFlagShims/openFeature.js.map +1 -1
  82. package/build/esm/integrations/featureFlagShims/statsig.js.map +1 -1
  83. package/build/esm/integrations/featureFlagShims/unleash.js.map +1 -1
  84. package/build/esm/integrations/fs/index.js.map +1 -1
  85. package/build/esm/integrations/http.js.map +1 -1
  86. package/build/esm/integrations/node-fetch/index.js +9 -50
  87. package/build/esm/integrations/node-fetch/index.js.map +1 -1
  88. package/build/esm/integrations/node-fetch/undici-instrumentation.js +264 -0
  89. package/build/esm/integrations/node-fetch/undici-instrumentation.js.map +1 -0
  90. package/build/esm/integrations/tracing/amqplib/index.js +3 -11
  91. package/build/esm/integrations/tracing/amqplib/index.js.map +1 -1
  92. package/build/esm/integrations/tracing/amqplib/vendored/instrumentation.js +115 -0
  93. package/build/esm/integrations/tracing/amqplib/vendored/instrumentation.js.map +1 -0
  94. package/build/esm/integrations/tracing/amqplib/vendored/patches.js +177 -0
  95. package/build/esm/integrations/tracing/amqplib/vendored/patches.js.map +1 -0
  96. package/build/esm/integrations/tracing/amqplib/vendored/semconv.js +12 -2
  97. package/build/esm/integrations/tracing/amqplib/vendored/semconv.js.map +1 -1
  98. package/build/esm/integrations/tracing/amqplib/vendored/types.js +1 -6
  99. package/build/esm/integrations/tracing/amqplib/vendored/types.js.map +1 -1
  100. package/build/esm/integrations/tracing/amqplib/vendored/utils.js +68 -78
  101. package/build/esm/integrations/tracing/amqplib/vendored/utils.js.map +1 -1
  102. package/build/esm/integrations/tracing/connect/index.js.map +1 -1
  103. package/build/esm/integrations/tracing/dataloader/index.js.map +1 -1
  104. package/build/esm/integrations/tracing/express.js.map +1 -1
  105. package/build/esm/integrations/tracing/fastify/index.js +8 -103
  106. package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
  107. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js +3 -4
  108. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js.map +1 -1
  109. package/build/esm/integrations/tracing/firebase/firebase.js +3 -26
  110. package/build/esm/integrations/tracing/firebase/firebase.js.map +1 -1
  111. package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js +3 -11
  112. package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -1
  113. package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js +34 -73
  114. package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -1
  115. package/build/esm/integrations/tracing/firebase/otel/patches/functions.js +47 -106
  116. package/build/esm/integrations/tracing/firebase/otel/patches/functions.js.map +1 -1
  117. package/build/esm/integrations/tracing/genericPool/index.js.map +1 -1
  118. package/build/esm/integrations/tracing/graphql/index.js.map +1 -1
  119. package/build/esm/integrations/tracing/hapi/index.js.map +1 -1
  120. package/build/esm/integrations/tracing/hono/index.js.map +1 -1
  121. package/build/esm/integrations/tracing/index.js +1 -2
  122. package/build/esm/integrations/tracing/index.js.map +1 -1
  123. package/build/esm/integrations/tracing/kafka/index.js.map +1 -1
  124. package/build/esm/integrations/tracing/knex/index.js.map +1 -1
  125. package/build/esm/integrations/tracing/koa/index.js.map +1 -1
  126. package/build/esm/integrations/tracing/lrumemoizer/index.js.map +1 -1
  127. package/build/esm/integrations/tracing/lrumemoizer/vendored/instrumentation.js +5 -3
  128. package/build/esm/integrations/tracing/lrumemoizer/vendored/instrumentation.js.map +1 -1
  129. package/build/esm/integrations/tracing/mongo/index.js.map +1 -1
  130. package/build/esm/integrations/tracing/mongoose/index.js.map +1 -1
  131. package/build/esm/integrations/tracing/mysql/index.js.map +1 -1
  132. package/build/esm/integrations/tracing/mysql/vendored/instrumentation.js +37 -131
  133. package/build/esm/integrations/tracing/mysql/vendored/instrumentation.js.map +1 -1
  134. package/build/esm/integrations/tracing/mysql/vendored/semconv.js +1 -2
  135. package/build/esm/integrations/tracing/mysql/vendored/semconv.js.map +1 -1
  136. package/build/esm/integrations/tracing/mysql/vendored/utils.js +3 -25
  137. package/build/esm/integrations/tracing/mysql/vendored/utils.js.map +1 -1
  138. package/build/esm/integrations/tracing/mysql2/index.js.map +1 -1
  139. package/build/esm/integrations/tracing/postgres/index.js.map +1 -1
  140. package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
  141. package/build/esm/integrations/tracing/prisma/index.js +2 -11
  142. package/build/esm/integrations/tracing/prisma/index.js.map +1 -1
  143. package/build/esm/integrations/tracing/prisma/vendored/active-tracing-helper.js +83 -57
  144. package/build/esm/integrations/tracing/prisma/vendored/active-tracing-helper.js.map +1 -1
  145. package/build/esm/integrations/tracing/prisma/vendored/constants.js.map +1 -1
  146. package/build/esm/integrations/tracing/prisma/vendored/global.js +2 -2
  147. package/build/esm/integrations/tracing/prisma/vendored/global.js.map +1 -1
  148. package/build/esm/integrations/tracing/prisma/vendored/instrumentation.js +1 -6
  149. package/build/esm/integrations/tracing/prisma/vendored/instrumentation.js.map +1 -1
  150. package/build/esm/integrations/tracing/redis/index.js +7 -5
  151. package/build/esm/integrations/tracing/redis/index.js.map +1 -1
  152. package/build/esm/integrations/tracing/tedious/index.js.map +1 -1
  153. package/build/esm/integrations/tracing/vercelai/constants.js.map +1 -1
  154. package/build/esm/integrations/tracing/vercelai/index.js +5 -4
  155. package/build/esm/integrations/tracing/vercelai/index.js.map +1 -1
  156. package/build/esm/package.json +1 -1
  157. package/build/esm/sdk/diagnosticsChannelInjection.js.map +1 -1
  158. package/build/esm/sdk/experimentalUseDiagnosticsChannelInjection.js +9 -7
  159. package/build/esm/sdk/experimentalUseDiagnosticsChannelInjection.js.map +1 -1
  160. package/build/types/integrations/featureFlagShims/launchDarkly.d.ts +3 -1
  161. package/build/types/integrations/featureFlagShims/launchDarkly.d.ts.map +1 -1
  162. package/build/types/integrations/featureFlagShims/openFeature.d.ts +3 -1
  163. package/build/types/integrations/featureFlagShims/openFeature.d.ts.map +1 -1
  164. package/build/types/integrations/featureFlagShims/statsig.d.ts +3 -1
  165. package/build/types/integrations/featureFlagShims/statsig.d.ts.map +1 -1
  166. package/build/types/integrations/featureFlagShims/unleash.d.ts +3 -1
  167. package/build/types/integrations/featureFlagShims/unleash.d.ts.map +1 -1
  168. package/build/types/integrations/fs/index.d.ts +3 -1
  169. package/build/types/integrations/fs/index.d.ts.map +1 -1
  170. package/build/types/integrations/http.d.ts +3 -1
  171. package/build/types/integrations/http.d.ts.map +1 -1
  172. package/build/types/integrations/node-fetch/index.d.ts +4 -35
  173. package/build/types/integrations/node-fetch/index.d.ts.map +1 -1
  174. package/build/types/integrations/node-fetch/types.d.ts +96 -0
  175. package/build/types/integrations/node-fetch/types.d.ts.map +1 -0
  176. package/build/types/integrations/node-fetch/undici-instrumentation.d.ts +14 -0
  177. package/build/types/integrations/node-fetch/undici-instrumentation.d.ts.map +1 -0
  178. package/build/types/integrations/tracing/amqplib/index.d.ts +4 -2
  179. package/build/types/integrations/tracing/amqplib/index.d.ts.map +1 -1
  180. package/build/types/integrations/tracing/amqplib/vendored/instrumentation.d.ts +11 -0
  181. package/build/types/integrations/tracing/amqplib/vendored/instrumentation.d.ts.map +1 -0
  182. package/build/types/integrations/tracing/amqplib/vendored/patches.d.ts +11 -0
  183. package/build/types/integrations/tracing/amqplib/vendored/patches.d.ts.map +1 -0
  184. package/build/types/integrations/tracing/amqplib/vendored/semconv.d.ts +25 -37
  185. package/build/types/integrations/tracing/amqplib/vendored/semconv.d.ts.map +1 -1
  186. package/build/types/integrations/tracing/amqplib/vendored/types.d.ts +0 -81
  187. package/build/types/integrations/tracing/amqplib/vendored/types.d.ts.map +1 -1
  188. package/build/types/integrations/tracing/amqplib/vendored/utils.d.ts +16 -9
  189. package/build/types/integrations/tracing/amqplib/vendored/utils.d.ts.map +1 -1
  190. package/build/types/integrations/tracing/anthropic-ai/index.d.ts +3 -1
  191. package/build/types/integrations/tracing/anthropic-ai/index.d.ts.map +1 -1
  192. package/build/types/integrations/tracing/connect/index.d.ts +3 -1
  193. package/build/types/integrations/tracing/connect/index.d.ts.map +1 -1
  194. package/build/types/integrations/tracing/dataloader/index.d.ts +3 -1
  195. package/build/types/integrations/tracing/dataloader/index.d.ts.map +1 -1
  196. package/build/types/integrations/tracing/express.d.ts +3 -1
  197. package/build/types/integrations/tracing/express.d.ts.map +1 -1
  198. package/build/types/integrations/tracing/fastify/index.d.ts +6 -6
  199. package/build/types/integrations/tracing/fastify/index.d.ts.map +1 -1
  200. package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts.map +1 -1
  201. package/build/types/integrations/tracing/firebase/firebase.d.ts +3 -1
  202. package/build/types/integrations/tracing/firebase/firebase.d.ts.map +1 -1
  203. package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts +4 -9
  204. package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts.map +1 -1
  205. package/build/types/integrations/tracing/firebase/otel/patches/firestore.d.ts +2 -5
  206. package/build/types/integrations/tracing/firebase/otel/patches/firestore.d.ts.map +1 -1
  207. package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts +3 -8
  208. package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts.map +1 -1
  209. package/build/types/integrations/tracing/firebase/otel/types.d.ts +0 -20
  210. package/build/types/integrations/tracing/firebase/otel/types.d.ts.map +1 -1
  211. package/build/types/integrations/tracing/genericPool/index.d.ts +3 -1
  212. package/build/types/integrations/tracing/genericPool/index.d.ts.map +1 -1
  213. package/build/types/integrations/tracing/google-genai/index.d.ts +3 -1
  214. package/build/types/integrations/tracing/google-genai/index.d.ts.map +1 -1
  215. package/build/types/integrations/tracing/graphql/index.d.ts +3 -1
  216. package/build/types/integrations/tracing/graphql/index.d.ts.map +1 -1
  217. package/build/types/integrations/tracing/hapi/index.d.ts +3 -1
  218. package/build/types/integrations/tracing/hapi/index.d.ts.map +1 -1
  219. package/build/types/integrations/tracing/hono/index.d.ts +3 -1
  220. package/build/types/integrations/tracing/hono/index.d.ts.map +1 -1
  221. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  222. package/build/types/integrations/tracing/kafka/index.d.ts +3 -1
  223. package/build/types/integrations/tracing/kafka/index.d.ts.map +1 -1
  224. package/build/types/integrations/tracing/knex/index.d.ts +3 -1
  225. package/build/types/integrations/tracing/knex/index.d.ts.map +1 -1
  226. package/build/types/integrations/tracing/koa/index.d.ts +3 -1
  227. package/build/types/integrations/tracing/koa/index.d.ts.map +1 -1
  228. package/build/types/integrations/tracing/langchain/index.d.ts +3 -1
  229. package/build/types/integrations/tracing/langchain/index.d.ts.map +1 -1
  230. package/build/types/integrations/tracing/langgraph/index.d.ts +3 -1
  231. package/build/types/integrations/tracing/langgraph/index.d.ts.map +1 -1
  232. package/build/types/integrations/tracing/lrumemoizer/index.d.ts +3 -1
  233. package/build/types/integrations/tracing/lrumemoizer/index.d.ts.map +1 -1
  234. package/build/types/integrations/tracing/lrumemoizer/vendored/instrumentation.d.ts.map +1 -1
  235. package/build/types/integrations/tracing/mongo/index.d.ts +3 -1
  236. package/build/types/integrations/tracing/mongo/index.d.ts.map +1 -1
  237. package/build/types/integrations/tracing/mongoose/index.d.ts +3 -1
  238. package/build/types/integrations/tracing/mongoose/index.d.ts.map +1 -1
  239. package/build/types/integrations/tracing/mysql/index.d.ts +3 -1
  240. package/build/types/integrations/tracing/mysql/index.d.ts.map +1 -1
  241. package/build/types/integrations/tracing/mysql/vendored/instrumentation.d.ts +3 -17
  242. package/build/types/integrations/tracing/mysql/vendored/instrumentation.d.ts.map +1 -1
  243. package/build/types/integrations/tracing/mysql/vendored/mysql-types.d.ts +16 -16
  244. package/build/types/integrations/tracing/mysql/vendored/mysql-types.d.ts.map +1 -1
  245. package/build/types/integrations/tracing/mysql/vendored/semconv.d.ts +0 -8
  246. package/build/types/integrations/tracing/mysql/vendored/semconv.d.ts.map +1 -1
  247. package/build/types/integrations/tracing/mysql/vendored/utils.d.ts +6 -9
  248. package/build/types/integrations/tracing/mysql/vendored/utils.d.ts.map +1 -1
  249. package/build/types/integrations/tracing/mysql2/index.d.ts +3 -1
  250. package/build/types/integrations/tracing/mysql2/index.d.ts.map +1 -1
  251. package/build/types/integrations/tracing/openai/index.d.ts +3 -1
  252. package/build/types/integrations/tracing/openai/index.d.ts.map +1 -1
  253. package/build/types/integrations/tracing/postgres/index.d.ts +3 -1
  254. package/build/types/integrations/tracing/postgres/index.d.ts.map +1 -1
  255. package/build/types/integrations/tracing/postgresjs.d.ts +3 -1
  256. package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -1
  257. package/build/types/integrations/tracing/prisma/index.d.ts +5 -21
  258. package/build/types/integrations/tracing/prisma/index.d.ts.map +1 -1
  259. package/build/types/integrations/tracing/prisma/vendored/active-tracing-helper.d.ts +5 -7
  260. package/build/types/integrations/tracing/prisma/vendored/active-tracing-helper.d.ts.map +1 -1
  261. package/build/types/integrations/tracing/prisma/vendored/constants.d.ts.map +1 -1
  262. package/build/types/integrations/tracing/prisma/vendored/global.d.ts.map +1 -1
  263. package/build/types/integrations/tracing/prisma/vendored/instrumentation.d.ts +2 -4
  264. package/build/types/integrations/tracing/prisma/vendored/instrumentation.d.ts.map +1 -1
  265. package/build/types/integrations/tracing/prisma/vendored/types.d.ts +5 -23
  266. package/build/types/integrations/tracing/prisma/vendored/types.d.ts.map +1 -1
  267. package/build/types/integrations/tracing/redis/index.d.ts +4 -2
  268. package/build/types/integrations/tracing/redis/index.d.ts.map +1 -1
  269. package/build/types/integrations/tracing/tedious/index.d.ts +3 -1
  270. package/build/types/integrations/tracing/tedious/index.d.ts.map +1 -1
  271. package/build/types/integrations/tracing/vercelai/constants.d.ts +1 -1
  272. package/build/types/integrations/tracing/vercelai/constants.d.ts.map +1 -1
  273. package/build/types/integrations/tracing/vercelai/index.d.ts +3 -2
  274. package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -1
  275. package/build/types/sdk/diagnosticsChannelInjection.d.ts +1 -1
  276. package/build/types/sdk/diagnosticsChannelInjection.d.ts.map +1 -1
  277. package/build/types/sdk/experimentalUseDiagnosticsChannelInjection.d.ts.map +1 -1
  278. package/build/types-ts3.8/integrations/featureFlagShims/launchDarkly.d.ts +3 -1
  279. package/build/types-ts3.8/integrations/featureFlagShims/openFeature.d.ts +3 -1
  280. package/build/types-ts3.8/integrations/featureFlagShims/statsig.d.ts +3 -1
  281. package/build/types-ts3.8/integrations/featureFlagShims/unleash.d.ts +3 -1
  282. package/build/types-ts3.8/integrations/fs/index.d.ts +3 -1
  283. package/build/types-ts3.8/integrations/http.d.ts +3 -1
  284. package/build/types-ts3.8/integrations/node-fetch/index.d.ts +4 -35
  285. package/build/types-ts3.8/integrations/node-fetch/types.d.ts +96 -0
  286. package/build/types-ts3.8/integrations/node-fetch/undici-instrumentation.d.ts +14 -0
  287. package/build/types-ts3.8/integrations/tracing/amqplib/index.d.ts +4 -2
  288. package/build/types-ts3.8/integrations/tracing/amqplib/vendored/instrumentation.d.ts +11 -0
  289. package/build/types-ts3.8/integrations/tracing/amqplib/vendored/patches.d.ts +11 -0
  290. package/build/types-ts3.8/integrations/tracing/amqplib/vendored/semconv.d.ts +25 -37
  291. package/build/types-ts3.8/integrations/tracing/amqplib/vendored/types.d.ts +0 -81
  292. package/build/types-ts3.8/integrations/tracing/amqplib/vendored/utils.d.ts +16 -9
  293. package/build/types-ts3.8/integrations/tracing/anthropic-ai/index.d.ts +3 -1
  294. package/build/types-ts3.8/integrations/tracing/connect/index.d.ts +3 -1
  295. package/build/types-ts3.8/integrations/tracing/dataloader/index.d.ts +3 -1
  296. package/build/types-ts3.8/integrations/tracing/express.d.ts +3 -1
  297. package/build/types-ts3.8/integrations/tracing/fastify/index.d.ts +6 -6
  298. package/build/types-ts3.8/integrations/tracing/firebase/firebase.d.ts +3 -1
  299. package/build/types-ts3.8/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts +4 -9
  300. package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/firestore.d.ts +2 -5
  301. package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/functions.d.ts +3 -8
  302. package/build/types-ts3.8/integrations/tracing/firebase/otel/types.d.ts +0 -20
  303. package/build/types-ts3.8/integrations/tracing/genericPool/index.d.ts +3 -1
  304. package/build/types-ts3.8/integrations/tracing/google-genai/index.d.ts +3 -1
  305. package/build/types-ts3.8/integrations/tracing/graphql/index.d.ts +3 -1
  306. package/build/types-ts3.8/integrations/tracing/hapi/index.d.ts +3 -1
  307. package/build/types-ts3.8/integrations/tracing/hono/index.d.ts +3 -1
  308. package/build/types-ts3.8/integrations/tracing/kafka/index.d.ts +3 -1
  309. package/build/types-ts3.8/integrations/tracing/knex/index.d.ts +3 -1
  310. package/build/types-ts3.8/integrations/tracing/koa/index.d.ts +3 -1
  311. package/build/types-ts3.8/integrations/tracing/langchain/index.d.ts +3 -1
  312. package/build/types-ts3.8/integrations/tracing/langgraph/index.d.ts +3 -1
  313. package/build/types-ts3.8/integrations/tracing/lrumemoizer/index.d.ts +3 -1
  314. package/build/types-ts3.8/integrations/tracing/mongo/index.d.ts +3 -1
  315. package/build/types-ts3.8/integrations/tracing/mongoose/index.d.ts +3 -1
  316. package/build/types-ts3.8/integrations/tracing/mysql/index.d.ts +3 -1
  317. package/build/types-ts3.8/integrations/tracing/mysql/vendored/instrumentation.d.ts +3 -17
  318. package/build/types-ts3.8/integrations/tracing/mysql/vendored/mysql-types.d.ts +16 -16
  319. package/build/types-ts3.8/integrations/tracing/mysql/vendored/semconv.d.ts +0 -8
  320. package/build/types-ts3.8/integrations/tracing/mysql/vendored/utils.d.ts +6 -9
  321. package/build/types-ts3.8/integrations/tracing/mysql2/index.d.ts +3 -1
  322. package/build/types-ts3.8/integrations/tracing/openai/index.d.ts +3 -1
  323. package/build/types-ts3.8/integrations/tracing/postgres/index.d.ts +3 -1
  324. package/build/types-ts3.8/integrations/tracing/postgresjs.d.ts +3 -1
  325. package/build/types-ts3.8/integrations/tracing/prisma/index.d.ts +5 -21
  326. package/build/types-ts3.8/integrations/tracing/prisma/vendored/active-tracing-helper.d.ts +5 -7
  327. package/build/types-ts3.8/integrations/tracing/prisma/vendored/instrumentation.d.ts +2 -4
  328. package/build/types-ts3.8/integrations/tracing/prisma/vendored/types.d.ts +5 -23
  329. package/build/types-ts3.8/integrations/tracing/redis/index.d.ts +4 -2
  330. package/build/types-ts3.8/integrations/tracing/tedious/index.d.ts +3 -1
  331. package/build/types-ts3.8/integrations/tracing/vercelai/constants.d.ts +1 -1
  332. package/build/types-ts3.8/integrations/tracing/vercelai/index.d.ts +3 -2
  333. package/build/types-ts3.8/sdk/diagnosticsChannelInjection.d.ts +1 -1
  334. package/package.json +6 -5
  335. package/build/cjs/integrations/node-fetch/vendored/semconv.js +0 -28
  336. package/build/cjs/integrations/node-fetch/vendored/semconv.js.map +0 -1
  337. package/build/cjs/integrations/node-fetch/vendored/undici.js +0 -302
  338. package/build/cjs/integrations/node-fetch/vendored/undici.js.map +0 -1
  339. package/build/cjs/integrations/tracing/amqplib/vendored/amqplib.js +0 -452
  340. package/build/cjs/integrations/tracing/amqplib/vendored/amqplib.js.map +0 -1
  341. package/build/cjs/integrations/tracing/amqplib/vendored/semconv-obsolete.js +0 -24
  342. package/build/cjs/integrations/tracing/amqplib/vendored/semconv-obsolete.js.map +0 -1
  343. package/build/cjs/integrations/tracing/fastify/vendored/instrumentation.js +0 -387
  344. package/build/cjs/integrations/tracing/fastify/vendored/instrumentation.js.map +0 -1
  345. package/build/cjs/integrations/tracing/mysql/vendored/AttributeNames.js +0 -9
  346. package/build/cjs/integrations/tracing/mysql/vendored/AttributeNames.js.map +0 -1
  347. package/build/esm/integrations/node-fetch/vendored/semconv.js +0 -15
  348. package/build/esm/integrations/node-fetch/vendored/semconv.js.map +0 -1
  349. package/build/esm/integrations/node-fetch/vendored/undici.js +0 -300
  350. package/build/esm/integrations/node-fetch/vendored/undici.js.map +0 -1
  351. package/build/esm/integrations/tracing/amqplib/vendored/amqplib.js +0 -450
  352. package/build/esm/integrations/tracing/amqplib/vendored/amqplib.js.map +0 -1
  353. package/build/esm/integrations/tracing/amqplib/vendored/semconv-obsolete.js +0 -13
  354. package/build/esm/integrations/tracing/amqplib/vendored/semconv-obsolete.js.map +0 -1
  355. package/build/esm/integrations/tracing/fastify/vendored/instrumentation.js +0 -385
  356. package/build/esm/integrations/tracing/fastify/vendored/instrumentation.js.map +0 -1
  357. package/build/esm/integrations/tracing/mysql/vendored/AttributeNames.js +0 -7
  358. package/build/esm/integrations/tracing/mysql/vendored/AttributeNames.js.map +0 -1
  359. package/build/types/integrations/node-fetch/vendored/internal-types.d.ts +0 -25
  360. package/build/types/integrations/node-fetch/vendored/internal-types.d.ts.map +0 -1
  361. package/build/types/integrations/node-fetch/vendored/semconv.d.ts +0 -13
  362. package/build/types/integrations/node-fetch/vendored/semconv.d.ts.map +0 -1
  363. package/build/types/integrations/node-fetch/vendored/types.d.ts +0 -60
  364. package/build/types/integrations/node-fetch/vendored/types.d.ts.map +0 -1
  365. package/build/types/integrations/node-fetch/vendored/undici.d.ts +0 -21
  366. package/build/types/integrations/node-fetch/vendored/undici.d.ts.map +0 -1
  367. package/build/types/integrations/tracing/amqplib/vendored/amqplib.d.ts +0 -26
  368. package/build/types/integrations/tracing/amqplib/vendored/amqplib.d.ts.map +0 -1
  369. package/build/types/integrations/tracing/amqplib/vendored/semconv-obsolete.d.ts +0 -63
  370. package/build/types/integrations/tracing/amqplib/vendored/semconv-obsolete.d.ts.map +0 -1
  371. package/build/types/integrations/tracing/fastify/vendored/instrumentation.d.ts +0 -27
  372. package/build/types/integrations/tracing/fastify/vendored/instrumentation.d.ts.map +0 -1
  373. package/build/types/integrations/tracing/mysql/vendored/AttributeNames.d.ts +0 -4
  374. package/build/types/integrations/tracing/mysql/vendored/AttributeNames.d.ts.map +0 -1
  375. package/build/types/integrations/tracing/mysql/vendored/types.d.ts +0 -9
  376. package/build/types/integrations/tracing/mysql/vendored/types.d.ts.map +0 -1
  377. package/build/types-ts3.8/integrations/node-fetch/vendored/internal-types.d.ts +0 -25
  378. package/build/types-ts3.8/integrations/node-fetch/vendored/semconv.d.ts +0 -13
  379. package/build/types-ts3.8/integrations/node-fetch/vendored/types.d.ts +0 -60
  380. package/build/types-ts3.8/integrations/node-fetch/vendored/undici.d.ts +0 -21
  381. package/build/types-ts3.8/integrations/tracing/amqplib/vendored/amqplib.d.ts +0 -26
  382. package/build/types-ts3.8/integrations/tracing/amqplib/vendored/semconv-obsolete.d.ts +0 -63
  383. package/build/types-ts3.8/integrations/tracing/fastify/vendored/instrumentation.d.ts +0 -27
  384. package/build/types-ts3.8/integrations/tracing/mysql/vendored/AttributeNames.d.ts +0 -4
  385. package/build/types-ts3.8/integrations/tracing/mysql/vendored/types.d.ts +0 -9
@@ -35,7 +35,7 @@ class SentryPrismaInteropInstrumentation extends instrumentation.PrismaInstrumen
35
35
  }
36
36
  try {
37
37
  engineSpanEvent.spans.forEach((engineSpan) => {
38
- const kind = engineSpanKindToOTELSpanKind(engineSpan.kind);
38
+ const kind = engineSpan.kind === "client" ? api.SpanKind.CLIENT : api.SpanKind.INTERNAL;
39
39
  const parentSpanId = engineSpan.parent_span_id;
40
40
  const spanId = engineSpan.span_id;
41
41
  const traceId = engineSpan.trace_id;
@@ -80,15 +80,6 @@ class SentryPrismaInteropInstrumentation extends instrumentation.PrismaInstrumen
80
80
  }
81
81
  }
82
82
  }
83
- function engineSpanKindToOTELSpanKind(engineSpanKind) {
84
- switch (engineSpanKind) {
85
- case "client":
86
- return api.SpanKind.CLIENT;
87
- case "internal":
88
- default:
89
- return api.SpanKind.INTERNAL;
90
- }
91
- }
92
83
  const instrumentPrisma = nodeCore.generateInstrumentOnce(INTEGRATION_NAME, (options) => {
93
84
  return new SentryPrismaInteropInstrumentation(options);
94
85
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/prisma/index.ts"],"sourcesContent":["import type { Link, Tracer } from '@opentelemetry/api';\nimport { context, SpanKind, trace, TraceFlags } from '@opentelemetry/api';\nimport type { Instrumentation } from '@opentelemetry/instrumentation';\nimport type { IdGenerator } from '@opentelemetry/sdk-trace-base';\nimport { consoleSandbox, defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { PrismaInstrumentation } from './vendored/instrumentation';\nimport type { PrismaV5TracingHelper } from './vendored/v5-tracing-helper';\nimport type { PrismaV6TracingHelper } from './vendored/v6-tracing-helper';\n\nconst INTEGRATION_NAME = 'Prisma';\n\ntype CompatibilityLayerTraceHelper = PrismaV5TracingHelper & PrismaV6TracingHelper;\n\n// Vendored in from @prisma/instrumentation v5:\ntype V5EngineSpanEvent = {\n span: boolean;\n spans: V5EngineSpan[];\n};\n\ntype V5EngineSpanKind = 'client' | 'internal';\n\ntype V5EngineSpan = {\n span: boolean;\n name: string;\n trace_id: string;\n span_id: string;\n parent_span_id: string;\n start_time: [number, number];\n end_time: [number, number];\n attributes?: Record<string, string>;\n links?: { trace_id: string; span_id: string }[];\n kind: V5EngineSpanKind;\n};\n\nfunction isPrismaV6TracingHelper(helper: unknown): helper is PrismaV6TracingHelper {\n return !!helper && typeof helper === 'object' && 'dispatchEngineSpans' in helper;\n}\n\nfunction getPrismaTracingHelper(): unknown | undefined {\n const prismaInstrumentationObject = (globalThis as Record<string, unknown>).PRISMA_INSTRUMENTATION;\n const prismaTracingHelper =\n prismaInstrumentationObject &&\n typeof prismaInstrumentationObject === 'object' &&\n 'helper' in prismaInstrumentationObject\n ? prismaInstrumentationObject.helper\n : undefined;\n\n return prismaTracingHelper;\n}\n\ntype TracerWithIdGenerator = Tracer & {\n _idGenerator?: IdGenerator;\n};\n\ninterface PrismaOptions {\n /**\n * @deprecated This is no longer used, v5 works out of the box.\n */\n prismaInstrumentation?: Instrumentation;\n /**\n * Configuration passed through to the {@link PrismaInstrumentation} constructor.\n */\n instrumentationConfig?: ConstructorParameters<typeof PrismaInstrumentation>[0];\n}\n\nclass SentryPrismaInteropInstrumentation extends PrismaInstrumentation {\n public constructor(options?: PrismaOptions) {\n super(options?.instrumentationConfig);\n }\n\n public enable(): void {\n super.enable();\n\n // The PrismaIntegration (super class) defines a global variable `global[\"PRISMA_INSTRUMENTATION\"]` when `enable()` is called. This global variable holds a \"TracingHelper\" which Prisma uses internally to create tracing data. It's their way of not depending on OTEL with their main package. The sucky thing is, prisma broke the interface of the tracing helper with the v6 major update. This means that if you use Prisma 5 with the v6 instrumentation (or vice versa) Prisma just blows up, because tries to call methods on the helper that no longer exist.\n // Because we actually want to use the v6 instrumentation and not blow up in Prisma 5 user's faces, what we're doing here is backfilling the v5 method (`createEngineSpan`) with a noop so that no longer crashes when it attempts to call that function.\n const prismaTracingHelper = getPrismaTracingHelper();\n\n if (isPrismaV6TracingHelper(prismaTracingHelper)) {\n // Inspired & adjusted from https://github.com/prisma/prisma/tree/5.22.0/packages/instrumentation\n (prismaTracingHelper as CompatibilityLayerTraceHelper).createEngineSpan = (\n engineSpanEvent: V5EngineSpanEvent,\n ) => {\n const tracer = trace.getTracer('prismaV5Compatibility') as TracerWithIdGenerator;\n\n // Prisma v5 relies on being able to create spans with a specific span & trace ID\n // this is no longer possible in OTEL v2, there is no public API to do this anymore\n // So in order to kind of hack this possibility, we rely on the internal `_idGenerator` property\n // This is used to generate the random IDs, and we overwrite this temporarily to generate static IDs\n // This is flawed and may not work, e.g. if the code is bundled and the private property is renamed\n // in such cases, these spans will not be captured and some Prisma spans will be missing\n const initialIdGenerator = tracer._idGenerator;\n\n if (!initialIdGenerator) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Could not find _idGenerator on tracer, skipping Prisma v5 compatibility - some Prisma spans may be missing!',\n );\n });\n\n return;\n }\n\n try {\n engineSpanEvent.spans.forEach(engineSpan => {\n const kind = engineSpanKindToOTELSpanKind(engineSpan.kind);\n\n const parentSpanId = engineSpan.parent_span_id;\n const spanId = engineSpan.span_id;\n const traceId = engineSpan.trace_id;\n\n const links: Link[] | undefined = engineSpan.links?.map(link => {\n return {\n context: {\n traceId: link.trace_id,\n spanId: link.span_id,\n traceFlags: TraceFlags.SAMPLED,\n },\n };\n });\n\n const ctx = trace.setSpanContext(context.active(), {\n traceId,\n spanId: parentSpanId,\n traceFlags: TraceFlags.SAMPLED,\n });\n\n context.with(ctx, () => {\n const temporaryIdGenerator: IdGenerator = {\n generateTraceId: () => {\n return traceId;\n },\n generateSpanId: () => {\n return spanId;\n },\n };\n\n tracer._idGenerator = temporaryIdGenerator;\n\n const span = tracer.startSpan(engineSpan.name, {\n kind,\n links,\n startTime: engineSpan.start_time,\n attributes: engineSpan.attributes,\n });\n\n span.end(engineSpan.end_time);\n\n tracer._idGenerator = initialIdGenerator;\n });\n });\n } finally {\n // Ensure we always restore this at the end, even if something errors\n tracer._idGenerator = initialIdGenerator;\n }\n };\n }\n }\n}\n\nfunction engineSpanKindToOTELSpanKind(engineSpanKind: V5EngineSpanKind): SpanKind {\n switch (engineSpanKind) {\n case 'client':\n return SpanKind.CLIENT;\n case 'internal':\n default: // Other span kinds aren't currently supported\n return SpanKind.INTERNAL;\n }\n}\n\nexport const instrumentPrisma = generateInstrumentOnce<PrismaOptions>(INTEGRATION_NAME, options => {\n return new SentryPrismaInteropInstrumentation(options);\n});\n\n/**\n * Adds Sentry tracing instrumentation for the [prisma](https://www.npmjs.com/package/prisma) library.\n * For more information, see the [`prismaIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/).\n *\n * NOTE: By default, this integration works with Prisma version 6.\n * To get performance instrumentation for other Prisma versions,\n * 1. Install the `@prisma/instrumentation` package with the desired version.\n * 1. Pass a `new PrismaInstrumentation()` instance as exported from `@prisma/instrumentation` to the `prismaInstrumentation` option of this integration:\n *\n * ```js\n * import { PrismaInstrumentation } from '@prisma/instrumentation'\n *\n * Sentry.init({\n * integrations: [\n * prismaIntegration({\n * // Override the default instrumentation that Sentry uses\n * prismaInstrumentation: new PrismaInstrumentation()\n * })\n * ]\n * })\n * ```\n *\n * The passed instrumentation instance will override the default instrumentation instance the integration would use, while the `prismaIntegration` will still ensure data compatibility for the various Prisma versions.\n * 1. Depending on your Prisma version (prior to version 6), add `previewFeatures = [\"tracing\"]` to the client generator block of your Prisma schema:\n *\n * ```\n * generator client {\n * provider = \"prisma-client-js\"\n * previewFeatures = [\"tracing\"]\n * }\n * ```\n */\nexport const prismaIntegration = defineIntegration((options?: PrismaOptions) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPrisma(options);\n },\n setup(client) {\n // If no tracing helper exists, we skip any work here\n // this means that prisma is not being used\n if (!getPrismaTracingHelper()) {\n return;\n }\n\n client.on('spanStart', span => {\n const spanJSON = spanToJSON(span);\n if (spanJSON.description?.startsWith('prisma:')) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.prisma');\n }\n\n // Make sure we use the query text as the span name, for ex. SELECT * FROM \"User\" WHERE \"id\" = $1.\n // v5/v6 emit `prisma:engine:db_query`; v7 inlined the engine and emits `prisma:client:db_query`.\n if (\n (spanJSON.description === 'prisma:engine:db_query' || spanJSON.description === 'prisma:client:db_query') &&\n spanJSON.data['db.query.text']\n ) {\n span.updateName(spanJSON.data['db.query.text'] as string);\n }\n\n // In Prisma v5.22+, the `db.system` attribute is automatically set\n // On older versions, this is missing, so we add it here\n if (spanJSON.description === 'prisma:engine:db_query' && !spanJSON.data['db.system']) {\n span.setAttribute('db.system', 'prisma');\n }\n });\n },\n };\n});\n"],"names":["PrismaInstrumentation","trace","consoleSandbox","TraceFlags","context","SpanKind","generateInstrumentOnce","defineIntegration","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;;AAUA,MAAM,gBAAA,GAAmB,QAAA;AAyBzB,SAAS,wBAAwB,MAAA,EAAkD;AACjF,EAAA,OAAO,CAAC,CAAC,MAAA,IAAU,OAAO,MAAA,KAAW,YAAY,qBAAA,IAAyB,MAAA;AAC5E;AAEA,SAAS,sBAAA,GAA8C;AACrD,EAAA,MAAM,8BAA+B,UAAA,CAAuC,sBAAA;AAC5E,EAAA,MAAM,mBAAA,GACJ,+BACA,OAAO,2BAAA,KAAgC,YACvC,QAAA,IAAY,2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AI,mCAAmC,OAAO,CAAA;AACvD,CAAC;AAkCM,MAAM,iBAAA,GAAoBC,sBAAA,CAAkB,CAAC,OAAA,KAA4B;AAC9E,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,gBAAA,CAAiB,OAAO,CAAA;AAAA,IAC1B,CAAA;AAAA,IACA,MAAM,MAAA,EAAQ;AAGZ,MAAA,IAAI,CAAC,wBAAuB,EAAG;AAC7B,QAAA;AAAA,MACF;AAEA,MAAA,MAAA,CAAO,EAAA,CAAG,aAAa,CAAA,IAAA,KAAQ;AAC7B,QAAA,MAAM,QAAA,GAAWC,gBAAW,IAAI,CAAA;AAChC,QAAA,IAAI,QAAA,CAAS,WAAA,EAAa,UAAA,CAAW,SAAS,CAAA,EAAG;AAC/C,UAAA,IAAA,CAAK,YAAA,CAAaC,uCAAkC,qBAAqB,CAAA;AAAA,QAC3E;AAIA,QAAA,IAAA,CACG,QAAA,CAAS,gBAAgB,wBAAA,IAA4B,QAAA,CAAS,gBAAgB,wBAAA,KAC/E,QAAA,CAAS,IAAA,CAAK,eAAe,CAAA,EAC7B;AACA,UAAA,IAAA,CAAK,UAAA,CAAW,QAAA,CAAS,IAAA,CAAK,eAAe,CAAW,CAAA;AAAA,QAC1D;AAIA,QAAA,IAAI,SAAS,WAAA,KAAgB,wBAAA,IAA4B,CAAC,QAAA,CAAS,IAAA,CAAK,WAAW,CAAA,EAAG;AACpF,UAAA,IAAA,CAAK,YAAA,CAAa,aAAa,QAAQ,CAAA;AAAA,QACzC;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAC;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/prisma/index.ts"],"sourcesContent":["import type { Link, Tracer } from '@opentelemetry/api';\nimport { context, SpanKind, trace, TraceFlags } from '@opentelemetry/api';\nimport type { Instrumentation } from '@opentelemetry/instrumentation';\nimport type { IdGenerator } from '@opentelemetry/sdk-trace-base';\nimport { consoleSandbox, defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { PrismaInstrumentation } from './vendored/instrumentation';\nimport type { PrismaV5TracingHelper } from './vendored/v5-tracing-helper';\nimport type { PrismaV6TracingHelper } from './vendored/v6-tracing-helper';\n\nconst INTEGRATION_NAME = 'Prisma' as const;\n\ntype CompatibilityLayerTraceHelper = PrismaV5TracingHelper & PrismaV6TracingHelper;\n\n// Vendored in from @prisma/instrumentation v5:\ntype V5EngineSpanEvent = {\n span: boolean;\n spans: V5EngineSpan[];\n};\n\ntype V5EngineSpanKind = 'client' | 'internal';\n\ntype V5EngineSpan = {\n span: boolean;\n name: string;\n trace_id: string;\n span_id: string;\n parent_span_id: string;\n start_time: [number, number];\n end_time: [number, number];\n attributes?: Record<string, string>;\n links?: { trace_id: string; span_id: string }[];\n kind: V5EngineSpanKind;\n};\n\nfunction isPrismaV6TracingHelper(helper: unknown): helper is PrismaV6TracingHelper {\n return !!helper && typeof helper === 'object' && 'dispatchEngineSpans' in helper;\n}\n\nfunction getPrismaTracingHelper(): unknown | undefined {\n const prismaInstrumentationObject = (globalThis as Record<string, unknown>).PRISMA_INSTRUMENTATION;\n const prismaTracingHelper =\n prismaInstrumentationObject &&\n typeof prismaInstrumentationObject === 'object' &&\n 'helper' in prismaInstrumentationObject\n ? prismaInstrumentationObject.helper\n : undefined;\n\n return prismaTracingHelper;\n}\n\ntype TracerWithIdGenerator = Tracer & {\n _idGenerator?: IdGenerator;\n};\n\ninterface PrismaOptions {\n /**\n * @deprecated This is no longer used, v5 works out of the box.\n */\n prismaInstrumentation?: Instrumentation;\n /**\n * Configuration passed through to the {@link PrismaInstrumentation} constructor.\n */\n instrumentationConfig?: ConstructorParameters<typeof PrismaInstrumentation>[0];\n}\n\nclass SentryPrismaInteropInstrumentation extends PrismaInstrumentation {\n public constructor(options?: PrismaOptions) {\n super(options?.instrumentationConfig);\n }\n\n public enable(): void {\n super.enable();\n\n // The PrismaIntegration (super class) defines a global variable `global[\"PRISMA_INSTRUMENTATION\"]` when `enable()` is called. This global variable holds a \"TracingHelper\" which Prisma uses internally to create tracing data. It's their way of not depending on OTEL with their main package. The sucky thing is, prisma broke the interface of the tracing helper with the v6 major update. This means that if you use Prisma 5 with the v6 instrumentation (or vice versa) Prisma just blows up, because tries to call methods on the helper that no longer exist.\n // Because we actually want to use the v6 instrumentation and not blow up in Prisma 5 user's faces, what we're doing here is backfilling the v5 method (`createEngineSpan`) with a noop so that no longer crashes when it attempts to call that function.\n const prismaTracingHelper = getPrismaTracingHelper();\n\n if (isPrismaV6TracingHelper(prismaTracingHelper)) {\n // Inspired & adjusted from https://github.com/prisma/prisma/tree/5.22.0/packages/instrumentation\n (prismaTracingHelper as CompatibilityLayerTraceHelper).createEngineSpan = (\n engineSpanEvent: V5EngineSpanEvent,\n ) => {\n const tracer = trace.getTracer('prismaV5Compatibility') as TracerWithIdGenerator;\n\n // Prisma v5 relies on being able to create spans with a specific span & trace ID\n // this is no longer possible in OTEL v2, there is no public API to do this anymore\n // So in order to kind of hack this possibility, we rely on the internal `_idGenerator` property\n // This is used to generate the random IDs, and we overwrite this temporarily to generate static IDs\n // This is flawed and may not work, e.g. if the code is bundled and the private property is renamed\n // in such cases, these spans will not be captured and some Prisma spans will be missing\n const initialIdGenerator = tracer._idGenerator;\n\n if (!initialIdGenerator) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Could not find _idGenerator on tracer, skipping Prisma v5 compatibility - some Prisma spans may be missing!',\n );\n });\n\n return;\n }\n\n try {\n engineSpanEvent.spans.forEach(engineSpan => {\n const kind = engineSpan.kind === 'client' ? SpanKind.CLIENT : SpanKind.INTERNAL;\n\n const parentSpanId = engineSpan.parent_span_id;\n const spanId = engineSpan.span_id;\n const traceId = engineSpan.trace_id;\n\n const links: Link[] | undefined = engineSpan.links?.map(link => {\n return {\n context: {\n traceId: link.trace_id,\n spanId: link.span_id,\n traceFlags: TraceFlags.SAMPLED,\n },\n };\n });\n\n const ctx = trace.setSpanContext(context.active(), {\n traceId,\n spanId: parentSpanId,\n traceFlags: TraceFlags.SAMPLED,\n });\n\n context.with(ctx, () => {\n const temporaryIdGenerator: IdGenerator = {\n generateTraceId: () => {\n return traceId;\n },\n generateSpanId: () => {\n return spanId;\n },\n };\n\n tracer._idGenerator = temporaryIdGenerator;\n\n const span = tracer.startSpan(engineSpan.name, {\n kind,\n links,\n startTime: engineSpan.start_time,\n attributes: engineSpan.attributes,\n });\n\n span.end(engineSpan.end_time);\n\n tracer._idGenerator = initialIdGenerator;\n });\n });\n } finally {\n // Ensure we always restore this at the end, even if something errors\n tracer._idGenerator = initialIdGenerator;\n }\n };\n }\n }\n}\n\nexport const instrumentPrisma = generateInstrumentOnce<PrismaOptions>(INTEGRATION_NAME, options => {\n return new SentryPrismaInteropInstrumentation(options);\n});\n\n/**\n * Adds Sentry tracing instrumentation for the [prisma](https://www.npmjs.com/package/prisma) library.\n * For more information, see the [`prismaIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/).\n *\n * NOTE: This integration works out of the box with Prisma v6, and v7.\n * On Prisma versions prior to v6, add `previewFeatures = [\"tracing\"]` to the client generator block of your Prisma schema:\n *\n * ```\n * generator client {\n * provider = \"prisma-client-js\"\n * previewFeatures = [\"tracing\"]\n * }\n * ```\n */\nexport const prismaIntegration = defineIntegration((options?: PrismaOptions) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPrisma(options);\n },\n setup(client) {\n // If no tracing helper exists, we skip any work here\n // this means that prisma is not being used\n if (!getPrismaTracingHelper()) {\n return;\n }\n\n // Prisma v5 engine spans are created via the `createEngineSpan` path above, which bypasses the\n // tracing helper, so this hook applies origin, the db_query rename, and the db.system backfill to\n // them. v6/v7 spans already get these from the helper; the guards are idempotent, so it's a no-op there.\n client.on('spanStart', span => {\n const spanJSON = spanToJSON(span);\n if (spanJSON.description?.startsWith('prisma:')) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.prisma');\n }\n\n // Make sure we use the query text as the span name, for ex. SELECT * FROM \"User\" WHERE \"id\" = $1.\n // v5/v6 emit `prisma:engine:db_query`; v7 inlined the engine and emits `prisma:client:db_query`.\n if (\n (spanJSON.description === 'prisma:engine:db_query' || spanJSON.description === 'prisma:client:db_query') &&\n spanJSON.data['db.query.text']\n ) {\n span.updateName(spanJSON.data['db.query.text'] as string);\n }\n\n // In Prisma v5.22+, the `db.system` attribute is automatically set\n // On older versions, this is missing, so we add it here\n if (spanJSON.description === 'prisma:engine:db_query' && !spanJSON.data['db.system']) {\n span.setAttribute('db.system', 'prisma');\n }\n });\n },\n };\n});\n"],"names":["PrismaInstrumentation","trace","consoleSandbox","SpanKind","TraceFlags","context","generateInstrumentOnce","defineIntegration","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;;AAUA,MAAM,gBAAA,GAAmB,QAAA;AAyBzB,SAAS,wBAAwB,MAAA,EAAkD;AACjF,EAAA,OAAO,CAAC,CAAC,MAAA,IAAU,OAAO,MAAA,KAAW,YAAY,qBAAA,IAAyB,MAAA;AAC5E;AAEA,SAAS,sBAAA,GAA8C;AACrD,EAAA,MAAM,8BAA+B,UAAA,CAAuC,sBAAA;AAC5E,EAAA,MAAM,mBAAA,GACJ,+BACA,OAAO,2BAAA,KAAgC,YACvC,QAAA,IAAY,2BAAA,GACR,4BAA4B,MAAA,GAC5B,MAAA;AAEN,EAAA,OAAO,mBAAA;AACT;AAiBA,MAAM,2CAA2CA,qCAAA,CAAsB;AAAA,EAC9D,YAAY,OAAA,EAAyB;AAC1C,IAAA,KAAA,CAAM,SAAS,qBAAqB,CAAA;AAAA,EACtC;AAAA,EAEO,MAAA,GAAe;AACpB,IAAA,KAAA,CAAM,MAAA,EAAO;AAIb,IAAA,MAAM,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I,QAAA,CAAS,WAAA,EAAa,UAAA,CAAW,SAAS,CAAA,EAAG;AAC/C,UAAA,IAAA,CAAK,YAAA,CAAaC,uCAAkC,qBAAqB,CAAA;AAAA,QAC3E;AAIA,QAAA,IAAA,CACG,QAAA,CAAS,gBAAgB,wBAAA,IAA4B,QAAA,CAAS,gBAAgB,wBAAA,KAC/E,QAAA,CAAS,IAAA,CAAK,eAAe,CAAA,EAC7B;AACA,UAAA,IAAA,CAAK,UAAA,CAAW,QAAA,CAAS,IAAA,CAAK,eAAe,CAAW,CAAA;AAAA,QAC1D;AAIA,QAAA,IAAI,SAAS,WAAA,KAAgB,wBAAA,IAA4B,CAAC,QAAA,CAAS,IAAA,CAAK,WAAW,CAAA,EAAG;AACpF,UAAA,IAAA,CAAK,YAAA,CAAa,aAAa,QAAQ,CAAA;AAAA,QACzC;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAC;;;;;"}
@@ -1,98 +1,124 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const api = require('@opentelemetry/api');
3
+ const core = require('@sentry/core');
4
4
 
5
5
  const showAllTraces = process.env.PRISMA_SHOW_ALL_TRACES === "true";
6
6
  const nonSampledTraceParent = `00-10-10-00`;
7
- function engineSpanKindToOtelSpanKind(engineSpanKind) {
8
- switch (engineSpanKind) {
9
- case "client":
10
- return api.SpanKind.CLIENT;
11
- case "internal":
12
- default:
13
- return api.SpanKind.INTERNAL;
7
+ const PRISMA_ORIGIN = "auto.db.otel.prisma";
8
+ function buildSpanAttributes(name, attributes) {
9
+ const merged = {
10
+ ...attributes,
11
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: PRISMA_ORIGIN
12
+ };
13
+ if (name === "prisma:engine:db_query" && merged["db.system"] == null) {
14
+ merged["db.system"] = "prisma";
15
+ }
16
+ return merged;
17
+ }
18
+ function buildSpanName(name, attributes) {
19
+ const queryText = attributes["db.query.text"];
20
+ if ((name === "prisma:engine:db_query" || name === "prisma:client:db_query") && typeof queryText === "string") {
21
+ return queryText;
14
22
  }
23
+ return name;
15
24
  }
16
25
  class ActiveTracingHelper {
17
- constructor({ tracerProvider, ignoreSpanTypes }) {
18
- this.tracerProvider = tracerProvider;
26
+ constructor({ ignoreSpanTypes }) {
19
27
  this.ignoreSpanTypes = ignoreSpanTypes;
20
28
  }
21
29
  isEnabled() {
22
30
  return true;
23
31
  }
24
- getTraceParent(context) {
25
- const span = api.trace.getSpanContext(context ?? api.context.active());
26
- if (span) {
27
- return `00-${span.traceId}-${span.spanId}-0${span.traceFlags}`;
32
+ getTraceParent(span) {
33
+ const spanContext = (span ?? core.getActiveSpan())?.spanContext();
34
+ if (spanContext) {
35
+ return `00-${spanContext.traceId}-${spanContext.spanId}-0${spanContext.traceFlags}`;
28
36
  }
29
37
  return nonSampledTraceParent;
30
38
  }
31
39
  dispatchEngineSpans(spans) {
32
- const tracer = this.tracerProvider.getTracer("prisma");
33
40
  const linkIds = /* @__PURE__ */ new Map();
34
41
  const roots = spans.filter((span) => span.parentId === null);
35
42
  for (const root of roots) {
36
- dispatchEngineSpan(tracer, root, spans, linkIds, this.ignoreSpanTypes);
43
+ dispatchEngineSpan(root, spans, linkIds, this.ignoreSpanTypes);
37
44
  }
38
45
  }
39
46
  getActiveContext() {
40
- return api.context.active();
47
+ return core.getActiveSpan();
41
48
  }
42
- runInChildSpan(options, callback) {
43
- if (typeof options === "string") {
44
- options = { name: options };
45
- }
49
+ runInChildSpan(nameOrOptions, callback) {
50
+ const options = typeof nameOrOptions === "string" ? { name: nameOrOptions } : nameOrOptions;
46
51
  if (options.internal && !showAllTraces) {
47
52
  return callback();
48
53
  }
49
- const tracer = this.tracerProvider.getTracer("prisma");
50
- const context = options.context ?? this.getActiveContext();
51
54
  const name = `prisma:client:${options.name}`;
52
55
  if (shouldIgnoreSpan(name, this.ignoreSpanTypes)) {
53
56
  return callback();
54
57
  }
58
+ const parentSpan = core.getActiveSpan();
59
+ const attributes = buildSpanAttributes(name, options.attributes);
60
+ const spanOptions = {
61
+ name: buildSpanName(name, attributes),
62
+ attributes,
63
+ kind: options.kind,
64
+ links: options.links,
65
+ startTime: options.startTime,
66
+ parentSpan
67
+ };
55
68
  if (options.active === false) {
56
- const span = tracer.startSpan(name, options, context);
57
- return endSpan(span, callback(span, context));
69
+ const span = core.startInactiveSpan(spanOptions);
70
+ return endSpan(span, () => callback(span, parentSpan));
58
71
  }
59
- return tracer.startActiveSpan(name, options, (span) => endSpan(span, callback(span, context)));
72
+ return core.startSpanManual(spanOptions, (span) => endSpan(span, () => callback(span, parentSpan)));
60
73
  }
61
74
  }
62
- function dispatchEngineSpan(tracer, engineSpan, allSpans, linkIds, ignoreSpanTypes) {
63
- if (shouldIgnoreSpan(engineSpan.name, ignoreSpanTypes)) return;
64
- const spanOptions = {
65
- attributes: engineSpan.attributes,
66
- kind: engineSpanKindToOtelSpanKind(engineSpan.kind),
67
- startTime: engineSpan.startTime
68
- };
69
- tracer.startActiveSpan(engineSpan.name, spanOptions, (span) => {
70
- linkIds.set(engineSpan.id, span.spanContext().spanId);
71
- if (engineSpan.links) {
72
- span.addLinks(
73
- engineSpan.links.flatMap((link) => {
74
- const linkedId = linkIds.get(link);
75
- if (!linkedId) {
76
- return [];
77
- }
78
- return {
79
- context: {
80
- spanId: linkedId,
81
- traceId: span.spanContext().traceId,
82
- traceFlags: span.spanContext().traceFlags
75
+ function dispatchEngineSpan(engineSpan, allSpans, linkIds, ignoreSpanTypes) {
76
+ if (shouldIgnoreSpan(engineSpan.name, ignoreSpanTypes)) {
77
+ return;
78
+ }
79
+ const attributes = buildSpanAttributes(engineSpan.name, engineSpan.attributes);
80
+ core.startSpanManual(
81
+ {
82
+ name: buildSpanName(engineSpan.name, attributes),
83
+ attributes,
84
+ kind: engineSpan.kind === "client" ? core.SPAN_KIND.CLIENT : core.SPAN_KIND.INTERNAL,
85
+ startTime: engineSpan.startTime
86
+ },
87
+ (span) => {
88
+ linkIds.set(engineSpan.id, span.spanContext().spanId);
89
+ if (engineSpan.links) {
90
+ span.addLinks(
91
+ engineSpan.links.flatMap((link) => {
92
+ const linkedId = linkIds.get(link);
93
+ if (!linkedId) {
94
+ return [];
83
95
  }
84
- };
85
- })
86
- );
87
- }
88
- const children = allSpans.filter((s) => s.parentId === engineSpan.id);
89
- for (const child of children) {
90
- dispatchEngineSpan(tracer, child, allSpans, linkIds, ignoreSpanTypes);
96
+ return {
97
+ context: {
98
+ spanId: linkedId,
99
+ traceId: span.spanContext().traceId,
100
+ traceFlags: span.spanContext().traceFlags
101
+ }
102
+ };
103
+ })
104
+ );
105
+ }
106
+ const children = allSpans.filter((s) => s.parentId === engineSpan.id);
107
+ for (const child of children) {
108
+ dispatchEngineSpan(child, allSpans, linkIds, ignoreSpanTypes);
109
+ }
110
+ span.end(engineSpan.endTime);
91
111
  }
92
- span.end(engineSpan.endTime);
93
- });
112
+ );
94
113
  }
95
- function endSpan(span, result) {
114
+ function endSpan(span, run) {
115
+ let result;
116
+ try {
117
+ result = run();
118
+ } catch (reason) {
119
+ span.end();
120
+ throw reason;
121
+ }
96
122
  if (isPromiseLike(result)) {
97
123
  return result.then(
98
124
  (value) => {
@@ -1 +1 @@
1
- {"version":3,"file":"active-tracing-helper.js","sources":["../../../../../../src/integrations/tracing/prisma/vendored/active-tracing-helper.ts"],"sourcesContent":["/*\n * Copyright Prisma\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/prisma/prisma/tree/b6feea5565ec577545a79547d24273ccdd11b4c7/packages/instrumentation\n * - Upstream version: @prisma/instrumentation@7.8.0\n * - Replaced `@prisma/instrumentation-contract` imports with local vendored types\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n */\n/* eslint-disable */\n\nimport {\n Attributes,\n Context,\n context as _context,\n Span,\n SpanKind,\n SpanOptions,\n trace,\n Tracer,\n TracerProvider,\n} from '@opentelemetry/api';\nimport type { EngineSpan, EngineSpanKind, ExtendedSpanOptions, SpanCallback, TracingHelper } from './types';\n\nconst showAllTraces = process.env.PRISMA_SHOW_ALL_TRACES === 'true';\n\nconst nonSampledTraceParent = `00-10-10-00`;\n\ntype Options = {\n tracerProvider: TracerProvider;\n ignoreSpanTypes: (string | RegExp)[];\n};\n\nfunction engineSpanKindToOtelSpanKind(engineSpanKind: EngineSpanKind): SpanKind {\n switch (engineSpanKind) {\n case 'client':\n return SpanKind.CLIENT;\n case 'internal':\n default:\n return SpanKind.INTERNAL;\n }\n}\n\nexport class ActiveTracingHelper implements TracingHelper {\n private tracerProvider: TracerProvider;\n private ignoreSpanTypes: (string | RegExp)[];\n\n constructor({ tracerProvider, ignoreSpanTypes }: Options) {\n this.tracerProvider = tracerProvider;\n this.ignoreSpanTypes = ignoreSpanTypes;\n }\n\n isEnabled(): boolean {\n return true;\n }\n\n getTraceParent(context?: Context | undefined): string {\n const span = trace.getSpanContext(context ?? _context.active());\n if (span) {\n return `00-${span.traceId}-${span.spanId}-0${span.traceFlags}`;\n }\n return nonSampledTraceParent;\n }\n\n dispatchEngineSpans(spans: EngineSpan[]): void {\n const tracer = this.tracerProvider.getTracer('prisma');\n const linkIds = new Map<string, string>();\n const roots = spans.filter(span => span.parentId === null);\n\n for (const root of roots) {\n dispatchEngineSpan(tracer, root, spans, linkIds, this.ignoreSpanTypes);\n }\n }\n\n getActiveContext(): Context | undefined {\n return _context.active();\n }\n\n runInChildSpan<R>(options: string | ExtendedSpanOptions, callback: SpanCallback<R>): R {\n if (typeof options === 'string') {\n options = { name: options };\n }\n\n if (options.internal && !showAllTraces) {\n return callback();\n }\n\n const tracer = this.tracerProvider.getTracer('prisma');\n const context = options.context ?? this.getActiveContext();\n const name = `prisma:client:${options.name}`;\n\n if (shouldIgnoreSpan(name, this.ignoreSpanTypes)) {\n return callback();\n }\n\n if (options.active === false) {\n const span = tracer.startSpan(name, options, context);\n return endSpan(span, callback(span, context));\n }\n\n return tracer.startActiveSpan(name, options, span => endSpan(span, callback(span, context)));\n }\n}\n\nfunction dispatchEngineSpan(\n tracer: Tracer,\n engineSpan: EngineSpan,\n allSpans: EngineSpan[],\n linkIds: Map<string, string>,\n ignoreSpanTypes: (string | RegExp)[],\n) {\n if (shouldIgnoreSpan(engineSpan.name, ignoreSpanTypes)) return;\n\n const spanOptions = {\n attributes: engineSpan.attributes as Attributes,\n kind: engineSpanKindToOtelSpanKind(engineSpan.kind),\n startTime: engineSpan.startTime,\n } satisfies SpanOptions;\n\n tracer.startActiveSpan(engineSpan.name, spanOptions, span => {\n linkIds.set(engineSpan.id, span.spanContext().spanId);\n\n if (engineSpan.links) {\n span.addLinks(\n engineSpan.links.flatMap(link => {\n const linkedId = linkIds.get(link);\n if (!linkedId) {\n return [];\n }\n return {\n context: {\n spanId: linkedId,\n traceId: span.spanContext().traceId,\n traceFlags: span.spanContext().traceFlags,\n },\n };\n }),\n );\n }\n\n const children = allSpans.filter(s => s.parentId === engineSpan.id);\n for (const child of children) {\n dispatchEngineSpan(tracer, child, allSpans, linkIds, ignoreSpanTypes);\n }\n\n span.end(engineSpan.endTime);\n });\n}\n\nfunction endSpan<T>(span: Span, result: T): T {\n if (isPromiseLike(result)) {\n return result.then(\n value => {\n span.end();\n return value;\n },\n reason => {\n span.end();\n throw reason;\n },\n ) as T;\n }\n span.end();\n return result;\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return value != null && typeof (value as Record<string, unknown>)['then'] === 'function';\n}\n\nfunction shouldIgnoreSpan(spanName: string, ignoreSpanTypes: (string | RegExp)[]): boolean {\n return ignoreSpanTypes.some(pattern => (typeof pattern === 'string' ? pattern === spanName : pattern.test(spanName)));\n}\n"],"names":["SpanKind","trace","_context"],"mappings":";;;;AAyBA,MAAM,aAAA,GAAgB,OAAA,CAAQ,GAAA,CAAI,sBAAA,KAA2B,MAAA;AAE7D,MAAM,qBAAA,GAAwB,CAAA,WAAA,CAAA;AAO9B,SAAS,6BAA6B,cAAA,EAA0C;AAC9E,EAAA,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AA,CAAO,IAAA;AAAA,MACZ,CAAA,KAAA,KAAS;AACP,QAAA,IAAA,CAAK,GAAA,EAAI;AACT,QAAA,OAAO,KAAA;AAAA,MACT,CAAA;AAAA,MACA,CAAA,MAAA,KAAU;AACR,QAAA,IAAA,CAAK,GAAA,EAAI;AACT,QAAA,MAAM,MAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,IAAA,CAAK,GAAA,EAAI;AACT,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,cAAc,KAAA,EAA+C;AACpE,EAAA,OAAO,KAAA,IAAS,IAAA,IAAQ,OAAQ,KAAA,CAAkC,MAAM,CAAA,KAAM,UAAA;AAChF;AAEA,SAAS,gBAAA,CAAiB,UAAkB,eAAA,EAA+C;AACzF,EAAA,OAAO,eAAA,CAAgB,IAAA,CAAK,CAAA,OAAA,KAAY,OAAO,OAAA,KAAY,QAAA,GAAW,OAAA,KAAY,QAAA,GAAW,OAAA,CAAQ,IAAA,CAAK,QAAQ,CAAE,CAAA;AACtH;;;;"}
1
+ {"version":3,"file":"active-tracing-helper.js","sources":["../../../../../../src/integrations/tracing/prisma/vendored/active-tracing-helper.ts"],"sourcesContent":["/*\n * Copyright Prisma\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/prisma/prisma/tree/b6feea5565ec577545a79547d24273ccdd11b4c7/packages/instrumentation\n * - Upstream version: @prisma/instrumentation@7.8.0\n * - Replaced `@prisma/instrumentation-contract` imports with local vendored types\n * - Span creation uses Sentry's span APIs (`startSpanManual` / `startInactiveSpan`) instead of the OTel tracer\n * - Span creation sets the Sentry origin, renames `db_query` spans to their SQL text, and backfills\n * `db.system` for older Prisma versions\n */\n\nimport type { Span, SpanAttributes, SpanKindValue, SpanLink } from '@sentry/core';\nimport {\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n startInactiveSpan,\n startSpanManual,\n} from '@sentry/core';\nimport type { EngineSpan, ExtendedSpanOptions, SpanCallback, TracingHelper } from './types';\n\nconst showAllTraces = process.env.PRISMA_SHOW_ALL_TRACES === 'true';\n\nconst nonSampledTraceParent = `00-10-10-00`;\n\nconst PRISMA_ORIGIN = 'auto.db.otel.prisma';\n\ntype Options = {\n ignoreSpanTypes: (string | RegExp)[];\n};\n\n/**\n * Older Prisma versions emit `prisma:engine:db_query` spans without a `db.system`, so it's backfilled here.\n */\nfunction buildSpanAttributes(name: string, attributes: Record<string, unknown> | undefined): SpanAttributes {\n const merged: SpanAttributes = {\n ...(attributes as SpanAttributes | undefined),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: PRISMA_ORIGIN,\n };\n\n if (name === 'prisma:engine:db_query' && merged['db.system'] == null) {\n merged['db.system'] = 'prisma';\n }\n\n return merged;\n}\n\n/**\n * Db query spans are named after their SQL text (e.g. `SELECT * FROM \"User\"`) rather than the generic\n * engine name. v5/v6 emit `prisma:engine:db_query`; v7 inlined the engine and emits `prisma:client:db_query`.\n */\nfunction buildSpanName(name: string, attributes: SpanAttributes): string {\n const queryText = attributes['db.query.text'];\n if ((name === 'prisma:engine:db_query' || name === 'prisma:client:db_query') && typeof queryText === 'string') {\n return queryText;\n }\n return name;\n}\n\nexport class ActiveTracingHelper implements TracingHelper {\n private ignoreSpanTypes: (string | RegExp)[];\n\n public constructor({ ignoreSpanTypes }: Options) {\n this.ignoreSpanTypes = ignoreSpanTypes;\n }\n\n public isEnabled(): boolean {\n return true;\n }\n\n public getTraceParent(span?: Span): string {\n const spanContext = (span ?? getActiveSpan())?.spanContext();\n if (spanContext) {\n return `00-${spanContext.traceId}-${spanContext.spanId}-0${spanContext.traceFlags}`;\n }\n return nonSampledTraceParent;\n }\n\n public dispatchEngineSpans(spans: EngineSpan[]): void {\n const linkIds = new Map<string, string>();\n const roots = spans.filter(span => span.parentId === null);\n\n for (const root of roots) {\n dispatchEngineSpan(root, spans, linkIds, this.ignoreSpanTypes);\n }\n }\n\n public getActiveContext(): Span | undefined {\n return getActiveSpan();\n }\n\n public runInChildSpan<R>(nameOrOptions: string | ExtendedSpanOptions, callback: SpanCallback<R>): R {\n const options: ExtendedSpanOptions = typeof nameOrOptions === 'string' ? { name: nameOrOptions } : nameOrOptions;\n\n if (options.internal && !showAllTraces) {\n return callback();\n }\n\n const name = `prisma:client:${options.name}`;\n\n if (shouldIgnoreSpan(name, this.ignoreSpanTypes)) {\n return callback();\n }\n\n const parentSpan = getActiveSpan();\n\n const attributes = buildSpanAttributes(name, options.attributes as Record<string, unknown> | undefined);\n const spanOptions = {\n name: buildSpanName(name, attributes),\n attributes,\n kind: options.kind as SpanKindValue | undefined,\n links: options.links as SpanLink[] | undefined,\n startTime: options.startTime,\n parentSpan,\n };\n\n if (options.active === false) {\n const span = startInactiveSpan(spanOptions);\n return endSpan(span, () => callback(span, parentSpan));\n }\n\n return startSpanManual(spanOptions, span => endSpan(span, () => callback(span, parentSpan)));\n }\n}\n\nfunction dispatchEngineSpan(\n engineSpan: EngineSpan,\n allSpans: EngineSpan[],\n linkIds: Map<string, string>,\n ignoreSpanTypes: (string | RegExp)[],\n): void {\n if (shouldIgnoreSpan(engineSpan.name, ignoreSpanTypes)) {\n return;\n }\n\n const attributes = buildSpanAttributes(engineSpan.name, engineSpan.attributes);\n\n startSpanManual(\n {\n name: buildSpanName(engineSpan.name, attributes),\n attributes,\n kind: engineSpan.kind === 'client' ? SPAN_KIND.CLIENT : SPAN_KIND.INTERNAL,\n startTime: engineSpan.startTime,\n },\n span => {\n linkIds.set(engineSpan.id, span.spanContext().spanId);\n\n if (engineSpan.links) {\n span.addLinks(\n engineSpan.links.flatMap(link => {\n const linkedId = linkIds.get(link);\n if (!linkedId) {\n return [];\n }\n return {\n context: {\n spanId: linkedId,\n traceId: span.spanContext().traceId,\n traceFlags: span.spanContext().traceFlags,\n },\n };\n }),\n );\n }\n\n const children = allSpans.filter(s => s.parentId === engineSpan.id);\n for (const child of children) {\n dispatchEngineSpan(child, allSpans, linkIds, ignoreSpanTypes);\n }\n\n span.end(engineSpan.endTime);\n },\n );\n}\n\nfunction endSpan<T>(span: Span, run: () => T): T {\n let result: T;\n try {\n result = run();\n } catch (reason) {\n span.end();\n throw reason;\n }\n\n if (isPromiseLike(result)) {\n return result.then(\n value => {\n span.end();\n return value;\n },\n reason => {\n span.end();\n throw reason;\n },\n ) as T;\n }\n span.end();\n return result;\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return value != null && typeof (value as Record<string, unknown>)['then'] === 'function';\n}\n\nfunction shouldIgnoreSpan(spanName: string, ignoreSpanTypes: (string | RegExp)[]): boolean {\n return ignoreSpanTypes.some(pattern => (typeof pattern === 'string' ? pattern === spanName : pattern.test(spanName)));\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getActiveSpan","startInactiveSpan","startSpanManual","SPAN_KIND"],"mappings":";;;;AAuBA,MAAM,aAAA,GAAgB,OAAA,CAAQ,GAAA,CAAI,sBAAA,KAA2B,MAAA;AAE7D,MAAM,qBAAA,GAAwB,CAAA,WAAA,CAAA;AAE9B,MAAM,aAAA,GAAgB,qBAAA;AAStB,SAAS,mBAAA,CAAoB,MAAc,UAAA,EAAiE;AAC1G,EAAA,MAAM,MAAA,GAAyB;AAAA,IAC7B,GAAI,UAAA;AAAA,IACJ,CAACA,qCAAgC,GAAG;AAAA,GACtC;AAEA,EAAA,IAAI,IAAA,KAAS,wBAAA,IAA4B,MAAA,CAAO,WAAW,KAAK,IAAA,EAAM;AACpE,IAAA,MAAA,CAAO,WAAW,CAAA,GAAI,QAAA;AAAA,EACxB;AAEA,EAAA,OAAO,MAAA;AACT;AAMA,SAAS,aAAA,CAAc,MAAc,UAAA,EAAoC;AACvE,EAAA,MAAM,SAAA,GAAY,WAAW,eAAe,CAAA;AAC5C,EAAA,IAAA,CAAK,SAAS,wBAAA,IAA4B,IAAA,KAAS,wBAAA,KAA6B,OAAO,cAAc,QAAA,EAAU;AAC7G,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AI;AAAA,EACf,SAAS,MAAA,EAAQ;AACf,IAAA,IAAA,CAAK,GAAA,EAAI;AACT,IAAA,MAAM,MAAA;AAAA,EACR;AAEA,EAAA,IAAI,aAAA,CAAc,MAAM,CAAA,EAAG;AACzB,IAAA,OAAO,MAAA,CAAO,IAAA;AAAA,MACZ,CAAA,KAAA,KAAS;AACP,QAAA,IAAA,CAAK,GAAA,EAAI;AACT,QAAA,OAAO,KAAA;AAAA,MACT,CAAA;AAAA,MACA,CAAA,MAAA,KAAU;AACR,QAAA,IAAA,CAAK,GAAA,EAAI;AACT,QAAA,MAAM,MAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,IAAA,CAAK,GAAA,EAAI;AACT,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,cAAc,KAAA,EAA+C;AACpE,EAAA,OAAO,KAAA,IAAS,IAAA,IAAQ,OAAQ,KAAA,CAAkC,MAAM,CAAA,KAAM,UAAA;AAChF;AAEA,SAAS,gBAAA,CAAiB,UAAkB,eAAA,EAA+C;AACzF,EAAA,OAAO,eAAA,CAAgB,IAAA,CAAK,CAAA,OAAA,KAAY,OAAO,OAAA,KAAY,QAAA,GAAW,OAAA,KAAY,QAAA,GAAW,OAAA,CAAQ,IAAA,CAAK,QAAQ,CAAE,CAAA;AACtH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../../../src/integrations/tracing/prisma/vendored/constants.ts"],"sourcesContent":["/*\n * Copyright Prisma\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/prisma/prisma/tree/b6feea5565ec577545a79547d24273ccdd11b4c7/packages/instrumentation\n * - Upstream version: @prisma/instrumentation@7.8.0\n * - Replaced `import packageJson from '../package.json'` with hardcoded values\n */\n/* eslint-disable */\n\nimport { SDK_VERSION } from '@sentry/core';\n\nexport const VERSION = SDK_VERSION;\n\nexport const NAME = '@sentry/instrumentation-prisma';\n\nexport const MODULE_NAME = '@prisma/client';\n\nexport const SUPPORTED_MODULE_VERSIONS = ['>=5.0.0'];\n"],"names":["SDK_VERSION"],"mappings":";;;;AAaO,MAAM,OAAA,GAAUA;AAEhB,MAAM,IAAA,GAAO;AAEb,MAAM,WAAA,GAAc;AAEpB,MAAM,yBAAA,GAA4B,CAAC,SAAS;;;;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../../../src/integrations/tracing/prisma/vendored/constants.ts"],"sourcesContent":["/*\n * Copyright Prisma\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/prisma/prisma/tree/b6feea5565ec577545a79547d24273ccdd11b4c7/packages/instrumentation\n * - Upstream version: @prisma/instrumentation@7.8.0\n * - Replaced `import packageJson from '../package.json'` with hardcoded values\n */\n\nimport { SDK_VERSION } from '@sentry/core';\n\nexport const VERSION = SDK_VERSION;\n\nexport const NAME = '@sentry/instrumentation-prisma';\n\nexport const MODULE_NAME = '@prisma/client';\n\nexport const SUPPORTED_MODULE_VERSIONS = ['>=5.0.0'];\n"],"names":["SDK_VERSION"],"mappings":";;;;AAYO,MAAM,OAAA,GAAUA;AAEhB,MAAM,IAAA,GAAO;AAEb,MAAM,WAAA,GAAc;AAEpB,MAAM,yBAAA,GAA4B,CAAC,SAAS;;;;;;;"}
@@ -18,8 +18,8 @@ function setGlobalTracingHelper(helper) {
18
18
  globalThisWithPrismaInstrumentation[GLOBAL_INSTRUMENTATION_KEY] = globalValue;
19
19
  }
20
20
  function clearGlobalTracingHelper() {
21
- delete globalThisWithPrismaInstrumentation[GLOBAL_VERSIONED_INSTRUMENTATION_KEY];
22
- delete globalThisWithPrismaInstrumentation[GLOBAL_INSTRUMENTATION_KEY];
21
+ globalThisWithPrismaInstrumentation[GLOBAL_VERSIONED_INSTRUMENTATION_KEY] = void 0;
22
+ globalThisWithPrismaInstrumentation[GLOBAL_INSTRUMENTATION_KEY] = void 0;
23
23
  }
24
24
 
25
25
  exports.clearGlobalTracingHelper = clearGlobalTracingHelper;
@@ -1 +1 @@
1
- {"version":3,"file":"global.js","sources":["../../../../../../src/integrations/tracing/prisma/vendored/global.ts"],"sourcesContent":["/*\n * Copyright Prisma\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/prisma/prisma/tree/b6feea5565ec577545a79547d24273ccdd11b4c7/packages/instrumentation-contract\n * - Upstream version: @prisma/instrumentation-contract@7.8.0\n * - Replaced `import packageJson from '../package.json'` with hardcoded major version\n */\n/* eslint-disable */\n\nimport type { PrismaInstrumentationGlobalValue, TracingHelper } from './types';\n\nconst majorVersion = '7';\n\nconst GLOBAL_INSTRUMENTATION_KEY = 'PRISMA_INSTRUMENTATION';\nconst GLOBAL_VERSIONED_INSTRUMENTATION_KEY = `V${majorVersion}_PRISMA_INSTRUMENTATION` as const;\n\ntype GlobalThisWithPrismaInstrumentation = typeof globalThis & {\n [GLOBAL_INSTRUMENTATION_KEY]?: PrismaInstrumentationGlobalValue;\n} & {\n [K in typeof GLOBAL_VERSIONED_INSTRUMENTATION_KEY]?: PrismaInstrumentationGlobalValue;\n};\n\nconst globalThisWithPrismaInstrumentation = globalThis as GlobalThisWithPrismaInstrumentation;\n\nexport function getGlobalTracingHelper(): TracingHelper | undefined {\n const versionedGlobal = globalThisWithPrismaInstrumentation[GLOBAL_VERSIONED_INSTRUMENTATION_KEY];\n\n if (versionedGlobal?.helper) {\n return versionedGlobal.helper;\n }\n\n const fallbackGlobal = globalThisWithPrismaInstrumentation[GLOBAL_INSTRUMENTATION_KEY];\n\n return fallbackGlobal?.helper;\n}\n\nexport function setGlobalTracingHelper(helper: TracingHelper): void {\n const globalValue: PrismaInstrumentationGlobalValue = { helper };\n\n globalThisWithPrismaInstrumentation[GLOBAL_VERSIONED_INSTRUMENTATION_KEY] = globalValue;\n globalThisWithPrismaInstrumentation[GLOBAL_INSTRUMENTATION_KEY] = globalValue;\n}\n\nexport function clearGlobalTracingHelper(): void {\n delete globalThisWithPrismaInstrumentation[GLOBAL_VERSIONED_INSTRUMENTATION_KEY];\n delete globalThisWithPrismaInstrumentation[GLOBAL_INSTRUMENTATION_KEY];\n}\n"],"names":[],"mappings":";;AAaA,MAAM,YAAA,GAAe,GAAA;AAErB,MAAM,0BAAA,GAA6B,wBAAA;AACnC,MAAM,oCAAA,GAAuC,IAAI,YAAY,CAAA,uBAAA,CAAA;AAQ7D,MAAM,mCAAA,GAAsC,UAAA;AAErC,SAAS,sBAAA,GAAoD;AAClE,EAAA,MAAM,eAAA,GAAkB,oCAAoC,oCAAoC,CAAA;AAEhG,EAAA,IAAI,iBAAiB,MAAA,EAAQ;AAC3B,IAAA,OAAO,eAAA,CAAgB,MAAA;AAAA,EACzB;AAEA,EAAA,MAAM,cAAA,GAAiB,oCAAoC,0BAA0B,CAAA;AAErF,EAAA,OAAO,cAAA,EAAgB,MAAA;AACzB;AAEO,SAAS,uBAAuB,MAAA,EAA6B;AAClE,EAAA,MAAM,WAAA,GAAgD,EAAE,MAAA,EAAO;AAE/D,EAAA,mCAAA,CAAoC,oCAAoC,CAAA,GAAI,WAAA;AAC5E,EAAA,mCAAA,CAAoC,0BAA0B,CAAA,GAAI,WAAA;AACpE;AAEO,SAAS,wBAAA,GAAiC;AAC/C,EAAA,OAAO,oCAAoC,oCAAoC,CAAA;AAC/E,EAAA,OAAO,oCAAoC,0BAA0B,CAAA;AACvE;;;;;;"}
1
+ {"version":3,"file":"global.js","sources":["../../../../../../src/integrations/tracing/prisma/vendored/global.ts"],"sourcesContent":["/*\n * Copyright Prisma\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/prisma/prisma/tree/b6feea5565ec577545a79547d24273ccdd11b4c7/packages/instrumentation-contract\n * - Upstream version: @prisma/instrumentation-contract@7.8.0\n * - Replaced `import packageJson from '../package.json'` with hardcoded major version\n */\n\nimport type { PrismaInstrumentationGlobalValue, TracingHelper } from './types';\n\nconst majorVersion = '7';\n\nconst GLOBAL_INSTRUMENTATION_KEY = 'PRISMA_INSTRUMENTATION';\nconst GLOBAL_VERSIONED_INSTRUMENTATION_KEY = `V${majorVersion}_PRISMA_INSTRUMENTATION` as const;\n\ntype GlobalThisWithPrismaInstrumentation = typeof globalThis & {\n [GLOBAL_INSTRUMENTATION_KEY]?: PrismaInstrumentationGlobalValue;\n} & {\n [K in typeof GLOBAL_VERSIONED_INSTRUMENTATION_KEY]?: PrismaInstrumentationGlobalValue;\n};\n\nconst globalThisWithPrismaInstrumentation = globalThis as GlobalThisWithPrismaInstrumentation;\n\nexport function getGlobalTracingHelper(): TracingHelper | undefined {\n const versionedGlobal = globalThisWithPrismaInstrumentation[GLOBAL_VERSIONED_INSTRUMENTATION_KEY];\n\n if (versionedGlobal?.helper) {\n return versionedGlobal.helper;\n }\n\n const fallbackGlobal = globalThisWithPrismaInstrumentation[GLOBAL_INSTRUMENTATION_KEY];\n\n return fallbackGlobal?.helper;\n}\n\nexport function setGlobalTracingHelper(helper: TracingHelper): void {\n const globalValue: PrismaInstrumentationGlobalValue = { helper };\n\n globalThisWithPrismaInstrumentation[GLOBAL_VERSIONED_INSTRUMENTATION_KEY] = globalValue;\n globalThisWithPrismaInstrumentation[GLOBAL_INSTRUMENTATION_KEY] = globalValue;\n}\n\nexport function clearGlobalTracingHelper(): void {\n globalThisWithPrismaInstrumentation[GLOBAL_VERSIONED_INSTRUMENTATION_KEY] = undefined;\n globalThisWithPrismaInstrumentation[GLOBAL_INSTRUMENTATION_KEY] = undefined;\n}\n"],"names":[],"mappings":";;AAYA,MAAM,YAAA,GAAe,GAAA;AAErB,MAAM,0BAAA,GAA6B,wBAAA;AACnC,MAAM,oCAAA,GAAuC,IAAI,YAAY,CAAA,uBAAA,CAAA;AAQ7D,MAAM,mCAAA,GAAsC,UAAA;AAErC,SAAS,sBAAA,GAAoD;AAClE,EAAA,MAAM,eAAA,GAAkB,oCAAoC,oCAAoC,CAAA;AAEhG,EAAA,IAAI,iBAAiB,MAAA,EAAQ;AAC3B,IAAA,OAAO,eAAA,CAAgB,MAAA;AAAA,EACzB;AAEA,EAAA,MAAM,cAAA,GAAiB,oCAAoC,0BAA0B,CAAA;AAErF,EAAA,OAAO,cAAA,EAAgB,MAAA;AACzB;AAEO,SAAS,uBAAuB,MAAA,EAA6B;AAClE,EAAA,MAAM,WAAA,GAAgD,EAAE,MAAA,EAAO;AAE/D,EAAA,mCAAA,CAAoC,oCAAoC,CAAA,GAAI,WAAA;AAC5E,EAAA,mCAAA,CAAoC,0BAA0B,CAAA,GAAI,WAAA;AACpE;AAEO,SAAS,wBAAA,GAAiC;AAC/C,EAAA,mCAAA,CAAoC,oCAAoC,CAAA,GAAI,MAAA;AAC5E,EAAA,mCAAA,CAAoC,0BAA0B,CAAA,GAAI,MAAA;AACpE;;;;;;"}
@@ -1,18 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const api = require('@opentelemetry/api');
4
3
  const instrumentation = require('@opentelemetry/instrumentation');
5
- const global = require('./global.js');
6
4
  const activeTracingHelper = require('./active-tracing-helper.js');
7
5
  const constants = require('./constants.js');
6
+ const global = require('./global.js');
8
7
 
9
8
  class PrismaInstrumentation extends instrumentation.InstrumentationBase {
10
9
  constructor(config = {}) {
11
10
  super(constants.NAME, constants.VERSION, config);
12
11
  }
13
- setTracerProvider(tracerProvider) {
14
- this.tracerProvider = tracerProvider;
15
- }
16
12
  init() {
17
13
  const module = new instrumentation.InstrumentationNodeModuleDefinition(constants.MODULE_NAME, constants.SUPPORTED_MODULE_VERSIONS);
18
14
  return [module];
@@ -21,7 +17,6 @@ class PrismaInstrumentation extends instrumentation.InstrumentationBase {
21
17
  const config = this._config;
22
18
  global.setGlobalTracingHelper(
23
19
  new activeTracingHelper.ActiveTracingHelper({
24
- tracerProvider: this.tracerProvider ?? api.trace.getTracerProvider(),
25
20
  ignoreSpanTypes: config.ignoreSpanTypes ?? []
26
21
  })
27
22
  );
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/prisma/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright Prisma\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/prisma/prisma/tree/b6feea5565ec577545a79547d24273ccdd11b4c7/packages/instrumentation\n * - Upstream version: @prisma/instrumentation@7.8.0\n * - Replaced `@prisma/instrumentation-contract` imports with local vendored equivalents\n * - Replaced `import { VERSION, NAME, MODULE_NAME } from './constants'` with local vendored constants\n */\n/* eslint-disable */\n\nimport { trace, TracerProvider } from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationConfig,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport { clearGlobalTracingHelper, getGlobalTracingHelper, setGlobalTracingHelper } from './global';\n\nimport { ActiveTracingHelper } from './active-tracing-helper';\nimport { MODULE_NAME, NAME, SUPPORTED_MODULE_VERSIONS, VERSION } from './constants';\n\nexport interface PrismaInstrumentationConfig {\n ignoreSpanTypes?: (string | RegExp)[];\n}\n\ntype Config = PrismaInstrumentationConfig & InstrumentationConfig;\n\nexport class PrismaInstrumentation extends InstrumentationBase {\n private tracerProvider: TracerProvider | undefined;\n\n constructor(config: Config = {}) {\n super(NAME, VERSION, config);\n }\n\n setTracerProvider(tracerProvider: TracerProvider): void {\n this.tracerProvider = tracerProvider;\n }\n\n init() {\n const module = new InstrumentationNodeModuleDefinition(MODULE_NAME, SUPPORTED_MODULE_VERSIONS);\n\n return [module];\n }\n\n enable() {\n const config = this._config as Config;\n\n setGlobalTracingHelper(\n new ActiveTracingHelper({\n tracerProvider: this.tracerProvider ?? trace.getTracerProvider(),\n ignoreSpanTypes: config.ignoreSpanTypes ?? [],\n }),\n );\n }\n\n disable() {\n clearGlobalTracingHelper();\n }\n\n isEnabled() {\n return getGlobalTracingHelper() !== undefined;\n }\n}\n"],"names":["InstrumentationBase","NAME","VERSION","InstrumentationNodeModuleDefinition","MODULE_NAME","SUPPORTED_MODULE_VERSIONS","setGlobalTracingHelper","ActiveTracingHelper","trace","clearGlobalTracingHelper","getGlobalTracingHelper"],"mappings":";;;;;;;;AA6BO,MAAM,8BAA8BA,mCAAA,CAAoB;AAAA,EAG7D,WAAA,CAAY,MAAA,GAAiB,EAAC,EAAG;AAC/B,IAAA,KAAA,CAAMC,cAAA,EAAMC,mBAAS,MAAM,CAAA;AAAA,EAC7B;AAAA,EAEA,kBAAkB,cAAA,EAAsC;AACtD,IAAA,IAAA,CAAK,cAAA,GAAiB,cAAA;AAAA,EACxB;AAAA,EAEA,IAAA,GAAO;AACL,IAAA,MAAM,MAAA,GAAS,IAAIC,mDAAA,CAAoCC,qBAAA,EAAaC,mCAAyB,CAAA;AAE7F,IAAA,OAAO,CAAC,MAAM,CAAA;AAAA,EAChB;AAAA,EAEA,MAAA,GAAS;AACP,IAAA,MAAM,SAAS,IAAA,CAAK,OAAA;AAEpB,IAAAC,6BAAA;AAAA,MACE,IAAIC,uCAAA,CAAoB;AAAA,QACtB,cAAA,EAAgB,IAAA,CAAK,cAAA,IAAkBC,SAAA,CAAM,iBAAA,EAAkB;AAAA,QAC/D,eAAA,EAAiB,MAAA,CAAO,eAAA,IAAmB;AAAC,OAC7C;AAAA,KACH;AAAA,EACF;AAAA,EAEA,OAAA,GAAU;AACR,IAAAC,+BAAA,EAAyB;AAAA,EAC3B;AAAA,EAEA,SAAA,GAAY;AACV,IAAA,OAAOC,+BAAuB,KAAM,MAAA;AAAA,EACtC;AACF;;;;"}
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/prisma/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright Prisma\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/prisma/prisma/tree/b6feea5565ec577545a79547d24273ccdd11b4c7/packages/instrumentation\n * - Upstream version: @prisma/instrumentation@7.8.0\n * - Replaced `@prisma/instrumentation-contract` imports with local vendored equivalents\n * - Replaced `import { VERSION, NAME, MODULE_NAME } from './constants'` with local vendored constants\n * - Removed the unused `setTracerProvider`/`tracerProvider` members; spans are created through Sentry's\n * span APIs, which resolve the active client themselves\n */\n\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport { ActiveTracingHelper } from './active-tracing-helper';\nimport { MODULE_NAME, NAME, SUPPORTED_MODULE_VERSIONS, VERSION } from './constants';\nimport { clearGlobalTracingHelper, getGlobalTracingHelper, setGlobalTracingHelper } from './global';\n\nexport interface PrismaInstrumentationConfig {\n ignoreSpanTypes?: (string | RegExp)[];\n}\n\ntype Config = PrismaInstrumentationConfig & InstrumentationConfig;\n\nexport class PrismaInstrumentation extends InstrumentationBase {\n public constructor(config: Config = {}) {\n super(NAME, VERSION, config);\n }\n\n public init(): InstrumentationNodeModuleDefinition[] {\n const module = new InstrumentationNodeModuleDefinition(MODULE_NAME, SUPPORTED_MODULE_VERSIONS);\n\n return [module];\n }\n\n public enable(): void {\n const config = this._config as Config;\n\n setGlobalTracingHelper(\n new ActiveTracingHelper({\n ignoreSpanTypes: config.ignoreSpanTypes ?? [],\n }),\n );\n }\n\n public disable(): void {\n clearGlobalTracingHelper();\n }\n\n public isEnabled(): boolean {\n return getGlobalTracingHelper() !== undefined;\n }\n}\n"],"names":["InstrumentationBase","NAME","VERSION","InstrumentationNodeModuleDefinition","MODULE_NAME","SUPPORTED_MODULE_VERSIONS","setGlobalTracingHelper","ActiveTracingHelper","clearGlobalTracingHelper","getGlobalTracingHelper"],"mappings":";;;;;;;AAyBO,MAAM,8BAA8BA,mCAAA,CAAoB;AAAA,EACtD,WAAA,CAAY,MAAA,GAAiB,EAAC,EAAG;AACtC,IAAA,KAAA,CAAMC,cAAA,EAAMC,mBAAS,MAAM,CAAA;AAAA,EAC7B;AAAA,EAEO,IAAA,GAA8C;AACnD,IAAA,MAAM,MAAA,GAAS,IAAIC,mDAAA,CAAoCC,qBAAA,EAAaC,mCAAyB,CAAA;AAE7F,IAAA,OAAO,CAAC,MAAM,CAAA;AAAA,EAChB;AAAA,EAEO,MAAA,GAAe;AACpB,IAAA,MAAM,SAAS,IAAA,CAAK,OAAA;AAEpB,IAAAC,6BAAA;AAAA,MACE,IAAIC,uCAAA,CAAoB;AAAA,QACtB,eAAA,EAAiB,MAAA,CAAO,eAAA,IAAmB;AAAC,OAC7C;AAAA,KACH;AAAA,EACF;AAAA,EAEO,OAAA,GAAgB;AACrB,IAAAC,+BAAA,EAAyB;AAAA,EAC3B;AAAA,EAEO,SAAA,GAAqB;AAC1B,IAAA,OAAOC,+BAAuB,KAAM,MAAA;AAAA,EACtC;AACF;;;;"}
@@ -52,9 +52,11 @@ const instrumentRedis = Object.assign(
52
52
  () => {
53
53
  instrumentIORedis();
54
54
  instrumentRedisModule();
55
- void Promise.resolve().then(
56
- () => serverUtils.subscribeRedisDiagnosticChannels(dc.tracingChannel, cacheResponseHook)
57
- );
55
+ if (dc.tracingChannel) {
56
+ core.waitForTracingChannelBinding(() => {
57
+ serverUtils.subscribeRedisDiagnosticChannels(dc.tracingChannel, cacheResponseHook);
58
+ });
59
+ }
58
60
  },
59
61
  { id: INTEGRATION_NAME }
60
62
  );
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/redis/index.ts"],"sourcesContent":["import type { IntegrationFn, Span } from '@sentry/core';\nimport {\n defineIntegration,\n SEMANTIC_ATTRIBUTE_CACHE_HIT,\n SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE,\n SEMANTIC_ATTRIBUTE_CACHE_KEY,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n spanToJSON,\n truncate,\n} from '@sentry/core';\nimport { tracingChannel } from 'node:diagnostics_channel';\nimport { subscribeRedisDiagnosticChannels, type RedisTracingChannelFactory } from '@sentry/server-utils';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport type { IORedisCommandArgs } from '../../../utils/redisCache';\nimport {\n calculateCacheItemSize,\n GET_COMMANDS,\n getCacheKeySafely,\n getCacheOperation,\n isInCommands,\n shouldConsiderForCache,\n} from '../../../utils/redisCache';\nimport type { IORedisResponseCustomAttributeFunction } from './vendored/types';\nimport { IORedisInstrumentation } from './vendored/ioredis-instrumentation';\nimport { RedisInstrumentation } from './vendored/redis-instrumentation';\n\ninterface RedisOptions {\n /**\n * Define cache prefixes for cache keys that should be captured as a cache span.\n *\n * Setting this to, for example, `['user:']` will capture cache keys that start with `user:`.\n */\n cachePrefixes?: string[];\n /**\n * Maximum length of the cache key added to the span description. If the key exceeds this length, it will be truncated.\n *\n * Passing `0` will use the full cache key without truncation.\n *\n * By default, the full cache key is used.\n */\n maxCacheKeyLength?: number;\n}\n\nconst INTEGRATION_NAME = 'Redis';\n\n/* Only exported for testing purposes */\nexport let _redisOptions: RedisOptions = {};\n\n/* Only exported for testing purposes */\nexport const cacheResponseHook: IORedisResponseCustomAttributeFunction = (\n span: Span,\n redisCommand: string,\n cmdArgs: IORedisCommandArgs,\n response: unknown,\n) => {\n const safeKey = getCacheKeySafely(redisCommand, cmdArgs);\n const cacheOperation = getCacheOperation(redisCommand);\n\n if (\n !safeKey ||\n !cacheOperation ||\n !_redisOptions.cachePrefixes ||\n !shouldConsiderForCache(redisCommand, safeKey, _redisOptions.cachePrefixes)\n ) {\n // not relevant for cache\n return;\n }\n\n // otel/ioredis seems to be using the old standard, as there was a change to those params: https://github.com/open-telemetry/opentelemetry-specification/issues/3199\n // We are using params based on the docs: https://opentelemetry.io/docs/specs/semconv/attributes-registry/network/\n // Fall back to stable semconv attributes (server.address/server.port) when\n // old-semconv ones are absent, eg OTEL_SEMCONV_STABILITY_OPT_IN=database\n // set for node-redis v4/v5.\n const spanData = spanToJSON(span).data;\n const networkPeerAddress = spanData['net.peer.name'] ?? spanData['server.address'];\n const networkPeerPort = spanData['net.peer.port'] ?? spanData['server.port'];\n if (networkPeerPort && networkPeerAddress) {\n span.setAttributes({ 'network.peer.address': networkPeerAddress, 'network.peer.port': networkPeerPort });\n }\n\n const cacheItemSize = calculateCacheItemSize(response);\n\n if (cacheItemSize) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE, cacheItemSize);\n }\n\n if (isInCommands(GET_COMMANDS, redisCommand) && cacheItemSize !== undefined) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_CACHE_HIT, cacheItemSize > 0);\n }\n\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: cacheOperation,\n [SEMANTIC_ATTRIBUTE_CACHE_KEY]: safeKey,\n });\n\n // todo: change to string[] once EAP supports it\n const spanDescription = safeKey.join(', ');\n\n span.updateName(\n _redisOptions.maxCacheKeyLength ? truncate(spanDescription, _redisOptions.maxCacheKeyLength) : spanDescription,\n );\n};\n\nconst instrumentIORedis = generateInstrumentOnce(`${INTEGRATION_NAME}.IORedis`, () => {\n return new IORedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\nconst instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME}.Redis`, () => {\n return new RedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\n/**\n * To be able to preload all Redis OTel instrumentations with just one ID\n * (\"Redis\"), all the instrumentations are generated in this one function\n */\nexport const instrumentRedis = Object.assign(\n (): void => {\n instrumentIORedis();\n instrumentRedisModule();\n // node-redis >= 5.12.0 and ioredis >= 5.11.0 publish via diagnostics_channel.\n // `bindTracingChannelToSpan` (inside the subscriber) makes the span the active\n // OTel context via `bindStore`, which needs the Sentry OTel context manager to\n // be registered — `initOpenTelemetry()` does that after integration `setupOnce`,\n // so defer to the next tick.\n void Promise.resolve().then(() =>\n subscribeRedisDiagnosticChannels(tracingChannel as RedisTracingChannelFactory, cacheResponseHook),\n );\n\n // todo: implement them gradually\n // new LegacyRedisInstrumentation({}),\n },\n { id: INTEGRATION_NAME },\n);\n\nconst _redisIntegration = ((options: RedisOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n _redisOptions = options;\n instrumentRedis();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and\n * [ioredis](https://www.npmjs.com/package/ioredis) libraries.\n *\n * For more information, see the [`redisIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.redisIntegration()],\n * });\n * ```\n */\nexport const redisIntegration = defineIntegration(_redisIntegration);\n"],"names":["_redisOptions","getCacheKeySafely","getCacheOperation","shouldConsiderForCache","spanToJSON","calculateCacheItemSize","SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE","isInCommands","GET_COMMANDS","SEMANTIC_ATTRIBUTE_CACHE_HIT","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_CACHE_KEY","truncate","generateInstrumentOnce","IORedisInstrumentation","RedisInstrumentation","subscribeRedisDiagnosticChannels","tracingChannel","defineIntegration"],"mappings":";;;;;;;;;;AA2CA,MAAM,gBAAA,GAAmB,OAAA;AAGdA,wBAA8B;AAGlC,MAAM,iBAAA,GAA4D,CACvE,IAAA,EACA,YAAA,EACA,SACA,QAAA,KACG;AACH,EAAA,MAAM,OAAA,GAAUC,4BAAA,CAAkB,YAAA,EAAc,OAAO,CAAA;AACvD,EAAA,MAAM,cAAA,GAAiBC,6BAAkB,YAAY,CAAA;AAErD,EAAA,IACE,CAAC,OAAA,IACD,CAAC,cAAA,IACD,CAACF,qBAAA,CAAc,aAAA,IACf,CAACG,iCAAA,CAAuB,YAAA,EAAc,OAAA,EAASH,qBAAA,CAAc,aAAa,CAAA,EAC1E;AAEA,IAAA;AAAA,EACF;AAOA,EAAA,MAAM,QAAA,GAAWI,eAAA,CAAW,IAAI,CAAA,CAAE,IAAA;AAClC,EAA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IAAIE,yCAAA,CAAqB;AAAA,IAC9B,YAAA,EAAc;AAAA,GACf,CAAA;AACH,CAAC,CAAA;AAMM,MAAM,kBAAkB,MAAA,CAAO,MAAA;AAAA,EACpC,MAAY;AACV,IAAA,iBAAA,EAAkB;AAClB,IAAA,qBAAA,EAAsB;AAMtB,IAAA,KAAK,OAAA,CAAQ,SAAQ,CAAE,IAAA;AAAA,MAAK,MAC1BC,4CAAA,CAAiCC,iBAAA,EAA8C,iBAAiB;AAAA,KAClG;AAAA,EAIF,CAAA;AAAA,EACA,EAAE,IAAI,gBAAA;AACR;AAEA,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAAwB,EAAC,KAAM;AACzD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAAjB,qBAAA,GAAgB,OAAA;AAChB,MAAA,eAAA,EAAgB;AAAA,IAClB;AAAA,GACF;AACF,CAAA,CAAA;AAiBO,MAAM,gBAAA,GAAmBkB,uBAAkB,iBAAiB;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/redis/index.ts"],"sourcesContent":["import type { IntegrationFn, Span } from '@sentry/core';\nimport {\n defineIntegration,\n SEMANTIC_ATTRIBUTE_CACHE_HIT,\n SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE,\n SEMANTIC_ATTRIBUTE_CACHE_KEY,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n spanToJSON,\n truncate,\n waitForTracingChannelBinding,\n} from '@sentry/core';\nimport * as dc from 'node:diagnostics_channel';\nimport { subscribeRedisDiagnosticChannels, type RedisTracingChannelFactory } from '@sentry/server-utils';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport type { IORedisCommandArgs } from '../../../utils/redisCache';\nimport {\n calculateCacheItemSize,\n GET_COMMANDS,\n getCacheKeySafely,\n getCacheOperation,\n isInCommands,\n shouldConsiderForCache,\n} from '../../../utils/redisCache';\nimport type { IORedisResponseCustomAttributeFunction } from './vendored/types';\nimport { IORedisInstrumentation } from './vendored/ioredis-instrumentation';\nimport { RedisInstrumentation } from './vendored/redis-instrumentation';\n\ninterface RedisOptions {\n /**\n * Define cache prefixes for cache keys that should be captured as a cache span.\n *\n * Setting this to, for example, `['user:']` will capture cache keys that start with `user:`.\n */\n cachePrefixes?: string[];\n /**\n * Maximum length of the cache key added to the span description. If the key exceeds this length, it will be truncated.\n *\n * Passing `0` will use the full cache key without truncation.\n *\n * By default, the full cache key is used.\n */\n maxCacheKeyLength?: number;\n}\n\nconst INTEGRATION_NAME = 'Redis' as const;\n\n/* Only exported for testing purposes */\nexport let _redisOptions: RedisOptions = {};\n\n/* Only exported for testing purposes */\nexport const cacheResponseHook: IORedisResponseCustomAttributeFunction = (\n span: Span,\n redisCommand: string,\n cmdArgs: IORedisCommandArgs,\n response: unknown,\n) => {\n const safeKey = getCacheKeySafely(redisCommand, cmdArgs);\n const cacheOperation = getCacheOperation(redisCommand);\n\n if (\n !safeKey ||\n !cacheOperation ||\n !_redisOptions.cachePrefixes ||\n !shouldConsiderForCache(redisCommand, safeKey, _redisOptions.cachePrefixes)\n ) {\n // not relevant for cache\n return;\n }\n\n // otel/ioredis seems to be using the old standard, as there was a change to those params: https://github.com/open-telemetry/opentelemetry-specification/issues/3199\n // We are using params based on the docs: https://opentelemetry.io/docs/specs/semconv/attributes-registry/network/\n // Fall back to stable semconv attributes (server.address/server.port) when\n // old-semconv ones are absent, eg OTEL_SEMCONV_STABILITY_OPT_IN=database\n // set for node-redis v4/v5.\n const spanData = spanToJSON(span).data;\n const networkPeerAddress = spanData['net.peer.name'] ?? spanData['server.address'];\n const networkPeerPort = spanData['net.peer.port'] ?? spanData['server.port'];\n if (networkPeerPort && networkPeerAddress) {\n span.setAttributes({ 'network.peer.address': networkPeerAddress, 'network.peer.port': networkPeerPort });\n }\n\n const cacheItemSize = calculateCacheItemSize(response);\n\n if (cacheItemSize) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE, cacheItemSize);\n }\n\n if (isInCommands(GET_COMMANDS, redisCommand) && cacheItemSize !== undefined) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_CACHE_HIT, cacheItemSize > 0);\n }\n\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: cacheOperation,\n [SEMANTIC_ATTRIBUTE_CACHE_KEY]: safeKey,\n });\n\n // todo: change to string[] once EAP supports it\n const spanDescription = safeKey.join(', ');\n\n span.updateName(\n _redisOptions.maxCacheKeyLength ? truncate(spanDescription, _redisOptions.maxCacheKeyLength) : spanDescription,\n );\n};\n\nconst instrumentIORedis = generateInstrumentOnce(`${INTEGRATION_NAME}.IORedis`, () => {\n return new IORedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\nconst instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME}.Redis`, () => {\n return new RedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\n/**\n * To be able to preload all Redis OTel instrumentations with just one ID\n * (\"Redis\"), all the instrumentations are generated in this one function\n */\nexport const instrumentRedis = Object.assign(\n (): void => {\n instrumentIORedis();\n instrumentRedisModule();\n // node-redis >= 5.12.0 and ioredis >= 5.11.0 publish via diagnostics_channel.\n // `bindTracingChannelToSpan` (inside the subscriber) makes the span the active\n // OTel context via `bindStore`, which needs the Sentry OTel context manager to\n // be registered — `initOpenTelemetry()` does that after integration `setupOnce`,\n // so defer to the next tick.\n // Check this here to ensure this does not fail at runtime for Node <= 18.18.0\n if (dc.tracingChannel) {\n waitForTracingChannelBinding(() => {\n subscribeRedisDiagnosticChannels(dc.tracingChannel as RedisTracingChannelFactory, cacheResponseHook);\n });\n }\n\n // todo: implement them gradually\n // new LegacyRedisInstrumentation({}),\n },\n { id: INTEGRATION_NAME },\n);\n\nconst _redisIntegration = ((options: RedisOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n _redisOptions = options;\n instrumentRedis();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and\n * [ioredis](https://www.npmjs.com/package/ioredis) libraries.\n *\n * For more information, see the [`redisIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.redisIntegration()],\n * });\n * ```\n */\nexport const redisIntegration = defineIntegration(_redisIntegration);\n"],"names":["_redisOptions","getCacheKeySafely","getCacheOperation","shouldConsiderForCache","spanToJSON","calculateCacheItemSize","SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE","isInCommands","GET_COMMANDS","SEMANTIC_ATTRIBUTE_CACHE_HIT","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_CACHE_KEY","truncate","generateInstrumentOnce","IORedisInstrumentation","RedisInstrumentation","waitForTracingChannelBinding","subscribeRedisDiagnosticChannels","defineIntegration"],"mappings":";;;;;;;;;;AA4CA,MAAM,gBAAA,GAAmB,OAAA;AAGdA,wBAA8B;AAGlC,MAAM,iBAAA,GAA4D,CACvE,IAAA,EACA,YAAA,EACA,SACA,QAAA,KACG;AACH,EAAA,MAAM,OAAA,GAAUC,4BAAA,CAAkB,YAAA,EAAc,OAAO,CAAA;AACvD,EAAA,MAAM,cAAA,GAAiBC,6BAAkB,YAAY,CAAA;AAErD,EAAA,IACE,CAAC,OAAA,IACD,CAAC,cAAA,IACD,CAACF,qBAAA,CAAc,aAAA,IACf,CAACG,iCAAA,CAAuB,YAAA,EAAc,OAAA,EAASH,qBAAA,CAAc,aAAa,CAAA,EAC1E;AAEA,IAAA;AAAA,EACF;AAOA,EAAA,MAAM,QAAA,GAAWI,eAAA,CAAW,IAAI,CAAA,CAAE,IAAA;AAClC,EAAA,MAAM,kBAAA,GAAqB,QAAA,CAAS,eAAe,CAAA,IAAK,SAAS,gBAAgB,CAAA;AACjF,EAAA,MAAM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M,kBAAkB,MAAA,CAAO,MAAA;AAAA,EACpC,MAAY;AACV,IAAA,iBAAA,EAAkB;AAClB,IAAA,qBAAA,EAAsB;AAOtB,IAAA,IAAI,GAAG,cAAA,EAAgB;AACrB,MAAAC,iCAAA,CAA6B,MAAM;AACjC,QAAAC,4CAAA,CAAiC,EAAA,CAAG,gBAA8C,iBAAiB,CAAA;AAAA,MACrG,CAAC,CAAA;AAAA,IACH;AAAA,EAIF,CAAA;AAAA,EACA,EAAE,IAAI,gBAAA;AACR;AAEA,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAAwB,EAAC,KAAM;AACzD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAAjB,qBAAA,GAAgB,OAAA;AAChB,MAAA,eAAA,EAAgB;AAAA,IAClB;AAAA,GACF;AACF,CAAA,CAAA;AAiBO,MAAM,gBAAA,GAAmBkB,uBAAkB,iBAAiB;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/tedious/index.ts"],"sourcesContent":["import { TediousInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Tedious';\n\nexport const instrumentTedious = generateInstrumentOnce(INTEGRATION_NAME, () => new TediousInstrumentation({}));\n\nconst _tediousIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentTedious();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [tedious](https://www.npmjs.com/package/tedious) library.\n *\n * For more information, see the [`tediousIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/tedious/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.tediousIntegration()],\n * });\n * ```\n */\nexport const tediousIntegration = defineIntegration(_tediousIntegration);\n"],"names":["generateInstrumentOnce","TediousInstrumentation","defineIntegration"],"mappings":";;;;;;AAKA,MAAM,gBAAA,GAAmB,SAAA;AAElB,MAAM,iBAAA,GAAoBA,gCAAuB,gBAAA,EAAkB,MAAM,IAAIC,sCAAA,CAAuB,EAAE,CAAC;AAE9G,MAAM,uBAAuB,MAAM;AACjC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,iBAAA,EAAkB;AAAA,IACpB;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,kBAAA,GAAqBC,uBAAkB,mBAAmB;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/tedious/index.ts"],"sourcesContent":["import { TediousInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Tedious' as const;\n\nexport const instrumentTedious = generateInstrumentOnce(INTEGRATION_NAME, () => new TediousInstrumentation({}));\n\nconst _tediousIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentTedious();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [tedious](https://www.npmjs.com/package/tedious) library.\n *\n * For more information, see the [`tediousIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/tedious/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.tediousIntegration()],\n * });\n * ```\n */\nexport const tediousIntegration = defineIntegration(_tediousIntegration);\n"],"names":["generateInstrumentOnce","TediousInstrumentation","defineIntegration"],"mappings":";;;;;;AAKA,MAAM,gBAAA,GAAmB,SAAA;AAElB,MAAM,iBAAA,GAAoBA,gCAAuB,gBAAA,EAAkB,MAAM,IAAIC,sCAAA,CAAuB,EAAE,CAAC;AAE9G,MAAM,uBAAuB,MAAM;AACjC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,iBAAA,EAAkB;AAAA,IACpB;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,kBAAA,GAAqBC,uBAAkB,mBAAmB;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../../src/integrations/tracing/vercelai/constants.ts"],"sourcesContent":["export const INTEGRATION_NAME = 'VercelAI';\n"],"names":[],"mappings":";;AAAO,MAAM,gBAAA,GAAmB;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../../src/integrations/tracing/vercelai/constants.ts"],"sourcesContent":["export const INTEGRATION_NAME = 'VercelAI' as const;\n"],"names":[],"mappings":";;AAAO,MAAM,gBAAA,GAAmB;;;;"}
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const core = require('@sentry/core');
4
4
  const nodeCore = require('@sentry/node-core');
5
+ const serverUtils = require('@sentry/server-utils');
5
6
  const constants = require('./constants.js');
6
7
  const instrumentation = require('./instrumentation.js');
7
8
 
@@ -12,8 +13,8 @@ function shouldForceIntegration(client) {
12
13
  }
13
14
  const _vercelAIIntegration = ((options = {}) => {
14
15
  let instrumentation;
15
- return {
16
- name: constants.INTEGRATION_NAME,
16
+ const parentIntegration = serverUtils.vercelAiIntegration(options);
17
+ return core.extendIntegration(parentIntegration, {
17
18
  options,
18
19
  setupOnce() {
19
20
  instrumentation = instrumentVercelAi();
@@ -26,7 +27,7 @@ const _vercelAIIntegration = ((options = {}) => {
26
27
  instrumentation?.callWhenPatched(() => core.addVercelAiProcessors(client));
27
28
  }
28
29
  }
29
- };
30
+ });
30
31
  });
31
32
  const vercelAIIntegration = core.defineIntegration(_vercelAIIntegration);
32
33
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/vercelai/index.ts"],"sourcesContent":["import type { Client, IntegrationFn } from '@sentry/core';\nimport { addVercelAiProcessors, defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce, type modulesIntegration } from '@sentry/node-core';\nimport { INTEGRATION_NAME } from './constants';\nimport { SentryVercelAiInstrumentation } from './instrumentation';\nimport type { VercelAiOptions } from './types';\n\nexport const instrumentVercelAi = generateInstrumentOnce(INTEGRATION_NAME, () => new SentryVercelAiInstrumentation({}));\n\n/**\n * Determines if the integration should be forced based on environment and package availability.\n * Returns true if the 'ai' package is available.\n */\nfunction shouldForceIntegration(client: Client): boolean {\n const modules = client.getIntegrationByName<ReturnType<typeof modulesIntegration>>('Modules');\n return !!modules?.getModules?.()?.ai;\n}\n\nconst _vercelAIIntegration = ((options: VercelAiOptions = {}) => {\n let instrumentation: undefined | SentryVercelAiInstrumentation;\n\n return {\n name: INTEGRATION_NAME,\n options,\n setupOnce() {\n instrumentation = instrumentVercelAi();\n },\n afterAllSetup(client) {\n // Auto-detect if we should force the integration when running with 'ai' package available\n // Note that this can only be detected if the 'Modules' integration is available, and running in CJS mode\n const shouldForce = options.force ?? shouldForceIntegration(client);\n\n if (shouldForce) {\n addVercelAiProcessors(client);\n } else {\n instrumentation?.callWhenPatched(() => addVercelAiProcessors(client));\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.\n * This integration is not enabled by default, you need to manually add it.\n *\n * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.vercelAIIntegration()],\n * });\n * ```\n *\n * This integration adds tracing support to all `ai` function calls.\n * You need to opt-in to collecting spans for a specific call,\n * you can do so by setting `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true },\n * });\n * ```\n *\n * If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each\n * function call by setting `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs`\n * to `true`.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },\n * });\n */\nexport const vercelAIIntegration = defineIntegration(_vercelAIIntegration);\n"],"names":["generateInstrumentOnce","INTEGRATION_NAME","SentryVercelAiInstrumentation","addVercelAiProcessors","defineIntegration"],"mappings":";;;;;;;AAOO,MAAM,kBAAA,GAAqBA,gCAAuBC,0BAAA,EAAkB,MAAM,IAAIC,6CAAA,CAA8B,EAAE,CAAC;AAMtH,SAAS,uBAAuB,MAAA,EAAyB;AACvD,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,oBAAA,CAA4D,SAAS,CAAA;AAC5F,EAAA,OAAO,CAAC,CAAC,OAAA,EAAS,UAAA,IAAa,EAAG,EAAA;AACpC;AAEA,MAAM,oBAAA,IAAwB,CAAC,OAAA,GAA2B,EAAC,KAAM;AAC/D,EAAA,IAAI,eAAA;AAEJ,EAAA,OAAO;AAAA,IACL,IAAA,EAAMD,0BAAA;AAAA,IACN,OAAA;AAAA,IACA,SAAA,GAAY;AACV,MAAA,eAAA,GAAkB,kBAAA,EAAmB;AAAA,IACvC,CAAA;AAAA,IACA,cAAc,MAAA,EAAQ;AAGpB,MAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,KAAA,IAAS,sBAAA,CAAuB,MAAM,CAAA;AAElE,MAAA,IAAI,WAAA,EAAa;AACf,QAAAE,0BAAA,CAAsB,MAAM,CAAA;AAAA,MAC9B,CAAA,MAAO;AACL,QAAA,eAAA,EAAiB,eAAA,CAAgB,MAAMA,0BAAA,CAAsB,MAAM,CAAC,CAAA;AAAA,MACtE;AAAA,IACF;AAAA,GACF;AACF,CAAA,CAAA;AAsCO,MAAM,mBAAA,GAAsBC,uBAAkB,oBAAoB;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/vercelai/index.ts"],"sourcesContent":["import type { Client, IntegrationFn } from '@sentry/core';\nimport { addVercelAiProcessors, defineIntegration, extendIntegration } from '@sentry/core';\nimport { generateInstrumentOnce, type modulesIntegration } from '@sentry/node-core';\nimport { vercelAiIntegration as serverUtilsVercelAiIntegration } from '@sentry/server-utils';\nimport { INTEGRATION_NAME } from './constants';\nimport { SentryVercelAiInstrumentation } from './instrumentation';\nimport type { VercelAiOptions } from './types';\n\nexport const instrumentVercelAi = generateInstrumentOnce(INTEGRATION_NAME, () => new SentryVercelAiInstrumentation({}));\n\n/**\n * Determines if the integration should be forced based on environment and package availability.\n * Returns true if the 'ai' package is available.\n */\nfunction shouldForceIntegration(client: Client): boolean {\n const modules = client.getIntegrationByName<ReturnType<typeof modulesIntegration>>('Modules');\n return !!modules?.getModules?.()?.ai;\n}\n\nconst _vercelAIIntegration = ((options: VercelAiOptions = {}) => {\n let instrumentation: undefined | SentryVercelAiInstrumentation;\n\n const parentIntegration = serverUtilsVercelAiIntegration(options);\n\n return extendIntegration(parentIntegration, {\n options,\n setupOnce() {\n instrumentation = instrumentVercelAi();\n },\n afterAllSetup(client) {\n // Auto-detect if we should force the integration when running with 'ai' package available\n // Note that this can only be detected if the 'Modules' integration is available, and running in CJS mode\n const shouldForce = options.force ?? shouldForceIntegration(client);\n\n if (shouldForce) {\n addVercelAiProcessors(client);\n } else {\n instrumentation?.callWhenPatched(() => addVercelAiProcessors(client));\n }\n },\n });\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.\n *\n * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.vercelAIIntegration()],\n * });\n * ```\n *\n * This integration adds tracing support to all `ai` function calls.\n * You need to opt-in to collecting spans for a specific call,\n * you can do so by setting `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true },\n * });\n * ```\n *\n * If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each\n * function call by setting `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs`\n * to `true`.\n *\n * ```javascript\n * const result = await generateText({\n * model: openai('gpt-4-turbo'),\n * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },\n * });\n */\nexport const vercelAIIntegration = defineIntegration(_vercelAIIntegration);\n"],"names":["generateInstrumentOnce","INTEGRATION_NAME","SentryVercelAiInstrumentation","serverUtilsVercelAiIntegration","extendIntegration","addVercelAiProcessors","defineIntegration"],"mappings":";;;;;;;;AAQO,MAAM,kBAAA,GAAqBA,gCAAuBC,0BAAA,EAAkB,MAAM,IAAIC,6CAAA,CAA8B,EAAE,CAAC;AAMtH,SAAS,uBAAuB,MAAA,EAAyB;AACvD,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,oBAAA,CAA4D,SAAS,CAAA;AAC5F,EAAA,OAAO,CAAC,CAAC,OAAA,EAAS,UAAA,IAAa,EAAG,EAAA;AACpC;AAEA,MAAM,oBAAA,IAAwB,CAAC,OAAA,GAA2B,EAAC,KAAM;AAC/D,EAAA,IAAI,eAAA;AAEJ,EAAA,MAAM,iBAAA,GAAoBC,gCAA+B,OAAO,CAAA;AAEhE,EAAA,OAAOC,uBAAkB,iBAAA,EAAmB;AAAA,IAC1C,OAAA;AAAA,IACA,SAAA,GAAY;AACV,MAAA,eAAA,GAAkB,kBAAA,EAAmB;AAAA,IACvC,CAAA;AAAA,IACA,cAAc,MAAA,EAAQ;AAGpB,MAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,KAAA,IAAS,sBAAA,CAAuB,MAAM,CAAA;AAElE,MAAA,IAAI,WAAA,EAAa;AACf,QAAAC,0BAAA,CAAsB,MAAM,CAAA;AAAA,MAC9B,CAAA,MAAO;AACL,QAAA,eAAA,EAAiB,eAAA,CAAgB,MAAMA,0BAAA,CAAsB,MAAM,CAAC,CAAA;AAAA,MACtE;AAAA,IACF;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAqCO,MAAM,mBAAA,GAAsBC,uBAAkB,oBAAoB;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"diagnosticsChannelInjection.js","sources":["../../../src/sdk/diagnosticsChannelInjection.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\n\n/**\n * The orchestrion-driven pieces, resolved lazily by the opt-in loader.\n *\n * IMPORTANT: this module (and everything `init()` imports) must NOT reference\n * the orchestrion code (`@sentry/server-utils/orchestrion/*`). The only\n * reference lives inside `experimentalUseDiagnosticsChannelInjection()` (a\n * separate module, reachable solely through that public export). That's the\n * tree-shaking boundary: if an app never calls the opt-in function, then a\n * bundler drops the entire orchestrion subtree, including its transitive\n * dependencies, while an app that does call it gets it bundled\n * normally.\n */\nexport interface DiagnosticsChannelInjection {\n /** Channel-based integrations to register, replacing their OTel equivalents. */\n integrations: Integration[];\n /** OTel integration names these replace; filtered out of the default set. */\n replacedOtelIntegrationNames: string[];\n /** Installs the module hooks that inject the diagnostics channels. */\n register: () => void;\n /** Warns (DEBUG only) about missing or doubled channel injection. */\n detect: () => void;\n}\n\nlet loader: (() => DiagnosticsChannelInjection) | undefined;\nlet cached: DiagnosticsChannelInjection | undefined;\n\n/**\n * Set by `experimentalUseDiagnosticsChannelInjection()`. The loader\n * is the only thing that pulls in the orchestrion modules; see\n * {@link DiagnosticsChannelInjection) re tree-shaking concerns this addresses.\n *\n * @internal\n */\nexport function setDiagnosticsChannelInjectionLoader(load: () => DiagnosticsChannelInjection): void {\n loader = load;\n}\n\n/** Whether `experimentalUseDiagnosticsChannelInjection()` was called. */\nexport function isDiagnosticsChannelInjectionEnabled(): boolean {\n return !!loader;\n}\n\n/**\n * Resolve and memoize the orchestrion pieces. This is what actually loads\n * the orchestrion modules. Returns `undefined` if the app never opted in.\n * Callers gate this on span recording, so the modules load only when both\n * opted in and tracing is enabled.\n */\nexport function resolveDiagnosticsChannelInjection(): DiagnosticsChannelInjection | undefined {\n if (!loader) {\n return undefined;\n }\n return (cached ??= loader());\n}\n"],"names":[],"mappings":";;AAyBA,IAAI,MAAA;AACJ,IAAI,MAAA;AASG,SAAS,qCAAqC,IAAA,EAA+C;AAClG,EAAA,MAAA,GAAS,IAAA;AACX;AAGO,SAAS,oCAAA,GAAgD;AAC9D,EAAA,OAAO,CAAC,CAAC,MAAA;AACX;AAQO,SAAS,kCAAA,GAA8E;AAC5F,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAQ,oBAAW,MAAA,EAAO,CAAA;AAC5B;;;;;;"}
1
+ {"version":3,"file":"diagnosticsChannelInjection.js","sources":["../../../src/sdk/diagnosticsChannelInjection.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\n\n/**\n * The orchestrion-driven pieces, resolved lazily by the opt-in loader.\n *\n * IMPORTANT: this module (and everything `init()` imports) must NOT reference\n * the orchestrion code (`@sentry/server-utils/orchestrion/*`). The only\n * reference lives inside `experimentalUseDiagnosticsChannelInjection()` (a\n * separate module, reachable solely through that public export). That's the\n * tree-shaking boundary: if an app never calls the opt-in function, then a\n * bundler drops the entire orchestrion subtree, including its transitive\n * dependencies, while an app that does call it gets it bundled\n * normally.\n */\nexport interface DiagnosticsChannelInjection {\n /** Channel-based integrations to register, replacing their OTel equivalents. */\n integrations: Integration[] | readonly Integration[];\n /** OTel integration names these replace; filtered out of the default set. */\n replacedOtelIntegrationNames: string[];\n /** Installs the module hooks that inject the diagnostics channels. */\n register: () => void;\n /** Warns (DEBUG only) about missing or doubled channel injection. */\n detect: () => void;\n}\n\nlet loader: (() => DiagnosticsChannelInjection) | undefined;\nlet cached: DiagnosticsChannelInjection | undefined;\n\n/**\n * Set by `experimentalUseDiagnosticsChannelInjection()`. The loader\n * is the only thing that pulls in the orchestrion modules; see\n * {@link DiagnosticsChannelInjection) re tree-shaking concerns this addresses.\n *\n * @internal\n */\nexport function setDiagnosticsChannelInjectionLoader(load: () => DiagnosticsChannelInjection): void {\n loader = load;\n}\n\n/** Whether `experimentalUseDiagnosticsChannelInjection()` was called. */\nexport function isDiagnosticsChannelInjectionEnabled(): boolean {\n return !!loader;\n}\n\n/**\n * Resolve and memoize the orchestrion pieces. This is what actually loads\n * the orchestrion modules. Returns `undefined` if the app never opted in.\n * Callers gate this on span recording, so the modules load only when both\n * opted in and tracing is enabled.\n */\nexport function resolveDiagnosticsChannelInjection(): DiagnosticsChannelInjection | undefined {\n if (!loader) {\n return undefined;\n }\n return (cached ??= loader());\n}\n"],"names":[],"mappings":";;AAyBA,IAAI,MAAA;AACJ,IAAI,MAAA;AASG,SAAS,qCAAqC,IAAA,EAA+C;AAClG,EAAA,MAAA,GAAS,IAAA;AACX;AAGO,SAAS,oCAAA,GAAgD;AAC9D,EAAA,OAAO,CAAC,CAAC,MAAA;AACX;AAQO,SAAS,kCAAA,GAA8E;AAC5F,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAQ,oBAAW,MAAA,EAAO,CAAA;AAC5B;;;;;;"}
@@ -5,14 +5,16 @@ const register = require('@sentry/server-utils/orchestrion/register');
5
5
  const diagnosticsChannelInjection = require('./diagnosticsChannelInjection.js');
6
6
 
7
7
  function experimentalUseDiagnosticsChannelInjection() {
8
- diagnosticsChannelInjection.setDiagnosticsChannelInjectionLoader(
9
- () => ({
10
- integrations: [orchestrion.mysqlChannelIntegration()],
11
- replacedOtelIntegrationNames: ["Mysql"],
8
+ diagnosticsChannelInjection.setDiagnosticsChannelInjectionLoader(() => {
9
+ const integrations = [orchestrion.mysqlChannelIntegration(), orchestrion.lruMemoizerChannelIntegration()];
10
+ const replacedOtelIntegrationNames = integrations.map((i) => i.name);
11
+ return {
12
+ integrations,
13
+ replacedOtelIntegrationNames,
12
14
  register: register.registerDiagnosticsChannelInjection,
13
15
  detect: orchestrion.detectOrchestrionSetup
14
- })
15
- );
16
+ };
17
+ });
16
18
  }
17
19
 
18
20
  exports.experimentalUseDiagnosticsChannelInjection = experimentalUseDiagnosticsChannelInjection;
@@ -1 +1 @@
1
- {"version":3,"file":"experimentalUseDiagnosticsChannelInjection.js","sources":["../../../src/sdk/experimentalUseDiagnosticsChannelInjection.ts"],"sourcesContent":["import { mysqlChannelIntegration, detectOrchestrionSetup } from '@sentry/server-utils/orchestrion';\nimport { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register';\nimport type { DiagnosticsChannelInjection } from './diagnosticsChannelInjection';\nimport { setDiagnosticsChannelInjectionLoader } from './diagnosticsChannelInjection';\n\n/**\n * EXPERIMENTAL: opt into diagnostics-channel-based auto-instrumentation.\n *\n * Call this BEFORE `Sentry.init()`:\n *\n * ```ts\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.experimentalUseDiagnosticsChannelInjection();\n * Sentry.init({\n * dsn: '__DSN__',\n * // other settings...\n * });\n * ```\n *\n * When this has been called AND span recording is enabled, `Sentry.init()`\n * uses the diagnostics-channel-injection-based integrations instead of the\n * OpenTelemetry ones, and installs the module hooks that inject the channels\n * (so libraries imported after `init()` publish the channel events).\n *\n * This is a standalone function rather than an `init()` option so that a\n * bundler drops all of it (and its transitive deps) when this function isn't\n * called. `init()` reads the loader registered below.\n *\n * An app that DOES call it gets the orchestrion code bundled as intended.\n *\n * In an unbundled (server-side runtime) app this eagerly loads only the small\n * subscriber/channel modules; the heavy code-transform dependencies stay lazy\n * inside `register()` and load only when injection actually runs.\n *\n * @experimental May change or be removed in any release.\n */\nexport function experimentalUseDiagnosticsChannelInjection(): void {\n setDiagnosticsChannelInjectionLoader(\n (): DiagnosticsChannelInjection => ({\n integrations: [mysqlChannelIntegration()],\n replacedOtelIntegrationNames: ['Mysql'],\n register: registerDiagnosticsChannelInjection,\n detect: detectOrchestrionSetup,\n }),\n );\n}\n"],"names":["setDiagnosticsChannelInjectionLoader","mysqlChannelIntegration","registerDiagnosticsChannelInjection","detectOrchestrionSetup"],"mappings":";;;;;;AAqCO,SAAS,0CAAA,GAAmD;AACjE,EAAAA,gEAAA;AAAA,IACE,OAAoC;AAAA,MAClC,YAAA,EAAc,CAACC,mCAAA,EAAyB,CAAA;AAAA,MACxC,4BAAA,EAA8B,CAAC,OAAO,CAAA;AAAA,MACtC,QAAA,EAAUC,4CAAA;AAAA,MACV,MAAA,EAAQC;AAAA,KACV;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"experimentalUseDiagnosticsChannelInjection.js","sources":["../../../src/sdk/experimentalUseDiagnosticsChannelInjection.ts"],"sourcesContent":["import {\n mysqlChannelIntegration,\n lruMemoizerChannelIntegration,\n detectOrchestrionSetup,\n} from '@sentry/server-utils/orchestrion';\nimport { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register';\nimport type { DiagnosticsChannelInjection } from './diagnosticsChannelInjection';\nimport { setDiagnosticsChannelInjectionLoader } from './diagnosticsChannelInjection';\n\n/**\n * EXPERIMENTAL: opt into diagnostics-channel-based auto-instrumentation.\n *\n * Call this BEFORE `Sentry.init()`:\n *\n * ```ts\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.experimentalUseDiagnosticsChannelInjection();\n * Sentry.init({\n * dsn: '__DSN__',\n * // other settings...\n * });\n * ```\n *\n * When this has been called AND span recording is enabled, `Sentry.init()`\n * uses the diagnostics-channel-injection-based integrations instead of the\n * OpenTelemetry ones, and installs the module hooks that inject the channels\n * (so libraries imported after `init()` publish the channel events).\n *\n * This is a standalone function rather than an `init()` option so that a\n * bundler drops all of it (and its transitive deps) when this function isn't\n * called. `init()` reads the loader registered below.\n *\n * An app that DOES call it gets the orchestrion code bundled as intended.\n *\n * In an unbundled (server-side runtime) app this eagerly loads only the small\n * subscriber/channel modules; the heavy code-transform dependencies stay lazy\n * inside `register()` and load only when injection actually runs.\n *\n * @experimental May change or be removed in any release.\n */\nexport function experimentalUseDiagnosticsChannelInjection(): void {\n setDiagnosticsChannelInjectionLoader((): DiagnosticsChannelInjection => {\n const integrations = [mysqlChannelIntegration(), lruMemoizerChannelIntegration()] as const;\n const replacedOtelIntegrationNames = integrations.map(i => i.name);\n\n return {\n integrations,\n replacedOtelIntegrationNames,\n register: registerDiagnosticsChannelInjection,\n detect: detectOrchestrionSetup,\n };\n });\n}\n"],"names":["setDiagnosticsChannelInjectionLoader","mysqlChannelIntegration","lruMemoizerChannelIntegration","registerDiagnosticsChannelInjection","detectOrchestrionSetup"],"mappings":";;;;;;AAyCO,SAAS,0CAAA,GAAmD;AACjE,EAAAA,gEAAA,CAAqC,MAAmC;AACtE,IAAA,MAAM,YAAA,GAAe,CAACC,mCAAA,EAAwB,EAAGC,2CAA+B,CAAA;AAChF,IAAA,MAAM,4BAAA,GAA+B,YAAA,CAAa,GAAA,CAAI,CAAA,CAAA,KAAK,EAAE,IAAI,CAAA;AAEjE,IAAA,OAAO;AAAA,MACL,YAAA;AAAA,MACA,4BAAA;AAAA,MACA,QAAA,EAAUC,4CAAA;AAAA,MACV,MAAA,EAAQC;AAAA,KACV;AAAA,EACF,CAAC,CAAA;AACH;;;;"}