@sentry/node 10.58.0 → 10.59.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 (502) hide show
  1. package/build/cjs/index.js +2 -0
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/integrations/fs/index.js +3 -84
  4. package/build/cjs/integrations/fs/index.js.map +1 -1
  5. package/build/cjs/integrations/fs/vendored/constants.js.map +1 -1
  6. package/build/cjs/integrations/fs/vendored/instrumentation.js +145 -175
  7. package/build/cjs/integrations/fs/vendored/instrumentation.js.map +1 -1
  8. package/build/cjs/integrations/fs/vendored/utils.js.map +1 -1
  9. package/build/cjs/integrations/node-fetch/vendored/undici.js.map +1 -1
  10. package/build/cjs/integrations/tracing/amqplib/vendored/amqplib.js.map +1 -1
  11. package/build/cjs/integrations/tracing/amqplib/vendored/semconv-obsolete.js.map +1 -1
  12. package/build/cjs/integrations/tracing/amqplib/vendored/semconv.js.map +1 -1
  13. package/build/cjs/integrations/tracing/amqplib/vendored/types.js.map +1 -1
  14. package/build/cjs/integrations/tracing/amqplib/vendored/utils.js.map +1 -1
  15. package/build/cjs/integrations/tracing/connect/index.js +0 -21
  16. package/build/cjs/integrations/tracing/connect/index.js.map +1 -1
  17. package/build/cjs/integrations/tracing/connect/vendored/enums/AttributeNames.js +0 -6
  18. package/build/cjs/integrations/tracing/connect/vendored/enums/AttributeNames.js.map +1 -1
  19. package/build/cjs/integrations/tracing/connect/vendored/instrumentation.js +33 -42
  20. package/build/cjs/integrations/tracing/connect/vendored/instrumentation.js.map +1 -1
  21. package/build/cjs/integrations/tracing/connect/vendored/internal-types.js.map +1 -1
  22. package/build/cjs/integrations/tracing/connect/vendored/utils.js +3 -2
  23. package/build/cjs/integrations/tracing/connect/vendored/utils.js.map +1 -1
  24. package/build/cjs/integrations/tracing/dataloader/vendored/instrumentation.js.map +1 -1
  25. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js +1 -1
  26. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js.map +1 -1
  27. package/build/cjs/integrations/tracing/fastify/vendored/instrumentation.js.map +1 -1
  28. package/build/cjs/integrations/tracing/genericPool/index.js +1 -15
  29. package/build/cjs/integrations/tracing/genericPool/index.js.map +1 -1
  30. package/build/cjs/integrations/tracing/genericPool/vendored/instrumentation.js +30 -18
  31. package/build/cjs/integrations/tracing/genericPool/vendored/instrumentation.js.map +1 -1
  32. package/build/cjs/integrations/tracing/graphql/index.js +1 -51
  33. package/build/cjs/integrations/tracing/graphql/index.js.map +1 -1
  34. package/build/cjs/integrations/tracing/graphql/vendored/enum.js.map +1 -1
  35. package/build/cjs/integrations/tracing/graphql/vendored/enums/AttributeNames.js +0 -2
  36. package/build/cjs/integrations/tracing/graphql/vendored/enums/AttributeNames.js.map +1 -1
  37. package/build/cjs/integrations/tracing/graphql/vendored/instrumentation.js +67 -57
  38. package/build/cjs/integrations/tracing/graphql/vendored/instrumentation.js.map +1 -1
  39. package/build/cjs/integrations/tracing/graphql/vendored/internal-types.js.map +1 -1
  40. package/build/cjs/integrations/tracing/graphql/vendored/symbols.js.map +1 -1
  41. package/build/cjs/integrations/tracing/graphql/vendored/utils.js +28 -62
  42. package/build/cjs/integrations/tracing/graphql/vendored/utils.js.map +1 -1
  43. package/build/cjs/integrations/tracing/hapi/index.js +0 -17
  44. package/build/cjs/integrations/tracing/hapi/index.js.map +1 -1
  45. package/build/cjs/integrations/tracing/hapi/vendored/enums/AttributeNames.js.map +1 -1
  46. package/build/cjs/integrations/tracing/hapi/vendored/instrumentation.js +28 -45
  47. package/build/cjs/integrations/tracing/hapi/vendored/instrumentation.js.map +1 -1
  48. package/build/cjs/integrations/tracing/hapi/vendored/internal-types.js.map +1 -1
  49. package/build/cjs/integrations/tracing/hapi/vendored/semconv.js.map +1 -1
  50. package/build/cjs/integrations/tracing/hapi/vendored/utils.js +4 -9
  51. package/build/cjs/integrations/tracing/hapi/vendored/utils.js.map +1 -1
  52. package/build/cjs/integrations/tracing/index.js +1 -0
  53. package/build/cjs/integrations/tracing/index.js.map +1 -1
  54. package/build/cjs/integrations/tracing/kafka/vendored/instrumentation.js.map +1 -1
  55. package/build/cjs/integrations/tracing/kafka/vendored/internal-types.js.map +1 -1
  56. package/build/cjs/integrations/tracing/kafka/vendored/propagator.js.map +1 -1
  57. package/build/cjs/integrations/tracing/kafka/vendored/semconv.js.map +1 -1
  58. package/build/cjs/integrations/tracing/knex/index.js +2 -17
  59. package/build/cjs/integrations/tracing/knex/index.js.map +1 -1
  60. package/build/cjs/integrations/tracing/knex/vendored/instrumentation.js +65 -93
  61. package/build/cjs/integrations/tracing/knex/vendored/instrumentation.js.map +1 -1
  62. package/build/cjs/integrations/tracing/knex/vendored/semconv.js +2 -0
  63. package/build/cjs/integrations/tracing/knex/vendored/semconv.js.map +1 -1
  64. package/build/cjs/integrations/tracing/knex/vendored/utils.js +2 -15
  65. package/build/cjs/integrations/tracing/knex/vendored/utils.js.map +1 -1
  66. package/build/cjs/integrations/tracing/koa/index.js +1 -24
  67. package/build/cjs/integrations/tracing/koa/index.js.map +1 -1
  68. package/build/cjs/integrations/tracing/koa/vendored/enums/AttributeNames.js.map +1 -1
  69. package/build/cjs/integrations/tracing/koa/vendored/instrumentation.js +29 -41
  70. package/build/cjs/integrations/tracing/koa/vendored/instrumentation.js.map +1 -1
  71. package/build/cjs/integrations/tracing/koa/vendored/internal-types.js.map +1 -1
  72. package/build/cjs/integrations/tracing/koa/vendored/types.js.map +1 -1
  73. package/build/cjs/integrations/tracing/koa/vendored/utils.js.map +1 -1
  74. package/build/cjs/integrations/tracing/lrumemoizer/vendored/instrumentation.js.map +1 -1
  75. package/build/cjs/integrations/tracing/mongo/index.js +1 -42
  76. package/build/cjs/integrations/tracing/mongo/index.js.map +1 -1
  77. package/build/cjs/integrations/tracing/mongo/vendored/instrumentation.js +12 -562
  78. package/build/cjs/integrations/tracing/mongo/vendored/instrumentation.js.map +1 -1
  79. package/build/cjs/integrations/tracing/mongo/vendored/internal-types.js.map +1 -1
  80. package/build/cjs/integrations/tracing/mongo/vendored/patches.js +151 -0
  81. package/build/cjs/integrations/tracing/mongo/vendored/patches.js.map +1 -0
  82. package/build/cjs/integrations/tracing/mongo/vendored/semconv.js +0 -4
  83. package/build/cjs/integrations/tracing/mongo/vendored/semconv.js.map +1 -1
  84. package/build/cjs/integrations/tracing/mongo/vendored/utils.js +153 -0
  85. package/build/cjs/integrations/tracing/mongo/vendored/utils.js.map +1 -0
  86. package/build/cjs/integrations/tracing/mongoose/index.js +1 -8
  87. package/build/cjs/integrations/tracing/mongoose/index.js.map +1 -1
  88. package/build/cjs/integrations/tracing/mongoose/vendored/mongoose.js +56 -203
  89. package/build/cjs/integrations/tracing/mongoose/vendored/mongoose.js.map +1 -1
  90. package/build/cjs/integrations/tracing/mongoose/vendored/semconv.js +0 -4
  91. package/build/cjs/integrations/tracing/mongoose/vendored/semconv.js.map +1 -1
  92. package/build/cjs/integrations/tracing/mongoose/vendored/utils.js +19 -49
  93. package/build/cjs/integrations/tracing/mongoose/vendored/utils.js.map +1 -1
  94. package/build/cjs/integrations/tracing/mysql/vendored/AttributeNames.js.map +1 -1
  95. package/build/cjs/integrations/tracing/mysql/vendored/instrumentation.js.map +1 -1
  96. package/build/cjs/integrations/tracing/mysql/vendored/semconv.js.map +1 -1
  97. package/build/cjs/integrations/tracing/mysql/vendored/utils.js.map +1 -1
  98. package/build/cjs/integrations/tracing/mysql2/index.js +1 -8
  99. package/build/cjs/integrations/tracing/mysql2/index.js.map +1 -1
  100. package/build/cjs/integrations/tracing/mysql2/vendored/instrumentation.js +21 -59
  101. package/build/cjs/integrations/tracing/mysql2/vendored/instrumentation.js.map +1 -1
  102. package/build/cjs/integrations/tracing/mysql2/vendored/semconv.js.map +1 -1
  103. package/build/cjs/integrations/tracing/mysql2/vendored/utils.js +14 -33
  104. package/build/cjs/integrations/tracing/mysql2/vendored/utils.js.map +1 -1
  105. package/build/cjs/integrations/tracing/postgres/index.js +0 -4
  106. package/build/cjs/integrations/tracing/postgres/index.js.map +1 -1
  107. package/build/cjs/integrations/tracing/postgres/vendored/enums/AttributeNames.js +0 -1
  108. package/build/cjs/integrations/tracing/postgres/vendored/enums/AttributeNames.js.map +1 -1
  109. package/build/cjs/integrations/tracing/postgres/vendored/enums/SpanNames.js.map +1 -1
  110. package/build/cjs/integrations/tracing/postgres/vendored/instrumentation.js +51 -261
  111. package/build/cjs/integrations/tracing/postgres/vendored/instrumentation.js.map +1 -1
  112. package/build/cjs/integrations/tracing/postgres/vendored/semconv.js +0 -12
  113. package/build/cjs/integrations/tracing/postgres/vendored/semconv.js.map +1 -1
  114. package/build/cjs/integrations/tracing/postgres/vendored/utils.js +43 -167
  115. package/build/cjs/integrations/tracing/postgres/vendored/utils.js.map +1 -1
  116. package/build/cjs/integrations/tracing/prisma/vendored/active-tracing-helper.js.map +1 -1
  117. package/build/cjs/integrations/tracing/prisma/vendored/constants.js.map +1 -1
  118. package/build/cjs/integrations/tracing/prisma/vendored/global.js.map +1 -1
  119. package/build/cjs/integrations/tracing/prisma/vendored/instrumentation.js.map +1 -1
  120. package/build/cjs/integrations/tracing/redis/index.js.map +1 -1
  121. package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js +89 -160
  122. package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -1
  123. package/build/cjs/integrations/tracing/redis/vendored/redis-common.js.map +1 -1
  124. package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js +92 -231
  125. package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -1
  126. package/build/cjs/integrations/tracing/redis/vendored/semconv.js +0 -2
  127. package/build/cjs/integrations/tracing/redis/vendored/semconv.js.map +1 -1
  128. package/build/cjs/integrations/tracing/tedious/index.js +1 -25
  129. package/build/cjs/integrations/tracing/tedious/index.js.map +1 -1
  130. package/build/cjs/integrations/tracing/tedious/vendored/instrumentation.js +25 -76
  131. package/build/cjs/integrations/tracing/tedious/vendored/instrumentation.js.map +1 -1
  132. package/build/cjs/integrations/tracing/tedious/vendored/semconv.js.map +1 -1
  133. package/build/cjs/integrations/tracing/tedious/vendored/utils.js.map +1 -1
  134. package/build/cjs/sdk/diagnosticsChannelInjection.js +21 -0
  135. package/build/cjs/sdk/diagnosticsChannelInjection.js.map +1 -0
  136. package/build/cjs/sdk/experimentalUseDiagnosticsChannelInjection.js +19 -0
  137. package/build/cjs/sdk/experimentalUseDiagnosticsChannelInjection.js.map +1 -0
  138. package/build/cjs/sdk/index.js +17 -1
  139. package/build/cjs/sdk/index.js.map +1 -1
  140. package/build/esm/index.js +1 -0
  141. package/build/esm/index.js.map +1 -1
  142. package/build/esm/integrations/fs/index.js +4 -85
  143. package/build/esm/integrations/fs/index.js.map +1 -1
  144. package/build/esm/integrations/fs/vendored/constants.js.map +1 -1
  145. package/build/esm/integrations/fs/vendored/instrumentation.js +147 -177
  146. package/build/esm/integrations/fs/vendored/instrumentation.js.map +1 -1
  147. package/build/esm/integrations/fs/vendored/utils.js.map +1 -1
  148. package/build/esm/integrations/node-fetch/vendored/undici.js.map +1 -1
  149. package/build/esm/integrations/tracing/amqplib/vendored/amqplib.js.map +1 -1
  150. package/build/esm/integrations/tracing/amqplib/vendored/semconv-obsolete.js.map +1 -1
  151. package/build/esm/integrations/tracing/amqplib/vendored/semconv.js.map +1 -1
  152. package/build/esm/integrations/tracing/amqplib/vendored/types.js.map +1 -1
  153. package/build/esm/integrations/tracing/amqplib/vendored/utils.js.map +1 -1
  154. package/build/esm/integrations/tracing/connect/index.js +1 -22
  155. package/build/esm/integrations/tracing/connect/index.js.map +1 -1
  156. package/build/esm/integrations/tracing/connect/vendored/enums/AttributeNames.js +1 -6
  157. package/build/esm/integrations/tracing/connect/vendored/enums/AttributeNames.js.map +1 -1
  158. package/build/esm/integrations/tracing/connect/vendored/instrumentation.js +36 -44
  159. package/build/esm/integrations/tracing/connect/vendored/instrumentation.js.map +1 -1
  160. package/build/esm/integrations/tracing/connect/vendored/internal-types.js.map +1 -1
  161. package/build/esm/integrations/tracing/connect/vendored/utils.js +3 -2
  162. package/build/esm/integrations/tracing/connect/vendored/utils.js.map +1 -1
  163. package/build/esm/integrations/tracing/dataloader/vendored/instrumentation.js.map +1 -1
  164. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js +1 -1
  165. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js.map +1 -1
  166. package/build/esm/integrations/tracing/fastify/vendored/instrumentation.js.map +1 -1
  167. package/build/esm/integrations/tracing/genericPool/index.js +3 -17
  168. package/build/esm/integrations/tracing/genericPool/index.js.map +1 -1
  169. package/build/esm/integrations/tracing/genericPool/vendored/instrumentation.js +31 -19
  170. package/build/esm/integrations/tracing/genericPool/vendored/instrumentation.js.map +1 -1
  171. package/build/esm/integrations/tracing/graphql/index.js +3 -53
  172. package/build/esm/integrations/tracing/graphql/index.js.map +1 -1
  173. package/build/esm/integrations/tracing/graphql/vendored/enum.js.map +1 -1
  174. package/build/esm/integrations/tracing/graphql/vendored/enums/AttributeNames.js +0 -2
  175. package/build/esm/integrations/tracing/graphql/vendored/enums/AttributeNames.js.map +1 -1
  176. package/build/esm/integrations/tracing/graphql/vendored/instrumentation.js +69 -59
  177. package/build/esm/integrations/tracing/graphql/vendored/instrumentation.js.map +1 -1
  178. package/build/esm/integrations/tracing/graphql/vendored/internal-types.js.map +1 -1
  179. package/build/esm/integrations/tracing/graphql/vendored/symbols.js.map +1 -1
  180. package/build/esm/integrations/tracing/graphql/vendored/utils.js +29 -62
  181. package/build/esm/integrations/tracing/graphql/vendored/utils.js.map +1 -1
  182. package/build/esm/integrations/tracing/hapi/index.js +1 -18
  183. package/build/esm/integrations/tracing/hapi/index.js.map +1 -1
  184. package/build/esm/integrations/tracing/hapi/vendored/enums/AttributeNames.js.map +1 -1
  185. package/build/esm/integrations/tracing/hapi/vendored/instrumentation.js +30 -47
  186. package/build/esm/integrations/tracing/hapi/vendored/instrumentation.js.map +1 -1
  187. package/build/esm/integrations/tracing/hapi/vendored/internal-types.js.map +1 -1
  188. package/build/esm/integrations/tracing/hapi/vendored/semconv.js.map +1 -1
  189. package/build/esm/integrations/tracing/hapi/vendored/utils.js +5 -10
  190. package/build/esm/integrations/tracing/hapi/vendored/utils.js.map +1 -1
  191. package/build/esm/integrations/tracing/index.js +1 -0
  192. package/build/esm/integrations/tracing/index.js.map +1 -1
  193. package/build/esm/integrations/tracing/kafka/vendored/instrumentation.js.map +1 -1
  194. package/build/esm/integrations/tracing/kafka/vendored/internal-types.js.map +1 -1
  195. package/build/esm/integrations/tracing/kafka/vendored/propagator.js.map +1 -1
  196. package/build/esm/integrations/tracing/kafka/vendored/semconv.js.map +1 -1
  197. package/build/esm/integrations/tracing/knex/index.js +4 -19
  198. package/build/esm/integrations/tracing/knex/index.js.map +1 -1
  199. package/build/esm/integrations/tracing/knex/vendored/instrumentation.js +66 -94
  200. package/build/esm/integrations/tracing/knex/vendored/instrumentation.js.map +1 -1
  201. package/build/esm/integrations/tracing/knex/vendored/semconv.js +2 -1
  202. package/build/esm/integrations/tracing/knex/vendored/semconv.js.map +1 -1
  203. package/build/esm/integrations/tracing/knex/vendored/utils.js +3 -15
  204. package/build/esm/integrations/tracing/knex/vendored/utils.js.map +1 -1
  205. package/build/esm/integrations/tracing/koa/index.js +3 -26
  206. package/build/esm/integrations/tracing/koa/index.js.map +1 -1
  207. package/build/esm/integrations/tracing/koa/vendored/enums/AttributeNames.js.map +1 -1
  208. package/build/esm/integrations/tracing/koa/vendored/instrumentation.js +31 -43
  209. package/build/esm/integrations/tracing/koa/vendored/instrumentation.js.map +1 -1
  210. package/build/esm/integrations/tracing/koa/vendored/internal-types.js.map +1 -1
  211. package/build/esm/integrations/tracing/koa/vendored/types.js.map +1 -1
  212. package/build/esm/integrations/tracing/koa/vendored/utils.js.map +1 -1
  213. package/build/esm/integrations/tracing/lrumemoizer/vendored/instrumentation.js.map +1 -1
  214. package/build/esm/integrations/tracing/mongo/index.js +3 -43
  215. package/build/esm/integrations/tracing/mongo/index.js.map +1 -1
  216. package/build/esm/integrations/tracing/mongo/vendored/instrumentation.js +13 -563
  217. package/build/esm/integrations/tracing/mongo/vendored/instrumentation.js.map +1 -1
  218. package/build/esm/integrations/tracing/mongo/vendored/internal-types.js.map +1 -1
  219. package/build/esm/integrations/tracing/mongo/vendored/patches.js +143 -0
  220. package/build/esm/integrations/tracing/mongo/vendored/patches.js.map +1 -0
  221. package/build/esm/integrations/tracing/mongo/vendored/semconv.js +1 -3
  222. package/build/esm/integrations/tracing/mongo/vendored/semconv.js.map +1 -1
  223. package/build/esm/integrations/tracing/mongo/vendored/utils.js +146 -0
  224. package/build/esm/integrations/tracing/mongo/vendored/utils.js.map +1 -0
  225. package/build/esm/integrations/tracing/mongoose/index.js +2 -9
  226. package/build/esm/integrations/tracing/mongoose/index.js.map +1 -1
  227. package/build/esm/integrations/tracing/mongoose/vendored/mongoose.js +59 -206
  228. package/build/esm/integrations/tracing/mongoose/vendored/mongoose.js.map +1 -1
  229. package/build/esm/integrations/tracing/mongoose/vendored/semconv.js +1 -3
  230. package/build/esm/integrations/tracing/mongoose/vendored/semconv.js.map +1 -1
  231. package/build/esm/integrations/tracing/mongoose/vendored/utils.js +20 -50
  232. package/build/esm/integrations/tracing/mongoose/vendored/utils.js.map +1 -1
  233. package/build/esm/integrations/tracing/mysql/vendored/AttributeNames.js.map +1 -1
  234. package/build/esm/integrations/tracing/mysql/vendored/instrumentation.js.map +1 -1
  235. package/build/esm/integrations/tracing/mysql/vendored/semconv.js.map +1 -1
  236. package/build/esm/integrations/tracing/mysql/vendored/utils.js.map +1 -1
  237. package/build/esm/integrations/tracing/mysql2/index.js +2 -9
  238. package/build/esm/integrations/tracing/mysql2/index.js.map +1 -1
  239. package/build/esm/integrations/tracing/mysql2/vendored/instrumentation.js +26 -64
  240. package/build/esm/integrations/tracing/mysql2/vendored/instrumentation.js.map +1 -1
  241. package/build/esm/integrations/tracing/mysql2/vendored/semconv.js.map +1 -1
  242. package/build/esm/integrations/tracing/mysql2/vendored/utils.js +15 -34
  243. package/build/esm/integrations/tracing/mysql2/vendored/utils.js.map +1 -1
  244. package/build/esm/integrations/tracing/postgres/index.js +1 -5
  245. package/build/esm/integrations/tracing/postgres/index.js.map +1 -1
  246. package/build/esm/integrations/tracing/postgres/vendored/enums/AttributeNames.js +0 -1
  247. package/build/esm/integrations/tracing/postgres/vendored/enums/AttributeNames.js.map +1 -1
  248. package/build/esm/integrations/tracing/postgres/vendored/enums/SpanNames.js.map +1 -1
  249. package/build/esm/integrations/tracing/postgres/vendored/instrumentation.js +52 -262
  250. package/build/esm/integrations/tracing/postgres/vendored/instrumentation.js.map +1 -1
  251. package/build/esm/integrations/tracing/postgres/vendored/semconv.js +1 -7
  252. package/build/esm/integrations/tracing/postgres/vendored/semconv.js.map +1 -1
  253. package/build/esm/integrations/tracing/postgres/vendored/utils.js +44 -165
  254. package/build/esm/integrations/tracing/postgres/vendored/utils.js.map +1 -1
  255. package/build/esm/integrations/tracing/prisma/vendored/active-tracing-helper.js.map +1 -1
  256. package/build/esm/integrations/tracing/prisma/vendored/constants.js.map +1 -1
  257. package/build/esm/integrations/tracing/prisma/vendored/global.js.map +1 -1
  258. package/build/esm/integrations/tracing/prisma/vendored/instrumentation.js.map +1 -1
  259. package/build/esm/integrations/tracing/redis/index.js.map +1 -1
  260. package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js +92 -163
  261. package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -1
  262. package/build/esm/integrations/tracing/redis/vendored/redis-common.js.map +1 -1
  263. package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js +94 -233
  264. package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -1
  265. package/build/esm/integrations/tracing/redis/vendored/semconv.js +1 -2
  266. package/build/esm/integrations/tracing/redis/vendored/semconv.js.map +1 -1
  267. package/build/esm/integrations/tracing/tedious/index.js +3 -27
  268. package/build/esm/integrations/tracing/tedious/index.js.map +1 -1
  269. package/build/esm/integrations/tracing/tedious/vendored/instrumentation.js +29 -79
  270. package/build/esm/integrations/tracing/tedious/vendored/instrumentation.js.map +1 -1
  271. package/build/esm/integrations/tracing/tedious/vendored/semconv.js.map +1 -1
  272. package/build/esm/integrations/tracing/tedious/vendored/utils.js.map +1 -1
  273. package/build/esm/package.json +1 -1
  274. package/build/esm/sdk/diagnosticsChannelInjection.js +17 -0
  275. package/build/esm/sdk/diagnosticsChannelInjection.js.map +1 -0
  276. package/build/esm/sdk/experimentalUseDiagnosticsChannelInjection.js +17 -0
  277. package/build/esm/sdk/experimentalUseDiagnosticsChannelInjection.js.map +1 -0
  278. package/build/esm/sdk/index.js +17 -1
  279. package/build/esm/sdk/index.js.map +1 -1
  280. package/build/import-hook.mjs +6 -0
  281. package/build/types/index.d.ts +1 -0
  282. package/build/types/index.d.ts.map +1 -1
  283. package/build/types/integrations/fs/index.d.ts.map +1 -1
  284. package/build/types/integrations/fs/vendored/constants.d.ts.map +1 -1
  285. package/build/types/integrations/fs/vendored/instrumentation.d.ts +6 -10
  286. package/build/types/integrations/fs/vendored/instrumentation.d.ts.map +1 -1
  287. package/build/types/integrations/fs/vendored/types.d.ts +10 -15
  288. package/build/types/integrations/fs/vendored/types.d.ts.map +1 -1
  289. package/build/types/integrations/fs/vendored/utils.d.ts +2 -2
  290. package/build/types/integrations/fs/vendored/utils.d.ts.map +1 -1
  291. package/build/types/integrations/node-fetch/vendored/internal-types.d.ts.map +1 -1
  292. package/build/types/integrations/node-fetch/vendored/types.d.ts.map +1 -1
  293. package/build/types/integrations/node-fetch/vendored/undici.d.ts.map +1 -1
  294. package/build/types/integrations/tracing/amqplib/vendored/amqplib.d.ts.map +1 -1
  295. package/build/types/integrations/tracing/amqplib/vendored/semconv-obsolete.d.ts.map +1 -1
  296. package/build/types/integrations/tracing/amqplib/vendored/semconv.d.ts.map +1 -1
  297. package/build/types/integrations/tracing/amqplib/vendored/types.d.ts.map +1 -1
  298. package/build/types/integrations/tracing/amqplib/vendored/utils.d.ts.map +1 -1
  299. package/build/types/integrations/tracing/connect/index.d.ts.map +1 -1
  300. package/build/types/integrations/tracing/connect/vendored/enums/AttributeNames.d.ts +0 -4
  301. package/build/types/integrations/tracing/connect/vendored/enums/AttributeNames.d.ts.map +1 -1
  302. package/build/types/integrations/tracing/connect/vendored/instrumentation.d.ts +5 -5
  303. package/build/types/integrations/tracing/connect/vendored/instrumentation.d.ts.map +1 -1
  304. package/build/types/integrations/tracing/connect/vendored/internal-types.d.ts +2 -2
  305. package/build/types/integrations/tracing/connect/vendored/internal-types.d.ts.map +1 -1
  306. package/build/types/integrations/tracing/connect/vendored/utils.d.ts +1 -1
  307. package/build/types/integrations/tracing/connect/vendored/utils.d.ts.map +1 -1
  308. package/build/types/integrations/tracing/dataloader/vendored/instrumentation.d.ts.map +1 -1
  309. package/build/types/integrations/tracing/dataloader/vendored/types.d.ts.map +1 -1
  310. package/build/types/integrations/tracing/fastify/vendored/instrumentation.d.ts.map +1 -1
  311. package/build/types/integrations/tracing/genericPool/index.d.ts.map +1 -1
  312. package/build/types/integrations/tracing/genericPool/vendored/instrumentation.d.ts.map +1 -1
  313. package/build/types/integrations/tracing/graphql/index.d.ts.map +1 -1
  314. package/build/types/integrations/tracing/graphql/vendored/enum.d.ts.map +1 -1
  315. package/build/types/integrations/tracing/graphql/vendored/enums/AttributeNames.d.ts +1 -3
  316. package/build/types/integrations/tracing/graphql/vendored/enums/AttributeNames.d.ts.map +1 -1
  317. package/build/types/integrations/tracing/graphql/vendored/instrumentation.d.ts +7 -2
  318. package/build/types/integrations/tracing/graphql/vendored/instrumentation.d.ts.map +1 -1
  319. package/build/types/integrations/tracing/graphql/vendored/internal-types.d.ts +4 -4
  320. package/build/types/integrations/tracing/graphql/vendored/internal-types.d.ts.map +1 -1
  321. package/build/types/integrations/tracing/graphql/vendored/symbols.d.ts.map +1 -1
  322. package/build/types/integrations/tracing/graphql/vendored/types.d.ts +5 -43
  323. package/build/types/integrations/tracing/graphql/vendored/types.d.ts.map +1 -1
  324. package/build/types/integrations/tracing/graphql/vendored/utils.d.ts +8 -11
  325. package/build/types/integrations/tracing/graphql/vendored/utils.d.ts.map +1 -1
  326. package/build/types/integrations/tracing/hapi/index.d.ts.map +1 -1
  327. package/build/types/integrations/tracing/hapi/vendored/enums/AttributeNames.d.ts.map +1 -1
  328. package/build/types/integrations/tracing/hapi/vendored/instrumentation.d.ts +2 -2
  329. package/build/types/integrations/tracing/hapi/vendored/instrumentation.d.ts.map +1 -1
  330. package/build/types/integrations/tracing/hapi/vendored/internal-types.d.ts.map +1 -1
  331. package/build/types/integrations/tracing/hapi/vendored/semconv.d.ts.map +1 -1
  332. package/build/types/integrations/tracing/hapi/vendored/utils.d.ts +3 -4
  333. package/build/types/integrations/tracing/hapi/vendored/utils.d.ts.map +1 -1
  334. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  335. package/build/types/integrations/tracing/kafka/vendored/instrumentation.d.ts.map +1 -1
  336. package/build/types/integrations/tracing/kafka/vendored/internal-types.d.ts.map +1 -1
  337. package/build/types/integrations/tracing/kafka/vendored/propagator.d.ts.map +1 -1
  338. package/build/types/integrations/tracing/kafka/vendored/semconv.d.ts.map +1 -1
  339. package/build/types/integrations/tracing/kafka/vendored/types.d.ts.map +1 -1
  340. package/build/types/integrations/tracing/knex/index.d.ts.map +1 -1
  341. package/build/types/integrations/tracing/knex/vendored/instrumentation.d.ts +8 -10
  342. package/build/types/integrations/tracing/knex/vendored/instrumentation.d.ts.map +1 -1
  343. package/build/types/integrations/tracing/knex/vendored/semconv.d.ts +1 -0
  344. package/build/types/integrations/tracing/knex/vendored/semconv.d.ts.map +1 -1
  345. package/build/types/integrations/tracing/knex/vendored/utils.d.ts +0 -6
  346. package/build/types/integrations/tracing/knex/vendored/utils.d.ts.map +1 -1
  347. package/build/types/integrations/tracing/koa/index.d.ts.map +1 -1
  348. package/build/types/integrations/tracing/koa/vendored/enums/AttributeNames.d.ts.map +1 -1
  349. package/build/types/integrations/tracing/koa/vendored/instrumentation.d.ts +1 -1
  350. package/build/types/integrations/tracing/koa/vendored/instrumentation.d.ts.map +1 -1
  351. package/build/types/integrations/tracing/koa/vendored/internal-types.d.ts +4 -4
  352. package/build/types/integrations/tracing/koa/vendored/internal-types.d.ts.map +1 -1
  353. package/build/types/integrations/tracing/koa/vendored/types.d.ts +2 -39
  354. package/build/types/integrations/tracing/koa/vendored/types.d.ts.map +1 -1
  355. package/build/types/integrations/tracing/koa/vendored/utils.d.ts +3 -3
  356. package/build/types/integrations/tracing/koa/vendored/utils.d.ts.map +1 -1
  357. package/build/types/integrations/tracing/lrumemoizer/vendored/instrumentation.d.ts.map +1 -1
  358. package/build/types/integrations/tracing/mongo/index.d.ts +0 -4
  359. package/build/types/integrations/tracing/mongo/index.d.ts.map +1 -1
  360. package/build/types/integrations/tracing/mongo/vendored/instrumentation.d.ts +4 -72
  361. package/build/types/integrations/tracing/mongo/vendored/instrumentation.d.ts.map +1 -1
  362. package/build/types/integrations/tracing/mongo/vendored/internal-types.d.ts +0 -59
  363. package/build/types/integrations/tracing/mongo/vendored/internal-types.d.ts.map +1 -1
  364. package/build/types/integrations/tracing/mongo/vendored/patches.d.ts +15 -0
  365. package/build/types/integrations/tracing/mongo/vendored/patches.d.ts.map +1 -0
  366. package/build/types/integrations/tracing/mongo/vendored/semconv.d.ts +0 -54
  367. package/build/types/integrations/tracing/mongo/vendored/semconv.d.ts.map +1 -1
  368. package/build/types/integrations/tracing/mongo/vendored/utils.d.ts +24 -0
  369. package/build/types/integrations/tracing/mongo/vendored/utils.d.ts.map +1 -0
  370. package/build/types/integrations/tracing/mongoose/index.d.ts.map +1 -1
  371. package/build/types/integrations/tracing/mongoose/vendored/mongoose-types.d.ts +3 -0
  372. package/build/types/integrations/tracing/mongoose/vendored/mongoose-types.d.ts.map +1 -1
  373. package/build/types/integrations/tracing/mongoose/vendored/mongoose.d.ts +3 -8
  374. package/build/types/integrations/tracing/mongoose/vendored/mongoose.d.ts.map +1 -1
  375. package/build/types/integrations/tracing/mongoose/vendored/semconv.d.ts +0 -14
  376. package/build/types/integrations/tracing/mongoose/vendored/semconv.d.ts.map +1 -1
  377. package/build/types/integrations/tracing/mongoose/vendored/utils.d.ts +4 -6
  378. package/build/types/integrations/tracing/mongoose/vendored/utils.d.ts.map +1 -1
  379. package/build/types/integrations/tracing/mysql/vendored/AttributeNames.d.ts.map +1 -1
  380. package/build/types/integrations/tracing/mysql/vendored/instrumentation.d.ts.map +1 -1
  381. package/build/types/integrations/tracing/mysql/vendored/mysql-types.d.ts.map +1 -1
  382. package/build/types/integrations/tracing/mysql/vendored/semconv.d.ts.map +1 -1
  383. package/build/types/integrations/tracing/mysql/vendored/types.d.ts.map +1 -1
  384. package/build/types/integrations/tracing/mysql/vendored/utils.d.ts.map +1 -1
  385. package/build/types/integrations/tracing/mysql2/index.d.ts.map +1 -1
  386. package/build/types/integrations/tracing/mysql2/vendored/instrumentation.d.ts +3 -6
  387. package/build/types/integrations/tracing/mysql2/vendored/instrumentation.d.ts.map +1 -1
  388. package/build/types/integrations/tracing/mysql2/vendored/semconv.d.ts.map +1 -1
  389. package/build/types/integrations/tracing/mysql2/vendored/utils.d.ts +3 -5
  390. package/build/types/integrations/tracing/mysql2/vendored/utils.d.ts.map +1 -1
  391. package/build/types/integrations/tracing/postgres/index.d.ts.map +1 -1
  392. package/build/types/integrations/tracing/postgres/vendored/enums/AttributeNames.d.ts +0 -1
  393. package/build/types/integrations/tracing/postgres/vendored/enums/AttributeNames.d.ts.map +1 -1
  394. package/build/types/integrations/tracing/postgres/vendored/enums/SpanNames.d.ts.map +1 -1
  395. package/build/types/integrations/tracing/postgres/vendored/instrumentation.d.ts +1 -9
  396. package/build/types/integrations/tracing/postgres/vendored/instrumentation.d.ts.map +1 -1
  397. package/build/types/integrations/tracing/postgres/vendored/internal-types.d.ts +0 -2
  398. package/build/types/integrations/tracing/postgres/vendored/internal-types.d.ts.map +1 -1
  399. package/build/types/integrations/tracing/postgres/vendored/pg-pool-types.d.ts.map +1 -1
  400. package/build/types/integrations/tracing/postgres/vendored/pg-types.d.ts.map +1 -1
  401. package/build/types/integrations/tracing/postgres/vendored/semconv.d.ts +0 -50
  402. package/build/types/integrations/tracing/postgres/vendored/semconv.d.ts.map +1 -1
  403. package/build/types/integrations/tracing/postgres/vendored/types.d.ts +2 -56
  404. package/build/types/integrations/tracing/postgres/vendored/types.d.ts.map +1 -1
  405. package/build/types/integrations/tracing/postgres/vendored/utils.d.ts +13 -26
  406. package/build/types/integrations/tracing/postgres/vendored/utils.d.ts.map +1 -1
  407. package/build/types/integrations/tracing/prisma/vendored/active-tracing-helper.d.ts.map +1 -1
  408. package/build/types/integrations/tracing/prisma/vendored/constants.d.ts.map +1 -1
  409. package/build/types/integrations/tracing/prisma/vendored/global.d.ts.map +1 -1
  410. package/build/types/integrations/tracing/prisma/vendored/instrumentation.d.ts.map +1 -1
  411. package/build/types/integrations/tracing/prisma/vendored/types.d.ts.map +1 -1
  412. package/build/types/integrations/tracing/redis/index.d.ts.map +1 -1
  413. package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts +3 -8
  414. package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts.map +1 -1
  415. package/build/types/integrations/tracing/redis/vendored/redis-common.d.ts.map +1 -1
  416. package/build/types/integrations/tracing/redis/vendored/redis-instrumentation.d.ts.map +1 -1
  417. package/build/types/integrations/tracing/redis/vendored/semconv.d.ts.map +1 -1
  418. package/build/types/integrations/tracing/redis/vendored/types.d.ts +2 -36
  419. package/build/types/integrations/tracing/redis/vendored/types.d.ts.map +1 -1
  420. package/build/types/integrations/tracing/tedious/index.d.ts.map +1 -1
  421. package/build/types/integrations/tracing/tedious/vendored/instrumentation.d.ts +3 -14
  422. package/build/types/integrations/tracing/tedious/vendored/instrumentation.d.ts.map +1 -1
  423. package/build/types/integrations/tracing/tedious/vendored/semconv.d.ts.map +1 -1
  424. package/build/types/integrations/tracing/tedious/vendored/utils.d.ts.map +1 -1
  425. package/build/types/sdk/diagnosticsChannelInjection.d.ts +41 -0
  426. package/build/types/sdk/diagnosticsChannelInjection.d.ts.map +1 -0
  427. package/build/types/sdk/experimentalUseDiagnosticsChannelInjection.d.ts +34 -0
  428. package/build/types/sdk/experimentalUseDiagnosticsChannelInjection.d.ts.map +1 -0
  429. package/build/types/sdk/index.d.ts.map +1 -1
  430. package/build/types-ts3.8/index.d.ts +1 -0
  431. package/build/types-ts3.8/integrations/fs/vendored/instrumentation.d.ts +6 -10
  432. package/build/types-ts3.8/integrations/fs/vendored/types.d.ts +10 -15
  433. package/build/types-ts3.8/integrations/fs/vendored/utils.d.ts +2 -2
  434. package/build/types-ts3.8/integrations/tracing/connect/vendored/enums/AttributeNames.d.ts +0 -4
  435. package/build/types-ts3.8/integrations/tracing/connect/vendored/instrumentation.d.ts +4 -4
  436. package/build/types-ts3.8/integrations/tracing/connect/vendored/internal-types.d.ts +2 -2
  437. package/build/types-ts3.8/integrations/tracing/graphql/vendored/enums/AttributeNames.d.ts +1 -3
  438. package/build/types-ts3.8/integrations/tracing/graphql/vendored/instrumentation.d.ts +6 -1
  439. package/build/types-ts3.8/integrations/tracing/graphql/vendored/internal-types.d.ts +3 -3
  440. package/build/types-ts3.8/integrations/tracing/graphql/vendored/types.d.ts +4 -42
  441. package/build/types-ts3.8/integrations/tracing/graphql/vendored/utils.d.ts +6 -9
  442. package/build/types-ts3.8/integrations/tracing/hapi/vendored/instrumentation.d.ts +2 -2
  443. package/build/types-ts3.8/integrations/tracing/hapi/vendored/utils.d.ts +1 -2
  444. package/build/types-ts3.8/integrations/tracing/knex/vendored/instrumentation.d.ts +8 -10
  445. package/build/types-ts3.8/integrations/tracing/knex/vendored/semconv.d.ts +1 -0
  446. package/build/types-ts3.8/integrations/tracing/knex/vendored/utils.d.ts +0 -6
  447. package/build/types-ts3.8/integrations/tracing/koa/vendored/internal-types.d.ts +4 -4
  448. package/build/types-ts3.8/integrations/tracing/koa/vendored/types.d.ts +1 -38
  449. package/build/types-ts3.8/integrations/tracing/mongo/index.d.ts +0 -4
  450. package/build/types-ts3.8/integrations/tracing/mongo/vendored/instrumentation.d.ts +4 -72
  451. package/build/types-ts3.8/integrations/tracing/mongo/vendored/internal-types.d.ts +0 -59
  452. package/build/types-ts3.8/integrations/tracing/mongo/vendored/patches.d.ts +15 -0
  453. package/build/types-ts3.8/integrations/tracing/mongo/vendored/semconv.d.ts +0 -54
  454. package/build/types-ts3.8/integrations/tracing/mongo/vendored/utils.d.ts +24 -0
  455. package/build/types-ts3.8/integrations/tracing/mongoose/vendored/mongoose-types.d.ts +3 -0
  456. package/build/types-ts3.8/integrations/tracing/mongoose/vendored/mongoose.d.ts +3 -8
  457. package/build/types-ts3.8/integrations/tracing/mongoose/vendored/semconv.d.ts +0 -14
  458. package/build/types-ts3.8/integrations/tracing/mongoose/vendored/utils.d.ts +4 -6
  459. package/build/types-ts3.8/integrations/tracing/mysql2/vendored/instrumentation.d.ts +3 -6
  460. package/build/types-ts3.8/integrations/tracing/mysql2/vendored/utils.d.ts +3 -5
  461. package/build/types-ts3.8/integrations/tracing/postgres/vendored/enums/AttributeNames.d.ts +0 -1
  462. package/build/types-ts3.8/integrations/tracing/postgres/vendored/instrumentation.d.ts +0 -8
  463. package/build/types-ts3.8/integrations/tracing/postgres/vendored/internal-types.d.ts +0 -2
  464. package/build/types-ts3.8/integrations/tracing/postgres/vendored/semconv.d.ts +0 -50
  465. package/build/types-ts3.8/integrations/tracing/postgres/vendored/types.d.ts +1 -55
  466. package/build/types-ts3.8/integrations/tracing/postgres/vendored/utils.d.ts +13 -26
  467. package/build/types-ts3.8/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts +3 -8
  468. package/build/types-ts3.8/integrations/tracing/redis/vendored/types.d.ts +2 -36
  469. package/build/types-ts3.8/integrations/tracing/tedious/vendored/instrumentation.d.ts +3 -14
  470. package/build/types-ts3.8/sdk/diagnosticsChannelInjection.d.ts +41 -0
  471. package/build/types-ts3.8/sdk/experimentalUseDiagnosticsChannelInjection.d.ts +34 -0
  472. package/package.json +20 -6
  473. package/build/cjs/integrations/tracing/knex/vendored/constants.js +0 -16
  474. package/build/cjs/integrations/tracing/knex/vendored/constants.js.map +0 -1
  475. package/build/cjs/integrations/tracing/postgres/vendored/internal-types.js +0 -6
  476. package/build/cjs/integrations/tracing/postgres/vendored/internal-types.js.map +0 -1
  477. package/build/cjs/integrations/tracing/utils/sql-common.js +0 -43
  478. package/build/cjs/integrations/tracing/utils/sql-common.js.map +0 -1
  479. package/build/esm/integrations/tracing/knex/vendored/constants.js +0 -13
  480. package/build/esm/integrations/tracing/knex/vendored/constants.js.map +0 -1
  481. package/build/esm/integrations/tracing/postgres/vendored/internal-types.js +0 -4
  482. package/build/esm/integrations/tracing/postgres/vendored/internal-types.js.map +0 -1
  483. package/build/esm/integrations/tracing/utils/sql-common.js +0 -41
  484. package/build/esm/integrations/tracing/utils/sql-common.js.map +0 -1
  485. package/build/types/integrations/tracing/knex/vendored/constants.d.ts +0 -3
  486. package/build/types/integrations/tracing/knex/vendored/constants.d.ts.map +0 -1
  487. package/build/types/integrations/tracing/knex/vendored/types.d.ts +0 -8
  488. package/build/types/integrations/tracing/knex/vendored/types.d.ts.map +0 -1
  489. package/build/types/integrations/tracing/mongo/vendored/types.d.ts +0 -51
  490. package/build/types/integrations/tracing/mongo/vendored/types.d.ts.map +0 -1
  491. package/build/types/integrations/tracing/mongoose/vendored/types.d.ts +0 -36
  492. package/build/types/integrations/tracing/mongoose/vendored/types.d.ts.map +0 -1
  493. package/build/types/integrations/tracing/mysql2/vendored/types.d.ts +0 -18
  494. package/build/types/integrations/tracing/mysql2/vendored/types.d.ts.map +0 -1
  495. package/build/types/integrations/tracing/tedious/vendored/types.d.ts +0 -10
  496. package/build/types/integrations/tracing/tedious/vendored/types.d.ts.map +0 -1
  497. package/build/types-ts3.8/integrations/tracing/knex/vendored/constants.d.ts +0 -3
  498. package/build/types-ts3.8/integrations/tracing/knex/vendored/types.d.ts +0 -8
  499. package/build/types-ts3.8/integrations/tracing/mongo/vendored/types.d.ts +0 -51
  500. package/build/types-ts3.8/integrations/tracing/mongoose/vendored/types.d.ts +0 -36
  501. package/build/types-ts3.8/integrations/tracing/mysql2/vendored/types.d.ts +0 -18
  502. package/build/types-ts3.8/integrations/tracing/tedious/vendored/types.d.ts +0 -10
@@ -1,35 +1,21 @@
1
- import { ATTR_DB_CONNECTION_STRING, ATTR_DB_NAME, ATTR_DB_USER, ATTR_NET_PEER_NAME, ATTR_NET_PEER_PORT } from './semconv.js';
2
- import { SemconvStability } from '@opentelemetry/instrumentation';
3
- import { ATTR_DB_NAMESPACE, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT } from '@opentelemetry/semantic-conventions';
1
+ import { ATTR_NET_PEER_NAME, ATTR_DB_USER, ATTR_DB_NAME, ATTR_DB_CONNECTION_STRING, ATTR_NET_PEER_PORT } from './semconv.js';
4
2
 
5
- function getConnectionAttributes(config, dbSemconvStability, netSemconvStability) {
3
+ function getConnectionAttributes(config) {
6
4
  const { host, port, database, user } = getConfig(config);
7
- const attrs = {};
8
- if (dbSemconvStability & SemconvStability.OLD) {
9
- attrs[ATTR_DB_CONNECTION_STRING] = getJDBCString(host, port, database);
10
- attrs[ATTR_DB_NAME] = database;
11
- attrs[ATTR_DB_USER] = user;
12
- }
13
- if (dbSemconvStability & SemconvStability.STABLE) {
14
- attrs[ATTR_DB_NAMESPACE] = database;
15
- }
5
+ const attrs = {
6
+ [ATTR_DB_CONNECTION_STRING]: getJDBCString(host, port, database),
7
+ [ATTR_DB_NAME]: database,
8
+ [ATTR_DB_USER]: user,
9
+ [ATTR_NET_PEER_NAME]: host
10
+ };
16
11
  const portNumber = parseInt(port, 10);
17
- if (netSemconvStability & SemconvStability.OLD) {
18
- attrs[ATTR_NET_PEER_NAME] = host;
19
- if (!isNaN(portNumber)) {
20
- attrs[ATTR_NET_PEER_PORT] = portNumber;
21
- }
22
- }
23
- if (netSemconvStability & SemconvStability.STABLE) {
24
- attrs[ATTR_SERVER_ADDRESS] = host;
25
- if (!isNaN(portNumber)) {
26
- attrs[ATTR_SERVER_PORT] = portNumber;
27
- }
12
+ if (!isNaN(portNumber)) {
13
+ attrs[ATTR_NET_PEER_PORT] = portNumber;
28
14
  }
29
15
  return attrs;
30
16
  }
31
17
  function getConfig(config) {
32
- const { host, port, database, user } = config && config.connectionConfig || config || {};
18
+ const { host, port, database, user } = config?.connectionConfig || config || {};
33
19
  return { host, port, database, user };
34
20
  }
35
21
  function getJDBCString(host, port, database) {
@@ -42,23 +28,18 @@ function getJDBCString(host, port, database) {
42
28
  }
43
29
  return jdbcString;
44
30
  }
45
- function getQueryText(query, format, values, maskStatement = false, maskStatementHook = defaultMaskingHook) {
31
+ function getQueryText(query, format, values) {
46
32
  const [querySql, queryValues] = typeof query === "string" ? [query, values] : [query.sql, hasValues(query) ? values || query.values : values];
47
33
  try {
48
- if (maskStatement) {
49
- return maskStatementHook(querySql);
50
- } else if (format && queryValues) {
34
+ if (format && queryValues) {
51
35
  return format(querySql, queryValues);
52
36
  } else {
53
37
  return querySql;
54
38
  }
55
- } catch (e) {
56
- return "Could not determine the query due to an error in masking or formatting";
39
+ } catch {
40
+ return "Could not determine the query due to an error in formatting";
57
41
  }
58
42
  }
59
- function defaultMaskingHook(query) {
60
- return query.replace(/\b\d+\b/g, "?").replace(/(["'])(?:(?=(\\?))\2.)*?\1/g, "?");
61
- }
62
43
  function hasValues(obj) {
63
44
  return "values" in obj;
64
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/mysql2/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mysql2\n * - Upstream version: @opentelemetry/instrumentation-mysql2@0.64.0\n * - Types from 'mysql2' inlined as simplified interfaces\n */\n/* eslint-disable */\n\nimport { Attributes } from '@opentelemetry/api';\nimport {\n ATTR_DB_CONNECTION_STRING,\n ATTR_DB_NAME,\n ATTR_DB_USER,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n} from './semconv';\nimport type { FormatFunction } from './mysql2-types';\nimport { MySQL2InstrumentationQueryMaskingHook } from './types';\nimport { SemconvStability } from '@opentelemetry/instrumentation';\nimport { ATTR_DB_NAMESPACE, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT } from '@opentelemetry/semantic-conventions';\n\ninterface QueryOptions {\n sql: string;\n values?: any | any[] | { [param: string]: any };\n}\n\ninterface Query {\n sql: string;\n}\n\ninterface Config {\n host?: string;\n port?: number;\n database?: string;\n user?: string;\n connectionConfig?: Config;\n}\n\nexport function getConnectionAttributes(\n config: Config,\n dbSemconvStability: SemconvStability,\n netSemconvStability: SemconvStability,\n): Attributes {\n const { host, port, database, user } = getConfig(config);\n\n const attrs: Attributes = {};\n if (dbSemconvStability & SemconvStability.OLD) {\n attrs[ATTR_DB_CONNECTION_STRING] = getJDBCString(host, port, database);\n attrs[ATTR_DB_NAME] = database;\n attrs[ATTR_DB_USER] = user;\n }\n if (dbSemconvStability & SemconvStability.STABLE) {\n attrs[ATTR_DB_NAMESPACE] = database;\n }\n\n const portNumber = parseInt(port, 10);\n if (netSemconvStability & SemconvStability.OLD) {\n attrs[ATTR_NET_PEER_NAME] = host;\n if (!isNaN(portNumber)) {\n attrs[ATTR_NET_PEER_PORT] = portNumber;\n }\n }\n if (netSemconvStability & SemconvStability.STABLE) {\n attrs[ATTR_SERVER_ADDRESS] = host;\n if (!isNaN(portNumber)) {\n attrs[ATTR_SERVER_PORT] = portNumber;\n }\n }\n\n return attrs;\n}\n\nfunction getConfig(config: any) {\n const { host, port, database, user } = (config && config.connectionConfig) || config || {};\n return { host, port, database, user };\n}\n\nfunction getJDBCString(host: string | undefined, port: number | undefined, database: string | undefined) {\n let jdbcString = `jdbc:mysql://${host || 'localhost'}`;\n\n if (typeof port === 'number') {\n jdbcString += `:${port}`;\n }\n\n if (typeof database === 'string') {\n jdbcString += `/${database}`;\n }\n\n return jdbcString;\n}\n\nexport function getQueryText(\n query: string | Query | QueryOptions,\n format?: FormatFunction,\n values?: any[],\n maskStatement = false,\n maskStatementHook: MySQL2InstrumentationQueryMaskingHook = defaultMaskingHook,\n): string {\n const [querySql, queryValues] =\n typeof query === 'string' ? [query, values] : [query.sql, hasValues(query) ? values || query.values : values];\n try {\n if (maskStatement) {\n return maskStatementHook(querySql);\n } else if (format && queryValues) {\n return format(querySql, queryValues);\n } else {\n return querySql;\n }\n } catch (e) {\n return 'Could not determine the query due to an error in masking or formatting';\n }\n}\n\nfunction defaultMaskingHook(query: string): string {\n return query.replace(/\\b\\d+\\b/g, '?').replace(/([\"'])(?:(?=(\\\\?))\\2.)*?\\1/g, '?');\n}\n\nfunction hasValues(obj: Query | QueryOptions): obj is QueryOptions {\n return 'values' in obj;\n}\n\nexport function getSpanName(query: string | Query | QueryOptions): string {\n const rawQuery = typeof query === 'object' ? query.sql : query;\n const firstSpace = rawQuery?.indexOf(' ');\n if (typeof firstSpace === 'number' && firstSpace !== -1) {\n return rawQuery?.substring(0, firstSpace);\n }\n return rawQuery;\n}\n\nexport const once = (fn: Function) => {\n let called = false;\n return (...args: unknown[]) => {\n if (called) return;\n called = true;\n return fn(...args);\n };\n};\n\nexport function getConnectionPrototypeToInstrument(connection: any) {\n const connectionPrototype = connection.prototype;\n const basePrototype = Object.getPrototypeOf(connectionPrototype);\n\n if (typeof basePrototype?.query === 'function' && typeof basePrototype?.execute === 'function') {\n return basePrototype;\n }\n\n return connectionPrototype;\n}\n"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/mysql2/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-mysql2\n * - Upstream version: @opentelemetry/instrumentation-mysql2@0.64.0\n * - Types from 'mysql2' inlined as simplified interfaces\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { SpanAttributes } from '@sentry/core';\nimport type { FormatFunction } from './mysql2-types';\nimport {\n ATTR_DB_CONNECTION_STRING,\n ATTR_DB_NAME,\n ATTR_DB_USER,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n} from './semconv';\n\ninterface QueryOptions {\n sql: string;\n values?: any | any[] | { [param: string]: any };\n}\n\ninterface Query {\n sql: string;\n}\n\ninterface Config {\n host?: string;\n port?: number;\n database?: string;\n user?: string;\n connectionConfig?: Config;\n}\n\nexport function getConnectionAttributes(config: Config): SpanAttributes {\n const { host, port, database, user } = getConfig(config);\n\n const attrs: SpanAttributes = {\n [ATTR_DB_CONNECTION_STRING]: getJDBCString(host, port, database),\n [ATTR_DB_NAME]: database,\n [ATTR_DB_USER]: user,\n [ATTR_NET_PEER_NAME]: host,\n };\n\n const portNumber = parseInt(port, 10);\n if (!isNaN(portNumber)) {\n attrs[ATTR_NET_PEER_PORT] = portNumber;\n }\n\n return attrs;\n}\n\nfunction getConfig(config: any) {\n const { host, port, database, user } = config?.connectionConfig || config || {};\n return { host, port, database, user };\n}\n\nfunction getJDBCString(host: string | undefined, port: number | undefined, database: string | undefined) {\n let jdbcString = `jdbc:mysql://${host || 'localhost'}`;\n\n if (typeof port === 'number') {\n jdbcString += `:${port}`;\n }\n\n if (typeof database === 'string') {\n jdbcString += `/${database}`;\n }\n\n return jdbcString;\n}\n\nexport function getQueryText(query: string | Query | QueryOptions, format?: FormatFunction, values?: any[]): string {\n const [querySql, queryValues] =\n typeof query === 'string' ? [query, values] : [query.sql, hasValues(query) ? values || query.values : values];\n try {\n if (format && queryValues) {\n return format(querySql, queryValues);\n } else {\n return querySql;\n }\n } catch {\n return 'Could not determine the query due to an error in formatting';\n }\n}\n\nfunction hasValues(obj: Query | QueryOptions): obj is QueryOptions {\n return 'values' in obj;\n}\n\nexport function getSpanName(query: string | Query | QueryOptions): string {\n const rawQuery = typeof query === 'object' ? query.sql : query;\n const firstSpace = rawQuery?.indexOf(' ');\n if (typeof firstSpace === 'number' && firstSpace !== -1) {\n return rawQuery?.substring(0, firstSpace);\n }\n return rawQuery;\n}\n\nexport const once = (fn: Function) => {\n let called = false;\n return (...args: unknown[]) => {\n if (called) return;\n called = true;\n return fn(...args);\n };\n};\n\nexport function getConnectionPrototypeToInstrument(connection: any) {\n const connectionPrototype = connection.prototype;\n const basePrototype = Object.getPrototypeOf(connectionPrototype);\n\n if (typeof basePrototype?.query === 'function' && typeof basePrototype?.execute === 'function') {\n return basePrototype;\n }\n\n return connectionPrototype;\n}\n"],"names":[],"mappings":"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"}
@@ -1,16 +1,12 @@
1
1
  import { PgInstrumentation } from './vendored/instrumentation.js';
2
2
  import { defineIntegration } from '@sentry/core';
3
- import { generateInstrumentOnce, addOriginToSpan } from '@sentry/node-core';
3
+ import { generateInstrumentOnce } from '@sentry/node-core';
4
4
 
5
5
  const INTEGRATION_NAME = "Postgres";
6
6
  const instrumentPostgres = generateInstrumentOnce(
7
7
  INTEGRATION_NAME,
8
8
  PgInstrumentation,
9
9
  (options) => ({
10
- requireParentSpan: true,
11
- requestHook(span) {
12
- addOriginToSpan(span, "auto.db.otel.postgres");
13
- },
14
10
  ignoreConnectSpans: options?.ignoreConnectSpans ?? false
15
11
  })
16
12
  );
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/postgres/index.ts"],"sourcesContent":["import { PgInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\n\ninterface PostgresIntegrationOptions {\n ignoreConnectSpans?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Postgres';\n\nexport const instrumentPostgres = generateInstrumentOnce(\n INTEGRATION_NAME,\n PgInstrumentation,\n (options?: PostgresIntegrationOptions) => ({\n requireParentSpan: true,\n requestHook(span) {\n addOriginToSpan(span, 'auto.db.otel.postgres');\n },\n ignoreConnectSpans: options?.ignoreConnectSpans ?? false,\n }),\n);\n\nconst _postgresIntegration = ((options?: PostgresIntegrationOptions) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgres(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [pg](https://www.npmjs.com/package/pg) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresIntegration()],\n * });\n * ```\n */\nexport const postgresIntegration = defineIntegration(_postgresIntegration);\n"],"names":[],"mappings":";;;;AASA,MAAM,gBAAA,GAAmB,UAAA;AAElB,MAAM,kBAAA,GAAqB,sBAAA;AAAA,EAChC,gBAAA;AAAA,EACA,iBAAA;AAAA,EACA,CAAC,OAAA,MAA0C;AAAA,IACzC,iBAAA,EAAmB,IAAA;AAAA,IACnB,YAAY,IAAA,EAAM;AAChB,MAAA,eAAA,CAAgB,MAAM,uBAAuB,CAAA;AAAA,IAC/C,CAAA;AAAA,IACA,kBAAA,EAAoB,SAAS,kBAAA,IAAsB;AAAA,GACrD;AACF;AAEA,MAAM,oBAAA,IAAwB,CAAC,OAAA,KAAyC;AACtE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,kBAAA,CAAmB,OAAO,CAAA;AAAA,IAC5B;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,mBAAA,GAAsB,kBAAkB,oBAAoB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/postgres/index.ts"],"sourcesContent":["import { PgInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\ninterface PostgresIntegrationOptions {\n ignoreConnectSpans?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Postgres';\n\nexport const instrumentPostgres = generateInstrumentOnce(\n INTEGRATION_NAME,\n PgInstrumentation,\n (options?: PostgresIntegrationOptions) => ({\n ignoreConnectSpans: options?.ignoreConnectSpans ?? false,\n }),\n);\n\nconst _postgresIntegration = ((options?: PostgresIntegrationOptions) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgres(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [pg](https://www.npmjs.com/package/pg) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresIntegration()],\n * });\n * ```\n */\nexport const postgresIntegration = defineIntegration(_postgresIntegration);\n"],"names":[],"mappings":";;;;AASA,MAAM,gBAAA,GAAmB,UAAA;AAElB,MAAM,kBAAA,GAAqB,sBAAA;AAAA,EAChC,gBAAA;AAAA,EACA,iBAAA;AAAA,EACA,CAAC,OAAA,MAA0C;AAAA,IACzC,kBAAA,EAAoB,SAAS,kBAAA,IAAsB;AAAA,GACrD;AACF;AAEA,MAAM,oBAAA,IAAwB,CAAC,OAAA,KAAyC;AACtE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,kBAAA,CAAmB,OAAO,CAAA;AAAA,IAC5B;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,mBAAA,GAAsB,kBAAkB,oBAAoB;;;;"}
@@ -1,5 +1,4 @@
1
1
  var AttributeNames = /* @__PURE__ */ ((AttributeNames2) => {
2
- AttributeNames2["PG_VALUES"] = "db.postgresql.values";
3
2
  AttributeNames2["PG_PLAN"] = "db.postgresql.plan";
4
3
  AttributeNames2["IDLE_TIMEOUT_MILLIS"] = "db.postgresql.idle.timeout.millis";
5
4
  AttributeNames2["MAX_CLIENT"] = "db.postgresql.max.client";
@@ -1 +1 @@
1
- {"version":3,"file":"AttributeNames.js","sources":["../../../../../../../src/integrations/tracing/postgres/vendored/enums/AttributeNames.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-pg\n * - Upstream version: @opentelemetry/instrumentation-pg@0.70.0\n */\n/* eslint-disable */\n\n// Postgresql specific attributes not covered by semantic conventions\nexport enum AttributeNames {\n PG_VALUES = 'db.postgresql.values',\n PG_PLAN = 'db.postgresql.plan',\n IDLE_TIMEOUT_MILLIS = 'db.postgresql.idle.timeout.millis',\n MAX_CLIENT = 'db.postgresql.max.client',\n}\n"],"names":["AttributeNames"],"mappings":"AAsBO,IAAK,cAAA,qBAAAA,eAAAA,KAAL;AACL,EAAAA,gBAAA,WAAA,CAAA,GAAY,sBAAA;AACZ,EAAAA,gBAAA,SAAA,CAAA,GAAU,oBAAA;AACV,EAAAA,gBAAA,qBAAA,CAAA,GAAsB,mCAAA;AACtB,EAAAA,gBAAA,YAAA,CAAA,GAAa,0BAAA;AAJH,EAAA,OAAAA,eAAAA;AAAA,CAAA,EAAA,cAAA,IAAA,EAAA;;;;"}
1
+ {"version":3,"file":"AttributeNames.js","sources":["../../../../../../../src/integrations/tracing/postgres/vendored/enums/AttributeNames.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-pg\n * - Upstream version: @opentelemetry/instrumentation-pg@0.70.0\n */\n\n// Postgresql specific attributes not covered by semantic conventions\nexport enum AttributeNames {\n PG_PLAN = 'db.postgresql.plan',\n IDLE_TIMEOUT_MILLIS = 'db.postgresql.idle.timeout.millis',\n MAX_CLIENT = 'db.postgresql.max.client',\n}\n"],"names":["AttributeNames"],"mappings":"AAUO,IAAK,cAAA,qBAAAA,eAAAA,KAAL;AACL,EAAAA,gBAAA,SAAA,CAAA,GAAU,oBAAA;AACV,EAAAA,gBAAA,qBAAA,CAAA,GAAsB,mCAAA;AACtB,EAAAA,gBAAA,YAAA,CAAA,GAAa,0BAAA;AAHH,EAAA,OAAAA,eAAAA;AAAA,CAAA,EAAA,cAAA,IAAA,EAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SpanNames.js","sources":["../../../../../../../src/integrations/tracing/postgres/vendored/enums/SpanNames.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-pg\n * - Upstream version: @opentelemetry/instrumentation-pg@0.70.0\n */\n/* eslint-disable */\n\n// Contains span names produced by instrumentation\nexport enum SpanNames {\n QUERY_PREFIX = 'pg.query',\n CONNECT = 'pg.connect',\n POOL_CONNECT = 'pg-pool.connect',\n}\n"],"names":["SpanNames"],"mappings":"AAsBO,IAAK,SAAA,qBAAAA,UAAAA,KAAL;AACL,EAAAA,WAAA,cAAA,CAAA,GAAe,UAAA;AACf,EAAAA,WAAA,SAAA,CAAA,GAAU,YAAA;AACV,EAAAA,WAAA,cAAA,CAAA,GAAe,iBAAA;AAHL,EAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA;;;;"}
1
+ {"version":3,"file":"SpanNames.js","sources":["../../../../../../../src/integrations/tracing/postgres/vendored/enums/SpanNames.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-pg\n * - Upstream version: @opentelemetry/instrumentation-pg@0.70.0\n */\n\n// Contains span names produced by instrumentation\nexport enum SpanNames {\n QUERY_PREFIX = 'pg.query',\n CONNECT = 'pg.connect',\n POOL_CONNECT = 'pg-pool.connect',\n}\n"],"names":["SpanNames"],"mappings":"AAUO,IAAK,SAAA,qBAAAA,UAAAA,KAAL;AACL,EAAAA,WAAA,cAAA,CAAA,GAAe,UAAA;AACf,EAAAA,WAAA,SAAA,CAAA,GAAU,YAAA;AACV,EAAAA,WAAA,cAAA,CAAA,GAAe,iBAAA;AAHL,EAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA;;;;"}
@@ -1,55 +1,22 @@
1
- import { InstrumentationBase, semconvStabilityFromStr, InstrumentationNodeModuleDefinition, isWrapped, SemconvStability, safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
1
+ import { SpanKind } from '@opentelemetry/api';
2
+ import { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';
3
+ import { SDK_VERSION, startInactiveSpan, getActiveSpan, withActiveSpan, SPAN_STATUS_ERROR } from '@sentry/core';
2
4
  import { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile.js';
3
- import { ValueType, SpanKind, trace, context, SpanStatusCode } from '@opentelemetry/api';
4
- import { EVENT_LISTENERS_SET } from './internal-types.js';
5
- import { shouldSkipInstrumentation, getSemanticAttributesFromConnection, patchClientConnectCallback, isObjectWithTextString, parseNormalizedOperationName, handleConfigQuery, patchCallback, sanitizedErrorMessage, getErrorMessage, handleExecutionResult, getPoolName, updateCounter, getSemanticAttributesFromPoolConnection, patchCallbackPGPool } from './utils.js';
6
- import { addSqlCommenterComment } from '../../utils/sql-common.js';
7
- import { SDK_VERSION, timestampInSeconds } from '@sentry/core';
8
5
  import { SpanNames } from './enums/SpanNames.js';
9
- import { METRIC_DB_CLIENT_OPERATION_DURATION, ATTR_DB_NAMESPACE, ATTR_ERROR_TYPE, ATTR_SERVER_PORT, ATTR_SERVER_ADDRESS, ATTR_DB_OPERATION_NAME, ATTR_DB_SYSTEM_NAME } from '@opentelemetry/semantic-conventions';
10
- import { METRIC_DB_CLIENT_CONNECTION_COUNT, METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS, ATTR_DB_SYSTEM, DB_SYSTEM_VALUE_POSTGRESQL } from './semconv.js';
6
+ import { shouldSkipInstrumentation, getSemanticAttributesFromConnection, patchClientConnectCallback, isObjectWithTextString, handleConfigQuery, patchCallback, getErrorMessage, getSemanticAttributesFromPoolConnection, patchCallbackPGPool } from './utils.js';
11
7
 
12
8
  const PACKAGE_NAME = "@sentry/instrumentation-pg";
13
9
  function extractModuleExports(module) {
14
10
  return module[Symbol.toStringTag] === "Module" ? module.default : module;
15
11
  }
12
+ function bindCallbackToSpan(parentSpan, callback) {
13
+ return function(...args) {
14
+ return withActiveSpan(parentSpan, () => callback.apply(this, args));
15
+ };
16
+ }
16
17
  class PgInstrumentation extends InstrumentationBase {
17
18
  constructor(config = {}) {
18
19
  super(PACKAGE_NAME, SDK_VERSION, config);
19
- // Pool events connect, acquire, release and remove can be called
20
- // multiple times without changing the values of total, idle and waiting
21
- // connections. The _connectionsCounter is used to keep track of latest
22
- // values and only update the metrics _connectionsCount and _connectionPendingRequests
23
- // when the value change.
24
- this._connectionsCounter = {
25
- used: 0,
26
- idle: 0,
27
- pending: 0
28
- };
29
- this._semconvStability = semconvStabilityFromStr("database", process.env.OTEL_SEMCONV_STABILITY_OPT_IN);
30
- }
31
- _updateMetricInstruments() {
32
- this._operationDuration = this.meter.createHistogram(METRIC_DB_CLIENT_OPERATION_DURATION, {
33
- description: "Duration of database client operations.",
34
- unit: "s",
35
- valueType: ValueType.DOUBLE,
36
- advice: {
37
- explicitBucketBoundaries: [1e-3, 5e-3, 0.01, 0.05, 0.1, 0.5, 1, 5, 10]
38
- }
39
- });
40
- this._connectionsCounter = {
41
- idle: 0,
42
- pending: 0,
43
- used: 0
44
- };
45
- this._connectionsCount = this.meter.createUpDownCounter(METRIC_DB_CLIENT_CONNECTION_COUNT, {
46
- description: "The number of connections that are currently in state described by the state attribute.",
47
- unit: "{connection}"
48
- });
49
- this._connectionPendingRequests = this.meter.createUpDownCounter(METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS, {
50
- description: "The number of current pending requests for an open connection.",
51
- unit: "{connection}"
52
- });
53
20
  }
54
21
  init() {
55
22
  const SUPPORTED_PG_VERSIONS = [">=8.0.3 <9"];
@@ -130,60 +97,36 @@ class PgInstrumentation extends InstrumentationBase {
130
97
  const plugin = this;
131
98
  return (original) => {
132
99
  return function connect(callback) {
133
- const config = plugin.getConfig();
134
- if (shouldSkipInstrumentation(config) || config.ignoreConnectSpans) {
100
+ if (shouldSkipInstrumentation() || plugin.getConfig().ignoreConnectSpans) {
135
101
  return original.call(this, callback);
136
102
  }
137
- const span = plugin.tracer.startSpan(SpanNames.CONNECT, {
103
+ const span = startInactiveSpan({
104
+ name: SpanNames.CONNECT,
138
105
  kind: SpanKind.CLIENT,
139
- attributes: getSemanticAttributesFromConnection(this, plugin._semconvStability)
106
+ attributes: getSemanticAttributesFromConnection(this)
140
107
  });
141
- if (callback) {
142
- const parentSpan = trace.getSpan(context.active());
143
- callback = patchClientConnectCallback(span, callback);
108
+ let cb = callback;
109
+ if (cb) {
110
+ const parentSpan = getActiveSpan();
111
+ cb = patchClientConnectCallback(span, cb);
144
112
  if (parentSpan) {
145
- callback = context.bind(context.active(), callback);
113
+ cb = bindCallbackToSpan(parentSpan, cb);
146
114
  }
147
115
  }
148
- const connectResult = context.with(trace.setSpan(context.active(), span), () => {
149
- return original.call(this, callback);
116
+ const connectResult = withActiveSpan(span, () => {
117
+ return original.call(this, cb);
150
118
  });
151
119
  return handleConnectResult(span, connectResult);
152
120
  };
153
121
  };
154
122
  }
155
- recordOperationDuration(attributes, startTime) {
156
- const metricsAttributes = {};
157
- const keysToCopy = [
158
- ATTR_DB_NAMESPACE,
159
- ATTR_ERROR_TYPE,
160
- ATTR_SERVER_PORT,
161
- ATTR_SERVER_ADDRESS,
162
- ATTR_DB_OPERATION_NAME
163
- ];
164
- if (this._semconvStability & SemconvStability.OLD) {
165
- keysToCopy.push(ATTR_DB_SYSTEM);
166
- }
167
- if (this._semconvStability & SemconvStability.STABLE) {
168
- keysToCopy.push(ATTR_DB_SYSTEM_NAME);
169
- }
170
- keysToCopy.forEach((key) => {
171
- if (key in attributes) {
172
- metricsAttributes[key] = attributes[key];
173
- }
174
- });
175
- const durationSeconds = timestampInSeconds() - startTime;
176
- this._operationDuration.record(durationSeconds, metricsAttributes);
177
- }
178
123
  _getClientQueryPatch() {
179
- const plugin = this;
180
124
  return (original) => {
181
125
  this._diag.debug("Patching pg.Client.prototype.query");
182
126
  return function query(...args) {
183
- if (shouldSkipInstrumentation(plugin.getConfig())) {
127
+ if (shouldSkipInstrumentation()) {
184
128
  return original.apply(this, args);
185
129
  }
186
- const startTime = timestampInSeconds();
187
130
  const arg0 = args[0];
188
131
  const firstArgIsString = typeof arg0 === "string";
189
132
  const firstArgIsQueryObjectWithText = isObjectWithTextString(arg0);
@@ -196,210 +139,66 @@ class PgInstrumentation extends InstrumentationBase {
196
139
  text: arg0.text,
197
140
  values: arg0.values ?? (Array.isArray(args[1]) ? args[1] : void 0)
198
141
  } : void 0;
199
- const attributes = {
200
- [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_POSTGRESQL,
201
- [ATTR_DB_NAMESPACE]: this.database,
202
- [ATTR_SERVER_PORT]: this.connectionParameters.port,
203
- [ATTR_SERVER_ADDRESS]: this.connectionParameters.host
204
- };
205
- if (queryConfig?.text) {
206
- attributes[ATTR_DB_OPERATION_NAME] = parseNormalizedOperationName(queryConfig?.text);
207
- }
208
- const recordDuration = () => {
209
- plugin.recordOperationDuration(attributes, startTime);
210
- };
211
- const instrumentationConfig = plugin.getConfig();
212
- const span = handleConfigQuery.call(
213
- this,
214
- plugin.tracer,
215
- instrumentationConfig,
216
- plugin._semconvStability,
217
- queryConfig
218
- );
219
- if (instrumentationConfig.addSqlCommenterCommentToQueries) {
220
- if (firstArgIsString) {
221
- args[0] = addSqlCommenterComment(span, arg0);
222
- } else if (firstArgIsQueryObjectWithText && !("name" in arg0)) {
223
- args[0] = {
224
- ...arg0,
225
- text: addSqlCommenterComment(span, arg0.text)
226
- };
227
- }
228
- }
142
+ const span = handleConfigQuery.call(this, queryConfig);
229
143
  if (args.length > 0) {
230
- const parentSpan = trace.getSpan(context.active());
144
+ const parentSpan = getActiveSpan();
231
145
  if (typeof args[args.length - 1] === "function") {
232
- args[args.length - 1] = patchCallback(
233
- instrumentationConfig,
234
- span,
235
- args[args.length - 1],
236
- // nb: not type safe.
237
- attributes,
238
- recordDuration
239
- );
146
+ args[args.length - 1] = patchCallback(span, args[args.length - 1]);
240
147
  if (parentSpan) {
241
- args[args.length - 1] = context.bind(context.active(), args[args.length - 1]);
148
+ args[args.length - 1] = bindCallbackToSpan(parentSpan, args[args.length - 1]);
242
149
  }
243
150
  } else if (typeof queryConfig?.callback === "function") {
244
- let callback = patchCallback(
245
- plugin.getConfig(),
246
- span,
247
- queryConfig.callback,
248
- // nb: not type safe.
249
- attributes,
250
- recordDuration
251
- );
151
+ let callback = patchCallback(span, queryConfig.callback);
252
152
  if (parentSpan) {
253
- callback = context.bind(context.active(), callback);
153
+ callback = bindCallbackToSpan(parentSpan, callback);
254
154
  }
255
155
  args[0].callback = callback;
256
156
  }
257
157
  }
258
- const { requestHook } = instrumentationConfig;
259
- if (typeof requestHook === "function" && queryConfig) {
260
- safeExecuteInTheMiddle(
261
- () => {
262
- const { database, host, port, user } = this.connectionParameters;
263
- const connection = { database, host, port, user };
264
- requestHook(span, {
265
- connection,
266
- query: {
267
- text: queryConfig.text,
268
- // nb: if `client.query` is called with illegal arguments
269
- // (e.g., if `queryConfig.values` is passed explicitly, but a
270
- // non-array is given), then the type casts will be wrong. But
271
- // we leave it up to the queryHook to handle that, and we
272
- // catch and swallow any errors it throws. The other options
273
- // are all worse. E.g., we could leave `queryConfig.values`
274
- // and `queryConfig.name` as `unknown`, but then the hook body
275
- // would be forced to validate (or cast) them before using
276
- // them, which seems incredibly cumbersome given that these
277
- // casts will be correct 99.9% of the time -- and pg.query
278
- // will immediately throw during development in the other .1%
279
- // of cases. Alternatively, we could simply skip calling the
280
- // hook when `values` or `name` don't have the expected type,
281
- // but that would add unnecessary validation overhead to every
282
- // hook invocation and possibly be even more confusing/unexpected.
283
- values: queryConfig.values,
284
- name: queryConfig.name
285
- }
286
- });
287
- },
288
- (err) => {
289
- if (err) {
290
- plugin._diag.error("Error running query hook", err);
291
- }
292
- },
293
- true
294
- );
295
- }
296
158
  let result;
297
159
  try {
298
160
  result = original.apply(this, args);
299
161
  } catch (e) {
300
- if (e instanceof Error) {
301
- span.recordException(sanitizedErrorMessage(e));
302
- }
303
- span.setStatus({
304
- code: SpanStatusCode.ERROR,
305
- message: getErrorMessage(e)
306
- });
162
+ span.setStatus({ code: SPAN_STATUS_ERROR, message: getErrorMessage(e) });
307
163
  span.end();
308
164
  throw e;
309
165
  }
310
166
  if (result instanceof Promise) {
311
167
  return result.then((result2) => {
312
- return new Promise((resolve) => {
313
- handleExecutionResult(plugin.getConfig(), span, result2);
314
- recordDuration();
315
- span.end();
316
- resolve(result2);
317
- });
168
+ span.end();
169
+ return result2;
318
170
  }).catch((error) => {
319
- return new Promise((_, reject) => {
320
- if (error instanceof Error) {
321
- span.recordException(sanitizedErrorMessage(error));
322
- }
323
- span.setStatus({
324
- code: SpanStatusCode.ERROR,
325
- message: error.message
326
- });
327
- recordDuration();
328
- span.end();
329
- reject(error);
330
- });
171
+ span.setStatus({ code: SPAN_STATUS_ERROR, message: getErrorMessage(error) });
172
+ span.end();
173
+ return Promise.reject(error);
331
174
  });
332
175
  }
333
176
  return result;
334
177
  };
335
178
  };
336
179
  }
337
- _setPoolConnectEventListeners(pgPool) {
338
- if (pgPool[EVENT_LISTENERS_SET]) return;
339
- const poolName = getPoolName(pgPool.options);
340
- pgPool.on("connect", () => {
341
- this._connectionsCounter = updateCounter(
342
- poolName,
343
- pgPool,
344
- this._connectionsCount,
345
- this._connectionPendingRequests,
346
- this._connectionsCounter
347
- );
348
- });
349
- pgPool.on("acquire", () => {
350
- this._connectionsCounter = updateCounter(
351
- poolName,
352
- pgPool,
353
- this._connectionsCount,
354
- this._connectionPendingRequests,
355
- this._connectionsCounter
356
- );
357
- });
358
- pgPool.on("remove", () => {
359
- this._connectionsCounter = updateCounter(
360
- poolName,
361
- pgPool,
362
- this._connectionsCount,
363
- this._connectionPendingRequests,
364
- this._connectionsCounter
365
- );
366
- });
367
- pgPool.on("release", () => {
368
- this._connectionsCounter = updateCounter(
369
- poolName,
370
- pgPool,
371
- this._connectionsCount,
372
- this._connectionPendingRequests,
373
- this._connectionsCounter
374
- );
375
- });
376
- pgPool[EVENT_LISTENERS_SET] = true;
377
- }
378
180
  _getPoolConnectPatch() {
379
181
  const plugin = this;
380
182
  return (originalConnect) => {
381
183
  return function connect(callback) {
382
- const config = plugin.getConfig();
383
- if (shouldSkipInstrumentation(config)) {
384
- return originalConnect.call(this, callback);
385
- }
386
- plugin._setPoolConnectEventListeners(this);
387
- if (config.ignoreConnectSpans) {
184
+ if (shouldSkipInstrumentation() || plugin.getConfig().ignoreConnectSpans) {
388
185
  return originalConnect.call(this, callback);
389
186
  }
390
- const span = plugin.tracer.startSpan(SpanNames.POOL_CONNECT, {
187
+ const span = startInactiveSpan({
188
+ name: SpanNames.POOL_CONNECT,
391
189
  kind: SpanKind.CLIENT,
392
- attributes: getSemanticAttributesFromPoolConnection(this.options, plugin._semconvStability)
190
+ attributes: getSemanticAttributesFromPoolConnection(this.options)
393
191
  });
394
- if (callback) {
395
- const parentSpan = trace.getSpan(context.active());
396
- callback = patchCallbackPGPool(span, callback);
192
+ let cb = callback;
193
+ if (cb) {
194
+ const parentSpan = getActiveSpan();
195
+ cb = patchCallbackPGPool(span, cb);
397
196
  if (parentSpan) {
398
- callback = context.bind(context.active(), callback);
197
+ cb = bindCallbackToSpan(parentSpan, cb);
399
198
  }
400
199
  }
401
- const connectResult = context.with(trace.setSpan(context.active(), span), () => {
402
- return originalConnect.call(this, callback);
200
+ const connectResult = withActiveSpan(span, () => {
201
+ return originalConnect.call(this, cb);
403
202
  });
404
203
  return handleConnectResult(span, connectResult);
405
204
  };
@@ -411,23 +210,14 @@ function handleConnectResult(span, connectResult) {
411
210
  return connectResult;
412
211
  }
413
212
  const connectResultPromise = connectResult;
414
- return context.bind(
415
- context.active(),
416
- connectResultPromise.then((result) => {
417
- span.end();
418
- return result;
419
- }).catch((error) => {
420
- if (error instanceof Error) {
421
- span.recordException(sanitizedErrorMessage(error));
422
- }
423
- span.setStatus({
424
- code: SpanStatusCode.ERROR,
425
- message: getErrorMessage(error)
426
- });
427
- span.end();
428
- return Promise.reject(error);
429
- })
430
- );
213
+ return connectResultPromise.then((result) => {
214
+ span.end();
215
+ return result;
216
+ }).catch((error) => {
217
+ span.setStatus({ code: SPAN_STATUS_ERROR, message: getErrorMessage(error) });
218
+ span.end();
219
+ return Promise.reject(error);
220
+ });
431
221
  }
432
222
 
433
223
  export { PgInstrumentation };