@depup/sentry__node 10.44.0-depup.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 (473) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -0
  3. package/build/cjs/debug-build.js +11 -0
  4. package/build/cjs/debug-build.js.map +1 -0
  5. package/build/cjs/index.js +216 -0
  6. package/build/cjs/index.js.map +1 -0
  7. package/build/cjs/init.js +10 -0
  8. package/build/cjs/init.js.map +1 -0
  9. package/build/cjs/integrations/featureFlagShims/growthbook.js +12 -0
  10. package/build/cjs/integrations/featureFlagShims/growthbook.js.map +1 -0
  11. package/build/cjs/integrations/featureFlagShims/launchDarkly.js +43 -0
  12. package/build/cjs/integrations/featureFlagShims/launchDarkly.js.map +1 -0
  13. package/build/cjs/integrations/featureFlagShims/openFeature.js +55 -0
  14. package/build/cjs/integrations/featureFlagShims/openFeature.js.map +1 -0
  15. package/build/cjs/integrations/featureFlagShims/statsig.js +23 -0
  16. package/build/cjs/integrations/featureFlagShims/statsig.js.map +1 -0
  17. package/build/cjs/integrations/featureFlagShims/unleash.js +23 -0
  18. package/build/cjs/integrations/featureFlagShims/unleash.js.map +1 -0
  19. package/build/cjs/integrations/fs.js +142 -0
  20. package/build/cjs/integrations/fs.js.map +1 -0
  21. package/build/cjs/integrations/http.js +224 -0
  22. package/build/cjs/integrations/http.js.map +1 -0
  23. package/build/cjs/integrations/node-fetch.js +108 -0
  24. package/build/cjs/integrations/node-fetch.js.map +1 -0
  25. package/build/cjs/integrations/tracing/amqplib.js +47 -0
  26. package/build/cjs/integrations/tracing/amqplib.js.map +1 -0
  27. package/build/cjs/integrations/tracing/anthropic-ai/index.js +79 -0
  28. package/build/cjs/integrations/tracing/anthropic-ai/index.js.map +1 -0
  29. package/build/cjs/integrations/tracing/anthropic-ai/instrumentation.js +95 -0
  30. package/build/cjs/integrations/tracing/anthropic-ai/instrumentation.js.map +1 -0
  31. package/build/cjs/integrations/tracing/connect.js +110 -0
  32. package/build/cjs/integrations/tracing/connect.js.map +1 -0
  33. package/build/cjs/integrations/tracing/dataloader.js +72 -0
  34. package/build/cjs/integrations/tracing/dataloader.js.map +1 -0
  35. package/build/cjs/integrations/tracing/express.js +166 -0
  36. package/build/cjs/integrations/tracing/express.js.map +1 -0
  37. package/build/cjs/integrations/tracing/fastify/index.js +270 -0
  38. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -0
  39. package/build/cjs/integrations/tracing/fastify/v3/constants.js +23 -0
  40. package/build/cjs/integrations/tracing/fastify/v3/constants.js.map +1 -0
  41. package/build/cjs/integrations/tracing/fastify/v3/enums/AttributeNames.js +37 -0
  42. package/build/cjs/integrations/tracing/fastify/v3/enums/AttributeNames.js.map +1 -0
  43. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js +304 -0
  44. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js.map +1 -0
  45. package/build/cjs/integrations/tracing/fastify/v3/utils.js +135 -0
  46. package/build/cjs/integrations/tracing/fastify/v3/utils.js.map +1 -0
  47. package/build/cjs/integrations/tracing/firebase/firebase.js +50 -0
  48. package/build/cjs/integrations/tracing/firebase/firebase.js.map +1 -0
  49. package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js +44 -0
  50. package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -0
  51. package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js +297 -0
  52. package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -0
  53. package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js +265 -0
  54. package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js.map +1 -0
  55. package/build/cjs/integrations/tracing/genericPool.js +59 -0
  56. package/build/cjs/integrations/tracing/genericPool.js.map +1 -0
  57. package/build/cjs/integrations/tracing/google-genai/index.js +78 -0
  58. package/build/cjs/integrations/tracing/google-genai/index.js.map +1 -0
  59. package/build/cjs/integrations/tracing/google-genai/instrumentation.js +88 -0
  60. package/build/cjs/integrations/tracing/google-genai/instrumentation.js.map +1 -0
  61. package/build/cjs/integrations/tracing/graphql.js +127 -0
  62. package/build/cjs/integrations/tracing/graphql.js.map +1 -0
  63. package/build/cjs/integrations/tracing/hapi/index.js +135 -0
  64. package/build/cjs/integrations/tracing/hapi/index.js.map +1 -0
  65. package/build/cjs/integrations/tracing/hono/constants.js +15 -0
  66. package/build/cjs/integrations/tracing/hono/constants.js.map +1 -0
  67. package/build/cjs/integrations/tracing/hono/index.js +137 -0
  68. package/build/cjs/integrations/tracing/hono/index.js.map +1 -0
  69. package/build/cjs/integrations/tracing/hono/instrumentation.js +236 -0
  70. package/build/cjs/integrations/tracing/hono/instrumentation.js.map +1 -0
  71. package/build/cjs/integrations/tracing/index.js +110 -0
  72. package/build/cjs/integrations/tracing/index.js.map +1 -0
  73. package/build/cjs/integrations/tracing/kafka.js +48 -0
  74. package/build/cjs/integrations/tracing/kafka.js.map +1 -0
  75. package/build/cjs/integrations/tracing/knex.js +57 -0
  76. package/build/cjs/integrations/tracing/knex.js.map +1 -0
  77. package/build/cjs/integrations/tracing/koa.js +138 -0
  78. package/build/cjs/integrations/tracing/koa.js.map +1 -0
  79. package/build/cjs/integrations/tracing/langchain/index.js +116 -0
  80. package/build/cjs/integrations/tracing/langchain/index.js.map +1 -0
  81. package/build/cjs/integrations/tracing/langchain/instrumentation.js +220 -0
  82. package/build/cjs/integrations/tracing/langchain/instrumentation.js.map +1 -0
  83. package/build/cjs/integrations/tracing/langgraph/index.js +93 -0
  84. package/build/cjs/integrations/tracing/langgraph/index.js.map +1 -0
  85. package/build/cjs/integrations/tracing/langgraph/instrumentation.js +60 -0
  86. package/build/cjs/integrations/tracing/langgraph/instrumentation.js.map +1 -0
  87. package/build/cjs/integrations/tracing/lrumemoizer.js +37 -0
  88. package/build/cjs/integrations/tracing/lrumemoizer.js.map +1 -0
  89. package/build/cjs/integrations/tracing/mongo.js +93 -0
  90. package/build/cjs/integrations/tracing/mongo.js.map +1 -0
  91. package/build/cjs/integrations/tracing/mongoose.js +46 -0
  92. package/build/cjs/integrations/tracing/mongoose.js.map +1 -0
  93. package/build/cjs/integrations/tracing/mysql.js +38 -0
  94. package/build/cjs/integrations/tracing/mysql.js.map +1 -0
  95. package/build/cjs/integrations/tracing/mysql2.js +46 -0
  96. package/build/cjs/integrations/tracing/mysql2.js.map +1 -0
  97. package/build/cjs/integrations/tracing/openai/index.js +78 -0
  98. package/build/cjs/integrations/tracing/openai/index.js.map +1 -0
  99. package/build/cjs/integrations/tracing/openai/instrumentation.js +104 -0
  100. package/build/cjs/integrations/tracing/openai/instrumentation.js.map +1 -0
  101. package/build/cjs/integrations/tracing/postgres.js +48 -0
  102. package/build/cjs/integrations/tracing/postgres.js.map +1 -0
  103. package/build/cjs/integrations/tracing/postgresjs.js +378 -0
  104. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -0
  105. package/build/cjs/integrations/tracing/prisma.js +203 -0
  106. package/build/cjs/integrations/tracing/prisma.js.map +1 -0
  107. package/build/cjs/integrations/tracing/redis.js +121 -0
  108. package/build/cjs/integrations/tracing/redis.js.map +1 -0
  109. package/build/cjs/integrations/tracing/tedious.js +67 -0
  110. package/build/cjs/integrations/tracing/tedious.js.map +1 -0
  111. package/build/cjs/integrations/tracing/vercelai/constants.js +6 -0
  112. package/build/cjs/integrations/tracing/vercelai/constants.js.map +1 -0
  113. package/build/cjs/integrations/tracing/vercelai/index.js +82 -0
  114. package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -0
  115. package/build/cjs/integrations/tracing/vercelai/instrumentation.js +274 -0
  116. package/build/cjs/integrations/tracing/vercelai/instrumentation.js.map +1 -0
  117. package/build/cjs/preload.js +21 -0
  118. package/build/cjs/preload.js.map +1 -0
  119. package/build/cjs/sdk/index.js +78 -0
  120. package/build/cjs/sdk/index.js.map +1 -0
  121. package/build/cjs/sdk/initOtel.js +126 -0
  122. package/build/cjs/sdk/initOtel.js.map +1 -0
  123. package/build/cjs/utils/redisCache.js +122 -0
  124. package/build/cjs/utils/redisCache.js.map +1 -0
  125. package/build/esm/debug-build.js +9 -0
  126. package/build/esm/debug-build.js.map +1 -0
  127. package/build/esm/index.js +44 -0
  128. package/build/esm/index.js.map +1 -0
  129. package/build/esm/init.js +10 -0
  130. package/build/esm/init.js.map +1 -0
  131. package/build/esm/integrations/featureFlagShims/growthbook.js +10 -0
  132. package/build/esm/integrations/featureFlagShims/growthbook.js.map +1 -0
  133. package/build/esm/integrations/featureFlagShims/launchDarkly.js +40 -0
  134. package/build/esm/integrations/featureFlagShims/launchDarkly.js.map +1 -0
  135. package/build/esm/integrations/featureFlagShims/openFeature.js +52 -0
  136. package/build/esm/integrations/featureFlagShims/openFeature.js.map +1 -0
  137. package/build/esm/integrations/featureFlagShims/statsig.js +21 -0
  138. package/build/esm/integrations/featureFlagShims/statsig.js.map +1 -0
  139. package/build/esm/integrations/featureFlagShims/unleash.js +21 -0
  140. package/build/esm/integrations/featureFlagShims/unleash.js.map +1 -0
  141. package/build/esm/integrations/fs.js +140 -0
  142. package/build/esm/integrations/fs.js.map +1 -0
  143. package/build/esm/integrations/http.js +219 -0
  144. package/build/esm/integrations/http.js.map +1 -0
  145. package/build/esm/integrations/node-fetch.js +105 -0
  146. package/build/esm/integrations/node-fetch.js.map +1 -0
  147. package/build/esm/integrations/tracing/amqplib.js +44 -0
  148. package/build/esm/integrations/tracing/amqplib.js.map +1 -0
  149. package/build/esm/integrations/tracing/anthropic-ai/index.js +76 -0
  150. package/build/esm/integrations/tracing/anthropic-ai/index.js.map +1 -0
  151. package/build/esm/integrations/tracing/anthropic-ai/instrumentation.js +93 -0
  152. package/build/esm/integrations/tracing/anthropic-ai/instrumentation.js.map +1 -0
  153. package/build/esm/integrations/tracing/connect.js +106 -0
  154. package/build/esm/integrations/tracing/connect.js.map +1 -0
  155. package/build/esm/integrations/tracing/dataloader.js +69 -0
  156. package/build/esm/integrations/tracing/dataloader.js.map +1 -0
  157. package/build/esm/integrations/tracing/express.js +161 -0
  158. package/build/esm/integrations/tracing/express.js.map +1 -0
  159. package/build/esm/integrations/tracing/fastify/index.js +265 -0
  160. package/build/esm/integrations/tracing/fastify/index.js.map +1 -0
  161. package/build/esm/integrations/tracing/fastify/v3/constants.js +21 -0
  162. package/build/esm/integrations/tracing/fastify/v3/constants.js.map +1 -0
  163. package/build/esm/integrations/tracing/fastify/v3/enums/AttributeNames.js +37 -0
  164. package/build/esm/integrations/tracing/fastify/v3/enums/AttributeNames.js.map +1 -0
  165. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js +302 -0
  166. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js.map +1 -0
  167. package/build/esm/integrations/tracing/fastify/v3/utils.js +131 -0
  168. package/build/esm/integrations/tracing/fastify/v3/utils.js.map +1 -0
  169. package/build/esm/integrations/tracing/firebase/firebase.js +47 -0
  170. package/build/esm/integrations/tracing/firebase/firebase.js.map +1 -0
  171. package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js +42 -0
  172. package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -0
  173. package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js +294 -0
  174. package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -0
  175. package/build/esm/integrations/tracing/firebase/otel/patches/functions.js +262 -0
  176. package/build/esm/integrations/tracing/firebase/otel/patches/functions.js.map +1 -0
  177. package/build/esm/integrations/tracing/genericPool.js +56 -0
  178. package/build/esm/integrations/tracing/genericPool.js.map +1 -0
  179. package/build/esm/integrations/tracing/google-genai/index.js +75 -0
  180. package/build/esm/integrations/tracing/google-genai/index.js.map +1 -0
  181. package/build/esm/integrations/tracing/google-genai/instrumentation.js +86 -0
  182. package/build/esm/integrations/tracing/google-genai/instrumentation.js.map +1 -0
  183. package/build/esm/integrations/tracing/graphql.js +124 -0
  184. package/build/esm/integrations/tracing/graphql.js.map +1 -0
  185. package/build/esm/integrations/tracing/hapi/index.js +130 -0
  186. package/build/esm/integrations/tracing/hapi/index.js.map +1 -0
  187. package/build/esm/integrations/tracing/hono/constants.js +12 -0
  188. package/build/esm/integrations/tracing/hono/constants.js.map +1 -0
  189. package/build/esm/integrations/tracing/hono/index.js +133 -0
  190. package/build/esm/integrations/tracing/hono/index.js.map +1 -0
  191. package/build/esm/integrations/tracing/hono/instrumentation.js +234 -0
  192. package/build/esm/integrations/tracing/hono/instrumentation.js.map +1 -0
  193. package/build/esm/integrations/tracing/index.js +107 -0
  194. package/build/esm/integrations/tracing/index.js.map +1 -0
  195. package/build/esm/integrations/tracing/kafka.js +45 -0
  196. package/build/esm/integrations/tracing/kafka.js.map +1 -0
  197. package/build/esm/integrations/tracing/knex.js +54 -0
  198. package/build/esm/integrations/tracing/knex.js.map +1 -0
  199. package/build/esm/integrations/tracing/koa.js +134 -0
  200. package/build/esm/integrations/tracing/koa.js.map +1 -0
  201. package/build/esm/integrations/tracing/langchain/index.js +113 -0
  202. package/build/esm/integrations/tracing/langchain/index.js.map +1 -0
  203. package/build/esm/integrations/tracing/langchain/instrumentation.js +218 -0
  204. package/build/esm/integrations/tracing/langchain/instrumentation.js.map +1 -0
  205. package/build/esm/integrations/tracing/langgraph/index.js +90 -0
  206. package/build/esm/integrations/tracing/langgraph/index.js.map +1 -0
  207. package/build/esm/integrations/tracing/langgraph/instrumentation.js +58 -0
  208. package/build/esm/integrations/tracing/langgraph/instrumentation.js.map +1 -0
  209. package/build/esm/integrations/tracing/lrumemoizer.js +34 -0
  210. package/build/esm/integrations/tracing/lrumemoizer.js.map +1 -0
  211. package/build/esm/integrations/tracing/mongo.js +89 -0
  212. package/build/esm/integrations/tracing/mongo.js.map +1 -0
  213. package/build/esm/integrations/tracing/mongoose.js +43 -0
  214. package/build/esm/integrations/tracing/mongoose.js.map +1 -0
  215. package/build/esm/integrations/tracing/mysql.js +35 -0
  216. package/build/esm/integrations/tracing/mysql.js.map +1 -0
  217. package/build/esm/integrations/tracing/mysql2.js +43 -0
  218. package/build/esm/integrations/tracing/mysql2.js.map +1 -0
  219. package/build/esm/integrations/tracing/openai/index.js +75 -0
  220. package/build/esm/integrations/tracing/openai/index.js.map +1 -0
  221. package/build/esm/integrations/tracing/openai/instrumentation.js +102 -0
  222. package/build/esm/integrations/tracing/openai/instrumentation.js.map +1 -0
  223. package/build/esm/integrations/tracing/postgres.js +45 -0
  224. package/build/esm/integrations/tracing/postgres.js.map +1 -0
  225. package/build/esm/integrations/tracing/postgresjs.js +374 -0
  226. package/build/esm/integrations/tracing/postgresjs.js.map +1 -0
  227. package/build/esm/integrations/tracing/prisma.js +200 -0
  228. package/build/esm/integrations/tracing/prisma.js.map +1 -0
  229. package/build/esm/integrations/tracing/redis.js +117 -0
  230. package/build/esm/integrations/tracing/redis.js.map +1 -0
  231. package/build/esm/integrations/tracing/tedious.js +64 -0
  232. package/build/esm/integrations/tracing/tedious.js.map +1 -0
  233. package/build/esm/integrations/tracing/vercelai/constants.js +4 -0
  234. package/build/esm/integrations/tracing/vercelai/constants.js.map +1 -0
  235. package/build/esm/integrations/tracing/vercelai/index.js +79 -0
  236. package/build/esm/integrations/tracing/vercelai/index.js.map +1 -0
  237. package/build/esm/integrations/tracing/vercelai/instrumentation.js +269 -0
  238. package/build/esm/integrations/tracing/vercelai/instrumentation.js.map +1 -0
  239. package/build/esm/package.json +1 -0
  240. package/build/esm/preload.js +21 -0
  241. package/build/esm/preload.js.map +1 -0
  242. package/build/esm/sdk/index.js +73 -0
  243. package/build/esm/sdk/index.js.map +1 -0
  244. package/build/esm/sdk/initOtel.js +121 -0
  245. package/build/esm/sdk/initOtel.js.map +1 -0
  246. package/build/esm/utils/redisCache.js +114 -0
  247. package/build/esm/utils/redisCache.js.map +1 -0
  248. package/build/import-hook.mjs +5 -0
  249. package/build/loader-hook.mjs +1 -0
  250. package/build/types/debug-build.d.ts +7 -0
  251. package/build/types/debug-build.d.ts.map +1 -0
  252. package/build/types/index.d.ts +42 -0
  253. package/build/types/index.d.ts.map +1 -0
  254. package/build/types/init.d.ts +2 -0
  255. package/build/types/init.d.ts.map +1 -0
  256. package/build/types/integrations/featureFlagShims/growthbook.d.ts +6 -0
  257. package/build/types/integrations/featureFlagShims/growthbook.d.ts.map +1 -0
  258. package/build/types/integrations/featureFlagShims/index.d.ts +6 -0
  259. package/build/types/integrations/featureFlagShims/index.d.ts.map +1 -0
  260. package/build/types/integrations/featureFlagShims/launchDarkly.d.ts +10 -0
  261. package/build/types/integrations/featureFlagShims/launchDarkly.d.ts.map +1 -0
  262. package/build/types/integrations/featureFlagShims/openFeature.d.ts +23 -0
  263. package/build/types/integrations/featureFlagShims/openFeature.d.ts.map +1 -0
  264. package/build/types/integrations/featureFlagShims/statsig.d.ts +6 -0
  265. package/build/types/integrations/featureFlagShims/statsig.d.ts.map +1 -0
  266. package/build/types/integrations/featureFlagShims/unleash.d.ts +6 -0
  267. package/build/types/integrations/featureFlagShims/unleash.d.ts.map +1 -0
  268. package/build/types/integrations/fs.d.ts +24 -0
  269. package/build/types/integrations/fs.d.ts.map +1 -0
  270. package/build/types/integrations/http.d.ts +136 -0
  271. package/build/types/integrations/http.d.ts.map +1 -0
  272. package/build/types/integrations/node-fetch.d.ts +36 -0
  273. package/build/types/integrations/node-fetch.d.ts.map +1 -0
  274. package/build/types/integrations/tracing/amqplib.d.ts +20 -0
  275. package/build/types/integrations/tracing/amqplib.d.ts.map +1 -0
  276. package/build/types/integrations/tracing/anthropic-ai/index.d.ts +59 -0
  277. package/build/types/integrations/tracing/anthropic-ai/index.d.ts.map +1 -0
  278. package/build/types/integrations/tracing/anthropic-ai/instrumentation.d.ts +19 -0
  279. package/build/types/integrations/tracing/anthropic-ai/instrumentation.d.ts.map +1 -0
  280. package/build/types/integrations/tracing/connect.d.ts +46 -0
  281. package/build/types/integrations/tracing/connect.d.ts.map +1 -0
  282. package/build/types/integrations/tracing/dataloader.d.ts +20 -0
  283. package/build/types/integrations/tracing/dataloader.d.ts.map +1 -0
  284. package/build/types/integrations/tracing/express.d.ts +72 -0
  285. package/build/types/integrations/tracing/express.d.ts.map +1 -0
  286. package/build/types/integrations/tracing/fastify/index.d.ts +119 -0
  287. package/build/types/integrations/tracing/fastify/index.d.ts.map +1 -0
  288. package/build/types/integrations/tracing/fastify/types.d.ts +33 -0
  289. package/build/types/integrations/tracing/fastify/types.d.ts.map +1 -0
  290. package/build/types/integrations/tracing/fastify/v3/constants.d.ts +3 -0
  291. package/build/types/integrations/tracing/fastify/v3/constants.d.ts.map +1 -0
  292. package/build/types/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts +15 -0
  293. package/build/types/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts.map +1 -0
  294. package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts +16 -0
  295. package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts.map +1 -0
  296. package/build/types/integrations/tracing/fastify/v3/internal-types.d.ts +7 -0
  297. package/build/types/integrations/tracing/fastify/v3/internal-types.d.ts.map +1 -0
  298. package/build/types/integrations/tracing/fastify/v3/types.d.ts +21 -0
  299. package/build/types/integrations/tracing/fastify/v3/types.d.ts.map +1 -0
  300. package/build/types/integrations/tracing/fastify/v3/utils.d.ts +28 -0
  301. package/build/types/integrations/tracing/fastify/v3/utils.d.ts.map +1 -0
  302. package/build/types/integrations/tracing/firebase/firebase.d.ts +6 -0
  303. package/build/types/integrations/tracing/firebase/firebase.d.ts.map +1 -0
  304. package/build/types/integrations/tracing/firebase/index.d.ts +2 -0
  305. package/build/types/integrations/tracing/firebase/index.d.ts.map +1 -0
  306. package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts +19 -0
  307. package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts.map +1 -0
  308. package/build/types/integrations/tracing/firebase/otel/index.d.ts +3 -0
  309. package/build/types/integrations/tracing/firebase/otel/index.d.ts.map +1 -0
  310. package/build/types/integrations/tracing/firebase/otel/patches/firestore.d.ts +25 -0
  311. package/build/types/integrations/tracing/firebase/otel/patches/firestore.d.ts.map +1 -0
  312. package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts +23 -0
  313. package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts.map +1 -0
  314. package/build/types/integrations/tracing/firebase/otel/types.d.ts +120 -0
  315. package/build/types/integrations/tracing/firebase/otel/types.d.ts.map +1 -0
  316. package/build/types/integrations/tracing/genericPool.d.ts +20 -0
  317. package/build/types/integrations/tracing/genericPool.d.ts.map +1 -0
  318. package/build/types/integrations/tracing/google-genai/index.d.ts +59 -0
  319. package/build/types/integrations/tracing/google-genai/index.d.ts.map +1 -0
  320. package/build/types/integrations/tracing/google-genai/instrumentation.d.ts +20 -0
  321. package/build/types/integrations/tracing/google-genai/instrumentation.d.ts.map +1 -0
  322. package/build/types/integrations/tracing/graphql.d.ts +48 -0
  323. package/build/types/integrations/tracing/graphql.d.ts.map +1 -0
  324. package/build/types/integrations/tracing/hapi/index.d.ts +50 -0
  325. package/build/types/integrations/tracing/hapi/index.d.ts.map +1 -0
  326. package/build/types/integrations/tracing/hapi/types.d.ts +166 -0
  327. package/build/types/integrations/tracing/hapi/types.d.ts.map +1 -0
  328. package/build/types/integrations/tracing/hono/constants.d.ts +11 -0
  329. package/build/types/integrations/tracing/hono/constants.d.ts.map +1 -0
  330. package/build/types/integrations/tracing/hono/index.d.ts +52 -0
  331. package/build/types/integrations/tracing/hono/index.d.ts.map +1 -0
  332. package/build/types/integrations/tracing/hono/instrumentation.d.ts +55 -0
  333. package/build/types/integrations/tracing/hono/instrumentation.d.ts.map +1 -0
  334. package/build/types/integrations/tracing/hono/types.d.ts +36 -0
  335. package/build/types/integrations/tracing/hono/types.d.ts.map +1 -0
  336. package/build/types/integrations/tracing/index.d.ts +12 -0
  337. package/build/types/integrations/tracing/index.d.ts.map +1 -0
  338. package/build/types/integrations/tracing/kafka.d.ts +19 -0
  339. package/build/types/integrations/tracing/kafka.d.ts.map +1 -0
  340. package/build/types/integrations/tracing/knex.d.ts +20 -0
  341. package/build/types/integrations/tracing/knex.d.ts.map +1 -0
  342. package/build/types/integrations/tracing/koa.d.ts +70 -0
  343. package/build/types/integrations/tracing/koa.d.ts.map +1 -0
  344. package/build/types/integrations/tracing/langchain/index.d.ts +97 -0
  345. package/build/types/integrations/tracing/langchain/index.d.ts.map +1 -0
  346. package/build/types/integrations/tracing/langchain/instrumentation.d.ts +29 -0
  347. package/build/types/integrations/tracing/langchain/instrumentation.d.ts.map +1 -0
  348. package/build/types/integrations/tracing/langgraph/index.d.ts +74 -0
  349. package/build/types/integrations/tracing/langgraph/index.d.ts.map +1 -0
  350. package/build/types/integrations/tracing/langgraph/instrumentation.d.ts +19 -0
  351. package/build/types/integrations/tracing/langgraph/instrumentation.d.ts.map +1 -0
  352. package/build/types/integrations/tracing/lrumemoizer.d.ts +19 -0
  353. package/build/types/integrations/tracing/lrumemoizer.d.ts.map +1 -0
  354. package/build/types/integrations/tracing/mongo.d.ts +24 -0
  355. package/build/types/integrations/tracing/mongo.d.ts.map +1 -0
  356. package/build/types/integrations/tracing/mongoose.d.ts +20 -0
  357. package/build/types/integrations/tracing/mongoose.d.ts.map +1 -0
  358. package/build/types/integrations/tracing/mysql.d.ts +20 -0
  359. package/build/types/integrations/tracing/mysql.d.ts.map +1 -0
  360. package/build/types/integrations/tracing/mysql2.d.ts +20 -0
  361. package/build/types/integrations/tracing/mysql2.d.ts.map +1 -0
  362. package/build/types/integrations/tracing/openai/index.d.ts +59 -0
  363. package/build/types/integrations/tracing/openai/index.d.ts.map +1 -0
  364. package/build/types/integrations/tracing/openai/instrumentation.d.ts +26 -0
  365. package/build/types/integrations/tracing/openai/instrumentation.d.ts.map +1 -0
  366. package/build/types/integrations/tracing/postgres.d.ts +24 -0
  367. package/build/types/integrations/tracing/postgres.d.ts.map +1 -0
  368. package/build/types/integrations/tracing/postgresjs.d.ts +101 -0
  369. package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -0
  370. package/build/types/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts +38 -0
  371. package/build/types/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts.map +1 -0
  372. package/build/types/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts +31 -0
  373. package/build/types/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts.map +1 -0
  374. package/build/types/integrations/tracing/prisma.d.ts +50 -0
  375. package/build/types/integrations/tracing/prisma.d.ts.map +1 -0
  376. package/build/types/integrations/tracing/redis.d.ts +41 -0
  377. package/build/types/integrations/tracing/redis.d.ts.map +1 -0
  378. package/build/types/integrations/tracing/tedious.d.ts +20 -0
  379. package/build/types/integrations/tracing/tedious.d.ts.map +1 -0
  380. package/build/types/integrations/tracing/vercelai/constants.d.ts +2 -0
  381. package/build/types/integrations/tracing/vercelai/constants.d.ts.map +1 -0
  382. package/build/types/integrations/tracing/vercelai/index.d.ts +43 -0
  383. package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -0
  384. package/build/types/integrations/tracing/vercelai/instrumentation.d.ts +56 -0
  385. package/build/types/integrations/tracing/vercelai/instrumentation.d.ts.map +1 -0
  386. package/build/types/integrations/tracing/vercelai/types.d.ts +59 -0
  387. package/build/types/integrations/tracing/vercelai/types.d.ts.map +1 -0
  388. package/build/types/preload.d.ts +2 -0
  389. package/build/types/preload.d.ts.map +1 -0
  390. package/build/types/sdk/index.d.ts +18 -0
  391. package/build/types/sdk/index.d.ts.map +1 -0
  392. package/build/types/sdk/initOtel.d.ts +28 -0
  393. package/build/types/sdk/initOtel.d.ts.map +1 -0
  394. package/build/types/types.d.ts +89 -0
  395. package/build/types/types.d.ts.map +1 -0
  396. package/build/types/utils/redisCache.d.ts +16 -0
  397. package/build/types/utils/redisCache.d.ts.map +1 -0
  398. package/build/types-ts3.8/debug-build.d.ts +7 -0
  399. package/build/types-ts3.8/index.d.ts +42 -0
  400. package/build/types-ts3.8/init.d.ts +2 -0
  401. package/build/types-ts3.8/integrations/featureFlagShims/growthbook.d.ts +6 -0
  402. package/build/types-ts3.8/integrations/featureFlagShims/index.d.ts +6 -0
  403. package/build/types-ts3.8/integrations/featureFlagShims/launchDarkly.d.ts +10 -0
  404. package/build/types-ts3.8/integrations/featureFlagShims/openFeature.d.ts +23 -0
  405. package/build/types-ts3.8/integrations/featureFlagShims/statsig.d.ts +6 -0
  406. package/build/types-ts3.8/integrations/featureFlagShims/unleash.d.ts +6 -0
  407. package/build/types-ts3.8/integrations/fs.d.ts +24 -0
  408. package/build/types-ts3.8/integrations/http.d.ts +139 -0
  409. package/build/types-ts3.8/integrations/node-fetch.d.ts +36 -0
  410. package/build/types-ts3.8/integrations/tracing/amqplib.d.ts +20 -0
  411. package/build/types-ts3.8/integrations/tracing/anthropic-ai/index.d.ts +59 -0
  412. package/build/types-ts3.8/integrations/tracing/anthropic-ai/instrumentation.d.ts +19 -0
  413. package/build/types-ts3.8/integrations/tracing/connect.d.ts +46 -0
  414. package/build/types-ts3.8/integrations/tracing/dataloader.d.ts +20 -0
  415. package/build/types-ts3.8/integrations/tracing/express.d.ts +72 -0
  416. package/build/types-ts3.8/integrations/tracing/fastify/index.d.ts +119 -0
  417. package/build/types-ts3.8/integrations/tracing/fastify/types.d.ts +33 -0
  418. package/build/types-ts3.8/integrations/tracing/fastify/v3/constants.d.ts +3 -0
  419. package/build/types-ts3.8/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts +15 -0
  420. package/build/types-ts3.8/integrations/tracing/fastify/v3/instrumentation.d.ts +16 -0
  421. package/build/types-ts3.8/integrations/tracing/fastify/v3/internal-types.d.ts +7 -0
  422. package/build/types-ts3.8/integrations/tracing/fastify/v3/types.d.ts +21 -0
  423. package/build/types-ts3.8/integrations/tracing/fastify/v3/utils.d.ts +28 -0
  424. package/build/types-ts3.8/integrations/tracing/firebase/firebase.d.ts +6 -0
  425. package/build/types-ts3.8/integrations/tracing/firebase/index.d.ts +2 -0
  426. package/build/types-ts3.8/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts +19 -0
  427. package/build/types-ts3.8/integrations/tracing/firebase/otel/index.d.ts +3 -0
  428. package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/firestore.d.ts +25 -0
  429. package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/functions.d.ts +23 -0
  430. package/build/types-ts3.8/integrations/tracing/firebase/otel/types.d.ts +120 -0
  431. package/build/types-ts3.8/integrations/tracing/genericPool.d.ts +20 -0
  432. package/build/types-ts3.8/integrations/tracing/google-genai/index.d.ts +59 -0
  433. package/build/types-ts3.8/integrations/tracing/google-genai/instrumentation.d.ts +20 -0
  434. package/build/types-ts3.8/integrations/tracing/graphql.d.ts +48 -0
  435. package/build/types-ts3.8/integrations/tracing/hapi/index.d.ts +50 -0
  436. package/build/types-ts3.8/integrations/tracing/hapi/types.d.ts +166 -0
  437. package/build/types-ts3.8/integrations/tracing/hono/constants.d.ts +11 -0
  438. package/build/types-ts3.8/integrations/tracing/hono/index.d.ts +52 -0
  439. package/build/types-ts3.8/integrations/tracing/hono/instrumentation.d.ts +55 -0
  440. package/build/types-ts3.8/integrations/tracing/hono/types.d.ts +36 -0
  441. package/build/types-ts3.8/integrations/tracing/index.d.ts +12 -0
  442. package/build/types-ts3.8/integrations/tracing/kafka.d.ts +19 -0
  443. package/build/types-ts3.8/integrations/tracing/knex.d.ts +20 -0
  444. package/build/types-ts3.8/integrations/tracing/koa.d.ts +70 -0
  445. package/build/types-ts3.8/integrations/tracing/langchain/index.d.ts +97 -0
  446. package/build/types-ts3.8/integrations/tracing/langchain/instrumentation.d.ts +29 -0
  447. package/build/types-ts3.8/integrations/tracing/langgraph/index.d.ts +74 -0
  448. package/build/types-ts3.8/integrations/tracing/langgraph/instrumentation.d.ts +19 -0
  449. package/build/types-ts3.8/integrations/tracing/lrumemoizer.d.ts +19 -0
  450. package/build/types-ts3.8/integrations/tracing/mongo.d.ts +24 -0
  451. package/build/types-ts3.8/integrations/tracing/mongoose.d.ts +20 -0
  452. package/build/types-ts3.8/integrations/tracing/mysql.d.ts +20 -0
  453. package/build/types-ts3.8/integrations/tracing/mysql2.d.ts +20 -0
  454. package/build/types-ts3.8/integrations/tracing/openai/index.d.ts +59 -0
  455. package/build/types-ts3.8/integrations/tracing/openai/instrumentation.d.ts +26 -0
  456. package/build/types-ts3.8/integrations/tracing/postgres.d.ts +24 -0
  457. package/build/types-ts3.8/integrations/tracing/postgresjs.d.ts +101 -0
  458. package/build/types-ts3.8/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts +44 -0
  459. package/build/types-ts3.8/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts +34 -0
  460. package/build/types-ts3.8/integrations/tracing/prisma.d.ts +50 -0
  461. package/build/types-ts3.8/integrations/tracing/redis.d.ts +41 -0
  462. package/build/types-ts3.8/integrations/tracing/tedious.d.ts +20 -0
  463. package/build/types-ts3.8/integrations/tracing/vercelai/constants.d.ts +2 -0
  464. package/build/types-ts3.8/integrations/tracing/vercelai/index.d.ts +43 -0
  465. package/build/types-ts3.8/integrations/tracing/vercelai/instrumentation.d.ts +56 -0
  466. package/build/types-ts3.8/integrations/tracing/vercelai/types.d.ts +59 -0
  467. package/build/types-ts3.8/preload.d.ts +2 -0
  468. package/build/types-ts3.8/sdk/index.d.ts +18 -0
  469. package/build/types-ts3.8/sdk/initOtel.d.ts +31 -0
  470. package/build/types-ts3.8/types.d.ts +89 -0
  471. package/build/types-ts3.8/utils/redisCache.d.ts +16 -0
  472. package/changes.json +10 -0
  473. package/package.json +150 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma.js","sources":["../../../../src/integrations/tracing/prisma.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 { PrismaInstrumentation } from '@prisma/instrumentation';\nimport { consoleSandbox, defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport type { PrismaV5TracingHelper } from './prisma/vendor/v5-tracing-helper';\nimport type { PrismaV6TracingHelper } from './prisma/vendor/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 if (spanJSON.description === 'prisma:engine:db_query' && spanJSON.data['db.query.text']) {\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,QAAQ;;AAyBjC,SAAS,uBAAuB,CAAC,MAAM,EAA4C;AACnF,EAAE,OAAO,CAAC,CAAC,MAAA,IAAU,OAAO,MAAA,KAAW,QAAA,IAAY,qBAAA,IAAyB,MAAM;AAClF;;AAEA,SAAS,sBAAsB,GAAwB;AACvD,EAAE,MAAM,2BAAA,GAA8B,CAAC,UAAA,GAAuC,sBAAsB;AACpG,EAAE,MAAM,mBAAA;AACR,IAAI,2BAAA;AACJ,IAAI,OAAO,2BAAA,KAAgC,QAAA;AAC3C,IAAI,YAAY;AAChB,QAAQ,2BAA2B,CAAC;AACpC,QAAQ,SAAS;;AAEjB,EAAE,OAAO,mBA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Q,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;AAC9F,UAAU,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC;AAClD,QAAQ;AACR,MAAM,CAAC,CAAC;AACR,IAAI,CAAC;AACL,GAAG;AACH,CAAC;;;;;"}
@@ -0,0 +1,121 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const instrumentationIoredis = require('@opentelemetry/instrumentation-ioredis');
4
+ const instrumentationRedis = require('@opentelemetry/instrumentation-redis');
5
+ const core = require('@sentry/core');
6
+ const nodeCore = require('@sentry/node-core');
7
+ const redisCache = require('../../utils/redisCache.js');
8
+
9
+ const INTEGRATION_NAME = 'Redis';
10
+
11
+ /* Only exported for testing purposes */
12
+ exports._redisOptions = {};
13
+
14
+ /* Only exported for testing purposes */
15
+ const cacheResponseHook = (
16
+ span,
17
+ redisCommand,
18
+ cmdArgs,
19
+ response,
20
+ ) => {
21
+ span.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.redis');
22
+
23
+ const safeKey = redisCache.getCacheKeySafely(redisCommand, cmdArgs);
24
+ const cacheOperation = redisCache.getCacheOperation(redisCommand);
25
+
26
+ if (
27
+ !safeKey ||
28
+ !cacheOperation ||
29
+ !exports._redisOptions.cachePrefixes ||
30
+ !redisCache.shouldConsiderForCache(redisCommand, safeKey, exports._redisOptions.cachePrefixes)
31
+ ) {
32
+ // not relevant for cache
33
+ return;
34
+ }
35
+
36
+ // 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
37
+ // We are using params based on the docs: https://opentelemetry.io/docs/specs/semconv/attributes-registry/network/
38
+ const networkPeerAddress = core.spanToJSON(span).data['net.peer.name'];
39
+ const networkPeerPort = core.spanToJSON(span).data['net.peer.port'];
40
+ if (networkPeerPort && networkPeerAddress) {
41
+ span.setAttributes({ 'network.peer.address': networkPeerAddress, 'network.peer.port': networkPeerPort });
42
+ }
43
+
44
+ const cacheItemSize = redisCache.calculateCacheItemSize(response);
45
+
46
+ if (cacheItemSize) {
47
+ span.setAttribute(core.SEMANTIC_ATTRIBUTE_CACHE_ITEM_SIZE, cacheItemSize);
48
+ }
49
+
50
+ if (redisCache.isInCommands(redisCache.GET_COMMANDS, redisCommand) && cacheItemSize !== undefined) {
51
+ span.setAttribute(core.SEMANTIC_ATTRIBUTE_CACHE_HIT, cacheItemSize > 0);
52
+ }
53
+
54
+ span.setAttributes({
55
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: cacheOperation,
56
+ [core.SEMANTIC_ATTRIBUTE_CACHE_KEY]: safeKey,
57
+ });
58
+
59
+ // todo: change to string[] once EAP supports it
60
+ const spanDescription = safeKey.join(', ');
61
+
62
+ span.updateName(
63
+ exports._redisOptions.maxCacheKeyLength ? core.truncate(spanDescription, exports._redisOptions.maxCacheKeyLength) : spanDescription,
64
+ );
65
+ };
66
+
67
+ const instrumentIORedis = nodeCore.generateInstrumentOnce(`${INTEGRATION_NAME}.IORedis`, () => {
68
+ return new instrumentationIoredis.IORedisInstrumentation({
69
+ responseHook: cacheResponseHook,
70
+ });
71
+ });
72
+
73
+ const instrumentRedisModule = nodeCore.generateInstrumentOnce(`${INTEGRATION_NAME}.Redis`, () => {
74
+ return new instrumentationRedis.RedisInstrumentation({
75
+ responseHook: cacheResponseHook,
76
+ });
77
+ });
78
+
79
+ /** To be able to preload all Redis OTel instrumentations with just one ID ("Redis"), all the instrumentations are generated in this one function */
80
+ const instrumentRedis = Object.assign(
81
+ () => {
82
+ instrumentIORedis();
83
+ instrumentRedisModule();
84
+
85
+ // todo: implement them gradually
86
+ // new LegacyRedisInstrumentation({}),
87
+ },
88
+ { id: INTEGRATION_NAME },
89
+ );
90
+
91
+ const _redisIntegration = ((options = {}) => {
92
+ return {
93
+ name: INTEGRATION_NAME,
94
+ setupOnce() {
95
+ exports._redisOptions = options;
96
+ instrumentRedis();
97
+ },
98
+ };
99
+ }) ;
100
+
101
+ /**
102
+ * Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and
103
+ * [ioredis](https://www.npmjs.com/package/ioredis) libraries.
104
+ *
105
+ * For more information, see the [`redisIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).
106
+ *
107
+ * @example
108
+ * ```javascript
109
+ * const Sentry = require('@sentry/node');
110
+ *
111
+ * Sentry.init({
112
+ * integrations: [Sentry.redisIntegration()],
113
+ * });
114
+ * ```
115
+ */
116
+ const redisIntegration = core.defineIntegration(_redisIntegration);
117
+
118
+ exports.cacheResponseHook = cacheResponseHook;
119
+ exports.instrumentRedis = instrumentRedis;
120
+ exports.redisIntegration = redisIntegration;
121
+ //# sourceMappingURL=redis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.js","sources":["../../../../src/integrations/tracing/redis.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { RedisResponseCustomAttributeFunction } from '@opentelemetry/instrumentation-ioredis';\nimport { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis';\nimport { RedisInstrumentation } from '@opentelemetry/instrumentation-redis';\nimport type { IntegrationFn } 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 SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n truncate,\n} from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport {\n calculateCacheItemSize,\n GET_COMMANDS,\n getCacheKeySafely,\n getCacheOperation,\n isInCommands,\n shouldConsiderForCache,\n} from '../../utils/redisCache';\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: RedisResponseCustomAttributeFunction = (\n span: Span,\n redisCommand,\n cmdArgs,\n response,\n) => {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.redis');\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 const networkPeerAddress = spanToJSON(span).data['net.peer.name'];\n const networkPeerPort = spanToJSON(span).data['net.peer.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/** To be able to preload all Redis OTel instrumentations with just one ID (\"Redis\"), all the instrumentations are generated in this one function */\nexport const instrumentRedis = Object.assign(\n (): void => {\n instrumentIORedis();\n instrumentRedisModule();\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","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","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","defineIntegration"],"mapp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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,gBAAA,GAAAiB,sBAAA,CAAA,iBAAA;;;;;;"}
@@ -0,0 +1,67 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const instrumentationTedious = require('@opentelemetry/instrumentation-tedious');
4
+ const core = require('@sentry/core');
5
+ const nodeCore = require('@sentry/node-core');
6
+
7
+ const TEDIUS_INSTRUMENTED_METHODS = new Set([
8
+ 'callProcedure',
9
+ 'execSql',
10
+ 'execSqlBatch',
11
+ 'execBulkLoad',
12
+ 'prepare',
13
+ 'execute',
14
+ ]);
15
+
16
+ const INTEGRATION_NAME = 'Tedious';
17
+
18
+ const instrumentTedious = nodeCore.generateInstrumentOnce(INTEGRATION_NAME, () => new instrumentationTedious.TediousInstrumentation({}));
19
+
20
+ const _tediousIntegration = (() => {
21
+ let instrumentationWrappedCallback;
22
+
23
+ return {
24
+ name: INTEGRATION_NAME,
25
+ setupOnce() {
26
+ const instrumentation = instrumentTedious();
27
+ instrumentationWrappedCallback = nodeCore.instrumentWhenWrapped(instrumentation);
28
+ },
29
+
30
+ setup(client) {
31
+ instrumentationWrappedCallback?.(() =>
32
+ client.on('spanStart', span => {
33
+ const { description, data } = core.spanToJSON(span);
34
+ // Tedius integration always set a span name and `db.system` attribute to `mssql`.
35
+ if (!description || data['db.system'] !== 'mssql') {
36
+ return;
37
+ }
38
+
39
+ const operation = description.split(' ')[0] || '';
40
+ if (TEDIUS_INSTRUMENTED_METHODS.has(operation)) {
41
+ span.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.tedious');
42
+ }
43
+ }),
44
+ );
45
+ },
46
+ };
47
+ }) ;
48
+
49
+ /**
50
+ * Adds Sentry tracing instrumentation for the [tedious](https://www.npmjs.com/package/tedious) library.
51
+ *
52
+ * For more information, see the [`tediousIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/tedious/).
53
+ *
54
+ * @example
55
+ * ```javascript
56
+ * const Sentry = require('@sentry/node');
57
+ *
58
+ * Sentry.init({
59
+ * integrations: [Sentry.tediousIntegration()],
60
+ * });
61
+ * ```
62
+ */
63
+ const tediousIntegration = core.defineIntegration(_tediousIntegration);
64
+
65
+ exports.instrumentTedious = instrumentTedious;
66
+ exports.tediousIntegration = tediousIntegration;
67
+ //# sourceMappingURL=tedious.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tedious.js","sources":["../../../../src/integrations/tracing/tedious.ts"],"sourcesContent":["import { TediousInstrumentation } from '@opentelemetry/instrumentation-tedious';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';\nimport { generateInstrumentOnce, instrumentWhenWrapped } from '@sentry/node-core';\n\nconst TEDIUS_INSTRUMENTED_METHODS = new Set([\n 'callProcedure',\n 'execSql',\n 'execSqlBatch',\n 'execBulkLoad',\n 'prepare',\n 'execute',\n]);\n\nconst INTEGRATION_NAME = 'Tedious';\n\nexport const instrumentTedious = generateInstrumentOnce(INTEGRATION_NAME, () => new TediousInstrumentation({}));\n\nconst _tediousIntegration = (() => {\n let instrumentationWrappedCallback: undefined | ((callback: () => void) => void);\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n const instrumentation = instrumentTedious();\n instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);\n },\n\n setup(client) {\n instrumentationWrappedCallback?.(() =>\n client.on('spanStart', span => {\n const { description, data } = spanToJSON(span);\n // Tedius integration always set a span name and `db.system` attribute to `mssql`.\n if (!description || data['db.system'] !== 'mssql') {\n return;\n }\n\n const operation = description.split(' ')[0] || '';\n if (TEDIUS_INSTRUMENTED_METHODS.has(operation)) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.tedious');\n }\n }),\n );\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","instrumentWhenWrapped","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","defineIntegration"],"mappings":";;;;;;AAKA,MAAM,2BAAA,GAA8B,IAAI,GAAG,CAAC;AAC5C,EAAE,eAAe;AACjB,EAAE,SAAS;AACX,EAAE,cAAc;AAChB,EAAE,cAAc;AAChB,EAAE,SAAS;AACX,EAAE,SAAS;AACX,CAAC,CAAC;;AAEF,MAAM,gBAAA,GAAmB,SAAS;;MAErB,iBAAA,GAAoBA,+BAAsB,CAAC,gBAAgB,EAAE,MAAM,IAAIC,6CAAsB,CAAC,EAAE,CAAC;;AAE9G,MAAM,mBAAA,IAAuB,MAAM;AACnC,EAAE,IAAI,8BAA8B;;AAEpC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,MAAM,eAAA,GAAkB,iBAAiB,EAAE;AACjD,MAAM,8BAAA,GAAiCC,8BAAqB,CAAC,eAAe,CAAC;AAC7E,IAAI,CAAC;;AAEL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,8BAA8B,GAAG;AACvC,QAAQ,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ;AACvC,UAAU,MAAM,EAAE,WAAW,EAAE,IAAA,KAASC,eAAU,CAAC,IAAI,CAAC;AACxD;AACA,UAAU,IAAI,CAAC,WAAA,IAAe,IAAI,CAAC,WAAW,CAAA,KAAM,OAAO,EAAE;AAC7D,YAAY;AACZ,UAAU;;AAEV,UAAU,MAAM,SAAA,GAAY,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA,IAAK,EAAE;AAC3D,UAAU,IAAI,2BAA2B,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;AAC1D,YAAY,IAAI,CAAC,YAAY,CAACC,qCAAgC,EAAE,sBAAsB,CAAC;AACvF,UAAU;AACV,QAAQ,CAAC,CAAC;AACV,OAAO;AACP,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,kBAAA,GAAqBC,sBAAiB,CAAC,mBAAmB;;;;;"}
@@ -0,0 +1,6 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const INTEGRATION_NAME = 'VercelAI';
4
+
5
+ exports.INTEGRATION_NAME = INTEGRATION_NAME;
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +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;;;;"}
@@ -0,0 +1,82 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const nodeCore = require('@sentry/node-core');
5
+ const constants = require('./constants.js');
6
+ const instrumentation = require('./instrumentation.js');
7
+
8
+ const instrumentVercelAi = nodeCore.generateInstrumentOnce(constants.INTEGRATION_NAME, () => new instrumentation.SentryVercelAiInstrumentation({}));
9
+
10
+ /**
11
+ * Determines if the integration should be forced based on environment and package availability.
12
+ * Returns true if the 'ai' package is available.
13
+ */
14
+ function shouldForceIntegration(client) {
15
+ const modules = client.getIntegrationByName('Modules');
16
+ return !!modules?.getModules?.()?.ai;
17
+ }
18
+
19
+ const _vercelAIIntegration = ((options = {}) => {
20
+ let instrumentation;
21
+
22
+ return {
23
+ name: constants.INTEGRATION_NAME,
24
+ options,
25
+ setupOnce() {
26
+ instrumentation = instrumentVercelAi();
27
+ },
28
+ afterAllSetup(client) {
29
+ // Auto-detect if we should force the integration when running with 'ai' package available
30
+ // Note that this can only be detected if the 'Modules' integration is available, and running in CJS mode
31
+ const shouldForce = options.force ?? shouldForceIntegration(client);
32
+
33
+ if (shouldForce) {
34
+ core.addVercelAiProcessors(client);
35
+ } else {
36
+ instrumentation?.callWhenPatched(() => core.addVercelAiProcessors(client));
37
+ }
38
+ },
39
+ };
40
+ }) ;
41
+
42
+ /**
43
+ * Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
44
+ * This integration is not enabled by default, you need to manually add it.
45
+ *
46
+ * For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
47
+ *
48
+ * @example
49
+ * ```javascript
50
+ * const Sentry = require('@sentry/node');
51
+ *
52
+ * Sentry.init({
53
+ * integrations: [Sentry.vercelAIIntegration()],
54
+ * });
55
+ * ```
56
+ *
57
+ * This integration adds tracing support to all `ai` function calls.
58
+ * You need to opt-in to collecting spans for a specific call,
59
+ * you can do so by setting `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
60
+ *
61
+ * ```javascript
62
+ * const result = await generateText({
63
+ * model: openai('gpt-4-turbo'),
64
+ * experimental_telemetry: { isEnabled: true },
65
+ * });
66
+ * ```
67
+ *
68
+ * If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each
69
+ * function call by setting `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs`
70
+ * to `true`.
71
+ *
72
+ * ```javascript
73
+ * const result = await generateText({
74
+ * model: openai('gpt-4-turbo'),
75
+ * experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },
76
+ * });
77
+ */
78
+ const vercelAIIntegration = core.defineIntegration(_vercelAIIntegration);
79
+
80
+ exports.instrumentVercelAi = instrumentVercelAi;
81
+ exports.vercelAIIntegration = vercelAIIntegration;
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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":";;;;;;;MAOa,kBAAA,GAAqBA,+BAAsB,CAACC,0BAAgB,EAAE,MAAM,IAAIC,6CAA6B,CAAC,EAAE,CAAC;;AAEtH;AACA;AACA;AACA;AACA,SAAS,sBAAsB,CAAC,MAAM,EAAmB;AACzD,EAAE,MAAM,UAAU,MAAM,CAAC,oBAAoB,CAAwC,SAAS,CAAC;AAC/F,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,UAAU,IAAI,EAAE,EAAE;AACtC;;AAEA,MAAM,oBAAA,IAAwB,CAAC,OAAO,GAAoB,EAAE,KAAK;AACjE,EAAE,IAAI,eAAe;;AAErB,EAAE,OAAO;AACT,IAAI,IAAI,EAAED,0BAAgB;AAC1B,IAAI,OAAO;AACX,IAAI,SAAS,GAAG;AAChB,MAAM,eAAA,GAAkB,kBAAkB,EAAE;AAC5C,IAAI,CAAC;AACL,IAAI,aAAa,CAAC,MAAM,EAAE;AAC1B;AACA;AACA,MAAM,MAAM,WAAA,GAAc,OAAO,CAAC,SAAS,sBAAsB,CAAC,MAAM,CAAC;;AAEzE,MAAM,IAAI,WAAW,EAAE;AACvB,QAAQE,0BAAqB,CAAC,MAAM,CAAC;AACrC,MAAM,OAAO;AACb,QAAQ,eAAe,EAAE,eAAe,CAAC,MAAMA,0BAAqB,CAAC,MAAM,CAAC,CAAC;AAC7E,MAAM;AACN,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,mBAAA,GAAsBC,sBAAiB,CAAC,oBAAoB;;;;;"}
@@ -0,0 +1,274 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const instrumentation = require('@opentelemetry/instrumentation');
4
+ const core = require('@sentry/core');
5
+ const constants = require('./constants.js');
6
+
7
+ const SUPPORTED_VERSIONS = ['>=3.0.0 <7'];
8
+
9
+ // List of patched methods
10
+ // From: https://sdk.vercel.ai/docs/ai-sdk-core/telemetry#collected-data
11
+ const INSTRUMENTED_METHODS = [
12
+ 'generateText',
13
+ 'streamText',
14
+ 'generateObject',
15
+ 'streamObject',
16
+ 'embed',
17
+ 'embedMany',
18
+ 'rerank',
19
+ ] ;
20
+
21
+ function isToolError(obj) {
22
+ if (typeof obj !== 'object' || obj === null) {
23
+ return false;
24
+ }
25
+
26
+ const candidate = obj ;
27
+ return (
28
+ 'type' in candidate &&
29
+ 'error' in candidate &&
30
+ 'toolName' in candidate &&
31
+ 'toolCallId' in candidate &&
32
+ candidate.type === 'tool-error' &&
33
+ candidate.error instanceof Error
34
+ );
35
+ }
36
+
37
+ /**
38
+ * Process tool call results: capture tool errors and clean up span context mappings.
39
+ *
40
+ * Error checking runs first (needs span context for linking), then cleanup removes all entries.
41
+ * Tool errors are not rejected in Vercel AI V5 — they appear as metadata in the result content.
42
+ */
43
+ function processToolCallResults(result) {
44
+ if (typeof result !== 'object' || result === null || !('content' in result)) {
45
+ return;
46
+ }
47
+
48
+ const resultObj = result ;
49
+ if (!Array.isArray(resultObj.content)) {
50
+ return;
51
+ }
52
+
53
+ captureToolErrors(resultObj.content);
54
+ cleanupToolCallSpanContexts(resultObj.content);
55
+ }
56
+
57
+ function captureToolErrors(content) {
58
+ for (const item of content) {
59
+ if (!isToolError(item)) {
60
+ continue;
61
+ }
62
+
63
+ // Try to get the span context associated with this tool call ID
64
+ const spanContext = core._INTERNAL_getSpanContextForToolCallId(item.toolCallId);
65
+
66
+ if (spanContext) {
67
+ // We have the span context, so link the error using span and trace IDs
68
+ core.withScope(scope => {
69
+ scope.setContext('trace', {
70
+ trace_id: spanContext.traceId,
71
+ span_id: spanContext.spanId,
72
+ });
73
+
74
+ scope.setTag('vercel.ai.tool.name', item.toolName);
75
+ scope.setTag('vercel.ai.tool.callId', item.toolCallId);
76
+ scope.setLevel('error');
77
+
78
+ core.captureException(item.error, {
79
+ mechanism: {
80
+ type: 'auto.vercelai.otel',
81
+ handled: false,
82
+ },
83
+ });
84
+ });
85
+ } else {
86
+ // Fallback: capture without span linking
87
+ core.withScope(scope => {
88
+ scope.setTag('vercel.ai.tool.name', item.toolName);
89
+ scope.setTag('vercel.ai.tool.callId', item.toolCallId);
90
+ scope.setLevel('error');
91
+
92
+ core.captureException(item.error, {
93
+ mechanism: {
94
+ type: 'auto.vercelai.otel',
95
+ handled: false,
96
+ },
97
+ });
98
+ });
99
+ }
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Remove span context entries for all completed tool calls in the content array.
105
+ */
106
+ function cleanupToolCallSpanContexts(content) {
107
+ for (const item of content) {
108
+ if (
109
+ typeof item === 'object' &&
110
+ item !== null &&
111
+ 'toolCallId' in item &&
112
+ typeof (item ).toolCallId === 'string'
113
+ ) {
114
+ core._INTERNAL_cleanupToolCallSpanContext((item ).toolCallId );
115
+ }
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Determines whether to record inputs and outputs for Vercel AI telemetry based on the configuration hierarchy.
121
+ *
122
+ * The order of precedence is:
123
+ * 1. The vercel ai integration options
124
+ * 2. The experimental_telemetry options in the vercel ai method calls
125
+ * 3. When telemetry is explicitly enabled (isEnabled: true), default to recording
126
+ * 4. Otherwise, use the sendDefaultPii option from client options
127
+ */
128
+ function determineRecordingSettings(
129
+ integrationRecordingOptions,
130
+ methodTelemetryOptions,
131
+ telemetryExplicitlyEnabled,
132
+ defaultRecordingEnabled,
133
+ ) {
134
+ const recordInputs =
135
+ integrationRecordingOptions?.recordInputs !== undefined
136
+ ? integrationRecordingOptions.recordInputs
137
+ : methodTelemetryOptions.recordInputs !== undefined
138
+ ? methodTelemetryOptions.recordInputs
139
+ : telemetryExplicitlyEnabled === true
140
+ ? true // When telemetry is explicitly enabled, default to recording inputs
141
+ : defaultRecordingEnabled;
142
+
143
+ const recordOutputs =
144
+ integrationRecordingOptions?.recordOutputs !== undefined
145
+ ? integrationRecordingOptions.recordOutputs
146
+ : methodTelemetryOptions.recordOutputs !== undefined
147
+ ? methodTelemetryOptions.recordOutputs
148
+ : telemetryExplicitlyEnabled === true
149
+ ? true // When telemetry is explicitly enabled, default to recording inputs
150
+ : defaultRecordingEnabled;
151
+
152
+ return { recordInputs, recordOutputs };
153
+ }
154
+
155
+ /**
156
+ * This detects is added by the Sentry Vercel AI Integration to detect if the integration should
157
+ * be enabled.
158
+ *
159
+ * It also patches the `ai` module to enable Vercel AI telemetry automatically for all methods.
160
+ */
161
+ class SentryVercelAiInstrumentation extends instrumentation.InstrumentationBase {
162
+ __init() {this._isPatched = false;}
163
+ __init2() {this._callbacks = [];}
164
+
165
+ constructor(config = {}) {
166
+ super('@sentry/instrumentation-vercel-ai', core.SDK_VERSION, config);SentryVercelAiInstrumentation.prototype.__init.call(this);SentryVercelAiInstrumentation.prototype.__init2.call(this); }
167
+
168
+ /**
169
+ * Initializes the instrumentation by defining the modules to be patched.
170
+ */
171
+ init() {
172
+ const module = new instrumentation.InstrumentationNodeModuleDefinition('ai', SUPPORTED_VERSIONS, this._patch.bind(this));
173
+ return module;
174
+ }
175
+
176
+ /**
177
+ * Call the provided callback when the module is patched.
178
+ * If it has already been patched, the callback will be called immediately.
179
+ */
180
+ callWhenPatched(callback) {
181
+ if (this._isPatched) {
182
+ callback();
183
+ } else {
184
+ this._callbacks.push(callback);
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Patches module exports to enable Vercel AI telemetry.
190
+ */
191
+ _patch(moduleExports) {
192
+ this._isPatched = true;
193
+
194
+ this._callbacks.forEach(callback => callback());
195
+ this._callbacks = [];
196
+
197
+ const generatePatch = (originalMethod) => {
198
+ return new Proxy(originalMethod, {
199
+ apply: (target, thisArg, args) => {
200
+ const existingExperimentalTelemetry = args[0].experimental_telemetry || {};
201
+ const isEnabled = existingExperimentalTelemetry.isEnabled;
202
+
203
+ const client = core.getClient();
204
+ const integration = client?.getIntegrationByName(constants.INTEGRATION_NAME);
205
+ const integrationOptions = integration?.options;
206
+ const shouldRecordInputsAndOutputs = integration ? Boolean(client?.getOptions().sendDefaultPii) : false;
207
+
208
+ const { recordInputs, recordOutputs } = determineRecordingSettings(
209
+ integrationOptions,
210
+ existingExperimentalTelemetry,
211
+ isEnabled,
212
+ shouldRecordInputsAndOutputs,
213
+ );
214
+
215
+ args[0].experimental_telemetry = {
216
+ ...existingExperimentalTelemetry,
217
+ isEnabled: isEnabled !== undefined ? isEnabled : true,
218
+ recordInputs,
219
+ recordOutputs,
220
+ };
221
+
222
+ return core.handleCallbackErrors(
223
+ () => Reflect.apply(target, thisArg, args),
224
+ error => {
225
+ // This error bubbles up to unhandledrejection handler (if not handled before),
226
+ // where we do not know the active span anymore
227
+ // So to circumvent this, we set the active span on the error object
228
+ // which is picked up by the unhandledrejection handler
229
+ if (error && typeof error === 'object') {
230
+ core.addNonEnumerableProperty(error, '_sentry_active_span', core.getActiveSpan());
231
+ }
232
+ },
233
+ () => {},
234
+ result => {
235
+ processToolCallResults(result);
236
+ },
237
+ );
238
+ },
239
+ });
240
+ };
241
+
242
+ // Is this an ESM module?
243
+ // https://tc39.es/ecma262/#sec-module-namespace-objects
244
+ if (Object.prototype.toString.call(moduleExports) === '[object Module]') {
245
+ // In ESM we take the usual route and just replace the exports we want to instrument
246
+ for (const method of INSTRUMENTED_METHODS) {
247
+ // Skip methods that don't exist in this version of the AI SDK (e.g., rerank was added in v6)
248
+ if (moduleExports[method] != null) {
249
+ moduleExports[method] = generatePatch(moduleExports[method]);
250
+ }
251
+ }
252
+
253
+ return moduleExports;
254
+ } else {
255
+ // In CJS we can't replace the exports in the original module because they
256
+ // don't have setters, so we create a new object with the same properties
257
+ const patchedModuleExports = INSTRUMENTED_METHODS.reduce((acc, curr) => {
258
+ // Skip methods that don't exist in this version of the AI SDK (e.g., rerank was added in v6)
259
+ if (moduleExports[curr] != null) {
260
+ acc[curr] = generatePatch(moduleExports[curr]);
261
+ }
262
+ return acc;
263
+ }, {} );
264
+
265
+ return { ...moduleExports, ...patchedModuleExports };
266
+ }
267
+ }
268
+ }
269
+
270
+ exports.SentryVercelAiInstrumentation = SentryVercelAiInstrumentation;
271
+ exports.cleanupToolCallSpanContexts = cleanupToolCallSpanContexts;
272
+ exports.determineRecordingSettings = determineRecordingSettings;
273
+ exports.processToolCallResults = processToolCallResults;
274
+ //# sourceMappingURL=instrumentation.js.map