@sentry/node 9.34.0-alpha.1 → 9.35.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 (474) hide show
  1. package/build/cjs/cron/common.js +56 -0
  2. package/build/cjs/cron/common.js.map +1 -0
  3. package/build/cjs/cron/cron.js +112 -0
  4. package/build/cjs/cron/cron.js.map +1 -0
  5. package/build/cjs/cron/index.js +15 -0
  6. package/build/cjs/cron/index.js.map +1 -0
  7. package/build/cjs/cron/node-cron.js +71 -0
  8. package/build/cjs/cron/node-cron.js.map +1 -0
  9. package/build/cjs/cron/node-schedule.js +65 -0
  10. package/build/cjs/cron/node-schedule.js.map +1 -0
  11. package/build/cjs/index.js +56 -38
  12. package/build/cjs/index.js.map +1 -1
  13. package/build/cjs/integrations/anr/index.js +238 -0
  14. package/build/cjs/integrations/anr/index.js.map +1 -0
  15. package/build/cjs/integrations/childProcess.js +100 -0
  16. package/build/cjs/integrations/childProcess.js.map +1 -0
  17. package/build/cjs/integrations/context.js +457 -0
  18. package/build/cjs/integrations/context.js.map +1 -0
  19. package/build/cjs/integrations/contextlines.js +405 -0
  20. package/build/cjs/integrations/contextlines.js.map +1 -0
  21. package/build/cjs/integrations/fs.js +2 -2
  22. package/build/cjs/integrations/fs.js.map +1 -1
  23. package/build/cjs/integrations/http/SentryHttpInstrumentation.js +558 -0
  24. package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -0
  25. package/build/cjs/integrations/http/index.js +11 -7
  26. package/build/cjs/integrations/http/index.js.map +1 -1
  27. package/build/cjs/integrations/local-variables/common.js +69 -0
  28. package/build/cjs/integrations/local-variables/common.js.map +1 -0
  29. package/build/cjs/integrations/local-variables/index.js +12 -0
  30. package/build/cjs/integrations/local-variables/index.js.map +1 -0
  31. package/build/cjs/integrations/local-variables/local-variables-async.js +143 -0
  32. package/build/cjs/integrations/local-variables/local-variables-async.js.map +1 -0
  33. package/build/cjs/integrations/local-variables/local-variables-sync.js +410 -0
  34. package/build/cjs/integrations/local-variables/local-variables-sync.js.map +1 -0
  35. package/build/cjs/integrations/modules.js +135 -0
  36. package/build/cjs/integrations/modules.js.map +1 -0
  37. package/build/cjs/integrations/node-fetch/SentryNodeFetchInstrumentation.js +291 -0
  38. package/build/cjs/integrations/node-fetch/SentryNodeFetchInstrumentation.js.map +1 -0
  39. package/build/cjs/integrations/node-fetch/index.js +5 -4
  40. package/build/cjs/integrations/node-fetch/index.js.map +1 -1
  41. package/build/cjs/integrations/onuncaughtexception.js +134 -0
  42. package/build/cjs/integrations/onuncaughtexception.js.map +1 -0
  43. package/build/cjs/integrations/onunhandledrejection.js +89 -0
  44. package/build/cjs/integrations/onunhandledrejection.js.map +1 -0
  45. package/build/cjs/integrations/processSession.js +36 -0
  46. package/build/cjs/integrations/processSession.js.map +1 -0
  47. package/build/cjs/integrations/spotlight.js +101 -0
  48. package/build/cjs/integrations/spotlight.js.map +1 -0
  49. package/build/cjs/integrations/tracing/amqplib.js +5 -4
  50. package/build/cjs/integrations/tracing/amqplib.js.map +1 -1
  51. package/build/cjs/integrations/tracing/connect.js +4 -3
  52. package/build/cjs/integrations/tracing/connect.js.map +1 -1
  53. package/build/cjs/integrations/tracing/dataloader.js +3 -3
  54. package/build/cjs/integrations/tracing/dataloader.js.map +1 -1
  55. package/build/cjs/integrations/tracing/express.js +7 -5
  56. package/build/cjs/integrations/tracing/express.js.map +1 -1
  57. package/build/cjs/integrations/tracing/fastify/fastify-otel/index.js +3 -3
  58. package/build/cjs/integrations/tracing/fastify/fastify-otel/index.js.map +1 -1
  59. package/build/cjs/integrations/tracing/fastify/index.js +6 -6
  60. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
  61. package/build/cjs/integrations/tracing/genericPool.js +3 -3
  62. package/build/cjs/integrations/tracing/genericPool.js.map +1 -1
  63. package/build/cjs/integrations/tracing/graphql.js +4 -3
  64. package/build/cjs/integrations/tracing/graphql.js.map +1 -1
  65. package/build/cjs/integrations/tracing/hapi/index.js +4 -3
  66. package/build/cjs/integrations/tracing/hapi/index.js.map +1 -1
  67. package/build/cjs/integrations/tracing/kafka.js +5 -4
  68. package/build/cjs/integrations/tracing/kafka.js.map +1 -1
  69. package/build/cjs/integrations/tracing/knex.js +3 -3
  70. package/build/cjs/integrations/tracing/knex.js.map +1 -1
  71. package/build/cjs/integrations/tracing/koa.js +6 -4
  72. package/build/cjs/integrations/tracing/koa.js.map +1 -1
  73. package/build/cjs/integrations/tracing/lrumemoizer.js +2 -2
  74. package/build/cjs/integrations/tracing/lrumemoizer.js.map +1 -1
  75. package/build/cjs/integrations/tracing/mongo.js +4 -3
  76. package/build/cjs/integrations/tracing/mongo.js.map +1 -1
  77. package/build/cjs/integrations/tracing/mongoose.js +4 -3
  78. package/build/cjs/integrations/tracing/mongoose.js.map +1 -1
  79. package/build/cjs/integrations/tracing/mysql.js +2 -2
  80. package/build/cjs/integrations/tracing/mysql.js.map +1 -1
  81. package/build/cjs/integrations/tracing/mysql2.js +4 -3
  82. package/build/cjs/integrations/tracing/mysql2.js.map +1 -1
  83. package/build/cjs/integrations/tracing/postgres.js +4 -3
  84. package/build/cjs/integrations/tracing/postgres.js.map +1 -1
  85. package/build/cjs/integrations/tracing/postgresjs.js +4 -3
  86. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
  87. package/build/cjs/integrations/tracing/prisma.js +2 -2
  88. package/build/cjs/integrations/tracing/prisma.js.map +1 -1
  89. package/build/cjs/integrations/tracing/redis.js +3 -3
  90. package/build/cjs/integrations/tracing/redis.js.map +1 -1
  91. package/build/cjs/integrations/tracing/tedious.js +3 -3
  92. package/build/cjs/integrations/tracing/tedious.js.map +1 -1
  93. package/build/cjs/integrations/tracing/vercelai/index.js +2 -2
  94. package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -1
  95. package/build/cjs/integrations/winston.js +151 -0
  96. package/build/cjs/integrations/winston.js.map +1 -0
  97. package/build/cjs/logs/capture.js +29 -0
  98. package/build/cjs/logs/capture.js.map +1 -0
  99. package/build/cjs/logs/exports.js +178 -0
  100. package/build/cjs/logs/exports.js.map +1 -0
  101. package/build/cjs/nodeVersion.js +12 -0
  102. package/build/cjs/nodeVersion.js.map +1 -0
  103. package/build/cjs/otel/contextManager.js +16 -0
  104. package/build/cjs/otel/contextManager.js.map +1 -0
  105. package/build/cjs/otel/instrument.js +139 -0
  106. package/build/cjs/otel/instrument.js.map +1 -0
  107. package/build/cjs/preload.js +2 -2
  108. package/build/cjs/preload.js.map +1 -1
  109. package/build/cjs/proxy/base.js +122 -0
  110. package/build/cjs/proxy/base.js.map +1 -0
  111. package/build/cjs/proxy/index.js +173 -0
  112. package/build/cjs/proxy/index.js.map +1 -0
  113. package/build/cjs/proxy/parse-proxy-response.js +104 -0
  114. package/build/cjs/proxy/parse-proxy-response.js.map +1 -0
  115. package/build/cjs/sdk/api.js +117 -0
  116. package/build/cjs/sdk/api.js.map +1 -0
  117. package/build/cjs/sdk/client.js +156 -0
  118. package/build/cjs/sdk/client.js.map +1 -0
  119. package/build/cjs/sdk/index.js +203 -22
  120. package/build/cjs/sdk/index.js.map +1 -1
  121. package/build/cjs/sdk/initOtel.js +22 -4
  122. package/build/cjs/sdk/initOtel.js.map +1 -1
  123. package/build/cjs/transports/http.js +158 -0
  124. package/build/cjs/transports/http.js.map +1 -0
  125. package/build/cjs/utils/addOriginToSpan.js +11 -0
  126. package/build/cjs/utils/addOriginToSpan.js.map +1 -0
  127. package/build/cjs/utils/baggage.js +36 -0
  128. package/build/cjs/utils/baggage.js.map +1 -0
  129. package/build/cjs/utils/commonjs.js +13 -0
  130. package/build/cjs/utils/commonjs.js.map +1 -0
  131. package/build/cjs/utils/createMissingInstrumentationContext.js +11 -0
  132. package/build/cjs/utils/createMissingInstrumentationContext.js.map +1 -0
  133. package/build/cjs/utils/debug.js +23 -0
  134. package/build/cjs/utils/debug.js.map +1 -0
  135. package/build/cjs/utils/ensureIsWrapped.js +41 -0
  136. package/build/cjs/utils/ensureIsWrapped.js.map +1 -0
  137. package/build/cjs/utils/envToBool.js +32 -0
  138. package/build/cjs/utils/envToBool.js.map +1 -0
  139. package/build/cjs/utils/errorhandling.js +42 -0
  140. package/build/cjs/utils/errorhandling.js.map +1 -0
  141. package/build/cjs/utils/getRequestUrl.js +18 -0
  142. package/build/cjs/utils/getRequestUrl.js.map +1 -0
  143. package/build/cjs/utils/module.js +60 -0
  144. package/build/cjs/utils/module.js.map +1 -0
  145. package/build/esm/cron/common.js +54 -0
  146. package/build/esm/cron/common.js.map +1 -0
  147. package/build/esm/cron/cron.js +110 -0
  148. package/build/esm/cron/cron.js.map +1 -0
  149. package/build/esm/cron/index.js +13 -0
  150. package/build/esm/cron/index.js.map +1 -0
  151. package/build/esm/cron/node-cron.js +69 -0
  152. package/build/esm/cron/node-cron.js.map +1 -0
  153. package/build/esm/cron/node-schedule.js +63 -0
  154. package/build/esm/cron/node-schedule.js.map +1 -0
  155. package/build/esm/index.js +21 -2
  156. package/build/esm/index.js.map +1 -1
  157. package/build/esm/integrations/anr/index.js +234 -0
  158. package/build/esm/integrations/anr/index.js.map +1 -0
  159. package/build/esm/integrations/anr/worker-script.js +2 -0
  160. package/build/esm/integrations/childProcess.js +98 -0
  161. package/build/esm/integrations/childProcess.js.map +1 -0
  162. package/build/esm/integrations/context.js +451 -0
  163. package/build/esm/integrations/context.js.map +1 -0
  164. package/build/esm/integrations/contextlines.js +399 -0
  165. package/build/esm/integrations/contextlines.js.map +1 -0
  166. package/build/esm/integrations/fs.js +1 -1
  167. package/build/esm/integrations/fs.js.map +1 -1
  168. package/build/esm/integrations/http/SentryHttpInstrumentation.js +555 -0
  169. package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -0
  170. package/build/esm/integrations/http/index.js +5 -1
  171. package/build/esm/integrations/http/index.js.map +1 -1
  172. package/build/esm/integrations/local-variables/common.js +64 -0
  173. package/build/esm/integrations/local-variables/common.js.map +1 -0
  174. package/build/esm/integrations/local-variables/index.js +10 -0
  175. package/build/esm/integrations/local-variables/index.js.map +1 -0
  176. package/build/esm/integrations/local-variables/local-variables-async.js +140 -0
  177. package/build/esm/integrations/local-variables/local-variables-async.js.map +1 -0
  178. package/build/esm/integrations/local-variables/local-variables-sync.js +405 -0
  179. package/build/esm/integrations/local-variables/local-variables-sync.js.map +1 -0
  180. package/build/esm/integrations/local-variables/worker-script.js +2 -0
  181. package/build/esm/integrations/modules.js +133 -0
  182. package/build/esm/integrations/modules.js.map +1 -0
  183. package/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js +289 -0
  184. package/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js.map +1 -0
  185. package/build/esm/integrations/node-fetch/index.js +3 -2
  186. package/build/esm/integrations/node-fetch/index.js.map +1 -1
  187. package/build/esm/integrations/onuncaughtexception.js +131 -0
  188. package/build/esm/integrations/onuncaughtexception.js.map +1 -0
  189. package/build/esm/integrations/onunhandledrejection.js +86 -0
  190. package/build/esm/integrations/onunhandledrejection.js.map +1 -0
  191. package/build/esm/integrations/processSession.js +34 -0
  192. package/build/esm/integrations/processSession.js.map +1 -0
  193. package/build/esm/integrations/spotlight.js +98 -0
  194. package/build/esm/integrations/spotlight.js.map +1 -0
  195. package/build/esm/integrations/tracing/amqplib.js +2 -1
  196. package/build/esm/integrations/tracing/amqplib.js.map +1 -1
  197. package/build/esm/integrations/tracing/connect.js +2 -1
  198. package/build/esm/integrations/tracing/connect.js.map +1 -1
  199. package/build/esm/integrations/tracing/dataloader.js +1 -1
  200. package/build/esm/integrations/tracing/dataloader.js.map +1 -1
  201. package/build/esm/integrations/tracing/express.js +4 -2
  202. package/build/esm/integrations/tracing/express.js.map +1 -1
  203. package/build/esm/integrations/tracing/fastify/fastify-otel/index.js +3 -3
  204. package/build/esm/integrations/tracing/fastify/fastify-otel/index.js.map +1 -1
  205. package/build/esm/integrations/tracing/fastify/index.js +5 -5
  206. package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
  207. package/build/esm/integrations/tracing/genericPool.js +1 -1
  208. package/build/esm/integrations/tracing/genericPool.js.map +1 -1
  209. package/build/esm/integrations/tracing/graphql.js +3 -2
  210. package/build/esm/integrations/tracing/graphql.js.map +1 -1
  211. package/build/esm/integrations/tracing/hapi/index.js +2 -1
  212. package/build/esm/integrations/tracing/hapi/index.js.map +1 -1
  213. package/build/esm/integrations/tracing/kafka.js +2 -1
  214. package/build/esm/integrations/tracing/kafka.js.map +1 -1
  215. package/build/esm/integrations/tracing/knex.js +1 -1
  216. package/build/esm/integrations/tracing/knex.js.map +1 -1
  217. package/build/esm/integrations/tracing/koa.js +4 -2
  218. package/build/esm/integrations/tracing/koa.js.map +1 -1
  219. package/build/esm/integrations/tracing/lrumemoizer.js +1 -1
  220. package/build/esm/integrations/tracing/lrumemoizer.js.map +1 -1
  221. package/build/esm/integrations/tracing/mongo.js +2 -1
  222. package/build/esm/integrations/tracing/mongo.js.map +1 -1
  223. package/build/esm/integrations/tracing/mongoose.js +2 -1
  224. package/build/esm/integrations/tracing/mongoose.js.map +1 -1
  225. package/build/esm/integrations/tracing/mysql.js +1 -1
  226. package/build/esm/integrations/tracing/mysql.js.map +1 -1
  227. package/build/esm/integrations/tracing/mysql2.js +2 -1
  228. package/build/esm/integrations/tracing/mysql2.js.map +1 -1
  229. package/build/esm/integrations/tracing/postgres.js +2 -1
  230. package/build/esm/integrations/tracing/postgres.js.map +1 -1
  231. package/build/esm/integrations/tracing/postgresjs.js +3 -2
  232. package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
  233. package/build/esm/integrations/tracing/prisma.js +1 -1
  234. package/build/esm/integrations/tracing/prisma.js.map +1 -1
  235. package/build/esm/integrations/tracing/redis.js +1 -1
  236. package/build/esm/integrations/tracing/redis.js.map +1 -1
  237. package/build/esm/integrations/tracing/tedious.js +1 -1
  238. package/build/esm/integrations/tracing/tedious.js.map +1 -1
  239. package/build/esm/integrations/tracing/vercelai/index.js +1 -1
  240. package/build/esm/integrations/tracing/vercelai/index.js.map +1 -1
  241. package/build/esm/integrations/winston.js +149 -0
  242. package/build/esm/integrations/winston.js.map +1 -0
  243. package/build/esm/logs/capture.js +27 -0
  244. package/build/esm/logs/capture.js.map +1 -0
  245. package/build/esm/logs/exports.js +170 -0
  246. package/build/esm/logs/exports.js.map +1 -0
  247. package/build/esm/nodeVersion.js +8 -0
  248. package/build/esm/nodeVersion.js.map +1 -0
  249. package/build/esm/otel/contextManager.js +14 -0
  250. package/build/esm/otel/contextManager.js.map +1 -0
  251. package/build/esm/otel/instrument.js +135 -0
  252. package/build/esm/otel/instrument.js.map +1 -0
  253. package/build/esm/package.json +1 -1
  254. package/build/esm/preload.js +1 -1
  255. package/build/esm/preload.js.map +1 -1
  256. package/build/esm/proxy/base.js +120 -0
  257. package/build/esm/proxy/base.js.map +1 -0
  258. package/build/esm/proxy/index.js +171 -0
  259. package/build/esm/proxy/index.js.map +1 -0
  260. package/build/esm/proxy/parse-proxy-response.js +102 -0
  261. package/build/esm/proxy/parse-proxy-response.js.map +1 -0
  262. package/build/esm/sdk/api.js +114 -0
  263. package/build/esm/sdk/api.js.map +1 -0
  264. package/build/esm/sdk/client.js +154 -0
  265. package/build/esm/sdk/client.js.map +1 -0
  266. package/build/esm/sdk/index.js +202 -22
  267. package/build/esm/sdk/index.js.map +1 -1
  268. package/build/esm/sdk/initOtel.js +21 -3
  269. package/build/esm/sdk/initOtel.js.map +1 -1
  270. package/build/esm/transports/http.js +156 -0
  271. package/build/esm/transports/http.js.map +1 -0
  272. package/build/esm/utils/addOriginToSpan.js +9 -0
  273. package/build/esm/utils/addOriginToSpan.js.map +1 -0
  274. package/build/esm/utils/baggage.js +34 -0
  275. package/build/esm/utils/baggage.js.map +1 -0
  276. package/build/esm/utils/commonjs.js +11 -0
  277. package/build/esm/utils/commonjs.js.map +1 -0
  278. package/build/esm/utils/createMissingInstrumentationContext.js +9 -0
  279. package/build/esm/utils/createMissingInstrumentationContext.js.map +1 -0
  280. package/build/esm/utils/debug.js +21 -0
  281. package/build/esm/utils/debug.js.map +1 -0
  282. package/build/esm/utils/ensureIsWrapped.js +39 -0
  283. package/build/esm/utils/ensureIsWrapped.js.map +1 -0
  284. package/build/esm/utils/envToBool.js +28 -0
  285. package/build/esm/utils/envToBool.js.map +1 -0
  286. package/build/esm/utils/errorhandling.js +40 -0
  287. package/build/esm/utils/errorhandling.js.map +1 -0
  288. package/build/esm/utils/getRequestUrl.js +16 -0
  289. package/build/esm/utils/getRequestUrl.js.map +1 -0
  290. package/build/esm/utils/module.js +58 -0
  291. package/build/esm/utils/module.js.map +1 -0
  292. package/build/types/cron/common.d.ts +5 -0
  293. package/build/types/cron/common.d.ts.map +1 -0
  294. package/build/types/cron/cron.d.ts +43 -0
  295. package/build/types/cron/cron.d.ts.map +1 -0
  296. package/build/types/cron/index.d.ts +10 -0
  297. package/build/types/cron/index.d.ts.map +1 -0
  298. package/build/types/cron/node-cron.d.ts +27 -0
  299. package/build/types/cron/node-cron.d.ts.map +1 -0
  300. package/build/types/cron/node-schedule.d.ts +19 -0
  301. package/build/types/cron/node-schedule.d.ts.map +1 -0
  302. package/build/types/index.d.ts +21 -2
  303. package/build/types/index.d.ts.map +1 -1
  304. package/build/types/integrations/anr/common.d.ts +52 -0
  305. package/build/types/integrations/anr/common.d.ts.map +1 -0
  306. package/build/types/integrations/anr/index.d.ts +13 -0
  307. package/build/types/integrations/anr/index.d.ts.map +1 -0
  308. package/build/types/integrations/anr/worker.d.ts +2 -0
  309. package/build/types/integrations/anr/worker.d.ts.map +1 -0
  310. package/build/types/integrations/childProcess.d.ts +20 -0
  311. package/build/types/integrations/childProcess.d.ts.map +1 -0
  312. package/build/types/integrations/context.d.ts +30 -0
  313. package/build/types/integrations/context.d.ts.map +1 -0
  314. package/build/types/integrations/contextlines.d.ts +31 -0
  315. package/build/types/integrations/contextlines.d.ts.map +1 -0
  316. package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +131 -0
  317. package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -0
  318. package/build/types/integrations/http/index.d.ts +1 -1
  319. package/build/types/integrations/http/index.d.ts.map +1 -1
  320. package/build/types/integrations/local-variables/common.d.ts +66 -0
  321. package/build/types/integrations/local-variables/common.d.ts.map +1 -0
  322. package/build/types/integrations/local-variables/index.d.ts +4 -0
  323. package/build/types/integrations/local-variables/index.d.ts.map +1 -0
  324. package/build/types/integrations/local-variables/local-variables-async.d.ts +7 -0
  325. package/build/types/integrations/local-variables/local-variables-async.d.ts.map +1 -0
  326. package/build/types/integrations/local-variables/local-variables-sync.d.ts +34 -0
  327. package/build/types/integrations/local-variables/local-variables-sync.d.ts.map +1 -0
  328. package/build/types/integrations/local-variables/worker.d.ts +2 -0
  329. package/build/types/integrations/local-variables/worker.d.ts.map +1 -0
  330. package/build/types/integrations/modules.d.ts +17 -0
  331. package/build/types/integrations/modules.d.ts.map +1 -0
  332. package/build/types/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts +56 -0
  333. package/build/types/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts.map +1 -0
  334. package/build/types/integrations/node-fetch/index.d.ts.map +1 -1
  335. package/build/types/integrations/onuncaughtexception.d.ts +31 -0
  336. package/build/types/integrations/onuncaughtexception.d.ts.map +1 -0
  337. package/build/types/integrations/onunhandledrejection.d.ts +23 -0
  338. package/build/types/integrations/onunhandledrejection.d.ts.map +1 -0
  339. package/build/types/integrations/processSession.d.ts +5 -0
  340. package/build/types/integrations/processSession.d.ts.map +1 -0
  341. package/build/types/integrations/spotlight.d.ts +18 -0
  342. package/build/types/integrations/spotlight.d.ts.map +1 -0
  343. package/build/types/integrations/tracing/amqplib.d.ts.map +1 -1
  344. package/build/types/integrations/tracing/connect.d.ts.map +1 -1
  345. package/build/types/integrations/tracing/express.d.ts.map +1 -1
  346. package/build/types/integrations/tracing/graphql.d.ts.map +1 -1
  347. package/build/types/integrations/tracing/hapi/index.d.ts.map +1 -1
  348. package/build/types/integrations/tracing/kafka.d.ts.map +1 -1
  349. package/build/types/integrations/tracing/koa.d.ts.map +1 -1
  350. package/build/types/integrations/tracing/mongo.d.ts.map +1 -1
  351. package/build/types/integrations/tracing/mongoose.d.ts.map +1 -1
  352. package/build/types/integrations/tracing/mysql2.d.ts.map +1 -1
  353. package/build/types/integrations/tracing/postgres.d.ts.map +1 -1
  354. package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -1
  355. package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -1
  356. package/build/types/integrations/winston.d.ts +44 -0
  357. package/build/types/integrations/winston.d.ts.map +1 -0
  358. package/build/types/logs/capture.d.ts +11 -0
  359. package/build/types/logs/capture.d.ts.map +1 -0
  360. package/build/types/logs/exports.d.ts +150 -0
  361. package/build/types/logs/exports.d.ts.map +1 -0
  362. package/build/types/nodeVersion.d.ts +8 -0
  363. package/build/types/nodeVersion.d.ts.map +1 -0
  364. package/build/types/otel/contextManager.d.ts +10 -0
  365. package/build/types/otel/contextManager.d.ts.map +1 -0
  366. package/build/types/otel/instrument.d.ts +23 -0
  367. package/build/types/otel/instrument.d.ts.map +1 -0
  368. package/build/types/proxy/base.d.ts +65 -0
  369. package/build/types/proxy/base.d.ts.map +1 -0
  370. package/build/types/proxy/helpers.d.ts +42 -0
  371. package/build/types/proxy/helpers.d.ts.map +1 -0
  372. package/build/types/proxy/index.d.ts +73 -0
  373. package/build/types/proxy/index.d.ts.map +1 -0
  374. package/build/types/proxy/parse-proxy-response.d.ts +43 -0
  375. package/build/types/proxy/parse-proxy-response.d.ts.map +1 -0
  376. package/build/types/sdk/api.d.ts +8 -0
  377. package/build/types/sdk/api.d.ts.map +1 -0
  378. package/build/types/sdk/client.d.ts +29 -0
  379. package/build/types/sdk/client.d.ts.map +1 -0
  380. package/build/types/sdk/index.d.ts +6 -2
  381. package/build/types/sdk/index.d.ts.map +1 -1
  382. package/build/types/sdk/initOtel.d.ts +1 -1
  383. package/build/types/sdk/initOtel.d.ts.map +1 -1
  384. package/build/types/sdk/scope.d.ts +7 -0
  385. package/build/types/sdk/scope.d.ts.map +1 -0
  386. package/build/types/transports/http-module.d.ts +31 -0
  387. package/build/types/transports/http-module.d.ts.map +1 -0
  388. package/build/types/transports/http.d.ts +21 -0
  389. package/build/types/transports/http.d.ts.map +1 -0
  390. package/build/types/transports/index.d.ts +3 -0
  391. package/build/types/transports/index.d.ts.map +1 -0
  392. package/build/types/types.d.ts +1 -1
  393. package/build/types/types.d.ts.map +1 -1
  394. package/build/types/utils/addOriginToSpan.d.ts +5 -0
  395. package/build/types/utils/addOriginToSpan.d.ts.map +1 -0
  396. package/build/types/utils/baggage.d.ts +6 -0
  397. package/build/types/utils/baggage.d.ts.map +1 -0
  398. package/build/types/utils/commonjs.d.ts +3 -0
  399. package/build/types/utils/commonjs.d.ts.map +1 -0
  400. package/build/types/utils/createMissingInstrumentationContext.d.ts +3 -0
  401. package/build/types/utils/createMissingInstrumentationContext.d.ts.map +1 -0
  402. package/build/types/utils/debug.d.ts +5 -0
  403. package/build/types/utils/debug.d.ts.map +1 -0
  404. package/build/types/utils/ensureIsWrapped.d.ts +5 -0
  405. package/build/types/utils/ensureIsWrapped.d.ts.map +1 -0
  406. package/build/types/utils/entry-point.d.ts +24 -0
  407. package/build/types/utils/entry-point.d.ts.map +1 -0
  408. package/build/types/utils/envToBool.d.ts +13 -0
  409. package/build/types/utils/envToBool.d.ts.map +1 -0
  410. package/build/types/utils/errorhandling.d.ts +5 -0
  411. package/build/types/utils/errorhandling.d.ts.map +1 -0
  412. package/build/types/utils/getRequestUrl.d.ts +5 -0
  413. package/build/types/utils/getRequestUrl.d.ts.map +1 -0
  414. package/build/types/utils/module.d.ts +3 -0
  415. package/build/types/utils/module.d.ts.map +1 -0
  416. package/build/types/utils/prepareEvent.d.ts +17 -0
  417. package/build/types/utils/prepareEvent.d.ts.map +1 -0
  418. package/build/types-ts3.8/cron/common.d.ts +5 -0
  419. package/build/types-ts3.8/cron/cron.d.ts +43 -0
  420. package/build/types-ts3.8/cron/index.d.ts +10 -0
  421. package/build/types-ts3.8/cron/node-cron.d.ts +27 -0
  422. package/build/types-ts3.8/cron/node-schedule.d.ts +19 -0
  423. package/build/types-ts3.8/index.d.ts +21 -2
  424. package/build/types-ts3.8/integrations/anr/common.d.ts +52 -0
  425. package/build/types-ts3.8/integrations/anr/index.d.ts +13 -0
  426. package/build/types-ts3.8/integrations/anr/worker.d.ts +2 -0
  427. package/build/types-ts3.8/integrations/childProcess.d.ts +20 -0
  428. package/build/types-ts3.8/integrations/context.d.ts +30 -0
  429. package/build/types-ts3.8/integrations/contextlines.d.ts +31 -0
  430. package/build/types-ts3.8/integrations/http/SentryHttpInstrumentation.d.ts +133 -0
  431. package/build/types-ts3.8/integrations/http/index.d.ts +1 -1
  432. package/build/types-ts3.8/integrations/local-variables/common.d.ts +66 -0
  433. package/build/types-ts3.8/integrations/local-variables/index.d.ts +4 -0
  434. package/build/types-ts3.8/integrations/local-variables/local-variables-async.d.ts +7 -0
  435. package/build/types-ts3.8/integrations/local-variables/local-variables-sync.d.ts +34 -0
  436. package/build/types-ts3.8/integrations/local-variables/worker.d.ts +2 -0
  437. package/build/types-ts3.8/integrations/modules.d.ts +17 -0
  438. package/build/types-ts3.8/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts +56 -0
  439. package/build/types-ts3.8/integrations/onuncaughtexception.d.ts +31 -0
  440. package/build/types-ts3.8/integrations/onunhandledrejection.d.ts +23 -0
  441. package/build/types-ts3.8/integrations/processSession.d.ts +5 -0
  442. package/build/types-ts3.8/integrations/spotlight.d.ts +18 -0
  443. package/build/types-ts3.8/integrations/winston.d.ts +44 -0
  444. package/build/types-ts3.8/logs/capture.d.ts +18 -0
  445. package/build/types-ts3.8/logs/exports.d.ts +150 -0
  446. package/build/types-ts3.8/nodeVersion.d.ts +8 -0
  447. package/build/types-ts3.8/otel/contextManager.d.ts +10 -0
  448. package/build/types-ts3.8/otel/instrument.d.ts +23 -0
  449. package/build/types-ts3.8/proxy/base.d.ts +60 -0
  450. package/build/types-ts3.8/proxy/helpers.d.ts +38 -0
  451. package/build/types-ts3.8/proxy/index.d.ts +74 -0
  452. package/build/types-ts3.8/proxy/parse-proxy-response.d.ts +40 -0
  453. package/build/types-ts3.8/sdk/api.d.ts +8 -0
  454. package/build/types-ts3.8/sdk/client.d.ts +32 -0
  455. package/build/types-ts3.8/sdk/index.d.ts +6 -2
  456. package/build/types-ts3.8/sdk/initOtel.d.ts +1 -1
  457. package/build/types-ts3.8/sdk/scope.d.ts +7 -0
  458. package/build/types-ts3.8/transports/http-module.d.ts +28 -0
  459. package/build/types-ts3.8/transports/http.d.ts +20 -0
  460. package/build/types-ts3.8/transports/index.d.ts +3 -0
  461. package/build/types-ts3.8/types.d.ts +1 -1
  462. package/build/types-ts3.8/utils/addOriginToSpan.d.ts +5 -0
  463. package/build/types-ts3.8/utils/baggage.d.ts +6 -0
  464. package/build/types-ts3.8/utils/commonjs.d.ts +3 -0
  465. package/build/types-ts3.8/utils/createMissingInstrumentationContext.d.ts +3 -0
  466. package/build/types-ts3.8/utils/debug.d.ts +5 -0
  467. package/build/types-ts3.8/utils/ensureIsWrapped.d.ts +5 -0
  468. package/build/types-ts3.8/utils/entry-point.d.ts +24 -0
  469. package/build/types-ts3.8/utils/envToBool.d.ts +13 -0
  470. package/build/types-ts3.8/utils/errorhandling.d.ts +5 -0
  471. package/build/types-ts3.8/utils/getRequestUrl.d.ts +5 -0
  472. package/build/types-ts3.8/utils/module.d.ts +3 -0
  473. package/build/types-ts3.8/utils/prepareEvent.d.ts +17 -0
  474. package/package.json +3 -4
@@ -2,16 +2,17 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const instrumentationMysql2 = require('@opentelemetry/instrumentation-mysql2');
4
4
  const core = require('@sentry/core');
5
- const nodeCore = require('@sentry/node-core');
5
+ const instrument = require('../../otel/instrument.js');
6
+ const addOriginToSpan = require('../../utils/addOriginToSpan.js');
6
7
 
7
8
  const INTEGRATION_NAME = 'Mysql2';
8
9
 
9
- const instrumentMysql2 = nodeCore.generateInstrumentOnce(
10
+ const instrumentMysql2 = instrument.generateInstrumentOnce(
10
11
  INTEGRATION_NAME,
11
12
  () =>
12
13
  new instrumentationMysql2.MySQL2Instrumentation({
13
14
  responseHook(span) {
14
- nodeCore.addOriginToSpan(span, 'auto.db.otel.mysql2');
15
+ addOriginToSpan.addOriginToSpan(span, 'auto.db.otel.mysql2');
15
16
  },
16
17
  }),
17
18
  );
@@ -1 +1 @@
1
- {"version":3,"file":"mysql2.js","sources":["../../../../src/integrations/tracing/mysql2.ts"],"sourcesContent":["import { MySQL2Instrumentation } from '@opentelemetry/instrumentation-mysql2';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Mysql2';\n\nexport const instrumentMysql2 = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n new MySQL2Instrumentation({\n responseHook(span) {\n addOriginToSpan(span, 'auto.db.otel.mysql2');\n },\n }),\n);\n\nconst _mysql2Integration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentMysql2();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library.\n *\n * For more information, see the [`mysql2Integration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql2/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.mysqlIntegration()],\n * });\n * ```\n */\nexport const mysql2Integration = defineIntegration(_mysql2Integration);\n"],"names":["generateInstrumentOnce","MySQL2Instrumentation","addOriginToSpan","defineIntegration"],"mappings":";;;;;;AAKA,MAAM,gBAAA,GAAmB,QAAQ;;AAE1B,MAAM,gBAAiB,GAAEA,+BAAsB;AACtD,EAAE,gBAAgB;AAClB,EAAE;AACF,IAAI,IAAIC,2CAAqB,CAAC;AAC9B,MAAM,YAAY,CAAC,IAAI,EAAE;AACzB,QAAQC,wBAAe,CAAC,IAAI,EAAE,qBAAqB,CAAC;AACpD,OAAO;AACP,KAAK,CAAC;AACN;;AAEA,MAAM,kBAAmB,IAAG,MAAM;AAClC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,gBAAgB,EAAE;AACxB,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,iBAAkB,GAAEC,sBAAiB,CAAC,kBAAkB;;;;;"}
1
+ {"version":3,"file":"mysql2.js","sources":["../../../../src/integrations/tracing/mysql2.ts"],"sourcesContent":["import { MySQL2Instrumentation } from '@opentelemetry/instrumentation-mysql2';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\n\nconst INTEGRATION_NAME = 'Mysql2';\n\nexport const instrumentMysql2 = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n new MySQL2Instrumentation({\n responseHook(span) {\n addOriginToSpan(span, 'auto.db.otel.mysql2');\n },\n }),\n);\n\nconst _mysql2Integration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentMysql2();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library.\n *\n * For more information, see the [`mysql2Integration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql2/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.mysqlIntegration()],\n * });\n * ```\n */\nexport const mysql2Integration = defineIntegration(_mysql2Integration);\n"],"names":["generateInstrumentOnce","MySQL2Instrumentation","addOriginToSpan","defineIntegration"],"mappings":";;;;;;;AAMA,MAAM,gBAAA,GAAmB,QAAQ;;AAE1B,MAAM,gBAAiB,GAAEA,iCAAsB;AACtD,EAAE,gBAAgB;AAClB,EAAE;AACF,IAAI,IAAIC,2CAAqB,CAAC;AAC9B,MAAM,YAAY,CAAC,IAAI,EAAE;AACzB,QAAQC,+BAAe,CAAC,IAAI,EAAE,qBAAqB,CAAC;AACpD,OAAO;AACP,KAAK,CAAC;AACN;;AAEA,MAAM,kBAAmB,IAAG,MAAM;AAClC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,gBAAgB,EAAE;AACxB,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,iBAAkB,GAAEC,sBAAiB,CAAC,kBAAkB;;;;;"}
@@ -2,17 +2,18 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const instrumentationPg = require('@opentelemetry/instrumentation-pg');
4
4
  const core = require('@sentry/core');
5
- const nodeCore = require('@sentry/node-core');
5
+ const instrument = require('../../otel/instrument.js');
6
+ const addOriginToSpan = require('../../utils/addOriginToSpan.js');
6
7
 
7
8
  const INTEGRATION_NAME = 'Postgres';
8
9
 
9
- const instrumentPostgres = nodeCore.generateInstrumentOnce(
10
+ const instrumentPostgres = instrument.generateInstrumentOnce(
10
11
  INTEGRATION_NAME,
11
12
  () =>
12
13
  new instrumentationPg.PgInstrumentation({
13
14
  requireParentSpan: true,
14
15
  requestHook(span) {
15
- nodeCore.addOriginToSpan(span, 'auto.db.otel.postgres');
16
+ addOriginToSpan.addOriginToSpan(span, 'auto.db.otel.postgres');
16
17
  },
17
18
  }),
18
19
  );
@@ -1 +1 @@
1
- {"version":3,"file":"postgres.js","sources":["../../../../src/integrations/tracing/postgres.ts"],"sourcesContent":["import { PgInstrumentation } from '@opentelemetry/instrumentation-pg';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Postgres';\n\nexport const instrumentPostgres = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n new PgInstrumentation({\n requireParentSpan: true,\n requestHook(span) {\n addOriginToSpan(span, 'auto.db.otel.postgres');\n },\n }),\n);\n\nconst _postgresIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgres();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [pg](https://www.npmjs.com/package/pg) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresIntegration()],\n * });\n * ```\n */\nexport const postgresIntegration = defineIntegration(_postgresIntegration);\n"],"names":["generateInstrumentOnce","PgInstrumentation","addOriginToSpan","defineIntegration"],"mappings":";;;;;;AAKA,MAAM,gBAAA,GAAmB,UAAU;;AAE5B,MAAM,kBAAmB,GAAEA,+BAAsB;AACxD,EAAE,gBAAgB;AAClB,EAAE;AACF,IAAI,IAAIC,mCAAiB,CAAC;AAC1B,MAAM,iBAAiB,EAAE,IAAI;AAC7B,MAAM,WAAW,CAAC,IAAI,EAAE;AACxB,QAAQC,wBAAe,CAAC,IAAI,EAAE,uBAAuB,CAAC;AACtD,OAAO;AACP,KAAK,CAAC;AACN;;AAEA,MAAM,oBAAqB,IAAG,MAAM;AACpC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,kBAAkB,EAAE;AAC1B,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,mBAAoB,GAAEC,sBAAiB,CAAC,oBAAoB;;;;;"}
1
+ {"version":3,"file":"postgres.js","sources":["../../../../src/integrations/tracing/postgres.ts"],"sourcesContent":["import { PgInstrumentation } from '@opentelemetry/instrumentation-pg';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\n\nconst INTEGRATION_NAME = 'Postgres';\n\nexport const instrumentPostgres = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n new PgInstrumentation({\n requireParentSpan: true,\n requestHook(span) {\n addOriginToSpan(span, 'auto.db.otel.postgres');\n },\n }),\n);\n\nconst _postgresIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgres();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [pg](https://www.npmjs.com/package/pg) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresIntegration()],\n * });\n * ```\n */\nexport const postgresIntegration = defineIntegration(_postgresIntegration);\n"],"names":["generateInstrumentOnce","PgInstrumentation","addOriginToSpan","defineIntegration"],"mappings":";;;;;;;AAMA,MAAM,gBAAA,GAAmB,UAAU;;AAE5B,MAAM,kBAAmB,GAAEA,iCAAsB;AACxD,EAAE,gBAAgB;AAClB,EAAE;AACF,IAAI,IAAIC,mCAAiB,CAAC;AAC1B,MAAM,iBAAiB,EAAE,IAAI;AAC7B,MAAM,WAAW,CAAC,IAAI,EAAE;AACxB,QAAQC,+BAAe,CAAC,IAAI,EAAE,uBAAuB,CAAC;AACtD,OAAO;AACP,KAAK,CAAC;AACN;;AAEA,MAAM,oBAAqB,IAAG,MAAM;AACpC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,kBAAkB,EAAE;AAC1B,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,mBAAoB,GAAEC,sBAAiB,CAAC,oBAAoB;;;;;"}
@@ -4,14 +4,15 @@ const api = require('@opentelemetry/api');
4
4
  const instrumentation = require('@opentelemetry/instrumentation');
5
5
  const semanticConventions = require('@opentelemetry/semantic-conventions');
6
6
  const core = require('@sentry/core');
7
- const nodeCore = require('@sentry/node-core');
7
+ const instrument = require('../../otel/instrument.js');
8
+ const addOriginToSpan = require('../../utils/addOriginToSpan.js');
8
9
 
9
10
  // Instrumentation for https://github.com/porsager/postgres
10
11
 
11
12
  const INTEGRATION_NAME = 'PostgresJs';
12
13
  const SUPPORTED_VERSIONS = ['>=3.0.0 <4'];
13
14
 
14
- const instrumentPostgresJs = nodeCore.generateInstrumentOnce(
15
+ const instrumentPostgresJs = instrument.generateInstrumentOnce(
15
16
  INTEGRATION_NAME,
16
17
  (options) =>
17
18
  new PostgresJsInstrumentation({
@@ -153,7 +154,7 @@ class PostgresJsInstrumentation extends instrumentation.InstrumentationBase {
153
154
 
154
155
  ;
155
156
 
156
- nodeCore.addOriginToSpan(span, 'auto.db.otel.postgres');
157
+ addOriginToSpan.addOriginToSpan(span, 'auto.db.otel.postgres');
157
158
 
158
159
  const { requestHook } = this.getConfig();
159
160
 
@@ -1 +1 @@
1
- {"version":3,"file":"postgresjs.js","sources":["../../../../src/integrations/tracing/postgresjs.ts"],"sourcesContent":["// Instrumentation for https://github.com/porsager/postgres\nimport { context, trace } from '@opentelemetry/api';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n ATTR_DB_NAMESPACE,\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_RESPONSE_STATUS_CODE,\n ATTR_DB_SYSTEM_NAME,\n ATTR_ERROR_TYPE,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n defineIntegration,\n getCurrentScope,\n logger,\n SDK_VERSION,\n SPAN_STATUS_ERROR,\n startSpanManual,\n} from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'PostgresJs';\nconst SUPPORTED_VERSIONS = ['>=3.0.0 <4'];\n\ntype PostgresConnectionContext = {\n ATTR_DB_NAMESPACE?: string; // Database name\n ATTR_SERVER_ADDRESS?: string; // Hostname or IP address of the database server\n ATTR_SERVER_PORT?: string; // Port number of the database server\n};\n\ntype PostgresJsInstrumentationConfig = InstrumentationConfig & {\n /**\n * Whether to require a parent span for the instrumentation.\n * If set to true, the instrumentation will only create spans if there is a parent span\n * available in the current scope.\n * @default true\n */\n requireParentSpan?: boolean;\n /**\n * Hook to modify the span before it is started.\n * This can be used to set additional attributes or modify the span in any way.\n */\n requestHook?: (span: Span, sanitizedSqlQuery: string, postgresConnectionContext?: PostgresConnectionContext) => void;\n};\n\nexport const instrumentPostgresJs = generateInstrumentOnce(\n INTEGRATION_NAME,\n (options?: PostgresJsInstrumentationConfig) =>\n new PostgresJsInstrumentation({\n requireParentSpan: options?.requireParentSpan ?? true,\n requestHook: options?.requestHook,\n }),\n);\n\n/**\n * Instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n * This instrumentation captures postgresjs queries and their attributes,\n */\nexport class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsInstrumentationConfig> {\n public constructor(config: PostgresJsInstrumentationConfig) {\n super('sentry-postgres-js', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation.\n */\n public init(): InstrumentationNodeModuleDefinition[] {\n const instrumentationModule = new InstrumentationNodeModuleDefinition('postgres', SUPPORTED_VERSIONS);\n\n ['src', 'cf/src', 'cjs/src'].forEach(path => {\n instrumentationModule.files.push(\n new InstrumentationNodeModuleFile(\n `postgres/${path}/connection.js`,\n ['*'],\n this._patchConnection.bind(this),\n this._unwrap.bind(this),\n ),\n );\n\n instrumentationModule.files.push(\n new InstrumentationNodeModuleFile(\n `postgres/${path}/query.js`,\n SUPPORTED_VERSIONS,\n this._patchQuery.bind(this),\n this._unwrap.bind(this),\n ),\n );\n });\n\n return [instrumentationModule];\n }\n\n /**\n * Determines whether a span should be created based on the current context.\n * If `requireParentSpan` is set to true in the configuration, a span will\n * only be created if there is a parent span available.\n */\n private _shouldCreateSpans(): boolean {\n const config = this.getConfig();\n const hasParentSpan = trace.getSpan(context.active()) !== undefined;\n return hasParentSpan || !config.requireParentSpan;\n }\n\n /**\n * Patches the reject method of the Query class to set the span status and end it\n */\n private _patchReject(rejectTarget: any, span: Span): any {\n return new Proxy(rejectTarget, {\n apply: (\n rejectTarget,\n rejectThisArg,\n rejectArgs: {\n message?: string;\n code?: string;\n name?: string;\n }[],\n ) => {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n // This message is the error message from the rejectArgs, when available\n // e.g \"relation 'User' does not exist\"\n message: rejectArgs?.[0]?.message || 'unknown_error',\n });\n\n const result = Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);\n\n // This status code is PG error code, e.g. '42P01' for \"relation does not exist\"\n // https://www.postgresql.org/docs/current/errcodes-appendix.html\n span.setAttribute(ATTR_DB_RESPONSE_STATUS_CODE, rejectArgs?.[0]?.code || 'Unknown error');\n // This is the error type, e.g. 'PostgresError' for a Postgres error\n span.setAttribute(ATTR_ERROR_TYPE, rejectArgs?.[0]?.name || 'Unknown error');\n\n span.end();\n return result;\n },\n });\n }\n\n /**\n * Patches the resolve method of the Query class to end the span when the query is resolved.\n */\n private _patchResolve(resolveTarget: any, span: Span): any {\n return new Proxy(resolveTarget, {\n apply: (resolveTarget, resolveThisArg, resolveArgs: [{ command?: string }]) => {\n const result = Reflect.apply(resolveTarget, resolveThisArg, resolveArgs);\n const sqlCommand = resolveArgs?.[0]?.command;\n\n if (sqlCommand) {\n // SQL command is only available when the query is resolved successfully\n span.setAttribute(ATTR_DB_OPERATION_NAME, sqlCommand);\n }\n span.end();\n return result;\n },\n });\n }\n\n /**\n * Patches the Query class to instrument the handle method.\n */\n private _patchQuery(moduleExports: {\n Query: {\n prototype: {\n handle: any;\n };\n };\n }): any {\n moduleExports.Query.prototype.handle = new Proxy(moduleExports.Query.prototype.handle, {\n apply: async (\n handleTarget,\n handleThisArg: {\n resolve: any;\n reject: any;\n strings?: string[];\n },\n handleArgs,\n ) => {\n if (!this._shouldCreateSpans()) {\n // If we don't need to create spans, just call the original method\n return Reflect.apply(handleTarget, handleThisArg, handleArgs);\n }\n\n const sanitizedSqlQuery = this._sanitizeSqlQuery(handleThisArg.strings?.[0]);\n\n return startSpanManual(\n {\n name: sanitizedSqlQuery || 'postgresjs.query',\n op: 'db',\n },\n (span: Span) => {\n const scope = getCurrentScope();\n const postgresConnectionContext = scope.getScopeData().contexts['postgresjsConnection'] as\n | PostgresConnectionContext\n | undefined;\n\n addOriginToSpan(span, 'auto.db.otel.postgres');\n\n const { requestHook } = this.getConfig();\n\n if (requestHook) {\n safeExecuteInTheMiddle(\n () => requestHook(span, sanitizedSqlQuery, postgresConnectionContext),\n error => {\n if (error) {\n logger.error(`Error in requestHook for ${INTEGRATION_NAME} integration:`, error);\n }\n },\n );\n }\n\n // ATTR_DB_NAMESPACE is used to indicate the database name and the schema name\n // It's only the database name as we don't have the schema information\n const databaseName = postgresConnectionContext?.ATTR_DB_NAMESPACE || '<unknown database>';\n const databaseHost = postgresConnectionContext?.ATTR_SERVER_ADDRESS || '<unknown host>';\n const databasePort = postgresConnectionContext?.ATTR_SERVER_PORT || '<unknown port>';\n\n span.setAttribute(ATTR_DB_SYSTEM_NAME, 'postgres');\n span.setAttribute(ATTR_DB_NAMESPACE, databaseName);\n span.setAttribute(ATTR_SERVER_ADDRESS, databaseHost);\n span.setAttribute(ATTR_SERVER_PORT, databasePort);\n span.setAttribute(ATTR_DB_QUERY_TEXT, sanitizedSqlQuery);\n\n handleThisArg.resolve = this._patchResolve(handleThisArg.resolve, span);\n handleThisArg.reject = this._patchReject(handleThisArg.reject, span);\n\n try {\n return Reflect.apply(handleTarget, handleThisArg, handleArgs);\n } catch (error) {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n });\n span.end();\n throw error; // Re-throw the error to propagate it\n }\n },\n );\n },\n });\n\n return moduleExports;\n }\n\n /**\n * Patches the Connection class to set the database, host, and port attributes\n * when a new connection is created.\n */\n private _patchConnection(Connection: any): any {\n return new Proxy(Connection, {\n apply: (connectionTarget, thisArg, connectionArgs: { database: string; host: string[]; port: number[] }[]) => {\n const databaseName = connectionArgs[0]?.database || '<unknown database>';\n const databaseHost = connectionArgs[0]?.host?.[0] || '<unknown host>';\n const databasePort = connectionArgs[0]?.port?.[0] || '<unknown port>';\n\n const scope = getCurrentScope();\n scope.setContext('postgresjsConnection', {\n ATTR_DB_NAMESPACE: databaseName,\n ATTR_SERVER_ADDRESS: databaseHost,\n ATTR_SERVER_PORT: databasePort,\n });\n\n return Reflect.apply(connectionTarget, thisArg, connectionArgs);\n },\n });\n }\n\n /**\n * Sanitize SQL query as per the OTEL semantic conventions\n * https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext\n */\n private _sanitizeSqlQuery(sqlQuery: string | undefined): string {\n if (!sqlQuery) {\n return 'Unknown SQL Query';\n }\n\n return (\n sqlQuery\n .replace(/\\s+/g, ' ')\n .trim() // Remove extra spaces including newlines and trim\n .substring(0, 1024) // Truncate to 1024 characters\n .replace(/--.*?(\\r?\\n|$)/g, '') // Single line comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Multi-line comments\n .replace(/;\\s*$/, '') // Remove trailing semicolons\n .replace(/\\b\\d+\\b/g, '?') // Replace standalone numbers\n // Collapse whitespace to a single space\n .replace(/\\s+/g, ' ')\n // Collapse IN and in clauses\n // eg. IN (?, ?, ?, ?) to IN (?)\n .replace(/\\bIN\\b\\s*\\(\\s*\\?(?:\\s*,\\s*\\?)*\\s*\\)/g, 'IN (?)')\n );\n }\n}\n\nconst _postgresJsIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgresJs();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresJsIntegration()],\n * });\n * ```\n */\n\nexport const postgresJsIntegration = defineIntegration(_postgresJsIntegration);\n"],"names":["generateInstrumentOnce","InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","InstrumentationNodeModuleFile","trace","context","SPAN_STATUS_ERROR","ATTR_DB_RESPONSE_STATUS_CODE","ATTR_ERROR_TYPE","ATTR_DB_OPERATION_NAME","startSpanManual","getCurrentScope","addOriginToSpan","safeExecuteInTheMiddle","logger","ATTR_DB_SYSTEM_NAME","ATTR_DB_NAMESPACE","ATTR_SERVER_ADDRESS","ATTR_SERVER_PORT","ATTR_DB_QUERY_TEXT","defineIntegration"],"mappings":";;;;;;;;AAAA;;AA8BA,MAAM,gBAAA,GAAmB,YAAY;AACrC,MAAM,kBAAmB,GAAE,CAAC,YAAY,CAAC;;AAuBlC,MAAM,oBAAqB,GAAEA,+BAAsB;AAC1D,EAAE,gBAAgB;AAClB,EAAE,CAAC,OAAO;AACV,IAAI,IAAI,yBAAyB,CAAC;AAClC,MAAM,iBAAiB,EAAE,OAAO,EAAE,iBAAA,IAAqB,IAAI;AAC3D,MAAM,WAA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AAE,EAAE,CAAA;AACtC,SAAS,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAA;AACxC,SAAS,OAAO,CAAC,OAAO,EAAE,EAAE,CAAA;AAC5B,SAAS,OAAO,CAAC,UAAU,EAAE,GAAG,CAAA;AAChC;AACA,SAAS,OAAO,CAAC,MAAM,EAAE,GAAG;AAC5B;AACA;AACA,SAAS,OAAO,CAAC,sCAAsC,EAAE,QAAQ;AACjE;AACA;AACA;;AAEA,MAAM,sBAAuB,IAAG,MAAM;AACtC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,oBAAoB,EAAE;AAC5B,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;MAEa,qBAAsB,GAAES,sBAAiB,CAAC,sBAAsB;;;;;;"}
1
+ {"version":3,"file":"postgresjs.js","sources":["../../../../src/integrations/tracing/postgresjs.ts"],"sourcesContent":["// Instrumentation for https://github.com/porsager/postgres\nimport { context, trace } from '@opentelemetry/api';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n ATTR_DB_NAMESPACE,\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_RESPONSE_STATUS_CODE,\n ATTR_DB_SYSTEM_NAME,\n ATTR_ERROR_TYPE,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n defineIntegration,\n getCurrentScope,\n logger,\n SDK_VERSION,\n SPAN_STATUS_ERROR,\n startSpanManual,\n} from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\n\nconst INTEGRATION_NAME = 'PostgresJs';\nconst SUPPORTED_VERSIONS = ['>=3.0.0 <4'];\n\ntype PostgresConnectionContext = {\n ATTR_DB_NAMESPACE?: string; // Database name\n ATTR_SERVER_ADDRESS?: string; // Hostname or IP address of the database server\n ATTR_SERVER_PORT?: string; // Port number of the database server\n};\n\ntype PostgresJsInstrumentationConfig = InstrumentationConfig & {\n /**\n * Whether to require a parent span for the instrumentation.\n * If set to true, the instrumentation will only create spans if there is a parent span\n * available in the current scope.\n * @default true\n */\n requireParentSpan?: boolean;\n /**\n * Hook to modify the span before it is started.\n * This can be used to set additional attributes or modify the span in any way.\n */\n requestHook?: (span: Span, sanitizedSqlQuery: string, postgresConnectionContext?: PostgresConnectionContext) => void;\n};\n\nexport const instrumentPostgresJs = generateInstrumentOnce(\n INTEGRATION_NAME,\n (options?: PostgresJsInstrumentationConfig) =>\n new PostgresJsInstrumentation({\n requireParentSpan: options?.requireParentSpan ?? true,\n requestHook: options?.requestHook,\n }),\n);\n\n/**\n * Instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n * This instrumentation captures postgresjs queries and their attributes,\n */\nexport class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsInstrumentationConfig> {\n public constructor(config: PostgresJsInstrumentationConfig) {\n super('sentry-postgres-js', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation.\n */\n public init(): InstrumentationNodeModuleDefinition[] {\n const instrumentationModule = new InstrumentationNodeModuleDefinition('postgres', SUPPORTED_VERSIONS);\n\n ['src', 'cf/src', 'cjs/src'].forEach(path => {\n instrumentationModule.files.push(\n new InstrumentationNodeModuleFile(\n `postgres/${path}/connection.js`,\n ['*'],\n this._patchConnection.bind(this),\n this._unwrap.bind(this),\n ),\n );\n\n instrumentationModule.files.push(\n new InstrumentationNodeModuleFile(\n `postgres/${path}/query.js`,\n SUPPORTED_VERSIONS,\n this._patchQuery.bind(this),\n this._unwrap.bind(this),\n ),\n );\n });\n\n return [instrumentationModule];\n }\n\n /**\n * Determines whether a span should be created based on the current context.\n * If `requireParentSpan` is set to true in the configuration, a span will\n * only be created if there is a parent span available.\n */\n private _shouldCreateSpans(): boolean {\n const config = this.getConfig();\n const hasParentSpan = trace.getSpan(context.active()) !== undefined;\n return hasParentSpan || !config.requireParentSpan;\n }\n\n /**\n * Patches the reject method of the Query class to set the span status and end it\n */\n private _patchReject(rejectTarget: any, span: Span): any {\n return new Proxy(rejectTarget, {\n apply: (\n rejectTarget,\n rejectThisArg,\n rejectArgs: {\n message?: string;\n code?: string;\n name?: string;\n }[],\n ) => {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n // This message is the error message from the rejectArgs, when available\n // e.g \"relation 'User' does not exist\"\n message: rejectArgs?.[0]?.message || 'unknown_error',\n });\n\n const result = Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);\n\n // This status code is PG error code, e.g. '42P01' for \"relation does not exist\"\n // https://www.postgresql.org/docs/current/errcodes-appendix.html\n span.setAttribute(ATTR_DB_RESPONSE_STATUS_CODE, rejectArgs?.[0]?.code || 'Unknown error');\n // This is the error type, e.g. 'PostgresError' for a Postgres error\n span.setAttribute(ATTR_ERROR_TYPE, rejectArgs?.[0]?.name || 'Unknown error');\n\n span.end();\n return result;\n },\n });\n }\n\n /**\n * Patches the resolve method of the Query class to end the span when the query is resolved.\n */\n private _patchResolve(resolveTarget: any, span: Span): any {\n return new Proxy(resolveTarget, {\n apply: (resolveTarget, resolveThisArg, resolveArgs: [{ command?: string }]) => {\n const result = Reflect.apply(resolveTarget, resolveThisArg, resolveArgs);\n const sqlCommand = resolveArgs?.[0]?.command;\n\n if (sqlCommand) {\n // SQL command is only available when the query is resolved successfully\n span.setAttribute(ATTR_DB_OPERATION_NAME, sqlCommand);\n }\n span.end();\n return result;\n },\n });\n }\n\n /**\n * Patches the Query class to instrument the handle method.\n */\n private _patchQuery(moduleExports: {\n Query: {\n prototype: {\n handle: any;\n };\n };\n }): any {\n moduleExports.Query.prototype.handle = new Proxy(moduleExports.Query.prototype.handle, {\n apply: async (\n handleTarget,\n handleThisArg: {\n resolve: any;\n reject: any;\n strings?: string[];\n },\n handleArgs,\n ) => {\n if (!this._shouldCreateSpans()) {\n // If we don't need to create spans, just call the original method\n return Reflect.apply(handleTarget, handleThisArg, handleArgs);\n }\n\n const sanitizedSqlQuery = this._sanitizeSqlQuery(handleThisArg.strings?.[0]);\n\n return startSpanManual(\n {\n name: sanitizedSqlQuery || 'postgresjs.query',\n op: 'db',\n },\n (span: Span) => {\n const scope = getCurrentScope();\n const postgresConnectionContext = scope.getScopeData().contexts['postgresjsConnection'] as\n | PostgresConnectionContext\n | undefined;\n\n addOriginToSpan(span, 'auto.db.otel.postgres');\n\n const { requestHook } = this.getConfig();\n\n if (requestHook) {\n safeExecuteInTheMiddle(\n () => requestHook(span, sanitizedSqlQuery, postgresConnectionContext),\n error => {\n if (error) {\n logger.error(`Error in requestHook for ${INTEGRATION_NAME} integration:`, error);\n }\n },\n );\n }\n\n // ATTR_DB_NAMESPACE is used to indicate the database name and the schema name\n // It's only the database name as we don't have the schema information\n const databaseName = postgresConnectionContext?.ATTR_DB_NAMESPACE || '<unknown database>';\n const databaseHost = postgresConnectionContext?.ATTR_SERVER_ADDRESS || '<unknown host>';\n const databasePort = postgresConnectionContext?.ATTR_SERVER_PORT || '<unknown port>';\n\n span.setAttribute(ATTR_DB_SYSTEM_NAME, 'postgres');\n span.setAttribute(ATTR_DB_NAMESPACE, databaseName);\n span.setAttribute(ATTR_SERVER_ADDRESS, databaseHost);\n span.setAttribute(ATTR_SERVER_PORT, databasePort);\n span.setAttribute(ATTR_DB_QUERY_TEXT, sanitizedSqlQuery);\n\n handleThisArg.resolve = this._patchResolve(handleThisArg.resolve, span);\n handleThisArg.reject = this._patchReject(handleThisArg.reject, span);\n\n try {\n return Reflect.apply(handleTarget, handleThisArg, handleArgs);\n } catch (error) {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n });\n span.end();\n throw error; // Re-throw the error to propagate it\n }\n },\n );\n },\n });\n\n return moduleExports;\n }\n\n /**\n * Patches the Connection class to set the database, host, and port attributes\n * when a new connection is created.\n */\n private _patchConnection(Connection: any): any {\n return new Proxy(Connection, {\n apply: (connectionTarget, thisArg, connectionArgs: { database: string; host: string[]; port: number[] }[]) => {\n const databaseName = connectionArgs[0]?.database || '<unknown database>';\n const databaseHost = connectionArgs[0]?.host?.[0] || '<unknown host>';\n const databasePort = connectionArgs[0]?.port?.[0] || '<unknown port>';\n\n const scope = getCurrentScope();\n scope.setContext('postgresjsConnection', {\n ATTR_DB_NAMESPACE: databaseName,\n ATTR_SERVER_ADDRESS: databaseHost,\n ATTR_SERVER_PORT: databasePort,\n });\n\n return Reflect.apply(connectionTarget, thisArg, connectionArgs);\n },\n });\n }\n\n /**\n * Sanitize SQL query as per the OTEL semantic conventions\n * https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext\n */\n private _sanitizeSqlQuery(sqlQuery: string | undefined): string {\n if (!sqlQuery) {\n return 'Unknown SQL Query';\n }\n\n return (\n sqlQuery\n .replace(/\\s+/g, ' ')\n .trim() // Remove extra spaces including newlines and trim\n .substring(0, 1024) // Truncate to 1024 characters\n .replace(/--.*?(\\r?\\n|$)/g, '') // Single line comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Multi-line comments\n .replace(/;\\s*$/, '') // Remove trailing semicolons\n .replace(/\\b\\d+\\b/g, '?') // Replace standalone numbers\n // Collapse whitespace to a single space\n .replace(/\\s+/g, ' ')\n // Collapse IN and in clauses\n // eg. IN (?, ?, ?, ?) to IN (?)\n .replace(/\\bIN\\b\\s*\\(\\s*\\?(?:\\s*,\\s*\\?)*\\s*\\)/g, 'IN (?)')\n );\n }\n}\n\nconst _postgresJsIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgresJs();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresJsIntegration()],\n * });\n * ```\n */\n\nexport const postgresJsIntegration = defineIntegration(_postgresJsIntegration);\n"],"names":["generateInstrumentOnce","InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","InstrumentationNodeModuleFile","trace","context","SPAN_STATUS_ERROR","ATTR_DB_RESPONSE_STATUS_CODE","ATTR_ERROR_TYPE","ATTR_DB_OPERATION_NAME","startSpanManual","getCurrentScope","addOriginToSpan","safeExecuteInTheMiddle","logger","ATTR_DB_SYSTEM_NAME","ATTR_DB_NAMESPACE","ATTR_SERVER_ADDRESS","ATTR_SERVER_PORT","ATTR_DB_QUERY_TEXT","defineIntegration"],"mappings":";;;;;;;;;AAAA;;AA+BA,MAAM,gBAAA,GAAmB,YAAY;AACrC,MAAM,kBAAmB,GAAE,CAAC,YAAY,CAAC;;AAuBlC,MAAM,oBAAqB,GAAEA,iCAAsB;AAC1D,EAAE,gBAAgB;AAClB,EAAE,CAAC,OAAO;AACV,IAAI,IAAI,yBAAyB,CAAC;AAClC,MAAM,iBAAiB,EAAE,OAAO,EAAE,iBAAA,IAAqB,IAAI;AAC3D,MAAM,WAAW,EAAE,OAAO,EAAE,WAAW;AACvC,KAAK,CAAC;AACN;;AAEA;AACA;AACA;AACA;AACO,MAAM,yBAAA,SAAkCC,mCAAmB,CAAkC;AACpG,GAAS,WAAW,CAAC,MAAM,EAAmC;AAC9D,IAAI,KAAK,CAAC,oBAAoB,EAAEC,gBAAW,EAAE,MAAM,CAAC;AACpD;;AAEA;AACA;AACA;AACA,GAAS,IAAI,GAA0C;AACvD,IAAI,MAAM,wBAAwB,IAAIC,mDAAmC,CAAC,UAAU,EAAE,kBAAkB,CAAC;;AAEzG,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IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,oBAAoB,EAAE;AAC5B,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;MAEa,qBAAsB,GAAES,sBAAiB,CAAC,sBAAsB;;;;;;"}
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const instrumentation = require('@prisma/instrumentation');
4
4
  const core = require('@sentry/core');
5
- const nodeCore = require('@sentry/node-core');
5
+ const instrument = require('../../otel/instrument.js');
6
6
 
7
7
  const INTEGRATION_NAME = 'Prisma';
8
8
 
@@ -53,7 +53,7 @@ class SentryPrismaInteropInstrumentation extends instrumentation.PrismaInstrumen
53
53
  }
54
54
  }
55
55
 
56
- const instrumentPrisma = nodeCore.generateInstrumentOnce(
56
+ const instrumentPrisma = instrument.generateInstrumentOnce(
57
57
  INTEGRATION_NAME,
58
58
  options => {
59
59
  // Use a passed instrumentation instance to support older Prisma versions
@@ -1 +1 @@
1
- {"version":3,"file":"prisma.js","sources":["../../../../src/integrations/tracing/prisma.ts"],"sourcesContent":["import type { Instrumentation } from '@opentelemetry/instrumentation';\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\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\nclass SentryPrismaInteropInstrumentation extends PrismaInstrumentation {\n public constructor() {\n super();\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 // We still won't fully emit all the spans, but this could potentially be implemented in the future.\n const prismaTracingHelper = getPrismaTracingHelper();\n\n let emittedWarning = false;\n\n if (isPrismaV6TracingHelper(prismaTracingHelper)) {\n (prismaTracingHelper as CompatibilityLayerTraceHelper).createEngineSpan = () => {\n consoleSandbox(() => {\n if (!emittedWarning) {\n emittedWarning = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] The Sentry SDK supports tracing with Prisma version 5 only with limited capabilities. For full tracing capabilities pass `prismaInstrumentation` for version 5 to the Sentry `prismaIntegration`. Read more: https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/',\n );\n }\n });\n };\n }\n }\n}\n\nexport const instrumentPrisma = generateInstrumentOnce<{ prismaInstrumentation?: Instrumentation }>(\n INTEGRATION_NAME,\n options => {\n // Use a passed instrumentation instance to support older Prisma versions\n if (options?.prismaInstrumentation) {\n return options.prismaInstrumentation;\n }\n\n return new SentryPrismaInteropInstrumentation();\n },\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(\n ({\n prismaInstrumentation,\n }: {\n /**\n * Overrides the instrumentation used by the Sentry SDK with the passed in instrumentation instance.\n *\n * NOTE: By default, the Sentry SDK uses the Prisma v6 instrumentation. Use this option if you need performance instrumentation different Prisma versions.\n *\n * For more information refer to the documentation of `prismaIntegration()` or see https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/\n */\n prismaInstrumentation?: Instrumentation;\n } = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPrisma({ prismaInstrumentation });\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);\n"],"names":["PrismaInstrumentation","consoleSandbox","generateInstrumentOnce","defineIntegration","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;AAOA,MAAM,gBAAA,GAAmB,QAAQ;;AAIjC,SAAS,uBAAuB,CAAC,MAAM,EAA4C;AACnF,EAAE,OAAO,CAAC,CAAC,MAAA,IAAU,OAAO,MAAO,KAAI,QAAS,IAAG,qBAAsB,IAAG,MAAM;AAClF;;AAEA,SAAS,sBAAsB,GAAwB;AACvD,EAAE,MAAM,2BAA4B,GAAE,CAAC,UAAW,GAA4B,sBAAsB;AACpG,EAAE,MAAM,mBAAoB;AAC5B,IAAI,2BAA4B;AAChC,IAAI,OAAO,2BAA4B,KAAI,QAAS;AACpD,IAAI,YAAY;AAChB,QAAQ,2BAA2B,CAAC;AACpC,QAAQ,SAAS;;AAEjB,EAAE,OAAO,mBAAmB;AAC5B;;AAEA,MAAM,kCAAA,SAA2CA,qCAAsB,CAAA;AACvE,GAAS,WAAW,GAAG;AACvB,IAAI,KAAK,EAAE;AACX;;AAEA,GAAS,MAAM,GAAS;AACxB,IAAI,KAAK,CAAC,MAAM,EAAE;;AAElB;AACA;AACA;AACA,IAAI,MAAM,mBAAA,GAAsB,sBAAsB,EAAE;;AAExD,IAAI,IAAI,cAAe,GAAE,KAAK;;AAE9B,IAAI,IAAI,uBAAuB,CAAC,mBAAmB,CAAC,EAAE;AACtD,MAAM,CAAC,sBAAsD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ACA,UAAU,IAAI,QAAQ,CAAC,gBAAgB,wBAAA,IAA4B,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;AACnG,YAAY,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAA,EAAY;AACrE;;AAEA;AACA;AACA,UAAU,IAAI,QAAQ,CAAC,gBAAgB,wBAAA,IAA4B,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;AAChG,YAAY,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC;AACpD;AACA,SAAS,CAAC;AACV,OAAO;AACP,KAAK;AACL,GAAG;AACH;;;;;"}
1
+ {"version":3,"file":"prisma.js","sources":["../../../../src/integrations/tracing/prisma.ts"],"sourcesContent":["import type { Instrumentation } from '@opentelemetry/instrumentation';\nimport { PrismaInstrumentation } from '@prisma/instrumentation';\nimport { consoleSandbox, defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\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\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\nclass SentryPrismaInteropInstrumentation extends PrismaInstrumentation {\n public constructor() {\n super();\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 // We still won't fully emit all the spans, but this could potentially be implemented in the future.\n const prismaTracingHelper = getPrismaTracingHelper();\n\n let emittedWarning = false;\n\n if (isPrismaV6TracingHelper(prismaTracingHelper)) {\n (prismaTracingHelper as CompatibilityLayerTraceHelper).createEngineSpan = () => {\n consoleSandbox(() => {\n if (!emittedWarning) {\n emittedWarning = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] The Sentry SDK supports tracing with Prisma version 5 only with limited capabilities. For full tracing capabilities pass `prismaInstrumentation` for version 5 to the Sentry `prismaIntegration`. Read more: https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/',\n );\n }\n });\n };\n }\n }\n}\n\nexport const instrumentPrisma = generateInstrumentOnce<{ prismaInstrumentation?: Instrumentation }>(\n INTEGRATION_NAME,\n options => {\n // Use a passed instrumentation instance to support older Prisma versions\n if (options?.prismaInstrumentation) {\n return options.prismaInstrumentation;\n }\n\n return new SentryPrismaInteropInstrumentation();\n },\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(\n ({\n prismaInstrumentation,\n }: {\n /**\n * Overrides the instrumentation used by the Sentry SDK with the passed in instrumentation instance.\n *\n * NOTE: By default, the Sentry SDK uses the Prisma v6 instrumentation. Use this option if you need performance instrumentation different Prisma versions.\n *\n * For more information refer to the documentation of `prismaIntegration()` or see https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/\n */\n prismaInstrumentation?: Instrumentation;\n } = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPrisma({ prismaInstrumentation });\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);\n"],"names":["PrismaInstrumentation","consoleSandbox","generateInstrumentOnce","defineIntegration","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;AAOA,MAAM,gBAAA,GAAmB,QAAQ;;AAIjC,SAAS,uBAAuB,CAAC,MAAM,EAA4C;AACnF,EAAE,OAAO,CAAC,CAAC,MAAA,IAAU,OAAO,MAAO,KAAI,QAAS,IAAG,qBAAsB,IAAG,MAAM;AAClF;;AAEA,SAAS,sBAAsB,GAAwB;AACvD,EAAE,MAAM,2BAA4B,GAAE,CAAC,UAAW,GAA4B,sBAAsB;AACpG,EAAE,MAAM,mBAAoB;AAC5B,IAAI,2BAA4B;AAChC,IAAI,OAAO,2BAA4B,KAAI,QAAS;AACpD,IAAI,YAAY;AAChB,QAAQ,2BAA2B,CAAC;AACpC,QAAQ,SAAS;;AAEjB,EAAE,OAAO,mBAAmB;AAC5B;;AAEA,MAAM,kCAAA,SAA2CA,qCAAsB,CAAA;AACvE,GAAS,WAAW,GAAG;AACvB,IAAI,KAAK,EAAE;AACX;;AAEA,GAAS,MAAM,GAAS;AACxB,IAAI,KAAK,CAAC,MAAM,EAAE;;AAElB;AACA;AACA;AACA,IAAI,MAAM,mBAAA,GAAsB,sBAAsB,EAAE;;AAExD,IAAI,IAAI,cAAe,GAAE,KAAK;;AAE9B,IAAI,IAAI,uBAAuB,CAAC,mBAAmB,CAAC,EAAE;AACtD,MAAM,CAAC,sBAAsD,mBAAmB,MAAM;AACtF,QAAQC,mBAAc,CAAC,MAAM;AAC7B,UAAU,IAAI,CAAC,cAAc,EAAE;AAC/B,YAAY,cAAA,GAAiB,IAAI;AACjC;AACA,YAAY,OAAO,CAAC,IAAI;AACxB,cAAc,kTAAkT;AAChU,aAAa;AACb;AACA,SAAS,CAAC;AACV,OAAO;AACP;AACA;AACA;;AAEO,MAAM,gBAAiB,GAAEC,iCAAsB;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,CAAC,WAAW,CAAC,EAAE;AAChG,YAAY,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC;AACpD;AACA,SAAS,CAAC;AACV,OAAO;AACP,KAAK;AACL,GAAG;AACH;;;;;"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const instrumentationIoredis = require('@opentelemetry/instrumentation-ioredis');
4
4
  const instrumentationRedis4 = require('@opentelemetry/instrumentation-redis-4');
5
5
  const core = require('@sentry/core');
6
- const nodeCore = require('@sentry/node-core');
6
+ const instrument = require('../../otel/instrument.js');
7
7
  const redisCache = require('../../utils/redisCache.js');
8
8
 
9
9
  const INTEGRATION_NAME = 'Redis';
@@ -54,13 +54,13 @@ const cacheResponseHook = (span, redisCommand, cmdArgs, response) => {
54
54
  span.updateName(core.truncate(spanDescription, 1024));
55
55
  };
56
56
 
57
- const instrumentIORedis = nodeCore.generateInstrumentOnce('IORedis', () => {
57
+ const instrumentIORedis = instrument.generateInstrumentOnce('IORedis', () => {
58
58
  return new instrumentationIoredis.IORedisInstrumentation({
59
59
  responseHook: cacheResponseHook,
60
60
  });
61
61
  });
62
62
 
63
- const instrumentRedis4 = nodeCore.generateInstrumentOnce('Redis-4', () => {
63
+ const instrumentRedis4 = instrument.generateInstrumentOnce('Redis-4', () => {
64
64
  return new instrumentationRedis4.RedisInstrumentation({
65
65
  responseHook: cacheResponseHook,
66
66
  });
@@ -1 +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-4';\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 cachePrefixes?: string[];\n}\n\nconst INTEGRATION_NAME = 'Redis';\n\nlet _redisOptions: RedisOptions = {};\n\nconst cacheResponseHook: RedisResponseCustomAttributeFunction = (span: Span, redisCommand, cmdArgs, response) => {\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 const spanDescription = safeKey.join(', ');\n\n span.updateName(truncate(spanDescription, 1024));\n};\n\nconst instrumentIORedis = generateInstrumentOnce('IORedis', () => {\n return new IORedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\nconst instrumentRedis4 = generateInstrumentOnce('Redis-4', () => {\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 instrumentRedis4();\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":["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","IORedis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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-4';\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 '../../otel/instrument';\nimport {\n calculateCacheItemSize,\n GET_COMMANDS,\n getCacheKeySafely,\n getCacheOperation,\n isInCommands,\n shouldConsiderForCache,\n} from '../../utils/redisCache';\n\ninterface RedisOptions {\n cachePrefixes?: string[];\n}\n\nconst INTEGRATION_NAME = 'Redis';\n\nlet _redisOptions: RedisOptions = {};\n\nconst cacheResponseHook: RedisResponseCustomAttributeFunction = (span: Span, redisCommand, cmdArgs, response) => {\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 const spanDescription = safeKey.join(', ');\n\n span.updateName(truncate(spanDescription, 1024));\n};\n\nconst instrumentIORedis = generateInstrumentOnce('IORedis', () => {\n return new IORedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\nconst instrumentRedis4 = generateInstrumentOnce('Redis-4', () => {\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 instrumentRedis4();\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":["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"],"mappings":";;;;;;;;AA6BA,MAAM,gBAAA,GAAmB,OAAO;;AAEhC,IAAI,aAAa,GAAiB,EAAE;;AAEpC,MAAM,iBAAiB,GAAyC,CAAC,IAAI,EAAQ,YAAY,EAAE,OAAO,EAAE,QAAQ,KAAK;AACjH,EAAE,IAAI,CAAC,YAAY,CAACA,qCAAgC,EAAE,oBAAoB,CAAC;;AAE3E,EAAE,MAAM,UAAUC,4BAAiB,CAAC,YAAY,EAAE,OAAO,CAAC;AAC1D,EAAE,MAAM,cAAe,GAAEC,4BAAiB,CAAC,YAAY,CAAC;;AAExD,EAAE;AACF,IAAI,CAAC,OAAQ;AACb,IAAI,CAAC,cAAe;AACpB,IAAI,CAAC,aAAa,CAAC,aAAc;AACjC,IAAI,CAACC,iCAAsB,CAAC,YAAY,EAAE,OAAO,EAAE,aAAa,CAAC,aAAa;AAC9E,IAAI;AACJ;AACA,IAAI;AACJ;;AAEA;AACA;AACA,EAAE,MAAM,kBAAmB,GAAEC,eAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;AACnE,EAAE,MAAM,eAAgB,GAAEA,eAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;AAChE,EAAE,IAAI,eAAgB,IAAG,kBAAkB,EAAE;AAC7C,IAAI,IAAI,CAAC,aAAa,CAAC,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,eA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AE,KAAK;AAC3D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,aAAA,GAAgB,OAAO;AAC7B,MAAM,eAAe,EAAE;AACvB,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,gBAAiB,GAAEC,sBAAiB,CAAC,iBAAiB;;;;;"}
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const instrumentationTedious = require('@opentelemetry/instrumentation-tedious');
4
4
  const core = require('@sentry/core');
5
- const nodeCore = require('@sentry/node-core');
5
+ const instrument = require('../../otel/instrument.js');
6
6
 
7
7
  const TEDIUS_INSTRUMENTED_METHODS = new Set([
8
8
  'callProcedure',
@@ -15,7 +15,7 @@ const TEDIUS_INSTRUMENTED_METHODS = new Set([
15
15
 
16
16
  const INTEGRATION_NAME = 'Tedious';
17
17
 
18
- const instrumentTedious = nodeCore.generateInstrumentOnce(INTEGRATION_NAME, () => new instrumentationTedious.TediousInstrumentation({}));
18
+ const instrumentTedious = instrument.generateInstrumentOnce(INTEGRATION_NAME, () => new instrumentationTedious.TediousInstrumentation({}));
19
19
 
20
20
  const _tediousIntegration = (() => {
21
21
  let instrumentationWrappedCallback;
@@ -24,7 +24,7 @@ const _tediousIntegration = (() => {
24
24
  name: INTEGRATION_NAME,
25
25
  setupOnce() {
26
26
  const instrumentation = instrumentTedious();
27
- instrumentationWrappedCallback = nodeCore.instrumentWhenWrapped(instrumentation);
27
+ instrumentationWrappedCallback = instrument.instrumentWhenWrapped(instrumentation);
28
28
  },
29
29
 
30
30
  setup(client) {
@@ -1 +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,2BAA4B,GAAE,IAAI,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 {"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 '../../otel/instrument';\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","TediousInstrument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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,kBAAmB,GAAEC,sBAAiB,CAAC,mBAAmB;;;;;"}
@@ -1,11 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const core = require('@sentry/core');
4
- const nodeCore = require('@sentry/node-core');
4
+ const instrument = require('../../../otel/instrument.js');
5
5
  const constants = require('./constants.js');
6
6
  const instrumentation = require('./instrumentation.js');
7
7
 
8
- const instrumentVercelAi = nodeCore.generateInstrumentOnce(constants.INTEGRATION_NAME, () => new instrumentation.SentryVercelAiInstrumentation({}));
8
+ const instrumentVercelAi = instrument.generateInstrumentOnce(constants.INTEGRATION_NAME, () => new instrumentation.SentryVercelAiInstrumentation({}));
9
9
 
10
10
  /**
11
11
  * Determines if the integration should be forced based on environment and package availability.
@@ -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 { type modulesIntegration, generateInstrumentOnce } 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,kBAAmB,GAAEA,+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,eAAgB,GAAE,kBAAkB,EAAE;AAC5C,KAAK;AACL,IAAI,aAAa,CAAC,MAAM,EAAE;AAC1B;AACA;AACA,MAAM,MAAM,WAAY,GAAE,OAAO,CAAC,SAAS,sBAAsB,CAAC,MAAM,CAAC;;AAEzE,MAAM,IAAI,WAAW,EAAE;AACvB,QAAQE,0BAAqB,CAAC,MAAM,CAAC;AACrC,aAAa;AACb,QAAQ,eAAe,EAAE,eAAe,CAAC,MAAMA,0BAAqB,CAAC,MAAM,CAAC,CAAC;AAC7E;AACA,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;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,mBAAoB,GAAEC,sBAAiB,CAAC,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 } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../../otel/instrument';\nimport type { modulesIntegration } from '../../modules';\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":";;;;;;;MAQa,kBAAmB,GAAEA,iCAAsB,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,eAAgB,GAAE,kBAAkB,EAAE;AAC5C,KAAK;AACL,IAAI,aAAa,CAAC,MAAM,EAAE;AAC1B;AACA;AACA,MAAM,MAAM,WAAY,GAAE,OAAO,CAAC,SAAS,sBAAsB,CAAC,MAAM,CAAC;;AAEzE,MAAM,IAAI,WAAW,EAAE;AACvB,QAAQE,0BAAqB,CAAC,MAAM,CAAC;AACrC,aAAa;AACb,QAAQ,eAAe,EAAE,eAAe,CAAC,MAAMA,0BAAqB,CAAC,MAAM,CAAC,CAAC;AAC7E;AACA,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;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,mBAAoB,GAAEC,sBAAiB,CAAC,oBAAoB;;;;;"}
@@ -0,0 +1,151 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const capture = require('../logs/capture.js');
4
+
5
+ const DEFAULT_CAPTURED_LEVELS = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];
6
+
7
+ // See: https://github.com/winstonjs/triple-beam
8
+ const LEVEL_SYMBOL = Symbol.for('level');
9
+ const MESSAGE_SYMBOL = Symbol.for('message');
10
+ const SPLAT_SYMBOL = Symbol.for('splat');
11
+
12
+ /**
13
+ * Options for the Sentry Winston transport.
14
+ */
15
+
16
+ /**
17
+ * Creates a new Sentry Winston transport that fowards logs to Sentry. Requires `_experiments.enableLogs` to be enabled.
18
+ *
19
+ * Supports Winston 3.x.x.
20
+ *
21
+ * @param TransportClass - The Winston transport class to extend.
22
+ * @returns The extended transport class.
23
+ *
24
+ * @experimental This method will experience breaking changes. This is not yet part of
25
+ * the stable Sentry SDK API and can be changed or removed without warning.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const winston = require('winston');
30
+ * const Transport = require('winston-transport');
31
+ *
32
+ * const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport);
33
+ *
34
+ * const logger = winston.createLogger({
35
+ * transports: [new SentryWinstonTransport()],
36
+ * });
37
+ * ```
38
+ */
39
+ function createSentryWinstonTransport(
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ TransportClass,
42
+ sentryWinstonOptions,
43
+ ) {
44
+ // @ts-ignore - We know this is safe because SentryWinstonTransport extends TransportClass
45
+ class SentryWinstonTransport extends TransportClass {
46
+
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ constructor(options) {
49
+ super(options);
50
+ this._levels = new Set(sentryWinstonOptions?.levels ?? DEFAULT_CAPTURED_LEVELS);
51
+ }
52
+
53
+ /**
54
+ * Forwards a winston log to the Sentry SDK.
55
+ */
56
+ log(info, callback) {
57
+ try {
58
+ setImmediate(() => {
59
+ // @ts-ignore - We know this is safe because SentryWinstonTransport extends TransportClass
60
+ this.emit('logged', info);
61
+ });
62
+
63
+ if (!isObject(info)) {
64
+ return;
65
+ }
66
+
67
+ const levelFromSymbol = info[LEVEL_SYMBOL];
68
+
69
+ // See: https://github.com/winstonjs/winston?tab=readme-ov-file#streams-objectmode-and-info-objects
70
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
71
+ const { level, message, timestamp, ...attributes } = info;
72
+ // Remove all symbols from the remaining attributes
73
+ attributes[LEVEL_SYMBOL] = undefined;
74
+ attributes[MESSAGE_SYMBOL] = undefined;
75
+ attributes[SPLAT_SYMBOL] = undefined;
76
+
77
+ const logSeverityLevel = WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP[levelFromSymbol ] ?? 'info';
78
+ if (this._levels.has(logSeverityLevel)) {
79
+ capture.captureLog(logSeverityLevel, message , {
80
+ ...attributes,
81
+ 'sentry.origin': 'auto.logging.winston',
82
+ });
83
+ }
84
+ } catch {
85
+ // do nothing
86
+ }
87
+
88
+ if (callback) {
89
+ callback();
90
+ }
91
+ }
92
+ }
93
+
94
+ return SentryWinstonTransport ;
95
+ }
96
+
97
+ function isObject(anything) {
98
+ return typeof anything === 'object' && anything != null;
99
+ }
100
+
101
+ // npm
102
+ // {
103
+ // error: 0,
104
+ // warn: 1,
105
+ // info: 2,
106
+ // http: 3,
107
+ // verbose: 4,
108
+ // debug: 5,
109
+ // silly: 6
110
+ // }
111
+ //
112
+ // syslog
113
+ // {
114
+ // emerg: 0,
115
+ // alert: 1,
116
+ // crit: 2,
117
+ // error: 3,
118
+ // warning: 4,
119
+ // notice: 5,
120
+ // info: 6,
121
+ // debug: 7,
122
+ // }
123
+ const WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP = {
124
+ // npm
125
+ silly: 'trace',
126
+ // npm and syslog
127
+ debug: 'debug',
128
+ // npm
129
+ verbose: 'debug',
130
+ // npm
131
+ http: 'debug',
132
+ // npm and syslog
133
+ info: 'info',
134
+ // syslog
135
+ notice: 'info',
136
+ // npm
137
+ warn: 'warn',
138
+ // syslog
139
+ warning: 'warn',
140
+ // npm and syslog
141
+ error: 'error',
142
+ // syslog
143
+ emerg: 'fatal',
144
+ // syslog
145
+ alert: 'fatal',
146
+ // syslog
147
+ crit: 'fatal',
148
+ };
149
+
150
+ exports.createSentryWinstonTransport = createSentryWinstonTransport;
151
+ //# sourceMappingURL=winston.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"winston.js","sources":["../../../src/integrations/winston.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport type { LogSeverityLevel } from '@sentry/core';\nimport { captureLog } from '../logs/capture';\n\nconst DEFAULT_CAPTURED_LEVELS: Array<LogSeverityLevel> = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];\n\n// See: https://github.com/winstonjs/triple-beam\nconst LEVEL_SYMBOL = Symbol.for('level');\nconst MESSAGE_SYMBOL = Symbol.for('message');\nconst SPLAT_SYMBOL = Symbol.for('splat');\n\n/**\n * Options for the Sentry Winston transport.\n */\ninterface WinstonTransportOptions {\n /**\n * Use this option to filter which levels should be captured. By default, all levels are captured.\n *\n * @example\n * ```ts\n * const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport, {\n * // Only capture error and warn logs\n * levels: ['error', 'warn'],\n * });\n * ```\n */\n levels?: Array<LogSeverityLevel>;\n}\n\n/**\n * Creates a new Sentry Winston transport that fowards logs to Sentry. Requires `_experiments.enableLogs` to be enabled.\n *\n * Supports Winston 3.x.x.\n *\n * @param TransportClass - The Winston transport class to extend.\n * @returns The extended transport class.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n *\n * @example\n * ```ts\n * const winston = require('winston');\n * const Transport = require('winston-transport');\n *\n * const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport);\n *\n * const logger = winston.createLogger({\n * transports: [new SentryWinstonTransport()],\n * });\n * ```\n */\nexport function createSentryWinstonTransport<TransportStreamInstance extends object>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TransportClass: new (options?: any) => TransportStreamInstance,\n sentryWinstonOptions?: WinstonTransportOptions,\n): typeof TransportClass {\n // @ts-ignore - We know this is safe because SentryWinstonTransport extends TransportClass\n class SentryWinstonTransport extends TransportClass {\n private _levels: Set<LogSeverityLevel>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(options?: any) {\n super(options);\n this._levels = new Set(sentryWinstonOptions?.levels ?? DEFAULT_CAPTURED_LEVELS);\n }\n\n /**\n * Forwards a winston log to the Sentry SDK.\n */\n public log(info: unknown, callback: () => void): void {\n try {\n setImmediate(() => {\n // @ts-ignore - We know this is safe because SentryWinstonTransport extends TransportClass\n this.emit('logged', info);\n });\n\n if (!isObject(info)) {\n return;\n }\n\n const levelFromSymbol = info[LEVEL_SYMBOL];\n\n // See: https://github.com/winstonjs/winston?tab=readme-ov-file#streams-objectmode-and-info-objects\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { level, message, timestamp, ...attributes } = info;\n // Remove all symbols from the remaining attributes\n attributes[LEVEL_SYMBOL] = undefined;\n attributes[MESSAGE_SYMBOL] = undefined;\n attributes[SPLAT_SYMBOL] = undefined;\n\n const logSeverityLevel = WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP[levelFromSymbol as string] ?? 'info';\n if (this._levels.has(logSeverityLevel)) {\n captureLog(logSeverityLevel, message as string, {\n ...attributes,\n 'sentry.origin': 'auto.logging.winston',\n });\n }\n } catch {\n // do nothing\n }\n\n if (callback) {\n callback();\n }\n }\n }\n\n return SentryWinstonTransport as typeof TransportClass;\n}\n\nfunction isObject(anything: unknown): anything is Record<string | symbol, unknown> {\n return typeof anything === 'object' && anything != null;\n}\n\n// npm\n// {\n// error: 0,\n// warn: 1,\n// info: 2,\n// http: 3,\n// verbose: 4,\n// debug: 5,\n// silly: 6\n// }\n//\n// syslog\n// {\n// emerg: 0,\n// alert: 1,\n// crit: 2,\n// error: 3,\n// warning: 4,\n// notice: 5,\n// info: 6,\n// debug: 7,\n// }\nconst WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP: Record<string, LogSeverityLevel> = {\n // npm\n silly: 'trace',\n // npm and syslog\n debug: 'debug',\n // npm\n verbose: 'debug',\n // npm\n http: 'debug',\n // npm and syslog\n info: 'info',\n // syslog\n notice: 'info',\n // npm\n warn: 'warn',\n // syslog\n warning: 'warn',\n // npm and syslog\n error: 'error',\n // syslog\n emerg: 'fatal',\n // syslog\n alert: 'fatal',\n // syslog\n crit: 'fatal',\n};\n"],"names":["captureLog"],"mappings":";;;;AAIA,MAAM,uBAAuB,GAA4B,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;;AAE7G;AACA,MAAM,eAAe,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;AACxC,MAAM,iBAAiB,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;AAC5C,MAAM,eAAe,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;;AAExC;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,4BAA4B;AAC5C;AACA,EAAE,cAAc;AAChB,EAAE,oBAAoB;AACtB,EAAyB;AACzB;AACA,EAAE,MAAM,sBAAuB,SAAQ,cAAe,CAAA;;AAEtD;AACA,KAAW,WAAW,CAAC,OAAO,EAAQ;AACtC,MAAM,KAAK,CAAC,OAAO,CAAC;AACpB,MAAM,IAAI,CAAC,OAAQ,GAAE,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAA,IAAU,uBAAuB,CAAC;AACrF;;AAEA;AACA;AACA;AACA,KAAW,GAAG,CAAC,IAAI,EAAW,QAAQ,EAAoB;AAC1D,MAAM,IAAI;AACV,QAAQ,YAAY,CAAC,MAAM;AAC3B;AACA,UAAU,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC;AACnC,SAAS,CAAC;;AAEV,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;AAC7B,UAAU;AACV;;AAEA,QAAQ,MAA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;AACA,EAAE,KAAK,EAAE,OAAO;AAChB;AACA,EAAE,KAAK,EAAE,OAAO;AAChB;AACA,EAAE,KAAK,EAAE,OAAO;AAChB;AACA,EAAE,IAAI,EAAE,OAAO;AACf,CAAC;;;;"}
@@ -0,0 +1,29 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const node_util = require('node:util');
4
+ const core = require('@sentry/core');
5
+
6
+ /**
7
+ * Capture a log with the given level.
8
+ *
9
+ * @param level - The level of the log.
10
+ * @param message - The message to log.
11
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.
12
+ */
13
+ function captureLog(level, ...args) {
14
+ const [messageOrMessageTemplate, paramsOrAttributes, maybeAttributes] = args;
15
+ if (Array.isArray(paramsOrAttributes)) {
16
+ const attributes = { ...maybeAttributes };
17
+ attributes['sentry.message.template'] = messageOrMessageTemplate;
18
+ paramsOrAttributes.forEach((param, index) => {
19
+ attributes[`sentry.message.parameter.${index}`] = param;
20
+ });
21
+ const message = node_util.format(messageOrMessageTemplate, ...paramsOrAttributes);
22
+ core._INTERNAL_captureLog({ level, message, attributes });
23
+ } else {
24
+ core._INTERNAL_captureLog({ level, message: messageOrMessageTemplate, attributes: paramsOrAttributes });
25
+ }
26
+ }
27
+
28
+ exports.captureLog = captureLog;
29
+ //# sourceMappingURL=capture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture.js","sources":["../../../src/logs/capture.ts"],"sourcesContent":["import { format } from 'node:util';\nimport type { Log, LogSeverityLevel, ParameterizedString } from '@sentry/core';\nimport { _INTERNAL_captureLog } from '@sentry/core';\n\nexport type CaptureLogArgs =\n | [message: ParameterizedString, attributes?: Log['attributes']]\n | [messageTemplate: string, messageParams: Array<unknown>, attributes?: Log['attributes']];\n\n/**\n * Capture a log with the given level.\n *\n * @param level - The level of the log.\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.\n */\nexport function captureLog(level: LogSeverityLevel, ...args: CaptureLogArgs): void {\n const [messageOrMessageTemplate, paramsOrAttributes, maybeAttributes] = args;\n if (Array.isArray(paramsOrAttributes)) {\n const attributes = { ...maybeAttributes };\n attributes['sentry.message.template'] = messageOrMessageTemplate;\n paramsOrAttributes.forEach((param, index) => {\n attributes[`sentry.message.parameter.${index}`] = param;\n });\n const message = format(messageOrMessageTemplate, ...paramsOrAttributes);\n _INTERNAL_captureLog({ level, message, attributes });\n } else {\n _INTERNAL_captureLog({ level, message: messageOrMessageTemplate, attributes: paramsOrAttributes });\n }\n}\n"],"names":["format","_INTERNAL_captureLog"],"mappings":";;;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,UAAU,CAAC,KAAK,EAAoB,GAAG,IAAI,EAAwB;AACnF,EAAE,MAAM,CAAC,wBAAwB,EAAE,kBAAkB,EAAE,eAAe,CAAE,GAAE,IAAI;AAC9E,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE;AACzC,IAAI,MAAM,UAAW,GAAE,EAAE,GAAG,iBAAiB;AAC7C,IAAI,UAAU,CAAC,yBAAyB,CAAA,GAAI,wBAAwB;AACpE,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK;AACjD,MAAM,UAAU,CAAC,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAA,CAAA,GAAA,KAAA;AACA,KAAA,CAAA;AACA,IAAA,MAAA,OAAA,GAAAA,gBAAA,CAAA,wBAAA,EAAA,GAAA,kBAAA,CAAA;AACA,IAAAC,yBAAA,CAAA,EAAA,KAAA,EAAA,OAAA,EAAA,UAAA,EAAA,CAAA;AACA,GAAA,MAAA;AACA,IAAAA,yBAAA,CAAA,EAAA,KAAA,EAAA,OAAA,EAAA,wBAAA,EAAA,UAAA,EAAA,kBAAA,EAAA,CAAA;AACA;AACA;;;;"}