@sentry/node 10.63.0 → 10.64.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 (259) hide show
  1. package/build/cjs/index.js +15 -14
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/integrations/node-fetch.js +24 -0
  4. package/build/cjs/integrations/node-fetch.js.map +1 -0
  5. package/build/cjs/integrations/tracing/amqplib/vendored/semconv.js +0 -6
  6. package/build/cjs/integrations/tracing/amqplib/vendored/semconv.js.map +1 -1
  7. package/build/cjs/integrations/tracing/amqplib/vendored/utils.js +11 -10
  8. package/build/cjs/integrations/tracing/amqplib/vendored/utils.js.map +1 -1
  9. package/build/cjs/integrations/tracing/connect/vendored/instrumentation.js +2 -2
  10. package/build/cjs/integrations/tracing/connect/vendored/instrumentation.js.map +1 -1
  11. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js +2 -2
  12. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js.map +1 -1
  13. package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js +9 -9
  14. package/build/cjs/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -1
  15. package/build/cjs/integrations/tracing/hapi/vendored/utils.js +8 -9
  16. package/build/cjs/integrations/tracing/hapi/vendored/utils.js.map +1 -1
  17. package/build/cjs/integrations/tracing/hono/index.js +7 -7
  18. package/build/cjs/integrations/tracing/hono/index.js.map +1 -1
  19. package/build/cjs/integrations/tracing/kafka/vendored/instrumentation.js +2 -1
  20. package/build/cjs/integrations/tracing/kafka/vendored/instrumentation.js.map +1 -1
  21. package/build/cjs/integrations/tracing/kafka/vendored/semconv.js +0 -12
  22. package/build/cjs/integrations/tracing/kafka/vendored/semconv.js.map +1 -1
  23. package/build/cjs/integrations/tracing/kafka/vendored/utils.js +12 -11
  24. package/build/cjs/integrations/tracing/kafka/vendored/utils.js.map +1 -1
  25. package/build/cjs/integrations/tracing/knex/vendored/instrumentation.js +11 -10
  26. package/build/cjs/integrations/tracing/knex/vendored/instrumentation.js.map +1 -1
  27. package/build/cjs/integrations/tracing/knex/vendored/semconv.js +0 -16
  28. package/build/cjs/integrations/tracing/knex/vendored/semconv.js.map +1 -1
  29. package/build/cjs/integrations/tracing/koa/vendored/instrumentation.js +2 -2
  30. package/build/cjs/integrations/tracing/koa/vendored/instrumentation.js.map +1 -1
  31. package/build/cjs/integrations/tracing/koa/vendored/utils.js +2 -2
  32. package/build/cjs/integrations/tracing/koa/vendored/utils.js.map +1 -1
  33. package/build/cjs/integrations/tracing/mongo/vendored/semconv.js +0 -12
  34. package/build/cjs/integrations/tracing/mongo/vendored/semconv.js.map +1 -1
  35. package/build/cjs/integrations/tracing/mongo/vendored/utils.js +12 -11
  36. package/build/cjs/integrations/tracing/mongo/vendored/utils.js.map +1 -1
  37. package/build/cjs/integrations/tracing/mongoose/index.js +3 -2
  38. package/build/cjs/integrations/tracing/mongoose/index.js.map +1 -1
  39. package/build/cjs/integrations/tracing/mongoose/vendored/mongoose.js +11 -8
  40. package/build/cjs/integrations/tracing/mongoose/vendored/mongoose.js.map +1 -1
  41. package/build/cjs/integrations/tracing/mongoose/vendored/semconv.js +0 -12
  42. package/build/cjs/integrations/tracing/mongoose/vendored/semconv.js.map +1 -1
  43. package/build/cjs/integrations/tracing/mongoose/vendored/utils.js +9 -9
  44. package/build/cjs/integrations/tracing/mongoose/vendored/utils.js.map +1 -1
  45. package/build/cjs/integrations/tracing/mysql/vendored/instrumentation.js +9 -8
  46. package/build/cjs/integrations/tracing/mysql/vendored/instrumentation.js.map +1 -1
  47. package/build/cjs/integrations/tracing/mysql/vendored/semconv.js +0 -12
  48. package/build/cjs/integrations/tracing/mysql/vendored/semconv.js.map +1 -1
  49. package/build/cjs/integrations/tracing/mysql2/vendored/instrumentation.js +7 -4
  50. package/build/cjs/integrations/tracing/mysql2/vendored/instrumentation.js.map +1 -1
  51. package/build/cjs/integrations/tracing/mysql2/vendored/semconv.js +0 -12
  52. package/build/cjs/integrations/tracing/mysql2/vendored/semconv.js.map +1 -1
  53. package/build/cjs/integrations/tracing/mysql2/vendored/utils.js +7 -4
  54. package/build/cjs/integrations/tracing/mysql2/vendored/utils.js.map +1 -1
  55. package/build/cjs/integrations/tracing/postgres/vendored/semconv.js +0 -12
  56. package/build/cjs/integrations/tracing/postgres/vendored/semconv.js.map +1 -1
  57. package/build/cjs/integrations/tracing/postgres/vendored/utils.js +12 -11
  58. package/build/cjs/integrations/tracing/postgres/vendored/utils.js.map +1 -1
  59. package/build/cjs/integrations/tracing/postgresjs.js +8 -7
  60. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
  61. package/build/cjs/integrations/tracing/prisma/index.js +48 -53
  62. package/build/cjs/integrations/tracing/prisma/index.js.map +1 -1
  63. package/build/cjs/integrations/tracing/redis/cache.js +41 -0
  64. package/build/cjs/integrations/tracing/redis/cache.js.map +1 -0
  65. package/build/cjs/integrations/tracing/redis/index.js +14 -36
  66. package/build/cjs/integrations/tracing/redis/index.js.map +1 -1
  67. package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js +22 -13
  68. package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -1
  69. package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js +21 -15
  70. package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -1
  71. package/build/cjs/integrations/tracing/redis/vendored/semconv.js +0 -8
  72. package/build/cjs/integrations/tracing/redis/vendored/semconv.js.map +1 -1
  73. package/build/cjs/integrations/tracing/tedious/vendored/instrumentation.js +9 -8
  74. package/build/cjs/integrations/tracing/tedious/vendored/instrumentation.js.map +1 -1
  75. package/build/cjs/integrations/tracing/tedious/vendored/semconv.js +0 -12
  76. package/build/cjs/integrations/tracing/tedious/vendored/semconv.js.map +1 -1
  77. package/build/cjs/sdk/experimentalUseDiagnosticsChannelInjection.js +12 -2
  78. package/build/cjs/sdk/experimentalUseDiagnosticsChannelInjection.js.map +1 -1
  79. package/build/cjs/sdk/index.js +2 -2
  80. package/build/cjs/sdk/index.js.map +1 -1
  81. package/build/cjs/sdk/initOtel.js +36 -0
  82. package/build/cjs/sdk/initOtel.js.map +1 -1
  83. package/build/esm/index.js +2 -2
  84. package/build/esm/integrations/node-fetch.js +22 -0
  85. package/build/esm/integrations/node-fetch.js.map +1 -0
  86. package/build/esm/integrations/tracing/amqplib/vendored/semconv.js +1 -4
  87. package/build/esm/integrations/tracing/amqplib/vendored/semconv.js.map +1 -1
  88. package/build/esm/integrations/tracing/amqplib/vendored/utils.js +7 -6
  89. package/build/esm/integrations/tracing/amqplib/vendored/utils.js.map +1 -1
  90. package/build/esm/integrations/tracing/connect/vendored/instrumentation.js +2 -2
  91. package/build/esm/integrations/tracing/connect/vendored/instrumentation.js.map +1 -1
  92. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js +2 -2
  93. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js.map +1 -1
  94. package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js +7 -7
  95. package/build/esm/integrations/tracing/firebase/otel/patches/firestore.js.map +1 -1
  96. package/build/esm/integrations/tracing/hapi/vendored/utils.js +3 -4
  97. package/build/esm/integrations/tracing/hapi/vendored/utils.js.map +1 -1
  98. package/build/esm/integrations/tracing/hono/index.js +3 -3
  99. package/build/esm/integrations/tracing/hono/index.js.map +1 -1
  100. package/build/esm/integrations/tracing/kafka/vendored/instrumentation.js +3 -2
  101. package/build/esm/integrations/tracing/kafka/vendored/instrumentation.js.map +1 -1
  102. package/build/esm/integrations/tracing/kafka/vendored/semconv.js +1 -7
  103. package/build/esm/integrations/tracing/kafka/vendored/semconv.js.map +1 -1
  104. package/build/esm/integrations/tracing/kafka/vendored/utils.js +11 -10
  105. package/build/esm/integrations/tracing/kafka/vendored/utils.js.map +1 -1
  106. package/build/esm/integrations/tracing/knex/vendored/instrumentation.js +10 -9
  107. package/build/esm/integrations/tracing/knex/vendored/instrumentation.js.map +1 -1
  108. package/build/esm/integrations/tracing/knex/vendored/semconv.js +1 -9
  109. package/build/esm/integrations/tracing/knex/vendored/semconv.js.map +1 -1
  110. package/build/esm/integrations/tracing/koa/vendored/instrumentation.js +2 -2
  111. package/build/esm/integrations/tracing/koa/vendored/instrumentation.js.map +1 -1
  112. package/build/esm/integrations/tracing/koa/vendored/utils.js +2 -2
  113. package/build/esm/integrations/tracing/koa/vendored/utils.js.map +1 -1
  114. package/build/esm/integrations/tracing/mongo/vendored/semconv.js +1 -7
  115. package/build/esm/integrations/tracing/mongo/vendored/semconv.js.map +1 -1
  116. package/build/esm/integrations/tracing/mongo/vendored/utils.js +9 -8
  117. package/build/esm/integrations/tracing/mongo/vendored/utils.js.map +1 -1
  118. package/build/esm/integrations/tracing/mongoose/index.js +4 -3
  119. package/build/esm/integrations/tracing/mongoose/index.js.map +1 -1
  120. package/build/esm/integrations/tracing/mongoose/vendored/mongoose.js +9 -6
  121. package/build/esm/integrations/tracing/mongoose/vendored/mongoose.js.map +1 -1
  122. package/build/esm/integrations/tracing/mongoose/vendored/semconv.js +1 -7
  123. package/build/esm/integrations/tracing/mongoose/vendored/semconv.js.map +1 -1
  124. package/build/esm/integrations/tracing/mongoose/vendored/utils.js +10 -10
  125. package/build/esm/integrations/tracing/mongoose/vendored/utils.js.map +1 -1
  126. package/build/esm/integrations/tracing/mysql/vendored/instrumentation.js +8 -7
  127. package/build/esm/integrations/tracing/mysql/vendored/instrumentation.js.map +1 -1
  128. package/build/esm/integrations/tracing/mysql/vendored/semconv.js +1 -7
  129. package/build/esm/integrations/tracing/mysql/vendored/semconv.js.map +1 -1
  130. package/build/esm/integrations/tracing/mysql2/vendored/instrumentation.js +6 -3
  131. package/build/esm/integrations/tracing/mysql2/vendored/instrumentation.js.map +1 -1
  132. package/build/esm/integrations/tracing/mysql2/vendored/semconv.js +1 -7
  133. package/build/esm/integrations/tracing/mysql2/vendored/semconv.js.map +1 -1
  134. package/build/esm/integrations/tracing/mysql2/vendored/utils.js +8 -5
  135. package/build/esm/integrations/tracing/mysql2/vendored/utils.js.map +1 -1
  136. package/build/esm/integrations/tracing/postgres/vendored/semconv.js +1 -7
  137. package/build/esm/integrations/tracing/postgres/vendored/semconv.js.map +1 -1
  138. package/build/esm/integrations/tracing/postgres/vendored/utils.js +13 -12
  139. package/build/esm/integrations/tracing/postgres/vendored/utils.js.map +1 -1
  140. package/build/esm/integrations/tracing/postgresjs.js +7 -6
  141. package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
  142. package/build/esm/integrations/tracing/prisma/index.js +49 -54
  143. package/build/esm/integrations/tracing/prisma/index.js.map +1 -1
  144. package/build/esm/integrations/tracing/redis/cache.js +38 -0
  145. package/build/esm/integrations/tracing/redis/cache.js.map +1 -0
  146. package/build/esm/integrations/tracing/redis/index.js +9 -34
  147. package/build/esm/integrations/tracing/redis/index.js.map +1 -1
  148. package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js +19 -10
  149. package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -1
  150. package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js +16 -10
  151. package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -1
  152. package/build/esm/integrations/tracing/redis/vendored/semconv.js +1 -5
  153. package/build/esm/integrations/tracing/redis/vendored/semconv.js.map +1 -1
  154. package/build/esm/integrations/tracing/tedious/vendored/instrumentation.js +8 -7
  155. package/build/esm/integrations/tracing/tedious/vendored/instrumentation.js.map +1 -1
  156. package/build/esm/integrations/tracing/tedious/vendored/semconv.js +1 -7
  157. package/build/esm/integrations/tracing/tedious/vendored/semconv.js.map +1 -1
  158. package/build/esm/package.json +1 -1
  159. package/build/esm/sdk/experimentalUseDiagnosticsChannelInjection.js +13 -4
  160. package/build/esm/sdk/experimentalUseDiagnosticsChannelInjection.js.map +1 -1
  161. package/build/esm/sdk/index.js +1 -1
  162. package/build/esm/sdk/initOtel.js +38 -2
  163. package/build/esm/sdk/initOtel.js.map +1 -1
  164. package/build/types/index.d.ts +1 -1
  165. package/build/types/index.d.ts.map +1 -1
  166. package/build/types/integrations/node-fetch.d.ts +9 -0
  167. package/build/types/integrations/node-fetch.d.ts.map +1 -0
  168. package/build/types/integrations/tracing/amqplib/vendored/semconv.d.ts +0 -6
  169. package/build/types/integrations/tracing/amqplib/vendored/semconv.d.ts.map +1 -1
  170. package/build/types/integrations/tracing/amqplib/vendored/utils.d.ts.map +1 -1
  171. package/build/types/integrations/tracing/hapi/vendored/utils.d.ts.map +1 -1
  172. package/build/types/integrations/tracing/kafka/vendored/semconv.d.ts +5 -63
  173. package/build/types/integrations/tracing/kafka/vendored/semconv.d.ts.map +1 -1
  174. package/build/types/integrations/tracing/kafka/vendored/utils.d.ts.map +1 -1
  175. package/build/types/integrations/tracing/knex/vendored/semconv.d.ts +0 -32
  176. package/build/types/integrations/tracing/knex/vendored/semconv.d.ts.map +1 -1
  177. package/build/types/integrations/tracing/mongo/vendored/semconv.d.ts +1 -37
  178. package/build/types/integrations/tracing/mongo/vendored/semconv.d.ts.map +1 -1
  179. package/build/types/integrations/tracing/mongo/vendored/utils.d.ts.map +1 -1
  180. package/build/types/integrations/tracing/mongoose/index.d.ts.map +1 -1
  181. package/build/types/integrations/tracing/mongoose/vendored/mongoose.d.ts.map +1 -1
  182. package/build/types/integrations/tracing/mongoose/vendored/semconv.d.ts +0 -48
  183. package/build/types/integrations/tracing/mongoose/vendored/semconv.d.ts.map +1 -1
  184. package/build/types/integrations/tracing/mongoose/vendored/utils.d.ts.map +1 -1
  185. package/build/types/integrations/tracing/mysql/vendored/instrumentation.d.ts.map +1 -1
  186. package/build/types/integrations/tracing/mysql/vendored/semconv.d.ts +1 -62
  187. package/build/types/integrations/tracing/mysql/vendored/semconv.d.ts.map +1 -1
  188. package/build/types/integrations/tracing/mysql2/vendored/instrumentation.d.ts.map +1 -1
  189. package/build/types/integrations/tracing/mysql2/vendored/semconv.d.ts +0 -6
  190. package/build/types/integrations/tracing/mysql2/vendored/semconv.d.ts.map +1 -1
  191. package/build/types/integrations/tracing/mysql2/vendored/utils.d.ts.map +1 -1
  192. package/build/types/integrations/tracing/postgres/vendored/semconv.d.ts +1 -50
  193. package/build/types/integrations/tracing/postgres/vendored/semconv.d.ts.map +1 -1
  194. package/build/types/integrations/tracing/postgres/vendored/utils.d.ts.map +1 -1
  195. package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -1
  196. package/build/types/integrations/tracing/prisma/index.d.ts.map +1 -1
  197. package/build/types/integrations/tracing/redis/cache.d.ts +22 -0
  198. package/build/types/integrations/tracing/redis/cache.d.ts.map +1 -0
  199. package/build/types/integrations/tracing/redis/index.d.ts +2 -20
  200. package/build/types/integrations/tracing/redis/index.d.ts.map +1 -1
  201. package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts.map +1 -1
  202. package/build/types/integrations/tracing/redis/vendored/redis-instrumentation.d.ts.map +1 -1
  203. package/build/types/integrations/tracing/redis/vendored/semconv.d.ts +0 -4
  204. package/build/types/integrations/tracing/redis/vendored/semconv.d.ts.map +1 -1
  205. package/build/types/integrations/tracing/tedious/vendored/instrumentation.d.ts.map +1 -1
  206. package/build/types/integrations/tracing/tedious/vendored/semconv.d.ts +1 -62
  207. package/build/types/integrations/tracing/tedious/vendored/semconv.d.ts.map +1 -1
  208. package/build/types/sdk/experimentalUseDiagnosticsChannelInjection.d.ts +2 -0
  209. package/build/types/sdk/experimentalUseDiagnosticsChannelInjection.d.ts.map +1 -1
  210. package/build/types/sdk/initOtel.d.ts +2 -3
  211. package/build/types/sdk/initOtel.d.ts.map +1 -1
  212. package/build/types-ts3.8/index.d.ts +1 -1
  213. package/build/types-ts3.8/integrations/node-fetch.d.ts +9 -0
  214. package/build/types-ts3.8/integrations/tracing/amqplib/vendored/semconv.d.ts +0 -6
  215. package/build/types-ts3.8/integrations/tracing/kafka/vendored/semconv.d.ts +5 -63
  216. package/build/types-ts3.8/integrations/tracing/knex/vendored/semconv.d.ts +0 -32
  217. package/build/types-ts3.8/integrations/tracing/mongo/vendored/semconv.d.ts +1 -37
  218. package/build/types-ts3.8/integrations/tracing/mongoose/vendored/semconv.d.ts +0 -48
  219. package/build/types-ts3.8/integrations/tracing/mysql/vendored/semconv.d.ts +1 -62
  220. package/build/types-ts3.8/integrations/tracing/mysql2/vendored/semconv.d.ts +0 -6
  221. package/build/types-ts3.8/integrations/tracing/postgres/vendored/semconv.d.ts +1 -50
  222. package/build/types-ts3.8/integrations/tracing/redis/cache.d.ts +22 -0
  223. package/build/types-ts3.8/integrations/tracing/redis/index.d.ts +2 -20
  224. package/build/types-ts3.8/integrations/tracing/redis/vendored/semconv.d.ts +0 -4
  225. package/build/types-ts3.8/integrations/tracing/tedious/vendored/semconv.d.ts +1 -62
  226. package/build/types-ts3.8/sdk/experimentalUseDiagnosticsChannelInjection.d.ts +2 -0
  227. package/build/types-ts3.8/sdk/initOtel.d.ts +3 -4
  228. package/package.json +8 -9
  229. package/build/cjs/integrations/node-fetch/index.js +0 -38
  230. package/build/cjs/integrations/node-fetch/index.js.map +0 -1
  231. package/build/cjs/integrations/node-fetch/undici-instrumentation.js +0 -266
  232. package/build/cjs/integrations/node-fetch/undici-instrumentation.js.map +0 -1
  233. package/build/cjs/integrations/tracing/hapi/vendored/semconv.js +0 -6
  234. package/build/cjs/integrations/tracing/hapi/vendored/semconv.js.map +0 -1
  235. package/build/cjs/integrations/tracing/redis/vendored/redis-common.js +0 -34
  236. package/build/cjs/integrations/tracing/redis/vendored/redis-common.js.map +0 -1
  237. package/build/esm/integrations/node-fetch/index.js +0 -36
  238. package/build/esm/integrations/node-fetch/index.js.map +0 -1
  239. package/build/esm/integrations/node-fetch/undici-instrumentation.js +0 -264
  240. package/build/esm/integrations/node-fetch/undici-instrumentation.js.map +0 -1
  241. package/build/esm/integrations/tracing/hapi/vendored/semconv.js +0 -4
  242. package/build/esm/integrations/tracing/hapi/vendored/semconv.js.map +0 -1
  243. package/build/esm/integrations/tracing/redis/vendored/redis-common.js +0 -32
  244. package/build/esm/integrations/tracing/redis/vendored/redis-common.js.map +0 -1
  245. package/build/types/integrations/node-fetch/index.d.ts +0 -5
  246. package/build/types/integrations/node-fetch/index.d.ts.map +0 -1
  247. package/build/types/integrations/node-fetch/types.d.ts +0 -96
  248. package/build/types/integrations/node-fetch/types.d.ts.map +0 -1
  249. package/build/types/integrations/node-fetch/undici-instrumentation.d.ts +0 -14
  250. package/build/types/integrations/node-fetch/undici-instrumentation.d.ts.map +0 -1
  251. package/build/types/integrations/tracing/hapi/vendored/semconv.d.ts +0 -13
  252. package/build/types/integrations/tracing/hapi/vendored/semconv.d.ts.map +0 -1
  253. package/build/types/integrations/tracing/redis/vendored/redis-common.d.ts +0 -6
  254. package/build/types/integrations/tracing/redis/vendored/redis-common.d.ts.map +0 -1
  255. package/build/types-ts3.8/integrations/node-fetch/index.d.ts +0 -5
  256. package/build/types-ts3.8/integrations/node-fetch/types.d.ts +0 -96
  257. package/build/types-ts3.8/integrations/node-fetch/undici-instrumentation.d.ts +0 -14
  258. package/build/types-ts3.8/integrations/tracing/hapi/vendored/semconv.d.ts +0 -13
  259. package/build/types-ts3.8/integrations/tracing/redis/vendored/redis-common.d.ts +0 -6
@@ -2,7 +2,7 @@ import * as api from '@opentelemetry/api';
2
2
  import { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';
3
3
  import { KoaLayerType } from './types.js';
4
4
  import { SDK_VERSION, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getIsolationScope, getDefaultIsolationScope, debug } from '@sentry/core';
5
- import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
5
+ import { HTTP_ROUTE } from '@sentry/conventions/attributes';
6
6
  import { isLayerIgnored, getMiddlewareMetadata } from './utils.js';
7
7
  import { setHttpServerSpanRouteAttribute } from '../../../../utils/setHttpServerSpanRouteAttribute.js';
8
8
  import { DEBUG_BUILD } from '../../../../debug-build.js';
@@ -107,7 +107,7 @@ class KoaInstrumentation extends InstrumentationBase {
107
107
  }
108
108
  },
109
109
  () => {
110
- const route = metadata.attributes[ATTR_HTTP_ROUTE];
110
+ const route = metadata.attributes[HTTP_ROUTE];
111
111
  if (getIsolationScope() === getDefaultIsolationScope()) {
112
112
  DEBUG_BUILD && debug.warn("Isolation scope is default isolation scope - skipping setting transactionName");
113
113
  } else if (route) {
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/koa/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-koa\n * - Upstream version: @opentelemetry/instrumentation-koa@0.66.0\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n * - Span creation migrated to the @sentry/core API; op/origin/name and transaction name folded into\n * span creation (previously set via a Sentry requestHook)\n */\n\nimport * as api from '@opentelemetry/api';\nimport { isWrapped, InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\n\nimport { KoaLayerType, type KoaInstrumentationConfig } from './types';\nimport {\n debug,\n getDefaultIsolationScope,\n getIsolationScope,\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startSpan,\n} from '@sentry/core';\nimport { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\nimport { getMiddlewareMetadata, isLayerIgnored } from './utils';\nimport { setHttpServerSpanRouteAttribute } from '../../../../utils/setHttpServerSpanRouteAttribute';\nimport { DEBUG_BUILD } from '../../../../debug-build';\nimport { AttributeNames } from './enums/AttributeNames';\nimport {\n kLayerPatched,\n type Next,\n type KoaContext,\n type KoaMiddleware,\n type KoaPatchedMiddleware,\n} from './internal-types';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-koa';\n\ninterface KoaModuleExports {\n prototype: { use: KoaMiddleware };\n}\n\ntype KoaModule = KoaModuleExports & { [Symbol.toStringTag]?: string; default?: KoaModuleExports };\n\n/** Koa instrumentation for OpenTelemetry */\nexport class KoaInstrumentation extends InstrumentationBase<KoaInstrumentationConfig> {\n constructor(config: KoaInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init() {\n return new InstrumentationNodeModuleDefinition(\n 'koa',\n ['>=2.0.0 <4'],\n (module: KoaModule) => {\n const moduleExports =\n module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n if (moduleExports == null) {\n return moduleExports;\n }\n if (isWrapped(moduleExports.prototype.use)) {\n this._unwrap(moduleExports.prototype, 'use');\n }\n this._wrap(moduleExports.prototype, 'use', this._getKoaUsePatch.bind(this));\n return module;\n },\n (module: KoaModule) => {\n const moduleExports =\n module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n if (moduleExports && isWrapped(moduleExports.prototype.use)) {\n this._unwrap(moduleExports.prototype, 'use');\n }\n },\n );\n }\n\n /**\n * Patches the Koa.use function in order to instrument each original\n * middleware layer which is introduced\n * @param {KoaMiddleware} middleware - the original middleware function\n */\n private _getKoaUsePatch(original: (middleware: KoaMiddleware) => unknown) {\n const patchRouterDispatch = this._patchRouterDispatch.bind(this);\n const patchLayer = this._patchLayer.bind(this);\n return function use(this: unknown, middlewareFunction: KoaMiddleware) {\n const patchedFunction = middlewareFunction.router\n ? patchRouterDispatch(middlewareFunction)\n : patchLayer(middlewareFunction, false);\n return original.apply(this, [patchedFunction]);\n };\n }\n\n /**\n * Patches the dispatch function used by @koa/router. This function\n * goes through each routed middleware and adds instrumentation via a call\n * to the @function _patchLayer function.\n * @param {KoaMiddleware} dispatchLayer - the original dispatch function which dispatches\n * routed middleware\n */\n private _patchRouterDispatch(dispatchLayer: KoaMiddleware): KoaMiddleware {\n const router = dispatchLayer.router;\n\n const routesStack = router?.stack ?? [];\n for (const pathLayer of routesStack) {\n const path = pathLayer.path;\n const pathStack = pathLayer.stack;\n for (let j = 0; j < pathStack.length; j++) {\n const routedMiddleware: KoaMiddleware = pathStack[j]!;\n pathStack[j] = this._patchLayer(routedMiddleware, true, path);\n }\n }\n\n return dispatchLayer;\n }\n\n /**\n * Patches each individual @param middlewareLayer function in order to create the\n * span and propagate context. It does not create spans when there is no parent span.\n * @param {KoaMiddleware} middlewareLayer - the original middleware function.\n * @param {boolean} isRouter - tracks whether the original middleware function\n * was dispatched by the router originally\n * @param {string?} layerPath - if present, provides additional data from the\n * router about the routed path which the middleware is attached to\n */\n private _patchLayer(\n middlewareLayer: KoaPatchedMiddleware,\n isRouter: boolean,\n layerPath?: string | RegExp,\n ): KoaMiddleware {\n const layerType = isRouter ? KoaLayerType.ROUTER : KoaLayerType.MIDDLEWARE;\n // Skip patching layer if its ignored in the config\n if (middlewareLayer[kLayerPatched] === true || isLayerIgnored(layerType, this.getConfig())) return middlewareLayer;\n\n if (\n middlewareLayer.constructor.name === 'GeneratorFunction' ||\n middlewareLayer.constructor.name === 'AsyncGeneratorFunction'\n ) {\n return middlewareLayer;\n }\n\n middlewareLayer[kLayerPatched] = true;\n\n return (context: KoaContext, next: Next) => {\n const parent = api.trace.getSpan(api.context.active());\n if (parent === undefined) {\n return middlewareLayer(context, next);\n }\n const metadata = getMiddlewareMetadata(context, middlewareLayer, isRouter, layerPath);\n\n if (context._matchedRoute) {\n setHttpServerSpanRouteAttribute(context._matchedRoute.toString());\n }\n\n const koaName = metadata.attributes[AttributeNames.KOA_NAME];\n // Somehow, name is sometimes `''` for middleware spans\n // See: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2220\n const name = typeof koaName === 'string' ? koaName || '< unknown >' : metadata.name;\n\n return startSpan(\n {\n name,\n op: `${layerType}.koa`,\n attributes: {\n ...metadata.attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.koa',\n },\n },\n () => {\n const route = metadata.attributes[ATTR_HTTP_ROUTE];\n if (getIsolationScope() === getDefaultIsolationScope()) {\n DEBUG_BUILD && debug.warn('Isolation scope is default isolation scope - skipping setting transactionName');\n } else if (route) {\n const method = (context.request as { method?: string } | undefined)?.method?.toUpperCase() || 'GET';\n getIsolationScope().setTransactionName(`${method} ${route}`);\n }\n return middlewareLayer(context, next);\n },\n );\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqCA,MAAM,YAAA,GAAe,6BAAA;AASd,MAAM,2BAA2B,mBAAA,CAA8C;AAAA,EACpF,WAAA,CAAY,MAAA,GAAmC,EAAC,EAAG;AACjD,IAAA,KAAA,CAAM,YAAA,EAAc,aAAa,MAAM,CAAA;AAAA,EACzC;AAAA,EAEU,IAAA,GAAO;AACf,IAAA,OAAO,IAAI,mCAAA;AAAA,MACT,KAAA;AAAA,MACA,CAAC,YAAY,CAAA;AAAA,MACb,CAAC,MAAA,KAAsB;AACrB,QAAA,MAAM,gBACJ,MAAA,CAAO,MAAA,CAAO,WAAW,CAAA,KAAM,QAAA,GAC3B,OAAO,OAAA,GACP,MAAA;AACN,QAAA,IAAI,iBAAiB,IAAA,EAAM;AACzB,UAAA,OAAO,aAAA;AAAA,QACT;AACA,QAAA,IAAI,SAAA,CAAU,aAAA,CAAc,SAAA,CAAU,GAAG,CAAA,EAAG;AAC1C,UAAA,IAAA,CAAK,OAAA,CAAQ,aAAA,CAAc,SAAA,EAAW,KAAK,CAAA;AAAA,QAC7C;AACA,QAAA,IAAA,CAAK,KAAA,CAAM,cAAc,SAAA,EAAW,KAAA,EAAO,KAAK,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAC,CAAA;AAC1E,QAAA,OAAO,MAAA;AAAA,MACT,CAAA;AAAA,MACA,CAAC,MAAA,KAAsB;AACrB,QAAA,MAAM,gBACJ,MAAA,CAAO,MAAA,CAAO,WAAW,CAAA,KAAM,QAAA,GAC3B,OAAO,OAAA,GACP,MAAA;AACN,QAAA,IAAI,aAAA,IAAiB,SAAA,CAAU,aAAA,CAAc,SAAA,CAAU,GA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,CAAA,IAAA,CAAA;AAAA,UAChB,UAAA,EAAY;AAAA,YACV,GAAG,QAAA,CAAS,UAAA;AAAA,YACZ,CAAC,gCAAgC,GAAG;AAAA;AACtC,SACF;AAAA,QACA,MAAM;AACJ,UAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,UAAA,CAAW,eAAe,CAAA;AACjD,UAAA,IAAI,iBAAA,EAAkB,KAAM,wBAAA,EAAyB,EAAG;AACtD,YAAA,WAAA,IAAe,KAAA,CAAM,KAAK,+EAA+E,CAAA;AAAA,UAC3G,WAAW,KAAA,EAAO;AAChB,YAAA,MAAM,MAAA,GAAU,OAAA,CAAQ,OAAA,EAA6C,MAAA,EAAQ,aAAY,IAAK,KAAA;AAC9F,YAAA,iBAAA,GAAoB,kBAAA,CAAmB,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,CAAA;AAAA,UAC7D;AACA,UAAA,OAAO,eAAA,CAAgB,SAAS,IAAI,CAAA;AAAA,QACtC;AAAA,OACF;AAAA,IACF,CAAA;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/koa/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-koa\n * - Upstream version: @opentelemetry/instrumentation-koa@0.66.0\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n * - Span creation migrated to the @sentry/core API; op/origin/name and transaction name folded into\n * span creation (previously set via a Sentry requestHook)\n */\n\nimport * as api from '@opentelemetry/api';\nimport { isWrapped, InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\n\nimport { KoaLayerType, type KoaInstrumentationConfig } from './types';\nimport {\n debug,\n getDefaultIsolationScope,\n getIsolationScope,\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startSpan,\n} from '@sentry/core';\nimport { HTTP_ROUTE } from '@sentry/conventions/attributes';\nimport { getMiddlewareMetadata, isLayerIgnored } from './utils';\nimport { setHttpServerSpanRouteAttribute } from '../../../../utils/setHttpServerSpanRouteAttribute';\nimport { DEBUG_BUILD } from '../../../../debug-build';\nimport { AttributeNames } from './enums/AttributeNames';\nimport {\n kLayerPatched,\n type Next,\n type KoaContext,\n type KoaMiddleware,\n type KoaPatchedMiddleware,\n} from './internal-types';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-koa';\n\ninterface KoaModuleExports {\n prototype: { use: KoaMiddleware };\n}\n\ntype KoaModule = KoaModuleExports & { [Symbol.toStringTag]?: string; default?: KoaModuleExports };\n\n/** Koa instrumentation for OpenTelemetry */\nexport class KoaInstrumentation extends InstrumentationBase<KoaInstrumentationConfig> {\n constructor(config: KoaInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init() {\n return new InstrumentationNodeModuleDefinition(\n 'koa',\n ['>=2.0.0 <4'],\n (module: KoaModule) => {\n const moduleExports =\n module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n if (moduleExports == null) {\n return moduleExports;\n }\n if (isWrapped(moduleExports.prototype.use)) {\n this._unwrap(moduleExports.prototype, 'use');\n }\n this._wrap(moduleExports.prototype, 'use', this._getKoaUsePatch.bind(this));\n return module;\n },\n (module: KoaModule) => {\n const moduleExports =\n module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n if (moduleExports && isWrapped(moduleExports.prototype.use)) {\n this._unwrap(moduleExports.prototype, 'use');\n }\n },\n );\n }\n\n /**\n * Patches the Koa.use function in order to instrument each original\n * middleware layer which is introduced\n * @param {KoaMiddleware} middleware - the original middleware function\n */\n private _getKoaUsePatch(original: (middleware: KoaMiddleware) => unknown) {\n const patchRouterDispatch = this._patchRouterDispatch.bind(this);\n const patchLayer = this._patchLayer.bind(this);\n return function use(this: unknown, middlewareFunction: KoaMiddleware) {\n const patchedFunction = middlewareFunction.router\n ? patchRouterDispatch(middlewareFunction)\n : patchLayer(middlewareFunction, false);\n return original.apply(this, [patchedFunction]);\n };\n }\n\n /**\n * Patches the dispatch function used by @koa/router. This function\n * goes through each routed middleware and adds instrumentation via a call\n * to the @function _patchLayer function.\n * @param {KoaMiddleware} dispatchLayer - the original dispatch function which dispatches\n * routed middleware\n */\n private _patchRouterDispatch(dispatchLayer: KoaMiddleware): KoaMiddleware {\n const router = dispatchLayer.router;\n\n const routesStack = router?.stack ?? [];\n for (const pathLayer of routesStack) {\n const path = pathLayer.path;\n const pathStack = pathLayer.stack;\n for (let j = 0; j < pathStack.length; j++) {\n const routedMiddleware: KoaMiddleware = pathStack[j]!;\n pathStack[j] = this._patchLayer(routedMiddleware, true, path);\n }\n }\n\n return dispatchLayer;\n }\n\n /**\n * Patches each individual @param middlewareLayer function in order to create the\n * span and propagate context. It does not create spans when there is no parent span.\n * @param {KoaMiddleware} middlewareLayer - the original middleware function.\n * @param {boolean} isRouter - tracks whether the original middleware function\n * was dispatched by the router originally\n * @param {string?} layerPath - if present, provides additional data from the\n * router about the routed path which the middleware is attached to\n */\n private _patchLayer(\n middlewareLayer: KoaPatchedMiddleware,\n isRouter: boolean,\n layerPath?: string | RegExp,\n ): KoaMiddleware {\n const layerType = isRouter ? KoaLayerType.ROUTER : KoaLayerType.MIDDLEWARE;\n // Skip patching layer if its ignored in the config\n if (middlewareLayer[kLayerPatched] === true || isLayerIgnored(layerType, this.getConfig())) return middlewareLayer;\n\n if (\n middlewareLayer.constructor.name === 'GeneratorFunction' ||\n middlewareLayer.constructor.name === 'AsyncGeneratorFunction'\n ) {\n return middlewareLayer;\n }\n\n middlewareLayer[kLayerPatched] = true;\n\n return (context: KoaContext, next: Next) => {\n const parent = api.trace.getSpan(api.context.active());\n if (parent === undefined) {\n return middlewareLayer(context, next);\n }\n const metadata = getMiddlewareMetadata(context, middlewareLayer, isRouter, layerPath);\n\n if (context._matchedRoute) {\n setHttpServerSpanRouteAttribute(context._matchedRoute.toString());\n }\n\n const koaName = metadata.attributes[AttributeNames.KOA_NAME];\n // Somehow, name is sometimes `''` for middleware spans\n // See: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2220\n const name = typeof koaName === 'string' ? koaName || '< unknown >' : metadata.name;\n\n return startSpan(\n {\n name,\n op: `${layerType}.koa`,\n attributes: {\n ...metadata.attributes,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.koa',\n },\n },\n () => {\n const route = metadata.attributes[HTTP_ROUTE];\n if (getIsolationScope() === getDefaultIsolationScope()) {\n DEBUG_BUILD && debug.warn('Isolation scope is default isolation scope - skipping setting transactionName');\n } else if (route) {\n const method = (context.request as { method?: string } | undefined)?.method?.toUpperCase() || 'GET';\n getIsolationScope().setTransactionName(`${method} ${route}`);\n }\n return middlewareLayer(context, next);\n },\n );\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAqCA,MAAM,YAAA,GAAe,6BAAA;AASd,MAAM,2BAA2B,mBAAA,CAA8C;AAAA,EACpF,WAAA,CAAY,MAAA,GAAmC,EAAC,EAAG;AACjD,IAAA,KAAA,CAAM,YAAA,EAAc,aAAa,MAAM,CAAA;AAAA,EACzC;AAAA,EAEU,IAAA,GAAO;AACf,IAAA,OAAO,IAAI,mCAAA;AAAA,MACT,KAAA;AAAA,MACA,CAAC,YAAY,CAAA;AAAA,MACb,CAAC,MAAA,KAAsB;AACrB,QAAA,MAAM,gBACJ,MAAA,CAAO,MAAA,CAAO,WAAW,CAAA,KAAM,QAAA,GAC3B,OAAO,OAAA,GACP,MAAA;AACN,QAAA,IAAI,iBAAiB,IAAA,EAAM;AACzB,UAAA,OAAO,aAAA;AAAA,QACT;AACA,QAAA,IAAI,SAAA,CAAU,aAAA,CAAc,SAAA,CAAU,GAAG,CAAA,EAAG;AAC1C,UAA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conventions';
3
+ import { HTTP_ROUTE } from '@sentry/conventions/attributes';
4
4
 
5
5
  const getMiddlewareMetadata = (context, layer, isRouter, layerPath) => {
6
6
  if (isRouter) {
@@ -8,7 +8,7 @@ const getMiddlewareMetadata = (context, layer, isRouter, layerPath) => {
8
8
  attributes: {
9
9
  [AttributeNames.KOA_NAME]: layerPath?.toString(),
10
10
  [AttributeNames.KOA_TYPE]: KoaLayerType.ROUTER,
11
- [ATTR_HTTP_ROUTE]: layerPath?.toString()
11
+ [HTTP_ROUTE]: layerPath?.toString()
12
12
  },
13
13
  name: context._matchedRouteName || `router - ${layerPath}`
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/koa/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-koa\n * - Upstream version: @opentelemetry/instrumentation-koa@0.66.0\n */\n\nimport { KoaLayerType, type KoaInstrumentationConfig } from './types';\nimport type { KoaContext, KoaMiddleware } from './internal-types';\nimport { AttributeNames } from './enums/AttributeNames';\nimport type { Attributes } from '@opentelemetry/api';\nimport { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\n\nexport const getMiddlewareMetadata = (\n context: KoaContext,\n layer: KoaMiddleware,\n isRouter: boolean,\n layerPath?: string | RegExp,\n): {\n attributes: Attributes;\n name: string;\n} => {\n if (isRouter) {\n return {\n attributes: {\n [AttributeNames.KOA_NAME]: layerPath?.toString(),\n [AttributeNames.KOA_TYPE]: KoaLayerType.ROUTER,\n [ATTR_HTTP_ROUTE]: layerPath?.toString(),\n },\n name: context._matchedRouteName || `router - ${layerPath}`,\n };\n } else {\n return {\n attributes: {\n [AttributeNames.KOA_NAME]: layer.name ?? 'middleware',\n [AttributeNames.KOA_TYPE]: KoaLayerType.MIDDLEWARE,\n },\n name: `middleware - ${layer.name}`,\n };\n }\n};\n\n/**\n * Check whether the given request is ignored by configuration\n * @param [list] List of ignore patterns\n * @param [onException] callback for doing something when an exception has\n * occurred\n */\nexport const isLayerIgnored = (type: KoaLayerType, config?: KoaInstrumentationConfig): boolean => {\n return !!(Array.isArray(config?.ignoreLayersType) && config?.ignoreLayersType?.includes(type));\n};\n"],"names":[],"mappings":";;;;AAeO,MAAM,qBAAA,GAAwB,CACnC,OAAA,EACA,KAAA,EACA,UACA,SAAA,KAIG;AACH,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,OAAO;AAAA,MACL,UAAA,EAAY;AAAA,QACV,CAAC,cAAA,CAAe,QAAQ,GAAG,WAAW,QAAA,EAAS;AAAA,QAC/C,CAAC,cAAA,CAAe,QAAQ,GAAG,YAAA,CAAa,MAAA;AAAA,QACxC,CAAC,eAAe,GAAG,SAAA,EAAW,QAAA;AAAS,OACzC;AAAA,MACA,IAAA,EAAM,OAAA,CAAQ,iBAAA,IAAqB,CAAA,SAAA,EAAY,SAAS,CAAA;AAAA,KAC1D;AAAA,EACF,CAAA,MAAO;AACL,IAAA,OAAO;AAAA,MACL,UAAA,EAAY;AAAA,QACV,CAAC,cAAA,CAAe,QAAQ,GAAG,MAAM,IAAA,IAAQ,YAAA;AAAA,QACzC,CAAC,cAAA,CAAe,QAAQ,GAAG,YAAA,CAAa;AAAA,OAC1C;AAAA,MACA,IAAA,EAAM,CAAA,aAAA,EAAgB,KAAA,CAAM,IAAI,CAAA;AAAA,KAClC;AAAA,EACF;AACF;AAQO,MAAM,cAAA,GAAiB,CAAC,IAAA,EAAoB,MAAA,KAA+C;AAChG,EAAA,OAAO,CAAC,EAAE,KAAA,CAAM,OAAA,CAAQ,MAAA,EAAQ,gBAAgB,CAAA,IAAK,MAAA,EAAQ,gBAAA,EAAkB,QAAA,CAAS,IAAI,CAAA,CAAA;AAC9F;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/koa/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-koa\n * - Upstream version: @opentelemetry/instrumentation-koa@0.66.0\n */\n\nimport { KoaLayerType, type KoaInstrumentationConfig } from './types';\nimport type { KoaContext, KoaMiddleware } from './internal-types';\nimport { AttributeNames } from './enums/AttributeNames';\nimport type { Attributes } from '@opentelemetry/api';\nimport { HTTP_ROUTE } from '@sentry/conventions/attributes';\n\nexport const getMiddlewareMetadata = (\n context: KoaContext,\n layer: KoaMiddleware,\n isRouter: boolean,\n layerPath?: string | RegExp,\n): {\n attributes: Attributes;\n name: string;\n} => {\n if (isRouter) {\n return {\n attributes: {\n [AttributeNames.KOA_NAME]: layerPath?.toString(),\n [AttributeNames.KOA_TYPE]: KoaLayerType.ROUTER,\n [HTTP_ROUTE]: layerPath?.toString(),\n },\n name: context._matchedRouteName || `router - ${layerPath}`,\n };\n } else {\n return {\n attributes: {\n [AttributeNames.KOA_NAME]: layer.name ?? 'middleware',\n [AttributeNames.KOA_TYPE]: KoaLayerType.MIDDLEWARE,\n },\n name: `middleware - ${layer.name}`,\n };\n }\n};\n\n/**\n * Check whether the given request is ignored by configuration\n * @param [list] List of ignore patterns\n * @param [onException] callback for doing something when an exception has\n * occurred\n */\nexport const isLayerIgnored = (type: KoaLayerType, config?: KoaInstrumentationConfig): boolean => {\n return !!(Array.isArray(config?.ignoreLayersType) && config?.ignoreLayersType?.includes(type));\n};\n"],"names":[],"mappings":";;;;AAeO,MAAM,qBAAA,GAAwB,CACnC,OAAA,EACA,KAAA,EACA,UACA,SAAA,KAIG;AACH,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,OAAO;AAAA,MACL,UAAA,EAAY;AAAA,QACV,CAAC,cAAA,CAAe,QAAQ,GAAG,WAAW,QAAA,EAAS;AAAA,QAC/C,CAAC,cAAA,CAAe,QAAQ,GAAG,YAAA,CAAa,MAAA;AAAA,QACxC,CAAC,UAAU,GAAG,SAAA,EAAW,QAAA;AAAS,OACpC;AAAA,MACA,IAAA,EAAM,OAAA,CAAQ,iBAAA,IAAqB,CAAA,SAAA,EAAY,SAAS,CAAA;AAAA,KAC1D;AAAA,EACF,CAAA,MAAO;AACL,IAAA,OAAO;AAAA,MACL,UAAA,EAAY;AAAA,QACV,CAAC,cAAA,CAAe,QAAQ,GAAG,MAAM,IAAA,IAAQ,YAAA;AAAA,QACzC,CAAC,cAAA,CAAe,QAAQ,GAAG,YAAA,CAAa;AAAA,OAC1C;AAAA,MACA,IAAA,EAAM,CAAA,aAAA,EAAgB,KAAA,CAAM,IAAI,CAAA;AAAA,KAClC;AAAA,EACF;AACF;AAQO,MAAM,cAAA,GAAiB,CAAC,IAAA,EAAoB,MAAA,KAA+C;AAChG,EAAA,OAAO,CAAC,EAAE,KAAA,CAAM,OAAA,CAAQ,MAAA,EAAQ,gBAAgB,CAAA,IAAK,MAAA,EAAQ,gBAAA,EAAkB,QAAA,CAAS,IAAI,CAAA,CAAA;AAC9F;;;;"}
@@ -1,12 +1,6 @@
1
1
  const ATTR_DB_CONNECTION_STRING = "db.connection_string";
2
2
  const ATTR_DB_MONGODB_COLLECTION = "db.mongodb.collection";
3
- const ATTR_DB_NAME = "db.name";
4
- const ATTR_DB_OPERATION = "db.operation";
5
- const ATTR_DB_STATEMENT = "db.statement";
6
- const ATTR_DB_SYSTEM = "db.system";
7
- const ATTR_NET_PEER_NAME = "net.peer.name";
8
- const ATTR_NET_PEER_PORT = "net.peer.port";
9
3
  const DB_SYSTEM_VALUE_MONGODB = "mongodb";
10
4
 
11
- export { ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION, ATTR_DB_NAME, ATTR_DB_OPERATION, ATTR_DB_STATEMENT, ATTR_DB_SYSTEM, ATTR_NET_PEER_NAME, ATTR_NET_PEER_PORT, DB_SYSTEM_VALUE_MONGODB };
5
+ export { ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION, DB_SYSTEM_VALUE_MONGODB };
12
6
  //# sourceMappingURL=semconv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semconv.js","sources":["../../../../../../src/integrations/tracing/mongo/vendored/semconv.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongodb\n * - Upstream version: @opentelemetry/instrumentation-mongodb@0.71.0\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * Deprecated, use `server.address`, `server.port` attributes instead.\n *\n * @deprecated Replaced by `server.address` and `server.port`.\n */\nexport const ATTR_DB_CONNECTION_STRING = 'db.connection_string' as const;\n\n/**\n * Deprecated, use `db.collection.name` instead.\n *\n * @deprecated Replaced by `db.collection.name`.\n */\nexport const ATTR_DB_MONGODB_COLLECTION = 'db.mongodb.collection' as const;\n\n/**\n * Deprecated, use `db.namespace` instead.\n *\n * @deprecated Replaced by `db.namespace`.\n */\nexport const ATTR_DB_NAME = 'db.name' as const;\n\n/**\n * Deprecated, use `db.operation.name` instead.\n *\n * @deprecated Replaced by `db.operation.name`.\n */\nexport const ATTR_DB_OPERATION = 'db.operation' as const;\n\n/**\n * The database statement being executed.\n *\n * @deprecated Replaced by `db.query.text`.\n */\nexport const ATTR_DB_STATEMENT = 'db.statement' as const;\n\n/**\n * Deprecated, use `db.system.name` instead.\n *\n * @deprecated Replaced by `db.system.name`.\n */\nexport const ATTR_DB_SYSTEM = 'db.system' as const;\n\n/**\n * Deprecated, use `server.address` on client spans and `client.address` on server spans.\n *\n * @deprecated Replaced by `server.address` on client spans and `client.address` on server spans.\n */\nexport const ATTR_NET_PEER_NAME = 'net.peer.name' as const;\n\n/**\n * Deprecated, use `server.port` on client spans and `client.port` on server spans.\n *\n * @deprecated Replaced by `server.port` on client spans and `client.port` on server spans.\n */\nexport const ATTR_NET_PEER_PORT = 'net.peer.port' as const;\n\n/**\n * Enum value \"mongodb\" for attribute {@link ATTR_DB_SYSTEM}.\n */\nexport const DB_SYSTEM_VALUE_MONGODB = 'mongodb' as const;\n"],"names":[],"mappings":"AAoBO,MAAM,yBAAA,GAA4B;AAOlC,MAAM,0BAAA,GAA6B;AAOnC,MAAM,YAAA,GAAe;AAOrB,MAAM,iBAAA,GAAoB;AAO1B,MAAM,iBAAA,GAAoB;AAO1B,MAAM,cAAA,GAAiB;AAOvB,MAAM,kBAAA,GAAqB;AAO3B,MAAM,kBAAA,GAAqB;AAK3B,MAAM,uBAAA,GAA0B;;;;"}
1
+ {"version":3,"file":"semconv.js","sources":["../../../../../../src/integrations/tracing/mongo/vendored/semconv.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongodb\n * - Upstream version: @opentelemetry/instrumentation-mongodb@0.71.0\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * Deprecated, use `server.address`, `server.port` attributes instead.\n *\n * @deprecated Replaced by `server.address` and `server.port`.\n */\nexport const ATTR_DB_CONNECTION_STRING = 'db.connection_string' as const;\n\n/**\n * Deprecated, use `db.collection.name` instead.\n *\n * @deprecated Replaced by `db.collection.name`.\n */\nexport const ATTR_DB_MONGODB_COLLECTION = 'db.mongodb.collection' as const;\n\n/**\n * Enum value \"mongodb\" for attribute `db.system`.\n */\nexport const DB_SYSTEM_VALUE_MONGODB = 'mongodb' as const;\n"],"names":[],"mappings":"AAoBO,MAAM,yBAAA,GAA4B;AAOlC,MAAM,0BAAA,GAA6B;AAKnC,MAAM,uBAAA,GAA0B;;;;"}
@@ -1,5 +1,6 @@
1
1
  import { getActiveSpan, startInactiveSpan, SPAN_KIND, SPAN_STATUS_ERROR, withActiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
2
- import { ATTR_DB_OPERATION, DB_SYSTEM_VALUE_MONGODB, ATTR_NET_PEER_NAME, ATTR_NET_PEER_PORT, ATTR_DB_STATEMENT, ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION, ATTR_DB_NAME, ATTR_DB_SYSTEM } from './semconv.js';
2
+ import { DB_OPERATION, NET_PEER_NAME, NET_PEER_PORT, DB_STATEMENT, DB_NAME, DB_SYSTEM } from '@sentry/conventions/attributes';
3
+ import { DB_SYSTEM_VALUE_MONGODB, ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION } from './semconv.js';
3
4
  import { MongodbCommandType } from './internal-types.js';
4
5
 
5
6
  const ORIGIN = "auto.db.otel.mongo";
@@ -87,26 +88,26 @@ function getSpanAttributes(dbName, dbCollection, host, port, commandObj, operati
87
88
  const attributes = {
88
89
  [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
89
90
  // eslint-disable-next-line typescript/no-deprecated
90
- [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_MONGODB,
91
+ [DB_SYSTEM]: DB_SYSTEM_VALUE_MONGODB,
91
92
  // eslint-disable-next-line typescript/no-deprecated
92
- [ATTR_DB_NAME]: dbName,
93
+ [DB_NAME]: dbName,
93
94
  // eslint-disable-next-line typescript/no-deprecated
94
95
  [ATTR_DB_MONGODB_COLLECTION]: dbCollection,
95
96
  // eslint-disable-next-line typescript/no-deprecated
96
- [ATTR_DB_OPERATION]: operation,
97
+ [DB_OPERATION]: operation,
97
98
  // eslint-disable-next-line typescript/no-deprecated
98
99
  [ATTR_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`
99
100
  };
100
101
  if (host && port) {
101
- attributes[ATTR_NET_PEER_NAME] = host;
102
+ attributes[NET_PEER_NAME] = host;
102
103
  const portNumber = parseInt(port, 10);
103
104
  if (!isNaN(portNumber)) {
104
- attributes[ATTR_NET_PEER_PORT] = portNumber;
105
+ attributes[NET_PEER_PORT] = portNumber;
105
106
  }
106
107
  }
107
108
  if (commandObj) {
108
109
  try {
109
- attributes[ATTR_DB_STATEMENT] = serializeDbStatement(commandObj);
110
+ attributes[DB_STATEMENT] = serializeDbStatement(commandObj);
110
111
  } catch {
111
112
  }
112
113
  }
@@ -115,7 +116,7 @@ function getSpanAttributes(dbName, dbCollection, host, port, commandObj, operati
115
116
  function startMongoSpan(attributes) {
116
117
  return startInactiveSpan({
117
118
  // eslint-disable-next-line typescript/no-deprecated
118
- name: `mongodb.${attributes[ATTR_DB_OPERATION] || "command"}`,
119
+ name: `mongodb.${attributes[DB_OPERATION] || "command"}`,
119
120
  kind: SPAN_KIND.CLIENT,
120
121
  attributes
121
122
  });
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/mongo/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongodb\n * - Upstream version: @opentelemetry/instrumentation-mongodb@0.71.0\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport {\n ATTR_DB_CONNECTION_STRING,\n ATTR_DB_MONGODB_COLLECTION,\n ATTR_DB_NAME,\n ATTR_DB_OPERATION,\n ATTR_DB_STATEMENT,\n ATTR_DB_SYSTEM,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n DB_SYSTEM_VALUE_MONGODB,\n} from './semconv';\nimport type { MongodbNamespace, MongoInternalCommand, MongoInternalTopology } from './internal-types';\nimport { MongodbCommandType } from './internal-types';\n\nconst ORIGIN = 'auto.db.otel.mongo';\n\n/**\n * Replaces values in the command object with '?', hiding PII and helping grouping.\n */\nfunction serializeDbStatement(commandObj: Record<string, unknown>): string {\n return JSON.stringify(scrubStatement(commandObj));\n}\n\nfunction scrubStatement(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(element => scrubStatement(element));\n }\n\n if (isCommandObj(value)) {\n const initial: Record<string, unknown> = {};\n return Object.entries(value)\n .map(([key, element]) => [key, scrubStatement(element)])\n .reduce((prev, current) => {\n if (isCommandEntry(current)) {\n prev[current[0]] = current[1];\n }\n return prev;\n }, initial);\n }\n\n // A value like string or number, possibly contains PII, scrub it\n return '?';\n}\n\nfunction isCommandObj(value: Record<string, unknown> | unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !isBuffer(value);\n}\n\nfunction isBuffer(value: unknown): boolean {\n return typeof Buffer !== 'undefined' && Buffer.isBuffer(value);\n}\n\nfunction isCommandEntry(value: [string, unknown] | unknown): value is [string, unknown] {\n return Array.isArray(value);\n}\n\n/**\n * Get the mongodb command type from the object.\n */\nexport function getCommandType(command: MongoInternalCommand): MongodbCommandType {\n if (command.createIndexes !== undefined) {\n return MongodbCommandType.CREATE_INDEXES;\n } else if (command.findandmodify !== undefined) {\n return MongodbCommandType.FIND_AND_MODIFY;\n } else if (command.ismaster !== undefined) {\n return MongodbCommandType.IS_MASTER;\n } else if (command.count !== undefined) {\n return MongodbCommandType.COUNT;\n } else if (command.aggregate !== undefined) {\n return MongodbCommandType.AGGREGATE;\n } else {\n return MongodbCommandType.UNKNOWN;\n }\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v4 connection context.\n */\nexport function getV4SpanAttributes(\n connectionCtx: any,\n ns: MongodbNamespace,\n command?: any,\n operation?: string,\n): SpanAttributes {\n let host, port: undefined | string;\n if (connectionCtx) {\n const hostParts = typeof connectionCtx.address === 'string' ? connectionCtx.address.split(':') : '';\n if (hostParts.length === 2) {\n host = hostParts[0];\n port = hostParts[1];\n }\n }\n let commandObj: Record<string, unknown>;\n if (command?.documents && command.documents[0]) {\n commandObj = command.documents[0];\n } else if (command?.cursors) {\n commandObj = command.cursors;\n } else {\n commandObj = command;\n }\n\n return getSpanAttributes(ns.db, ns.collection, host, port, commandObj, operation);\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v3 topology.\n */\nexport function getV3SpanAttributes(\n ns: string,\n topology: MongoInternalTopology,\n command?: MongoInternalCommand,\n operation?: string | undefined,\n): SpanAttributes {\n let host: undefined | string;\n let port: undefined | string;\n if (topology?.s) {\n host = topology.s.options?.host ?? topology.s.host;\n port = (topology.s.options?.port ?? topology.s.port)?.toString();\n if (host == null || port == null) {\n const address = topology.description?.address;\n if (address) {\n const addressSegments = address.split(':');\n host = addressSegments[0];\n port = addressSegments[1];\n }\n }\n }\n\n // The namespace is a combination of the database name and the name of the\n // collection or index, like so: [database-name].[collection-or-index-name].\n // It could be a string or an instance of MongoDBNamespace, as such we\n // always coerce to a string to extract db and collection.\n const [dbName, dbCollection] = ns.toString().split('.');\n const commandObj = command?.query ?? command?.q ?? command;\n\n return getSpanAttributes(dbName, dbCollection, host, port, commandObj, operation);\n}\n\nfunction getSpanAttributes(\n dbName?: string,\n dbCollection?: string,\n host?: undefined | string,\n port?: undefined | string,\n commandObj?: any,\n operation?: string | undefined,\n): SpanAttributes {\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_MONGODB,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_NAME]: dbName,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_MONGODB_COLLECTION]: dbCollection,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_OPERATION]: operation,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`,\n };\n\n if (host && port) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[ATTR_NET_PEER_NAME] = host;\n const portNumber = parseInt(port, 10);\n if (!isNaN(portNumber)) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[ATTR_NET_PEER_PORT] = portNumber;\n }\n }\n\n if (commandObj) {\n try {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[ATTR_DB_STATEMENT] = serializeDbStatement(commandObj);\n } catch {\n // ignore serialization errors — the statement is best-effort metadata\n }\n }\n\n return attributes;\n}\n\nexport function startMongoSpan(attributes: SpanAttributes): Span {\n return startInactiveSpan({\n // eslint-disable-next-line typescript/no-deprecated\n name: `mongodb.${attributes[ATTR_DB_OPERATION] || 'command'}`,\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n}\n\n/**\n * Wraps the result handler so it ends the span (with error status on failure) and runs the\n * original callback re-activated under the parent span — mongodb loses the async context when\n * it invokes the callback on a later tick.\n */\nexport function patchEnd(span: Span | undefined, resultHandler: Function): Function {\n const parentSpan = getActiveSpan();\n let spanEnded = false;\n\n return function patchedEnd(this: {}, ...args: unknown[]) {\n if (!spanEnded) {\n spanEnded = true;\n const error = args[0];\n if (span) {\n if (error instanceof Error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n }\n }\n\n return withActiveSpan(parentSpan ?? null, () => resultHandler.apply(this, args));\n };\n}\n\n// The instrumentation only creates spans when there is an active parent span,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B,aAAA,EAAmC;AAClF,EAAA,MAAM,aAAa,aAAA,EAAc;AACjC,EAAA,IAAI,SAAA,GAAY,KAAA;AAEhB,EAAA,OAAO,SAAS,cAAwB,IAAA,EAAiB;AACvD,IAAA,IAAI,CAAC,SAAA,EAAW;AACd,MAAA,SAAA,GAAY,IAAA;AACZ,MAAA,MAAM,KAAA,GAAQ,KAAK,CAAC,CAAA;AACpB,MAAA,IAAI,IAAA,EAAM;AACR,QAAA,IAAI,iBAAiB,KAAA,EAAO;AAC1B,UAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,mBAAmB,OAAA,EAAS,KAAA,CAAM,SAAS,CAAA;AAAA,QACpE;AACA,QAAA,IAAA,CAAK,GAAA,EAAI;AAAA,MACX;AAAA,IACF;AAEA,IAAA,OAAO,cAAA,CAAe,cAAc,IAAA,EAAM,MAAM,cAAc,KAAA,CAAM,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,EACjF,CAAA;AACF;AAIO,SAAS,yBAAA,GAAqC;AACnD,EAAA,OAAO,CAAC,aAAA,EAAc;AACxB;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/mongo/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongodb\n * - Upstream version: @opentelemetry/instrumentation-mongodb@0.71.0\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport {\n DB_NAME,\n DB_OPERATION,\n DB_STATEMENT,\n DB_SYSTEM,\n NET_PEER_NAME,\n NET_PEER_PORT,\n} from '@sentry/conventions/attributes';\nimport { ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION, DB_SYSTEM_VALUE_MONGODB } from './semconv';\nimport type { MongodbNamespace, MongoInternalCommand, MongoInternalTopology } from './internal-types';\nimport { MongodbCommandType } from './internal-types';\n\nconst ORIGIN = 'auto.db.otel.mongo';\n\n/**\n * Replaces values in the command object with '?', hiding PII and helping grouping.\n */\nfunction serializeDbStatement(commandObj: Record<string, unknown>): string {\n return JSON.stringify(scrubStatement(commandObj));\n}\n\nfunction scrubStatement(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(element => scrubStatement(element));\n }\n\n if (isCommandObj(value)) {\n const initial: Record<string, unknown> = {};\n return Object.entries(value)\n .map(([key, element]) => [key, scrubStatement(element)])\n .reduce((prev, current) => {\n if (isCommandEntry(current)) {\n prev[current[0]] = current[1];\n }\n return prev;\n }, initial);\n }\n\n // A value like string or number, possibly contains PII, scrub it\n return '?';\n}\n\nfunction isCommandObj(value: Record<string, unknown> | unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !isBuffer(value);\n}\n\nfunction isBuffer(value: unknown): boolean {\n return typeof Buffer !== 'undefined' && Buffer.isBuffer(value);\n}\n\nfunction isCommandEntry(value: [string, unknown] | unknown): value is [string, unknown] {\n return Array.isArray(value);\n}\n\n/**\n * Get the mongodb command type from the object.\n */\nexport function getCommandType(command: MongoInternalCommand): MongodbCommandType {\n if (command.createIndexes !== undefined) {\n return MongodbCommandType.CREATE_INDEXES;\n } else if (command.findandmodify !== undefined) {\n return MongodbCommandType.FIND_AND_MODIFY;\n } else if (command.ismaster !== undefined) {\n return MongodbCommandType.IS_MASTER;\n } else if (command.count !== undefined) {\n return MongodbCommandType.COUNT;\n } else if (command.aggregate !== undefined) {\n return MongodbCommandType.AGGREGATE;\n } else {\n return MongodbCommandType.UNKNOWN;\n }\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v4 connection context.\n */\nexport function getV4SpanAttributes(\n connectionCtx: any,\n ns: MongodbNamespace,\n command?: any,\n operation?: string,\n): SpanAttributes {\n let host, port: undefined | string;\n if (connectionCtx) {\n const hostParts = typeof connectionCtx.address === 'string' ? connectionCtx.address.split(':') : '';\n if (hostParts.length === 2) {\n host = hostParts[0];\n port = hostParts[1];\n }\n }\n let commandObj: Record<string, unknown>;\n if (command?.documents && command.documents[0]) {\n commandObj = command.documents[0];\n } else if (command?.cursors) {\n commandObj = command.cursors;\n } else {\n commandObj = command;\n }\n\n return getSpanAttributes(ns.db, ns.collection, host, port, commandObj, operation);\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v3 topology.\n */\nexport function getV3SpanAttributes(\n ns: string,\n topology: MongoInternalTopology,\n command?: MongoInternalCommand,\n operation?: string | undefined,\n): SpanAttributes {\n let host: undefined | string;\n let port: undefined | string;\n if (topology?.s) {\n host = topology.s.options?.host ?? topology.s.host;\n port = (topology.s.options?.port ?? topology.s.port)?.toString();\n if (host == null || port == null) {\n const address = topology.description?.address;\n if (address) {\n const addressSegments = address.split(':');\n host = addressSegments[0];\n port = addressSegments[1];\n }\n }\n }\n\n // The namespace is a combination of the database name and the name of the\n // collection or index, like so: [database-name].[collection-or-index-name].\n // It could be a string or an instance of MongoDBNamespace, as such we\n // always coerce to a string to extract db and collection.\n const [dbName, dbCollection] = ns.toString().split('.');\n const commandObj = command?.query ?? command?.q ?? command;\n\n return getSpanAttributes(dbName, dbCollection, host, port, commandObj, operation);\n}\n\nfunction getSpanAttributes(\n dbName?: string,\n dbCollection?: string,\n host?: undefined | string,\n port?: undefined | string,\n commandObj?: any,\n operation?: string | undefined,\n): SpanAttributes {\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: DB_SYSTEM_VALUE_MONGODB,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_NAME]: dbName,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_MONGODB_COLLECTION]: dbCollection,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_OPERATION]: operation,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`,\n };\n\n if (host && port) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[NET_PEER_NAME] = host;\n const portNumber = parseInt(port, 10);\n if (!isNaN(portNumber)) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[NET_PEER_PORT] = portNumber;\n }\n }\n\n if (commandObj) {\n try {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[DB_STATEMENT] = serializeDbStatement(commandObj);\n } catch {\n // ignore serialization errors — the statement is best-effort metadata\n }\n }\n\n return attributes;\n}\n\nexport function startMongoSpan(attributes: SpanAttributes): Span {\n return startInactiveSpan({\n // eslint-disable-next-line typescript/no-deprecated\n name: `mongodb.${attributes[DB_OPERATION] || 'command'}`,\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n}\n\n/**\n * Wraps the result handler so it ends the span (with error status on failure) and runs the\n * original callback re-activated under the parent span — mongodb loses the async context when\n * it invokes the callback on a later tick.\n */\nexport function patchEnd(span: Span | undefined, resultHandler: Function): Function {\n const parentSpan = getActiveSpan();\n let spanEnded = false;\n\n return function patchedEnd(this: {}, ...args: unknown[]) {\n if (!spanEnded) {\n spanEnded = true;\n const error = args[0];\n if (span) {\n if (error instanceof Error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n }\n }\n\n return withActiveSpan(parentSpan ?? null, () => resultHandler.apply(this, args));\n };\n}\n\n// The instrumentation only creates spans when there is an active parent span, to avoid emitting\n// orphaned mongodb spans.\nexport function shouldSkipInstrumentation(): boolean {\n return !getActiveSpan();\n}\n"],"names":[],"mappings":";;;;;AA+BA,MAAM,MAAA,GAAS,oBAAA;AAKf,SAAS,qBAAqB,UAAA,EAA6C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W;AACd,MAAA,SAAA,GAAY,IAAA;AACZ,MAAA,MAAM,KAAA,GAAQ,KAAK,CAAC,CAAA;AACpB,MAAA,IAAI,IAAA,EAAM;AACR,QAAA,IAAI,iBAAiB,KAAA,EAAO;AAC1B,UAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,mBAAmB,OAAA,EAAS,KAAA,CAAM,SAAS,CAAA;AAAA,QACpE;AACA,QAAA,IAAA,CAAK,GAAA,EAAI;AAAA,MACX;AAAA,IACF;AAEA,IAAA,OAAO,cAAA,CAAe,cAAc,IAAA,EAAM,MAAM,cAAc,KAAA,CAAM,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,EACjF,CAAA;AACF;AAIO,SAAS,yBAAA,GAAqC;AACnD,EAAA,OAAO,CAAC,aAAA,EAAc;AACxB;;;;"}
@@ -1,16 +1,17 @@
1
1
  import { MongooseInstrumentation } from './vendored/mongoose.js';
2
- import { defineIntegration } from '@sentry/core';
2
+ import { defineIntegration, extendIntegration } from '@sentry/core';
3
3
  import { generateInstrumentOnce } from '@sentry/node-core';
4
+ import { mongooseIntegration as mongooseIntegration$1 } from '@sentry/server-utils';
4
5
 
5
6
  const INTEGRATION_NAME = "Mongoose";
6
7
  const instrumentMongoose = generateInstrumentOnce(INTEGRATION_NAME, () => new MongooseInstrumentation());
7
8
  const _mongooseIntegration = (() => {
8
- return {
9
+ return extendIntegration(mongooseIntegration$1(), {
9
10
  name: INTEGRATION_NAME,
10
11
  setupOnce() {
11
12
  instrumentMongoose();
12
13
  }
13
- };
14
+ });
14
15
  });
15
16
  const mongooseIntegration = defineIntegration(_mongooseIntegration);
16
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/mongoose/index.ts"],"sourcesContent":["import { MongooseInstrumentation } from './vendored/mongoose';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Mongoose' as const;\n\nexport const instrumentMongoose = generateInstrumentOnce(INTEGRATION_NAME, () => new MongooseInstrumentation());\n\nconst _mongooseIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentMongoose();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [mongoose](https://www.npmjs.com/package/mongoose) library.\n *\n * For more information, see the [`mongooseIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mongoose/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.mongooseIntegration()],\n * });\n * ```\n */\nexport const mongooseIntegration = defineIntegration(_mongooseIntegration);\n"],"names":[],"mappings":";;;;AAKA,MAAM,gBAAA,GAAmB,UAAA;AAElB,MAAM,qBAAqB,sBAAA,CAAuB,gBAAA,EAAkB,MAAM,IAAI,yBAAyB;AAE9G,MAAM,wBAAwB,MAAM;AAClC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,kBAAA,EAAmB;AAAA,IACrB;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,mBAAA,GAAsB,kBAAkB,oBAAoB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/mongoose/index.ts"],"sourcesContent":["import { MongooseInstrumentation } from './vendored/mongoose';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, extendIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { mongooseIntegration as mongooseChannelIntegration } from '@sentry/server-utils';\n\nconst INTEGRATION_NAME = 'Mongoose' as const;\n\nexport const instrumentMongoose = generateInstrumentOnce(INTEGRATION_NAME, () => new MongooseInstrumentation());\n\nconst _mongooseIntegration = (() => {\n // The diagnostics_channel subscription (mongoose >= 9.7) lives in server-utils so it is shared\n // across server runtimes; we extend it here to also run the IITM-based patcher for mongoose < 9.7.\n return extendIntegration(mongooseChannelIntegration(), {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentMongoose();\n },\n });\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [mongoose](https://www.npmjs.com/package/mongoose) library.\n *\n * For more information, see the [`mongooseIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mongoose/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.mongooseIntegration()],\n * });\n * ```\n */\nexport const mongooseIntegration = defineIntegration(_mongooseIntegration);\n"],"names":["mongooseChannelIntegration"],"mappings":";;;;;AAMA,MAAM,gBAAA,GAAmB,UAAA;AAElB,MAAM,qBAAqB,sBAAA,CAAuB,gBAAA,EAAkB,MAAM,IAAI,yBAAyB;AAE9G,MAAM,wBAAwB,MAAM;AAGlC,EAAA,OAAO,iBAAA,CAAkBA,uBAA2B,EAAG;AAAA,IACrD,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,kBAAA,EAAmB;AAAA,IACrB;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAgBO,MAAM,mBAAA,GAAsB,kBAAkB,oBAAoB;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
2
+ import { DB_SYSTEM, DB_OPERATION } from '@sentry/conventions/attributes';
2
3
  import { SDK_VERSION, getActiveSpan, startInactiveSpan, SPAN_KIND, withActiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
3
- import { ATTR_DB_SYSTEM, ATTR_DB_OPERATION } from './semconv.js';
4
4
  import { getAttributesFromCollection, handleCallbackResponse, handlePromiseResponse } from './utils.js';
5
5
 
6
6
  const PACKAGE_NAME = "@sentry/instrumentation-mongoose";
@@ -52,7 +52,10 @@ class MongooseInstrumentation extends InstrumentationBase {
52
52
  init() {
53
53
  const module = new InstrumentationNodeModuleDefinition(
54
54
  "mongoose",
55
- [">=5.9.7 <10"],
55
+ // mongoose >= 9.7.0 publishes via diagnostics_channel and is instrumented by
56
+ // `subscribeMongooseDiagnosticChannels` instead, so this IITM patcher must not
57
+ // overlap it — otherwise every operation would emit two mongoose spans.
58
+ [">=5.9.7 <9.7.0"],
56
59
  this.patch.bind(this),
57
60
  this.unpatch.bind(this)
58
61
  );
@@ -193,10 +196,10 @@ class MongooseInstrumentation extends InstrumentationBase {
193
196
  _startSpan(collection, modelName, operation, parentSpan) {
194
197
  const attributes = {
195
198
  ...getAttributesFromCollection(collection),
196
- // eslint-disable-next-line typescript/no-deprecated
197
- [ATTR_DB_OPERATION]: operation,
198
- // eslint-disable-next-line typescript/no-deprecated
199
- [ATTR_DB_SYSTEM]: "mongoose",
199
+ // oxlint-disable-next-line typescript/no-deprecated
200
+ [DB_OPERATION]: operation,
201
+ // oxlint-disable-next-line typescript/no-deprecated
202
+ [DB_SYSTEM]: "mongoose",
200
203
  // keep for backwards compatibility
201
204
  [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN
202
205
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mongoose.js","sources":["../../../../../../src/integrations/tracing/mongoose/vendored/mongoose.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongoose\n * - Upstream version: @opentelemetry/instrumentation-mongoose@0.64.0\n * - Types vendored from mongoose as simplified interfaces\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport {\n type InstrumentationConfig,\n InstrumentationBase,\n type InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport type * as mongoose from './mongoose-types';\nimport { ATTR_DB_OPERATION, ATTR_DB_SYSTEM } from './semconv';\nimport { getAttributesFromCollection, handleCallbackResponse, handlePromiseResponse } from './utils';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-mongoose';\nconst ORIGIN = 'auto.db.otel.mongoose';\n\ntype MongooseModuleExports = typeof mongoose;\n\n// The raw imported `mongoose` module: either the CJS object itself, or an ESM\n// namespace wrapper exposing the same shape under `.default`.\ntype MongooseModule = MongooseModuleExports & {\n default?: MongooseModuleExports;\n [Symbol.toStringTag]?: string;\n};\n\nconst contextCaptureFunctionsCommon = [\n 'deleteOne',\n 'deleteMany',\n 'find',\n 'findOne',\n 'estimatedDocumentCount',\n 'countDocuments',\n 'distinct',\n 'where',\n '$where',\n 'findOneAndUpdate',\n 'findOneAndDelete',\n 'findOneAndReplace',\n];\n\nconst contextCaptureFunctions6 = ['remove', 'count', 'findOneAndRemove', ...contextCaptureFunctionsCommon];\nconst contextCaptureFunctions7 = ['count', 'findOneAndRemove', ...contextCaptureFunctionsCommon];\nconst contextCaptureFunctions8 = [...contextCaptureFunctionsCommon];\n\nfunction getContextCaptureFunctions(moduleVersion: string | undefined): string[] {\n /* istanbul ignore next */\n if (!moduleVersion) {\n return contextCaptureFunctionsCommon;\n } else if (moduleVersion.startsWith('6.') || moduleVersion.startsWith('5.')) {\n return contextCaptureFunctions6;\n } else if (moduleVersion.startsWith('7.')) {\n return contextCaptureFunctions7;\n } else {\n return contextCaptureFunctions8;\n }\n}\n\nfunction instrumentRemove(moduleVersion: string | undefined): boolean {\n return (moduleVersion && (moduleVersion.startsWith('5.') || moduleVersion.startsWith('6.'))) || false;\n}\n\n/**\n * 8.21.0 changed Document.updateOne/deleteOne so that the Query is not fully built when Query.exec() is called.\n * @param moduleVersion\n */\nfunction needsDocumentMethodPatch(moduleVersion: string | undefined): boolean {\n if (!moduleVersion || !moduleVersion.startsWith('8.')) {\n return false;\n }\n\n const minor = parseInt(moduleVersion.split('.')[1]!, 10);\n return minor >= 21;\n}\n\n// when mongoose functions are called, we store the original call context\n// and then set it as the parent for the spans created by Query/Aggregate exec()\n// calls. this bypass the unlinked spans issue on thenables await operations.\nexport const _STORED_PARENT_SPAN: unique symbol = Symbol('stored-parent-span');\n\n// Prevents double-instrumentation when doc.updateOne/deleteOne (Mongoose 8.21.0+)\n// creates a span and returns a Query that also calls exec()\nexport const _ALREADY_INSTRUMENTED: unique symbol = Symbol('already-instrumented');\n\nexport class MongooseInstrumentation extends InstrumentationBase<InstrumentationConfig> {\n constructor(config: InstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init(): InstrumentationModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition(\n 'mongoose',\n ['>=5.9.7 <10'],\n this.patch.bind(this),\n this.unpatch.bind(this),\n );\n return module;\n }\n\n private patch(module: MongooseModule, moduleVersion: string | undefined) {\n const moduleExports: MongooseModuleExports =\n module[Symbol.toStringTag] === 'Module' && module.default ? module.default : module;\n\n this._wrap(moduleExports.Model.prototype, 'save', this.patchOnModelMethods('save'));\n // mongoose applies this code on module require:\n // Model.prototype.$save = Model.prototype.save;\n // which captures the save function before it is patched.\n // so we need to apply the same logic after instrumenting the save function.\n moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save;\n\n if (instrumentRemove(moduleVersion)) {\n this._wrap(moduleExports.Model.prototype, 'remove', this.patchOnModelMethods('remove'));\n }\n\n // Mongoose 8.21.0+ changed Document.updateOne()/deleteOne() so that the Query is not fully built when Query.exec() is called.\n if (needsDocumentMethodPatch(moduleVersion)) {\n this._wrap(moduleExports.Model.prototype, 'updateOne', this._patchDocumentUpdateMethods('updateOne'));\n this._wrap(moduleExports.Model.prototype, 'deleteOne', this._patchDocumentUpdateMethods('deleteOne'));\n }\n\n this._wrap(moduleExports.Query.prototype, 'exec', this.patchQueryExec());\n this._wrap(moduleExports.Aggregate.prototype, 'exec', this.patchAggregateExec());\n\n const contextCaptureFunctions = getContextCaptureFunctions(moduleVersion);\n\n contextCaptureFunctions.forEach((funcName: string) => {\n this._wrap(moduleExports.Query.prototype, funcName as any, this.patchAndCaptureSpanContext(funcName));\n });\n this._wrap(moduleExports.Model, 'aggregate', this.patchModelAggregate());\n\n this._wrap(moduleExports.Model, 'insertMany', this.patchModelStatic('insertMany'));\n this._wrap(moduleExports.Model, 'bulkWrite', this.patchModelStatic('bulkWrite'));\n\n return moduleExports;\n }\n\n private unpatch(module: MongooseModule, moduleVersion: string | undefined): void {\n const moduleExports: MongooseModuleExports =\n module[Symbol.toStringTag] === 'Module' && module.default ? module.default : module;\n\n const contextCaptureFunctions = getContextCaptureFunctions(moduleVersion);\n\n this._unwrap(moduleExports.Model.prototype, 'save');\n // revert the patch for $save which we applied by aliasing it to patched `save`\n moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save;\n\n if (instrumentRemove(moduleVersion)) {\n this._unwrap(moduleExports.Model.prototype, 'remove');\n }\n\n if (needsDocumentMethodPatch(moduleVersion)) {\n this._unwrap(moduleExports.Model.prototype, 'updateOne');\n this._unwrap(moduleExports.Model.prototype, 'deleteOne');\n }\n\n this._unwrap(moduleExports.Query.prototype, 'exec');\n this._unwrap(moduleExports.Aggregate.prototype, 'exec');\n\n contextCaptureFunctions.forEach((funcName: string) => {\n this._unwrap(moduleExports.Query.prototype, funcName as any);\n });\n this._unwrap(moduleExports.Model, 'aggregate');\n\n this._unwrap(moduleExports.Model, 'insertMany');\n this._unwrap(moduleExports.Model, 'bulkWrite');\n }\n\n private patchAggregateExec() {\n const self = this;\n return (originalAggregate: Function) => {\n return function exec(this: any, callback?: Function) {\n const parentSpan = this[_STORED_PARENT_SPAN];\n const span = self._startSpan(this._model.collection, this._model?.modelName, 'aggregate', parentSpan);\n\n return self._handleResponse(span, originalAggregate, this, arguments, callback);\n };\n };\n }\n\n private patchQueryExec() {\n const self = this;\n return (originalExec: Function) => {\n return function exec(this: any, callback?: Function) {\n // Skip if already instrumented by document instance method patch\n if (this[_ALREADY_INSTRUMENTED]) {\n return originalExec.apply(this, arguments);\n }\n\n const parentSpan = this[_STORED_PARENT_SPAN];\n const span = self._startSpan(this.mongooseCollection, this.model.modelName, this.op, parentSpan);\n\n return self._handleResponse(span, originalExec, this, arguments, callback);\n };\n };\n }\n\n private patchOnModelMethods(op: string) {\n const self = this;\n return (originalOnModelFunction: Function) => {\n return function method(this: any, options?: any, callback?: Function) {\n const span = self._startSpan(this.constructor.collection, this.constructor.modelName, op);\n\n if (options instanceof Function) {\n // oxlint-disable-next-line no-param-reassign\n callback = options;\n }\n\n return self._handleResponse(span, originalOnModelFunction, this, arguments, callback);\n };\n };\n }\n\n // Patch document instance methods (doc.updateOne/deleteOne) for Mongoose 8.21.0+.\n private _patchDocumentUpdateMethods(op: string) {\n const self = this;\n return (originalMethod: Function) => {\n return function method(this: any, update?: any, options?: any, callback?: Function) {\n // determine actual callback since different argument patterns are allowed\n let actualCallback: Function | undefined = callback;\n if (typeof update === 'function') {\n actualCallback = update;\n } else if (typeof options === 'function') {\n actualCallback = options;\n }\n\n const span = self._startSpan(this.constructor.collection, this.constructor.modelName, op);\n\n const result = self._handleResponse(span, originalMethod, this, arguments, actualCallback);\n\n // Mark returned Query to prevent double-instrumentation when exec() is eventually called\n if (result && typeof result === 'object') {\n result[_ALREADY_INSTRUMENTED] = true;\n }\n\n return result;\n };\n };\n }\n\n private patchModelStatic(op: string) {\n const self = this;\n return (original: Function) => {\n return function patchedStatic(this: any, docsOrOps: any, options?: any, callback?: Function) {\n if (typeof options === 'function') {\n // oxlint-disable-next-line no-param-reassign\n callback = options;\n }\n\n const span = self._startSpan(this.collection, this.modelName, op);\n\n return self._handleResponse(span, original, this, arguments, callback);\n };\n };\n }\n\n // we want to capture the otel span on the object which is calling exec.\n // in the special case of aggregate, we need have no function to path\n // on the Aggregate object to capture the context on, so we patch\n // the aggregate of Model, and set the context on the Aggregate object\n private patchModelAggregate() {\n return (original: Function) => {\n return function captureSpanContext(this: any) {\n const currentSpan = getActiveSpan();\n const aggregate = original.apply(this, arguments);\n if (aggregate) aggregate[_STORED_PARENT_SPAN] = currentSpan;\n return aggregate;\n };\n };\n }\n\n private patchAndCaptureSpanContext(_funcName: string) {\n return (original: Function) => {\n return function captureSpanContext(this: any) {\n this[_STORED_PARENT_SPAN] = getActiveSpan();\n return original.apply(this, arguments);\n };\n };\n }\n\n private _startSpan(collection: mongoose.Collection, modelName: string, operation: string, parentSpan?: Span): Span {\n const attributes: SpanAttributes = {\n ...getAttributesFromCollection(collection),\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_OPERATION]: operation,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_SYSTEM]: 'mongoose', // keep for backwards compatibility\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n\n return startInactiveSpan({\n name: `mongoose.${modelName}.${operation}`,\n kind: SPAN_KIND.CLIENT,\n attributes,\n parentSpan,\n });\n }\n\n private _handleResponse(span: Span, exec: Function, originalThis: any, args: IArguments, callback?: Function) {\n // Activate the span while the underlying operation runs so that nested instrumentation\n // (e.g. the mongodb driver spans) is parented to this span. `withActiveSpan` returns the\n // callback's result untouched, so lazy mongoose Query thenables are handed back unexecuted.\n return withActiveSpan(span, () => {\n if (callback instanceof Function) {\n return handleCallbackResponse(callback, exec, originalThis, span, args);\n } else {\n const response = exec.apply(originalThis, args);\n return handlePromiseResponse(response, span);\n }\n });\n }\n}\n"],"names":[],"mappings":";;;;;AA+BA,MAAM,YAAA,GAAe,kCAAA;AACrB,MAAM,MAAA,GAAS,uBAAA;AAWf,MAAM,6BAAA,GAAgC;AAAA,EACpC,WAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,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AAA,OAAO,iBAAA,CAAkB;AAAA,MACvB,IAAA,EAAM,CAAA,SAAA,EAAY,SAAS,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA;AAAA,MACxC,MAAM,SAAA,CAAU,MAAA;AAAA,MAChB,UAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AAAA,EAEQ,eAAA,CAAgB,IAAA,EAAY,IAAA,EAAgB,YAAA,EAAmB,MAAkB,QAAA,EAAqB;AAI5G,IAAA,OAAO,cAAA,CAAe,MAAM,MAAM;AAChC,MAAA,IAAI,oBAAoB,QAAA,EAAU;AAChC,QAAA,OAAO,sBAAA,CAAuB,QAAA,EAAU,IAAA,EAAM,YAAA,EAAc,MAAM,IAAI,CAAA;AAAA,MACxE,CAAA,MAAO;AACL,QAAA,MAAM,QAAA,GAAW,IAAA,CAAK,KAAA,CAAM,YAAA,EAAc,IAAI,CAAA;AAC9C,QAAA,OAAO,qBAAA,CAAsB,UAAU,IAAI,CAAA;AAAA,MAC7C;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF;;;;"}
1
+ {"version":3,"file":"mongoose.js","sources":["../../../../../../src/integrations/tracing/mongoose/vendored/mongoose.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongoose\n * - Upstream version: @opentelemetry/instrumentation-mongoose@0.64.0\n * - Types vendored from mongoose as simplified interfaces\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport {\n type InstrumentationConfig,\n InstrumentationBase,\n type InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport { DB_OPERATION, DB_SYSTEM } from '@sentry/conventions/attributes';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport type * as mongoose from './mongoose-types';\nimport { getAttributesFromCollection, handleCallbackResponse, handlePromiseResponse } from './utils';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-mongoose';\nconst ORIGIN = 'auto.db.otel.mongoose';\n\ntype MongooseModuleExports = typeof mongoose;\n\n// The raw imported `mongoose` module: either the CJS object itself, or an ESM\n// namespace wrapper exposing the same shape under `.default`.\ntype MongooseModule = MongooseModuleExports & {\n default?: MongooseModuleExports;\n [Symbol.toStringTag]?: string;\n};\n\nconst contextCaptureFunctionsCommon = [\n 'deleteOne',\n 'deleteMany',\n 'find',\n 'findOne',\n 'estimatedDocumentCount',\n 'countDocuments',\n 'distinct',\n 'where',\n '$where',\n 'findOneAndUpdate',\n 'findOneAndDelete',\n 'findOneAndReplace',\n];\n\nconst contextCaptureFunctions6 = ['remove', 'count', 'findOneAndRemove', ...contextCaptureFunctionsCommon];\nconst contextCaptureFunctions7 = ['count', 'findOneAndRemove', ...contextCaptureFunctionsCommon];\nconst contextCaptureFunctions8 = [...contextCaptureFunctionsCommon];\n\nfunction getContextCaptureFunctions(moduleVersion: string | undefined): string[] {\n /* istanbul ignore next */\n if (!moduleVersion) {\n return contextCaptureFunctionsCommon;\n } else if (moduleVersion.startsWith('6.') || moduleVersion.startsWith('5.')) {\n return contextCaptureFunctions6;\n } else if (moduleVersion.startsWith('7.')) {\n return contextCaptureFunctions7;\n } else {\n return contextCaptureFunctions8;\n }\n}\n\nfunction instrumentRemove(moduleVersion: string | undefined): boolean {\n return (moduleVersion && (moduleVersion.startsWith('5.') || moduleVersion.startsWith('6.'))) || false;\n}\n\n/**\n * 8.21.0 changed Document.updateOne/deleteOne so that the Query is not fully built when Query.exec() is called.\n * @param moduleVersion\n */\nfunction needsDocumentMethodPatch(moduleVersion: string | undefined): boolean {\n if (!moduleVersion || !moduleVersion.startsWith('8.')) {\n return false;\n }\n\n const minor = parseInt(moduleVersion.split('.')[1]!, 10);\n return minor >= 21;\n}\n\n// when mongoose functions are called, we store the original call context\n// and then set it as the parent for the spans created by Query/Aggregate exec()\n// calls. this bypass the unlinked spans issue on thenables await operations.\nexport const _STORED_PARENT_SPAN: unique symbol = Symbol('stored-parent-span');\n\n// Prevents double-instrumentation when doc.updateOne/deleteOne (Mongoose 8.21.0+)\n// creates a span and returns a Query that also calls exec()\nexport const _ALREADY_INSTRUMENTED: unique symbol = Symbol('already-instrumented');\n\nexport class MongooseInstrumentation extends InstrumentationBase<InstrumentationConfig> {\n constructor(config: InstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init(): InstrumentationModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition(\n 'mongoose',\n // mongoose >= 9.7.0 publishes via diagnostics_channel and is instrumented by\n // `subscribeMongooseDiagnosticChannels` instead, so this IITM patcher must not\n // overlap it — otherwise every operation would emit two mongoose spans.\n ['>=5.9.7 <9.7.0'],\n this.patch.bind(this),\n this.unpatch.bind(this),\n );\n return module;\n }\n\n private patch(module: MongooseModule, moduleVersion: string | undefined) {\n const moduleExports: MongooseModuleExports =\n module[Symbol.toStringTag] === 'Module' && module.default ? module.default : module;\n\n this._wrap(moduleExports.Model.prototype, 'save', this.patchOnModelMethods('save'));\n // mongoose applies this code on module require:\n // Model.prototype.$save = Model.prototype.save;\n // which captures the save function before it is patched.\n // so we need to apply the same logic after instrumenting the save function.\n moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save;\n\n if (instrumentRemove(moduleVersion)) {\n this._wrap(moduleExports.Model.prototype, 'remove', this.patchOnModelMethods('remove'));\n }\n\n // Mongoose 8.21.0+ changed Document.updateOne()/deleteOne() so that the Query is not fully built when Query.exec() is called.\n if (needsDocumentMethodPatch(moduleVersion)) {\n this._wrap(moduleExports.Model.prototype, 'updateOne', this._patchDocumentUpdateMethods('updateOne'));\n this._wrap(moduleExports.Model.prototype, 'deleteOne', this._patchDocumentUpdateMethods('deleteOne'));\n }\n\n this._wrap(moduleExports.Query.prototype, 'exec', this.patchQueryExec());\n this._wrap(moduleExports.Aggregate.prototype, 'exec', this.patchAggregateExec());\n\n const contextCaptureFunctions = getContextCaptureFunctions(moduleVersion);\n\n contextCaptureFunctions.forEach((funcName: string) => {\n this._wrap(moduleExports.Query.prototype, funcName as any, this.patchAndCaptureSpanContext(funcName));\n });\n this._wrap(moduleExports.Model, 'aggregate', this.patchModelAggregate());\n\n this._wrap(moduleExports.Model, 'insertMany', this.patchModelStatic('insertMany'));\n this._wrap(moduleExports.Model, 'bulkWrite', this.patchModelStatic('bulkWrite'));\n\n return moduleExports;\n }\n\n private unpatch(module: MongooseModule, moduleVersion: string | undefined): void {\n const moduleExports: MongooseModuleExports =\n module[Symbol.toStringTag] === 'Module' && module.default ? module.default : module;\n\n const contextCaptureFunctions = getContextCaptureFunctions(moduleVersion);\n\n this._unwrap(moduleExports.Model.prototype, 'save');\n // revert the patch for $save which we applied by aliasing it to patched `save`\n moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save;\n\n if (instrumentRemove(moduleVersion)) {\n this._unwrap(moduleExports.Model.prototype, 'remove');\n }\n\n if (needsDocumentMethodPatch(moduleVersion)) {\n this._unwrap(moduleExports.Model.prototype, 'updateOne');\n this._unwrap(moduleExports.Model.prototype, 'deleteOne');\n }\n\n this._unwrap(moduleExports.Query.prototype, 'exec');\n this._unwrap(moduleExports.Aggregate.prototype, 'exec');\n\n contextCaptureFunctions.forEach((funcName: string) => {\n this._unwrap(moduleExports.Query.prototype, funcName as any);\n });\n this._unwrap(moduleExports.Model, 'aggregate');\n\n this._unwrap(moduleExports.Model, 'insertMany');\n this._unwrap(moduleExports.Model, 'bulkWrite');\n }\n\n private patchAggregateExec() {\n const self = this;\n return (originalAggregate: Function) => {\n return function exec(this: any, callback?: Function) {\n const parentSpan = this[_STORED_PARENT_SPAN];\n const span = self._startSpan(this._model.collection, this._model?.modelName, 'aggregate', parentSpan);\n\n return self._handleResponse(span, originalAggregate, this, arguments, callback);\n };\n };\n }\n\n private patchQueryExec() {\n const self = this;\n return (originalExec: Function) => {\n return function exec(this: any, callback?: Function) {\n // Skip if already instrumented by document instance method patch\n if (this[_ALREADY_INSTRUMENTED]) {\n return originalExec.apply(this, arguments);\n }\n\n const parentSpan = this[_STORED_PARENT_SPAN];\n const span = self._startSpan(this.mongooseCollection, this.model.modelName, this.op, parentSpan);\n\n return self._handleResponse(span, originalExec, this, arguments, callback);\n };\n };\n }\n\n private patchOnModelMethods(op: string) {\n const self = this;\n return (originalOnModelFunction: Function) => {\n return function method(this: any, options?: any, callback?: Function) {\n const span = self._startSpan(this.constructor.collection, this.constructor.modelName, op);\n\n if (options instanceof Function) {\n // oxlint-disable-next-line no-param-reassign\n callback = options;\n }\n\n return self._handleResponse(span, originalOnModelFunction, this, arguments, callback);\n };\n };\n }\n\n // Patch document instance methods (doc.updateOne/deleteOne) for Mongoose 8.21.0+.\n private _patchDocumentUpdateMethods(op: string) {\n const self = this;\n return (originalMethod: Function) => {\n return function method(this: any, update?: any, options?: any, callback?: Function) {\n // determine actual callback since different argument patterns are allowed\n let actualCallback: Function | undefined = callback;\n if (typeof update === 'function') {\n actualCallback = update;\n } else if (typeof options === 'function') {\n actualCallback = options;\n }\n\n const span = self._startSpan(this.constructor.collection, this.constructor.modelName, op);\n\n const result = self._handleResponse(span, originalMethod, this, arguments, actualCallback);\n\n // Mark returned Query to prevent double-instrumentation when exec() is eventually called\n if (result && typeof result === 'object') {\n result[_ALREADY_INSTRUMENTED] = true;\n }\n\n return result;\n };\n };\n }\n\n private patchModelStatic(op: string) {\n const self = this;\n return (original: Function) => {\n return function patchedStatic(this: any, docsOrOps: any, options?: any, callback?: Function) {\n if (typeof options === 'function') {\n // oxlint-disable-next-line no-param-reassign\n callback = options;\n }\n\n const span = self._startSpan(this.collection, this.modelName, op);\n\n return self._handleResponse(span, original, this, arguments, callback);\n };\n };\n }\n\n // we want to capture the otel span on the object which is calling exec.\n // in the special case of aggregate, we need have no function to path\n // on the Aggregate object to capture the context on, so we patch\n // the aggregate of Model, and set the context on the Aggregate object\n private patchModelAggregate() {\n return (original: Function) => {\n return function captureSpanContext(this: any) {\n const currentSpan = getActiveSpan();\n const aggregate = original.apply(this, arguments);\n if (aggregate) aggregate[_STORED_PARENT_SPAN] = currentSpan;\n return aggregate;\n };\n };\n }\n\n private patchAndCaptureSpanContext(_funcName: string) {\n return (original: Function) => {\n return function captureSpanContext(this: any) {\n this[_STORED_PARENT_SPAN] = getActiveSpan();\n return original.apply(this, arguments);\n };\n };\n }\n\n private _startSpan(collection: mongoose.Collection, modelName: string, operation: string, parentSpan?: Span): Span {\n const attributes: SpanAttributes = {\n ...getAttributesFromCollection(collection),\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_OPERATION]: operation,\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: 'mongoose', // keep for backwards compatibility\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n\n return startInactiveSpan({\n name: `mongoose.${modelName}.${operation}`,\n kind: SPAN_KIND.CLIENT,\n attributes,\n parentSpan,\n });\n }\n\n private _handleResponse(span: Span, exec: Function, originalThis: any, args: IArguments, callback?: Function) {\n // Activate the span while the underlying operation runs so that nested instrumentation\n // (e.g. the mongodb driver spans) is parented to this span. `withActiveSpan` returns the\n // callback's result untouched, so lazy mongoose Query thenables are handed back unexecuted.\n return withActiveSpan(span, () => {\n if (callback instanceof Function) {\n return handleCallbackResponse(callback, exec, originalThis, span, args);\n } else {\n const response = exec.apply(originalThis, args);\n return handlePromiseResponse(response, span);\n }\n });\n }\n}\n"],"names":[],"mappings":";;;;;AA+BA,MAAM,YAAA,GAAe,kCAAA;AACrB,MAAM,MAAA,GAAS,uBAAA;AAWf,MAAM,6BAAA,GAAgC;AAAA,EACpC,WAAA;AAAA,E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,GAAG,UAAA;AAAA;AAAA,MACb,CAAC,gCAAgC,GAAG;AAAA,KACtC;AAEA,IAAA,OAAO,iBAAA,CAAkB;AAAA,MACvB,IAAA,EAAM,CAAA,SAAA,EAAY,SAAS,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA;AAAA,MACxC,MAAM,SAAA,CAAU,MAAA;AAAA,MAChB,UAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AAAA,EAEQ,eAAA,CAAgB,IAAA,EAAY,IAAA,EAAgB,YAAA,EAAmB,MAAkB,QAAA,EAAqB;AAI5G,IAAA,OAAO,cAAA,CAAe,MAAM,MAAM;AAChC,MAAA,IAAI,oBAAoB,QAAA,EAAU;AAChC,QAAA,OAAO,sBAAA,CAAuB,QAAA,EAAU,IAAA,EAAM,YAAA,EAAc,MAAM,IAAI,CAAA;AAAA,MACxE,CAAA,MAAO;AACL,QAAA,MAAM,QAAA,GAAW,IAAA,CAAK,KAAA,CAAM,YAAA,EAAc,IAAI,CAAA;AAC9C,QAAA,OAAO,qBAAA,CAAsB,UAAU,IAAI,CAAA;AAAA,MAC7C;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF;;;;"}
@@ -1,10 +1,4 @@
1
1
  const ATTR_DB_MONGODB_COLLECTION = "db.mongodb.collection";
2
- const ATTR_DB_NAME = "db.name";
3
- const ATTR_DB_OPERATION = "db.operation";
4
- const ATTR_DB_SYSTEM = "db.system";
5
- const ATTR_DB_USER = "db.user";
6
- const ATTR_NET_PEER_NAME = "net.peer.name";
7
- const ATTR_NET_PEER_PORT = "net.peer.port";
8
2
 
9
- export { ATTR_DB_MONGODB_COLLECTION, ATTR_DB_NAME, ATTR_DB_OPERATION, ATTR_DB_SYSTEM, ATTR_DB_USER, ATTR_NET_PEER_NAME, ATTR_NET_PEER_PORT };
3
+ export { ATTR_DB_MONGODB_COLLECTION };
10
4
  //# sourceMappingURL=semconv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semconv.js","sources":["../../../../../../src/integrations/tracing/mongoose/vendored/semconv.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongoose\n * - Upstream version: @opentelemetry/instrumentation-mongoose@0.64.0\n */\n\n/**\n * Deprecated, use `db.collection.name` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.collection.name`.\n */\nexport const ATTR_DB_MONGODB_COLLECTION = 'db.mongodb.collection' as const;\n\n/**\n * Deprecated, use `db.namespace` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.namespace`.\n */\nexport const ATTR_DB_NAME = 'db.name' as const;\n\n/**\n * Deprecated, use `db.operation.name` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.operation.name`.\n */\nexport const ATTR_DB_OPERATION = 'db.operation' as const;\n\n/**\n * Deprecated, use `db.system.name` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.system.name`.\n */\nexport const ATTR_DB_SYSTEM = 'db.system' as const;\n\n/**\n * Deprecated, no replacement at this time.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Removed, no replacement at this time.\n */\nexport const ATTR_DB_USER = 'db.user' as const;\n\n/**\n * Deprecated, use `server.address` on client spans and `client.address` on server spans.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `server.address` on client spans and `client.address` on server spans.\n */\nexport const ATTR_NET_PEER_NAME = 'net.peer.name' as const;\n\n/**\n * Deprecated, use `server.port` on client spans and `client.port` on server spans.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `server.port` on client spans and `client.port` on server spans.\n */\nexport const ATTR_NET_PEER_PORT = 'net.peer.port' as const;\n"],"names":[],"mappings":"AAgBO,MAAM,0BAAA,GAA6B;AASnC,MAAM,YAAA,GAAe;AASrB,MAAM,iBAAA,GAAoB;AAS1B,MAAM,cAAA,GAAiB;AASvB,MAAM,YAAA,GAAe;AASrB,MAAM,kBAAA,GAAqB;AAS3B,MAAM,kBAAA,GAAqB;;;;"}
1
+ {"version":3,"file":"semconv.js","sources":["../../../../../../src/integrations/tracing/mongoose/vendored/semconv.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongoose\n * - Upstream version: @opentelemetry/instrumentation-mongoose@0.64.0\n */\n\n/**\n * Deprecated, use `db.collection.name` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.collection.name`.\n */\nexport const ATTR_DB_MONGODB_COLLECTION = 'db.mongodb.collection' as const;\n"],"names":[],"mappings":"AAgBO,MAAM,0BAAA,GAA6B;;;;"}
@@ -1,18 +1,18 @@
1
+ import { NET_PEER_PORT, NET_PEER_NAME, DB_USER, DB_NAME } from '@sentry/conventions/attributes';
1
2
  import { SPAN_STATUS_ERROR } from '@sentry/core';
2
- import { ATTR_NET_PEER_PORT, ATTR_NET_PEER_NAME, ATTR_DB_USER, ATTR_DB_NAME, ATTR_DB_MONGODB_COLLECTION } from './semconv.js';
3
+ import { ATTR_DB_MONGODB_COLLECTION } from './semconv.js';
3
4
 
4
5
  function getAttributesFromCollection(collection) {
5
6
  return {
6
- // eslint-disable-next-line typescript/no-deprecated
7
+ // oxlint-disable-next-line typescript/no-deprecated
7
8
  [ATTR_DB_MONGODB_COLLECTION]: collection.name,
8
- // eslint-disable-next-line typescript/no-deprecated
9
- [ATTR_DB_NAME]: collection.conn.name,
10
- // eslint-disable-next-line typescript/no-deprecated
11
- [ATTR_DB_USER]: collection.conn.user,
12
- // eslint-disable-next-line typescript/no-deprecated
13
- [ATTR_NET_PEER_NAME]: collection.conn.host,
14
- // eslint-disable-next-line typescript/no-deprecated
15
- [ATTR_NET_PEER_PORT]: collection.conn.port
9
+ // oxlint-disable-next-line typescript/no-deprecated
10
+ [DB_NAME]: collection.conn.name,
11
+ [DB_USER]: collection.conn.user,
12
+ // oxlint-disable-next-line typescript/no-deprecated
13
+ [NET_PEER_NAME]: collection.conn.host,
14
+ // oxlint-disable-next-line typescript/no-deprecated
15
+ [NET_PEER_PORT]: collection.conn.port
16
16
  };
17
17
  }
18
18
  function setErrorStatus(span, error) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/mongoose/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongoose\n * - Upstream version: @opentelemetry/instrumentation-mongoose@0.64.0\n * - Types vendored from mongoose as simplified interfaces\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport { SPAN_STATUS_ERROR } from '@sentry/core';\nimport type { Collection, MongooseError } from './mongoose-types';\nimport {\n ATTR_DB_MONGODB_COLLECTION,\n ATTR_DB_NAME,\n ATTR_DB_USER,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n} from './semconv';\n\nexport function getAttributesFromCollection(collection: Collection): SpanAttributes {\n return {\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_MONGODB_COLLECTION]: collection.name,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_NAME]: collection.conn.name,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_USER]: collection.conn.user,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_NET_PEER_NAME]: collection.conn.host,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_NET_PEER_PORT]: collection.conn.port,\n };\n}\n\nfunction setErrorStatus(span: Span, error: MongooseError): void {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: `${error.message} ${error.code ? `\\nMongoose Error Code: ${error.code}` : ''}`,\n });\n}\n\nexport function handlePromiseResponse(execResponse: any, span: Span): any {\n if (!(execResponse instanceof Promise)) {\n span.end();\n return execResponse;\n }\n\n return execResponse\n .catch((err: any) => {\n setErrorStatus(span, err);\n throw err;\n })\n .finally(() => span.end());\n}\n\nexport function handleCallbackResponse(\n callback: Function,\n exec: Function,\n originalThis: any,\n span: Span,\n args: IArguments,\n) {\n let callbackArgumentIndex = 0;\n if (args.length === 2) {\n callbackArgumentIndex = 1;\n } else if (args.length === 3) {\n callbackArgumentIndex = 2;\n }\n\n args[callbackArgumentIndex] = (err: Error, response: any): any => {\n if (err) {\n setErrorStatus(span, err);\n }\n\n span.end();\n return callback(err, response);\n };\n\n return exec.apply(originalThis, args);\n}\n"],"names":[],"mappings":";;;AAsBO,SAAS,4BAA4B,UAAA,EAAwC;AAClF,EAAA,OAAO;AAAA;AAAA,IAEL,CAAC,0BAA0B,GAAG,UAAA,CAAW,IAAA;AAAA;AAAA,IAEzC,CAAC,YAAY,GAAG,UAAA,CAAW,IAAA,CAAK,IAAA;AAAA;AAAA,IAEhC,CAAC,YAAY,GAAG,UAAA,CAAW,IAAA,CAAK,IAAA;AAAA;AAAA,IAEhC,CAAC,kBAAkB,G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AC1B;AAEA,IAAA,IAAA,CAAK,GAAA,EAAI;AACT,IAAA,OAAO,QAAA,CAAS,KAAK,QAAQ,CAAA;AAAA,EAC/B,CAAA;AAEA,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,YAAA,EAAc,IAAI,CAAA;AACtC;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/mongoose/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongoose\n * - Upstream version: @opentelemetry/instrumentation-mongoose@0.64.0\n * - Types vendored from mongoose as simplified interfaces\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport { DB_NAME, DB_USER, NET_PEER_NAME, NET_PEER_PORT } from '@sentry/conventions/attributes';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport { SPAN_STATUS_ERROR } from '@sentry/core';\nimport type { Collection, MongooseError } from './mongoose-types';\nimport { ATTR_DB_MONGODB_COLLECTION } from './semconv';\n\nexport function getAttributesFromCollection(collection: Collection): SpanAttributes {\n return {\n // oxlint-disable-next-line typescript/no-deprecated\n [ATTR_DB_MONGODB_COLLECTION]: collection.name,\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_NAME]: collection.conn.name,\n [DB_USER]: collection.conn.user,\n // oxlint-disable-next-line typescript/no-deprecated\n [NET_PEER_NAME]: collection.conn.host,\n // oxlint-disable-next-line typescript/no-deprecated\n [NET_PEER_PORT]: collection.conn.port,\n };\n}\n\nfunction setErrorStatus(span: Span, error: MongooseError): void {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: `${error.message} ${error.code ? `\\nMongoose Error Code: ${error.code}` : ''}`,\n });\n}\n\nexport function handlePromiseResponse(execResponse: any, span: Span): any {\n if (!(execResponse instanceof Promise)) {\n span.end();\n return execResponse;\n }\n\n return execResponse\n .catch((err: any) => {\n setErrorStatus(span, err);\n throw err;\n })\n .finally(() => span.end());\n}\n\nexport function handleCallbackResponse(\n callback: Function,\n exec: Function,\n originalThis: any,\n span: Span,\n args: IArguments,\n) {\n let callbackArgumentIndex = 0;\n if (args.length === 2) {\n callbackArgumentIndex = 1;\n } else if (args.length === 3) {\n callbackArgumentIndex = 2;\n }\n\n args[callbackArgumentIndex] = (err: Error, response: any): any => {\n if (err) {\n setErrorStatus(span, err);\n }\n\n span.end();\n return callback(err, response);\n };\n\n return exec.apply(originalThis, args);\n}\n"],"names":[],"mappings":";;;;AAiBO,SAAS,4BAA4B,UAAA,EAAwC;AAClF,EAAA,OAAO;AAAA;AAAA,IAEL,CAAC,0BAA0B,GAAG,UAAA,CAAW,IAAA;AAAA;AAAA,IAEzC,CAAC,OAAO,GAAG,UAAA,CAAW,IAAA,CAAK,IAAA;AAAA,IAC3B,CAAC,OAAO,GAAG,UAAA,CAAW,IAAA,CAAK,IAAA;AAAA;AAAA,IAE3B,CAAC,aAAa,GAAG,UAAA,CAAW,IAAA,CAAK,IAAA;AAAA;AAAA,IAEjC,CAAC,aAAa,GAAG,UAAA,CAAW,IAAA,CAAK;AAAA,GACnC;AACF;AAEA,SAAS,cAAA,CAAe,MAAY,KAAA,EAA4B;AAC9D,EAAA,IAAA,CAAK,SAAA,CAAU;AAAA,IACb,IAAA,EAAM,iBAAA;AAAA,IACN,SAAS,CAAA,EAAG,KAAA,CAAM,OAAO,CAAA,CAAA,EAAI,MAAM,IAAA,GAAO;AAAA,qBAAA,EAA0B,KAAA,CAAM,IAAI,CAAA,CAAA,GAAK,EAAE,CAAA;AAAA,GACtF,CAAA;AACH;AAEO,SAAS,qBAAA,CAAsB,cAAmB,IAAA,EAAiB;AACxE,EAAA,IAAI,EAAE,wBAAwB,OAAA,CAAA,EAAU;AACtC,IAAA,IAAA,CAAK,GAAA,EAAI;AACT,IAAA,OAAO,YAAA;AAAA,EACT;AAEA,EAAA,OAAO,YAAA,CACJ,KAAA,CAAM,CAAC,GAAA,KAAa;AACnB,IAAA,cAAA,CAAe,MAAM,GAAG,CAAA;AACxB,IAAA,MAAM,GAAA;AAAA,EACR,CAAC,CAAA,CACA,OAAA,CAAQ,MAAM,IAAA,CAAK,KAAK,CAAA;AAC7B;AAEO,SAAS,sBAAA,CACd,QAAA,EACA,IAAA,EACA,YAAA,EACA,MACA,IAAA,EACA;AACA,EAAA,IAAI,qBAAA,GAAwB,CAAA;AAC5B,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACrB,IAAA,qBAAA,GAAwB,CAAA;AAAA,EAC1B,CAAA,MAAA,IAAW,IAAA,CAAK,MAAA,KAAW,CAAA,EAAG;AAC5B,IAAA,qBAAA,GAAwB,CAAA;AAAA,EAC1B;AAEA,EAAA,IAAA,CAAK,qBAAqB,CAAA,GAAI,CAAC,GAAA,EAAY,QAAA,KAAuB;AAChE,IAAA,IAAI,GAAA,EAAK;AACP,MAAA,cAAA,CAAe,MAAM,GAAG,CAAA;AAAA,IAC1B;AAEA,IAAA,IAAA,CAAK,GAAA,EAAI;AACT,IAAA,OAAO,QAAA,CAAS,KAAK,QAAQ,CAAA;AAAA,EAC/B,CAAA;AAEA,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,YAAA,EAAc,IAAI,CAAA;AACtC;;;;"}
@@ -1,6 +1,7 @@
1
1
  import { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';
2
2
  import { SDK_VERSION, getCurrentScope, withScope, startInactiveSpan, SPAN_KIND, withActiveSpan, bindScopeToEmitter, SPAN_STATUS_ERROR, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
3
- import { ATTR_DB_STATEMENT, DB_SYSTEM_VALUE_MYSQL, ATTR_NET_PEER_NAME, ATTR_DB_USER, ATTR_DB_NAME, ATTR_DB_CONNECTION_STRING, ATTR_DB_SYSTEM, ATTR_NET_PEER_PORT } from './semconv.js';
3
+ import { DB_STATEMENT, NET_PEER_NAME, DB_USER, DB_NAME, DB_SYSTEM, NET_PEER_PORT } from '@sentry/conventions/attributes';
4
+ import { DB_SYSTEM_VALUE_MYSQL, ATTR_DB_CONNECTION_STRING } from './semconv.js';
4
5
  import { getConfig, getDbQueryText, getSpanName, getJDBCString } from './utils.js';
5
6
 
6
7
  const PACKAGE_NAME = "@sentry/instrumentation-mysql";
@@ -123,15 +124,15 @@ class MySQLInstrumentation extends InstrumentationBase {
123
124
  const portNumber = parseInt(String(port), 10);
124
125
  const attributes = {
125
126
  [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
126
- [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_MYSQL,
127
+ [DB_SYSTEM]: DB_SYSTEM_VALUE_MYSQL,
127
128
  [ATTR_DB_CONNECTION_STRING]: getJDBCString(host, port, database),
128
- [ATTR_DB_NAME]: database,
129
- [ATTR_DB_USER]: user,
130
- [ATTR_DB_STATEMENT]: getDbQueryText(query),
131
- [ATTR_NET_PEER_NAME]: host
129
+ [DB_NAME]: database,
130
+ [DB_USER]: user,
131
+ [DB_STATEMENT]: getDbQueryText(query),
132
+ [NET_PEER_NAME]: host
132
133
  };
133
134
  if (!isNaN(portNumber)) {
134
- attributes[ATTR_NET_PEER_PORT] = portNumber;
135
+ attributes[NET_PEER_PORT] = portNumber;
135
136
  }
136
137
  const span = startInactiveSpan({
137
138
  name: getSpanName(query),