@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 +1 @@
1
- {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/postgres/vendored/instrumentation.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 * - Types from `pg` and `pg-pool` packages inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments\n */\n/* eslint-disable */\n\nimport {\n isWrapped,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n safeExecuteInTheMiddle,\n SemconvStability,\n semconvStabilityFromStr,\n} from '@opentelemetry/instrumentation';\nimport { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile';\nimport {\n context,\n trace,\n Span,\n SpanStatusCode,\n SpanKind,\n Histogram,\n ValueType,\n Attributes,\n UpDownCounter,\n} from '@opentelemetry/api';\nimport type { PgClient } from './pg-types';\nimport {\n PgClientConnect,\n PgClientExtended,\n PostgresCallback,\n PgPoolExtended,\n PgPoolCallback,\n EVENT_LISTENERS_SET,\n} from './internal-types';\nimport { PgInstrumentationConfig } from './types';\nimport * as utils from './utils';\nimport { addSqlCommenterComment } from '../../utils/sql-common';\nimport { SDK_VERSION, timestampInSeconds } from '@sentry/core';\nconst PACKAGE_NAME = '@sentry/instrumentation-pg';\nimport { SpanNames } from './enums/SpanNames';\nimport {\n ATTR_ERROR_TYPE,\n ATTR_SERVER_PORT,\n ATTR_SERVER_ADDRESS,\n ATTR_DB_NAMESPACE,\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_SYSTEM_NAME,\n METRIC_DB_CLIENT_OPERATION_DURATION,\n} from '@opentelemetry/semantic-conventions';\nimport {\n METRIC_DB_CLIENT_CONNECTION_COUNT,\n METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS,\n ATTR_DB_SYSTEM,\n DB_SYSTEM_VALUE_POSTGRESQL,\n} from './semconv';\n\nfunction extractModuleExports(module: any) {\n return module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n}\n\nexport class PgInstrumentation extends InstrumentationBase<PgInstrumentationConfig> {\n declare private _operationDuration: Histogram;\n declare private _connectionsCount: UpDownCounter;\n declare private _connectionPendingRequests: UpDownCounter;\n // Pool events connect, acquire, release and remove can be called\n // multiple times without changing the values of total, idle and waiting\n // connections. The _connectionsCounter is used to keep track of latest\n // values and only update the metrics _connectionsCount and _connectionPendingRequests\n // when the value change.\n private _connectionsCounter: utils.poolConnectionsCounter = {\n used: 0,\n idle: 0,\n pending: 0,\n };\n private _semconvStability: SemconvStability;\n\n constructor(config: PgInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n this._semconvStability = semconvStabilityFromStr('database', process.env.OTEL_SEMCONV_STABILITY_OPT_IN);\n }\n\n override _updateMetricInstruments() {\n this._operationDuration = this.meter.createHistogram(METRIC_DB_CLIENT_OPERATION_DURATION, {\n description: 'Duration of database client operations.',\n unit: 's',\n valueType: ValueType.DOUBLE,\n advice: {\n explicitBucketBoundaries: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10],\n },\n });\n\n this._connectionsCounter = {\n idle: 0,\n pending: 0,\n used: 0,\n };\n this._connectionsCount = this.meter.createUpDownCounter(METRIC_DB_CLIENT_CONNECTION_COUNT, {\n description: 'The number of connections that are currently in state described by the state attribute.',\n unit: '{connection}',\n });\n this._connectionPendingRequests = this.meter.createUpDownCounter(METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS, {\n description: 'The number of current pending requests for an open connection.',\n unit: '{connection}',\n });\n }\n\n protected init() {\n const SUPPORTED_PG_VERSIONS = ['>=8.0.3 <9'];\n const SUPPORTED_PG_POOL_VERSIONS = ['>=2.0.0 <4'];\n\n const modulePgNativeClient = new InstrumentationNodeModuleFile(\n 'pg/lib/native/client.js',\n SUPPORTED_PG_VERSIONS,\n this._patchPgClient.bind(this),\n this._unpatchPgClient.bind(this),\n );\n\n const modulePgClient = new InstrumentationNodeModuleFile(\n 'pg/lib/client.js',\n SUPPORTED_PG_VERSIONS,\n this._patchPgClient.bind(this),\n this._unpatchPgClient.bind(this),\n );\n\n const modulePG = new InstrumentationNodeModuleDefinition(\n 'pg',\n SUPPORTED_PG_VERSIONS,\n (module: any) => {\n const moduleExports = extractModuleExports(module);\n\n this._patchPgClient(moduleExports.Client);\n return module;\n },\n (module: any) => {\n const moduleExports = extractModuleExports(module);\n\n this._unpatchPgClient(moduleExports.Client);\n return module;\n },\n [modulePgClient, modulePgNativeClient],\n );\n\n const modulePGPool = new InstrumentationNodeModuleDefinition(\n 'pg-pool',\n SUPPORTED_PG_POOL_VERSIONS,\n (module: any) => {\n const moduleExports = extractModuleExports(module);\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n this._wrap(moduleExports.prototype, 'connect', this._getPoolConnectPatch() as any);\n return moduleExports;\n },\n (module: any) => {\n const moduleExports = extractModuleExports(module);\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n },\n );\n\n return [modulePG, modulePGPool];\n }\n\n private _patchPgClient(module: any) {\n if (!module) {\n return;\n }\n\n const moduleExports = extractModuleExports(module);\n\n if (isWrapped(moduleExports.prototype.query)) {\n this._unwrap(moduleExports.prototype, 'query');\n }\n\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n\n this._wrap(moduleExports.prototype, 'query', this._getClientQueryPatch() as any);\n\n this._wrap(moduleExports.prototype, 'connect', this._getClientConnectPatch() as any);\n\n return module;\n }\n\n private _unpatchPgClient(module: any) {\n const moduleExports = extractModuleExports(module);\n\n if (isWrapped(moduleExports.prototype.query)) {\n this._unwrap(moduleExports.prototype, 'query');\n }\n\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n\n return module;\n }\n\n private _getClientConnectPatch() {\n const plugin = this;\n return (original: PgClientConnect) => {\n return function connect(this: PgClient, callback?: Function) {\n const config = plugin.getConfig();\n\n if (utils.shouldSkipInstrumentation(config) || config.ignoreConnectSpans) {\n return original.call(this, callback);\n }\n\n const span = plugin.tracer.startSpan(SpanNames.CONNECT, {\n kind: SpanKind.CLIENT,\n attributes: utils.getSemanticAttributesFromConnection(this, plugin._semconvStability),\n });\n\n if (callback) {\n const parentSpan = trace.getSpan(context.active());\n callback = utils.patchClientConnectCallback(span, callback);\n if (parentSpan) {\n callback = context.bind(context.active(), callback);\n }\n }\n\n const connectResult: unknown = context.with(trace.setSpan(context.active(), span), () => {\n return original.call(this, callback);\n });\n\n return handleConnectResult(span, connectResult);\n };\n };\n }\n\n private recordOperationDuration(attributes: Attributes, startTime: number) {\n const metricsAttributes: Attributes = {};\n const keysToCopy: string[] = [\n ATTR_DB_NAMESPACE,\n ATTR_ERROR_TYPE,\n ATTR_SERVER_PORT,\n ATTR_SERVER_ADDRESS,\n ATTR_DB_OPERATION_NAME,\n ];\n if (this._semconvStability & SemconvStability.OLD) {\n keysToCopy.push(ATTR_DB_SYSTEM);\n }\n if (this._semconvStability & SemconvStability.STABLE) {\n keysToCopy.push(ATTR_DB_SYSTEM_NAME);\n }\n\n keysToCopy.forEach(key => {\n if (key in attributes) {\n metricsAttributes[key] = attributes[key];\n }\n });\n\n const durationSeconds = timestampInSeconds() - startTime;\n this._operationDuration.record(durationSeconds, metricsAttributes);\n }\n\n private _getClientQueryPatch() {\n const plugin = this;\n return (original: (...args: any[]) => any) => {\n this._diag.debug('Patching pg.Client.prototype.query');\n return function query(this: PgClientExtended, ...args: unknown[]) {\n if (utils.shouldSkipInstrumentation(plugin.getConfig())) {\n return original.apply(this, args as never);\n }\n const startTime = timestampInSeconds();\n\n // client.query(text, cb?), client.query(text, values, cb?), and\n // client.query(configObj, cb?) are all valid signatures. We construct\n // a queryConfig obj from all (valid) signatures to build the span in a\n // unified way. We verify that we at least have query text, and code\n // defensively when dealing with `queryConfig` after that (to handle all\n // the other invalid cases, like a non-array for values being provided).\n // The type casts here reflect only what we've actually validated.\n const arg0 = args[0];\n const firstArgIsString = typeof arg0 === 'string';\n const firstArgIsQueryObjectWithText = utils.isObjectWithTextString(arg0);\n\n // TODO: remove the `as ...` casts below when the TS version is upgraded.\n // Newer TS versions will use the result of firstArgIsQueryObjectWithText\n // to properly narrow arg0, but TS 4.3.5 does not.\n const queryConfig = firstArgIsString\n ? {\n text: arg0 as string,\n values: Array.isArray(args[1]) ? args[1] : undefined,\n }\n : firstArgIsQueryObjectWithText\n ? {\n ...(arg0 as any),\n name: arg0.name,\n text: arg0.text,\n values: (arg0 as any).values ?? (Array.isArray(args[1]) ? args[1] : undefined),\n }\n : undefined;\n\n const attributes: Attributes = {\n [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_POSTGRESQL,\n [ATTR_DB_NAMESPACE]: this.database,\n [ATTR_SERVER_PORT]: this.connectionParameters.port,\n [ATTR_SERVER_ADDRESS]: this.connectionParameters.host,\n };\n\n if (queryConfig?.text) {\n attributes[ATTR_DB_OPERATION_NAME] = utils.parseNormalizedOperationName(queryConfig?.text);\n }\n\n const recordDuration = () => {\n plugin.recordOperationDuration(attributes, startTime);\n };\n\n const instrumentationConfig = plugin.getConfig();\n\n const span = utils.handleConfigQuery.call(\n this,\n plugin.tracer,\n instrumentationConfig,\n plugin._semconvStability,\n queryConfig,\n );\n\n // Modify query text w/ a tracing comment before invoking original for\n // tracing, but only if args[0] has one of our expected shapes.\n if (instrumentationConfig.addSqlCommenterCommentToQueries) {\n if (firstArgIsString) {\n args[0] = addSqlCommenterComment(span, arg0);\n } else if (firstArgIsQueryObjectWithText && !('name' in arg0)) {\n // In the case of a query object, we need to ensure there's no name field\n // as this indicates a prepared query, where the comment would remain the same\n // for every invocation and contain an outdated trace context.\n args[0] = {\n ...arg0,\n text: addSqlCommenterComment(span, arg0.text),\n };\n }\n }\n\n // Bind callback (if any) to parent span (if any)\n if (args.length > 0) {\n const parentSpan = trace.getSpan(context.active());\n if (typeof args[args.length - 1] === 'function') {\n // Patch ParameterQuery callback\n args[args.length - 1] = utils.patchCallback(\n instrumentationConfig,\n span,\n args[args.length - 1] as PostgresCallback, // nb: not type safe.\n attributes,\n recordDuration,\n );\n\n // If a parent span exists, bind the callback\n if (parentSpan) {\n args[args.length - 1] = context.bind(context.active(), args[args.length - 1]);\n }\n } else if (typeof queryConfig?.callback === 'function') {\n // Patch ConfigQuery callback\n let callback = utils.patchCallback(\n plugin.getConfig(),\n span,\n queryConfig.callback as PostgresCallback, // nb: not type safe.\n attributes,\n recordDuration,\n );\n\n // If a parent span existed, bind the callback\n if (parentSpan) {\n callback = context.bind(context.active(), callback);\n }\n\n (args[0] as { callback?: PostgresCallback }).callback = callback;\n }\n }\n\n const { requestHook } = instrumentationConfig;\n if (typeof requestHook === 'function' && queryConfig) {\n safeExecuteInTheMiddle(\n () => {\n // pick keys to expose explicitly, so we're not leaking pg package\n // internals that are subject to change\n const { database, host, port, user } = this.connectionParameters;\n const connection = { database, host, port, user };\n\n requestHook(span, {\n connection,\n query: {\n text: queryConfig.text,\n // nb: if `client.query` is called with illegal arguments\n // (e.g., if `queryConfig.values` is passed explicitly, but a\n // non-array is given), then the type casts will be wrong. But\n // we leave it up to the queryHook to handle that, and we\n // catch and swallow any errors it throws. The other options\n // are all worse. E.g., we could leave `queryConfig.values`\n // and `queryConfig.name` as `unknown`, but then the hook body\n // would be forced to validate (or cast) them before using\n // them, which seems incredibly cumbersome given that these\n // casts will be correct 99.9% of the time -- and pg.query\n // will immediately throw during development in the other .1%\n // of cases. Alternatively, we could simply skip calling the\n // hook when `values` or `name` don't have the expected type,\n // but that would add unnecessary validation overhead to every\n // hook invocation and possibly be even more confusing/unexpected.\n values: queryConfig.values as unknown[],\n name: queryConfig.name as string | undefined,\n },\n });\n },\n err => {\n if (err) {\n plugin._diag.error('Error running query hook', err);\n }\n },\n true,\n );\n }\n\n let result: unknown;\n try {\n result = original.apply(this, args as never);\n } catch (e: unknown) {\n if (e instanceof Error) {\n span.recordException(utils.sanitizedErrorMessage(e));\n }\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: utils.getErrorMessage(e),\n });\n span.end();\n throw e;\n }\n\n // Bind promise to parent span and end the span\n if (result instanceof Promise) {\n return result\n .then((result: unknown) => {\n // Return a pass-along promise which ends the span and then goes to user's orig resolvers\n return new Promise(resolve => {\n utils.handleExecutionResult(plugin.getConfig(), span, result);\n recordDuration();\n span.end();\n resolve(result);\n });\n })\n .catch((error: Error) => {\n return new Promise((_, reject) => {\n if (error instanceof Error) {\n span.recordException(utils.sanitizedErrorMessage(error));\n }\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n recordDuration();\n span.end();\n reject(error);\n });\n });\n }\n\n // else returns void\n return result; // void\n };\n };\n }\n\n private _setPoolConnectEventListeners(pgPool: PgPoolExtended) {\n if (pgPool[EVENT_LISTENERS_SET]) return;\n const poolName = utils.getPoolName(pgPool.options);\n\n pgPool.on('connect', () => {\n this._connectionsCounter = utils.updateCounter(\n poolName,\n pgPool,\n this._connectionsCount,\n this._connectionPendingRequests,\n this._connectionsCounter,\n );\n });\n\n pgPool.on('acquire', () => {\n this._connectionsCounter = utils.updateCounter(\n poolName,\n pgPool,\n this._connectionsCount,\n this._connectionPendingRequests,\n this._connectionsCounter,\n );\n });\n\n pgPool.on('remove', () => {\n this._connectionsCounter = utils.updateCounter(\n poolName,\n pgPool,\n this._connectionsCount,\n this._connectionPendingRequests,\n this._connectionsCounter,\n );\n });\n\n pgPool.on('release' as any, () => {\n this._connectionsCounter = utils.updateCounter(\n poolName,\n pgPool,\n this._connectionsCount,\n this._connectionPendingRequests,\n this._connectionsCounter,\n );\n });\n pgPool[EVENT_LISTENERS_SET] = true;\n }\n\n private _getPoolConnectPatch() {\n const plugin = this;\n return (originalConnect: (...args: any[]) => any) => {\n return function connect(this: PgPoolExtended, callback?: PgPoolCallback) {\n const config = plugin.getConfig();\n\n if (utils.shouldSkipInstrumentation(config)) {\n return originalConnect.call(this, callback as any);\n }\n\n // Still set up event listeners for metrics even when skipping spans\n plugin._setPoolConnectEventListeners(this);\n\n if (config.ignoreConnectSpans) {\n return originalConnect.call(this, callback as any);\n }\n\n // setup span\n const span = plugin.tracer.startSpan(SpanNames.POOL_CONNECT, {\n kind: SpanKind.CLIENT,\n attributes: utils.getSemanticAttributesFromPoolConnection(this.options, plugin._semconvStability),\n });\n\n if (callback) {\n const parentSpan = trace.getSpan(context.active());\n callback = utils.patchCallbackPGPool(span, callback) as PgPoolCallback;\n // If a parent span exists, bind the callback\n if (parentSpan) {\n callback = context.bind(context.active(), callback);\n }\n }\n\n const connectResult: unknown = context.with(trace.setSpan(context.active(), span), () => {\n return originalConnect.call(this, callback as any);\n });\n\n return handleConnectResult(span, connectResult);\n };\n };\n }\n}\n\nfunction handleConnectResult(span: Span, connectResult: unknown) {\n if (!(connectResult instanceof Promise)) {\n return connectResult;\n }\n\n const connectResultPromise = connectResult as Promise<unknown>;\n return context.bind(\n context.active(),\n connectResultPromise\n .then(result => {\n span.end();\n return result;\n })\n .catch((error: unknown) => {\n if (error instanceof Error) {\n span.recordException(utils.sanitizedErrorMessage(error));\n }\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: utils.getErrorMessage(error),\n });\n span.end();\n return Promise.reject(error);\n }),\n );\n}\n"],"names":["InstrumentationBase","SDK_VERSION","semconvStabilityFromStr","METRIC_DB_CLIENT_OPERATION_DURATION","ValueType","METRIC_DB_CLIENT_CONNECTION_COUNT","METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS","InstrumentationNodeModuleFile","InstrumentationNodeModuleDefinition","isWrapped","utils.shouldSkipInstrumentation","SpanNames","SpanKind","utils.getSemanticAttributesFromConnection","trace","context","utils.patchClientConnectCallback","ATTR_DB_NAMESPACE","ATTR_ERROR_TYPE","ATTR_SERVER_PORT","ATTR_SERVER_ADDRESS","ATTR_DB_OPERATION_NAME","SemconvStability","ATTR_DB_SYSTEM","ATTR_DB_SYSTEM_NAME","timestampInSeconds","utils.isObjectWithTextString","DB_SYSTEM_VALUE_POSTGRESQL","utils.parseNormalizedOperationName","utils.handleConfigQuery","addSqlCommenterComment","utils.patchCallback","safeExecuteInTheMiddle","utils.sanitizedErrorMessage","SpanStatusCode","utils.getErrorMessage","result","utils.handleExecutionResult","EVENT_LISTENERS_SET","utils.getPoolName","utils.updateCounter","utils.getSemanticAttributesFromPoolConnection","utils.patchCallbackPGPool"],"mappings":";;;;;;;;;;;;;AAwDA,MAAM,YAAA,GAAe,4BAAA;AAkBrB,SAAS,qBAAqB,MAAA,EAAa;AACzC,EAAA,OAAO,OAAO,MAAA,CAAO,WAAW,CAAA,KAAM,QAAA,GAClC,OAAO,OAAA,GACP,MAAA;AACN;AAEO,MAAM,0BAA0BA,mCAAA,CAA6C;AAAA,EAgBlF,WAAA,CAAY,MAAA,GAAkC,EAAC,EAAG;AAChD,IAAA,KAAA,CAAM,YAAA,EAAcC,kBAAa,MAAM,CAAA;AARzC;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAQ,mBAAA,GAAoD;AAAA,MAC1D,IAAA,EAAM,CAAA;AAA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js","sources":["../../../../../../src/integrations/tracing/postgres/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-pg\n * - Upstream version: @opentelemetry/instrumentation-pg@0.70.0\n * - Types from `pg` and `pg-pool` packages inlined as simplified interfaces\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n * - Dropped the OTel metrics (no MeterProvider is wired up), the `SemconvStability`\n * dual-emission, and config the SDK never passes (request/response hooks,\n * enhancedDatabaseReporting, addSqlCommenterCommentToQueries)\n */\n\nimport { SpanKind } from '@opentelemetry/api';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport type { Span } from '@sentry/core';\nimport { getActiveSpan, SDK_VERSION, SPAN_STATUS_ERROR, startInactiveSpan, withActiveSpan } from '@sentry/core';\nimport { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile';\nimport { SpanNames } from './enums/SpanNames';\nimport type {\n PgClientConnect,\n PgClientExtended,\n PgPoolCallback,\n PgPoolExtended,\n PostgresCallback,\n} from './internal-types';\nimport type { PgInstrumentationConfig } from './types';\nimport * as utils from './utils';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-pg';\n\nfunction extractModuleExports(module: any): any {\n return module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n}\n\n/**\n * Binds `callback` to `parentSpan`, so that the span is active again whenever the\n * (deferred) callback runs. This mirrors the upstream `context.bind(context.active(), callback)`:\n * `pg` invokes callbacks outside of the original async scope (e.g. for pooled connections), so we\n * re-establish the trace context to keep spans created inside the callback correctly parented.\n */\nfunction bindCallbackToSpan<T extends (...args: any[]) => any>(parentSpan: Span, callback: T): T {\n return function (this: unknown, ...args: any[]): unknown {\n return withActiveSpan(parentSpan, () => callback.apply(this, args));\n } as T;\n}\n\nexport class PgInstrumentation extends InstrumentationBase<PgInstrumentationConfig> {\n public constructor(config: PgInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init(): InstrumentationNodeModuleDefinition[] {\n const SUPPORTED_PG_VERSIONS = ['>=8.0.3 <9'];\n const SUPPORTED_PG_POOL_VERSIONS = ['>=2.0.0 <4'];\n\n const modulePgNativeClient = new InstrumentationNodeModuleFile(\n 'pg/lib/native/client.js',\n SUPPORTED_PG_VERSIONS,\n this._patchPgClient.bind(this),\n this._unpatchPgClient.bind(this),\n );\n\n const modulePgClient = new InstrumentationNodeModuleFile(\n 'pg/lib/client.js',\n SUPPORTED_PG_VERSIONS,\n this._patchPgClient.bind(this),\n this._unpatchPgClient.bind(this),\n );\n\n const modulePG = new InstrumentationNodeModuleDefinition(\n 'pg',\n SUPPORTED_PG_VERSIONS,\n (module: any) => {\n const moduleExports = extractModuleExports(module);\n\n this._patchPgClient(moduleExports.Client);\n return module;\n },\n (module: any) => {\n const moduleExports = extractModuleExports(module);\n\n this._unpatchPgClient(moduleExports.Client);\n return module;\n },\n [modulePgClient, modulePgNativeClient],\n );\n\n const modulePGPool = new InstrumentationNodeModuleDefinition(\n 'pg-pool',\n SUPPORTED_PG_POOL_VERSIONS,\n (module: any) => {\n const moduleExports = extractModuleExports(module);\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n this._wrap(moduleExports.prototype, 'connect', this._getPoolConnectPatch());\n return moduleExports;\n },\n (module: any) => {\n const moduleExports = extractModuleExports(module);\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n },\n );\n\n return [modulePG, modulePGPool];\n }\n\n private _patchPgClient(module: any): any {\n if (!module) {\n return;\n }\n\n const moduleExports = extractModuleExports(module);\n\n if (isWrapped(moduleExports.prototype.query)) {\n this._unwrap(moduleExports.prototype, 'query');\n }\n\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n\n this._wrap(moduleExports.prototype, 'query', this._getClientQueryPatch());\n\n this._wrap(moduleExports.prototype, 'connect', this._getClientConnectPatch());\n\n return module;\n }\n\n private _unpatchPgClient(module: any): any {\n const moduleExports = extractModuleExports(module);\n\n if (isWrapped(moduleExports.prototype.query)) {\n this._unwrap(moduleExports.prototype, 'query');\n }\n\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n\n return module;\n }\n\n private _getClientConnectPatch() {\n const plugin = this;\n return (original: PgClientConnect) => {\n return function connect(this: PgClientExtended, callback?: (...args: unknown[]) => void) {\n if (utils.shouldSkipInstrumentation() || plugin.getConfig().ignoreConnectSpans) {\n return original.call(this, callback);\n }\n\n const span = startInactiveSpan({\n name: SpanNames.CONNECT,\n kind: SpanKind.CLIENT,\n attributes: utils.getSemanticAttributesFromConnection(this),\n });\n\n let cb = callback;\n if (cb) {\n const parentSpan = getActiveSpan();\n cb = utils.patchClientConnectCallback(span, cb);\n if (parentSpan) {\n cb = bindCallbackToSpan(parentSpan, cb);\n }\n }\n\n const connectResult: unknown = withActiveSpan(span, () => {\n return original.call(this, cb);\n });\n\n return handleConnectResult(span, connectResult);\n };\n };\n }\n\n private _getClientQueryPatch() {\n return (original: (...args: any[]) => any) => {\n this._diag.debug('Patching pg.Client.prototype.query');\n return function query(this: PgClientExtended, ...args: unknown[]) {\n if (utils.shouldSkipInstrumentation()) {\n return original.apply(this, args as never);\n }\n\n // client.query(text, cb?), client.query(text, values, cb?), and\n // client.query(configObj, cb?) are all valid signatures. We construct\n // a queryConfig obj from all (valid) signatures to build the span in a\n // unified way. We verify that we at least have query text, and code\n // defensively when dealing with `queryConfig` after that (to handle all\n // the other invalid cases, like a non-array for values being provided).\n // The type casts here reflect only what we've actually validated.\n const arg0 = args[0];\n const firstArgIsString = typeof arg0 === 'string';\n const firstArgIsQueryObjectWithText = utils.isObjectWithTextString(arg0);\n\n const queryConfig = firstArgIsString\n ? {\n text: arg0,\n values: Array.isArray(args[1]) ? args[1] : undefined,\n }\n : firstArgIsQueryObjectWithText\n ? {\n ...(arg0 as any),\n name: arg0.name,\n text: arg0.text,\n values: (arg0 as any).values ?? (Array.isArray(args[1]) ? args[1] : undefined),\n }\n : undefined;\n\n const span = utils.handleConfigQuery.call(this, queryConfig);\n\n // Bind callback (if any) to parent span (if any)\n if (args.length > 0) {\n const parentSpan = getActiveSpan();\n if (typeof args[args.length - 1] === 'function') {\n // Patch ParameterQuery callback\n args[args.length - 1] = utils.patchCallback(span, args[args.length - 1] as PostgresCallback);\n\n // If a parent span exists, bind the callback\n if (parentSpan) {\n args[args.length - 1] = bindCallbackToSpan(parentSpan, args[args.length - 1] as PostgresCallback);\n }\n } else if (typeof queryConfig?.callback === 'function') {\n // Patch ConfigQuery callback\n let callback = utils.patchCallback(span, queryConfig.callback as PostgresCallback);\n\n // If a parent span existed, bind the callback\n if (parentSpan) {\n callback = bindCallbackToSpan(parentSpan, callback);\n }\n\n (args[0] as { callback?: PostgresCallback }).callback = callback;\n }\n }\n\n let result: unknown;\n try {\n result = original.apply(this, args as never);\n } catch (e: unknown) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: utils.getErrorMessage(e) });\n span.end();\n throw e;\n }\n\n // Bind promise to parent span and end the span\n if (result instanceof Promise) {\n return result\n .then((result: unknown) => {\n span.end();\n return result;\n })\n .catch((error: unknown) => {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: utils.getErrorMessage(error) });\n span.end();\n return Promise.reject(error);\n });\n }\n\n // else returns void\n return result; // void\n };\n };\n }\n\n private _getPoolConnectPatch() {\n const plugin = this;\n return (originalConnect: (...args: any[]) => any) => {\n return function connect(this: PgPoolExtended, callback?: PgPoolCallback) {\n if (utils.shouldSkipInstrumentation() || plugin.getConfig().ignoreConnectSpans) {\n return originalConnect.call(this, callback);\n }\n\n const span = startInactiveSpan({\n name: SpanNames.POOL_CONNECT,\n kind: SpanKind.CLIENT,\n attributes: utils.getSemanticAttributesFromPoolConnection(this.options),\n });\n\n let cb = callback;\n if (cb) {\n const parentSpan = getActiveSpan();\n cb = utils.patchCallbackPGPool(span, cb);\n // If a parent span exists, bind the callback\n if (parentSpan) {\n cb = bindCallbackToSpan(parentSpan, cb);\n }\n }\n\n const connectResult: unknown = withActiveSpan(span, () => {\n return originalConnect.call(this, cb);\n });\n\n return handleConnectResult(span, connectResult);\n };\n };\n }\n}\n\nfunction handleConnectResult(span: Span, connectResult: unknown): unknown {\n if (!(connectResult instanceof Promise)) {\n return connectResult;\n }\n\n const connectResultPromise = connectResult as Promise<unknown>;\n // The caller's continuation after `await client.connect()` keeps its trace context via the\n // SDK's async context propagation, so we don't need to re-bind the returned promise.\n return connectResultPromise\n .then(result => {\n span.end();\n return result;\n })\n .catch((error: unknown) => {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: utils.getErrorMessage(error) });\n span.end();\n return Promise.reject(error);\n });\n}\n"],"names":["withActiveSpan","InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleFile","InstrumentationNodeModuleDefinition","isWrapped","utils.shouldSkipInstrumentation","startInactiveSpan","SpanNames","SpanKind","utils.getSemanticAttributesFromConnection","getActiveSpan","utils.patchClientConnectCallback","utils.isObjectWithTextString","utils.handleConfigQuery","utils.patchCallback","SPAN_STATUS_ERROR","utils.getErrorMessage","result","utils.getSemanticAttributesFromPoolConnection","utils.patchCallbackPGPool"],"mappings":";;;;;;;;;AA8BA,MAAM,YAAA,GAAe,4BAAA;AAErB,SAAS,qBAAqB,MAAA,EAAkB;AAC9C,EAAA,OAAO,OAAO,MAAA,CAAO,WAAW,CAAA,KAAM,QAAA,GAClC,OAAO,OAAA,GACP,MAAA;AACN;AAQA,SAAS,kBAAA,CAAsD,YAAkB,QAAA,EAAgB;AAC/F,EAAA,OAAO,YAA4B,IAAA,EAAsB;AACvD,IAAA,OAAOA,oBAAe,UAAA,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A,IAAI,EAAA,EAAI;AACN,UAAA,MAAM,aAAaR,kBAAA,EAAc;AACjC,UAAA,EAAA,GAAKS,yBAAM,CAAoB,IAAA,EAAM,EAAE,CAAA;AAEvC,UAAA,IAAI,UAAA,EAAY;AACd,YAAA,EAAA,GAAK,kBAAA,CAAmB,YAAY,EAAE,CAAA;AAAA,UACxC;AAAA,QACF;AAEA,QAAA,MAAM,aAAA,GAAyBpB,mBAAA,CAAe,IAAA,EAAM,MAAM;AACxD,UAAA,OAAO,eAAA,CAAgB,IAAA,CAAK,IAAA,EAAM,EAAE,CAAA;AAAA,QACtC,CAAC,CAAA;AAED,QAAA,OAAO,mBAAA,CAAoB,MAAM,aAAa,CAAA;AAAA,MAChD,CAAA;AAAA,IACF,CAAA;AAAA,EACF;AACF;AAEA,SAAS,mBAAA,CAAoB,MAAY,aAAA,EAAiC;AACxE,EAAA,IAAI,EAAE,yBAAyB,OAAA,CAAA,EAAU;AACvC,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,MAAM,oBAAA,GAAuB,aAAA;AAG7B,EAAA,OAAO,oBAAA,CACJ,KAAK,CAAA,MAAA,KAAU;AACd,IAAA,IAAA,CAAK,GAAA,EAAI;AACT,IAAA,OAAO,MAAA;AAAA,EACT,CAAC,CAAA,CACA,KAAA,CAAM,CAAC,KAAA,KAAmB;AACzB,IAAA,IAAA,CAAK,SAAA,CAAU,EAAE,IAAA,EAAMgB,sBAAA,EAAmB,SAASC,qBAAM,CAAgB,KAAK,CAAA,EAAG,CAAA;AACjF,IAAA,IAAA,CAAK,GAAA,EAAI;AACT,IAAA,OAAO,OAAA,CAAQ,OAAO,KAAK,CAAA;AAAA,EAC7B,CAAC,CAAA;AACL;;;;"}
@@ -1,7 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const ATTR_DB_CLIENT_CONNECTION_POOL_NAME = "db.client.connection.pool.name";
4
- const ATTR_DB_CLIENT_CONNECTION_STATE = "db.client.connection.state";
5
3
  const ATTR_DB_CONNECTION_STRING = "db.connection_string";
6
4
  const ATTR_DB_NAME = "db.name";
7
5
  const ATTR_DB_STATEMENT = "db.statement";
@@ -9,14 +7,8 @@ const ATTR_DB_SYSTEM = "db.system";
9
7
  const ATTR_DB_USER = "db.user";
10
8
  const ATTR_NET_PEER_NAME = "net.peer.name";
11
9
  const ATTR_NET_PEER_PORT = "net.peer.port";
12
- const DB_CLIENT_CONNECTION_STATE_VALUE_IDLE = "idle";
13
- const DB_CLIENT_CONNECTION_STATE_VALUE_USED = "used";
14
10
  const DB_SYSTEM_VALUE_POSTGRESQL = "postgresql";
15
- const METRIC_DB_CLIENT_CONNECTION_COUNT = "db.client.connection.count";
16
- const METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS = "db.client.connection.pending_requests";
17
11
 
18
- exports.ATTR_DB_CLIENT_CONNECTION_POOL_NAME = ATTR_DB_CLIENT_CONNECTION_POOL_NAME;
19
- exports.ATTR_DB_CLIENT_CONNECTION_STATE = ATTR_DB_CLIENT_CONNECTION_STATE;
20
12
  exports.ATTR_DB_CONNECTION_STRING = ATTR_DB_CONNECTION_STRING;
21
13
  exports.ATTR_DB_NAME = ATTR_DB_NAME;
22
14
  exports.ATTR_DB_STATEMENT = ATTR_DB_STATEMENT;
@@ -24,9 +16,5 @@ exports.ATTR_DB_SYSTEM = ATTR_DB_SYSTEM;
24
16
  exports.ATTR_DB_USER = ATTR_DB_USER;
25
17
  exports.ATTR_NET_PEER_NAME = ATTR_NET_PEER_NAME;
26
18
  exports.ATTR_NET_PEER_PORT = ATTR_NET_PEER_PORT;
27
- exports.DB_CLIENT_CONNECTION_STATE_VALUE_IDLE = DB_CLIENT_CONNECTION_STATE_VALUE_IDLE;
28
- exports.DB_CLIENT_CONNECTION_STATE_VALUE_USED = DB_CLIENT_CONNECTION_STATE_VALUE_USED;
29
19
  exports.DB_SYSTEM_VALUE_POSTGRESQL = DB_SYSTEM_VALUE_POSTGRESQL;
30
- exports.METRIC_DB_CLIENT_CONNECTION_COUNT = METRIC_DB_CLIENT_CONNECTION_COUNT;
31
- exports.METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS = METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS;
32
20
  //# sourceMappingURL=semconv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semconv.js","sources":["../../../../../../src/integrations/tracing/postgres/vendored/semconv.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/*\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 * The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation **SHOULD** use a combination of parameters that would make the name unique, for example, combining attributes `server.address`, `server.port`, and `db.namespace`, formatted as `server.address:server.port/db.namespace`. Instrumentations that generate connection pool name following different patterns **SHOULD** document it.\n *\n * @example myDataSource\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_DB_CLIENT_CONNECTION_POOL_NAME = 'db.client.connection.pool.name' as const;\n\n/**\n * The state of a connection in the pool\n *\n * @example idle\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_DB_CLIENT_CONNECTION_STATE = 'db.client.connection.state' as const;\n\n/**\n * Deprecated, use `server.address`, `server.port` attributes instead.\n *\n * @example \"Server=(localdb)\\\\v11.0;Integrated Security=true;\"\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` and `server.port`.\n */\nexport const ATTR_DB_CONNECTION_STRING = 'db.connection_string' as const;\n\n/**\n * Deprecated, use `db.namespace` instead.\n *\n * @example customers\n * @example main\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 * The database statement being executed.\n *\n * @example SELECT * FROM wuser_table\n * @example SET mykey \"WuValue\"\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.query.text`.\n */\nexport const ATTR_DB_STATEMENT = 'db.statement' 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 * @example readonly_user\n * @example reporting_user\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 * @example example.com\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 * @example 8080\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\n/**\n * Enum value \"idle\" for attribute {@link ATTR_DB_CLIENT_CONNECTION_STATE}.\n */\nexport const DB_CLIENT_CONNECTION_STATE_VALUE_IDLE = 'idle' as const;\n\n/**\n * Enum value \"used\" for attribute {@link ATTR_DB_CLIENT_CONNECTION_STATE}.\n */\nexport const DB_CLIENT_CONNECTION_STATE_VALUE_USED = 'used' as const;\n\n/**\n * Enum value \"postgresql\" for attribute {@link ATTR_DB_SYSTEM}.\n */\nexport const DB_SYSTEM_VALUE_POSTGRESQL = 'postgresql' as const;\n\n/**\n * The number of connections that are currently in state described by the `state` attribute\n *\n * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const METRIC_DB_CLIENT_CONNECTION_COUNT = 'db.client.connection.count' as const;\n\n/**\n * The number of current pending requests for an open connection\n *\n * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS = 'db.client.connection.pending_requests' as const;\n"],"names":[],"mappings":";;AAkCO,MAAM,mCAAA,GAAsC;AAS5C,MAAM,+BAAA,GAAkC;AAWxC,MAAM,yBAAA,GAA4B;AAYlC,MAAM,YAAA,GAAe;AAYrB,MAAM,iBAAA,GAAoB;AAS1B,MAAM,cAAA,GAAiB;AAYvB,MAAM,YAAA,GAAe;AAWrB,MAAM,kBAAA,GAAqB;AAW3B,MAAM,kBAAA,GAAqB;AAK3B,MAAM,qCAAA,GAAwC;AAK9C,MAAM,qCAAA,GAAwC;AAK9C,MAAM,0BAAA,GAA6B;AAOnC,MAAM,iCAAA,GAAoC;AAO1C,MAAM,4CAAA,GAA+C;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"semconv.js","sources":["../../../../../../src/integrations/tracing/postgres/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-pg\n * - Upstream version: @opentelemetry/instrumentation-pg@0.70.0\n * - Trimmed to the (old) semantic conventions the SDK actually emits\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 * @example \"Server=(localdb)\\\\v11.0;Integrated Security=true;\"\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.namespace` instead.\n *\n * @example customers\n * @example main\n *\n * @deprecated Replaced by `db.namespace`.\n */\nexport const ATTR_DB_NAME = 'db.name' as const;\n\n/**\n * The database statement being executed.\n *\n * @example SELECT * FROM wuser_table\n * @example SET mykey \"WuValue\"\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, no replacement at this time.\n *\n * @example readonly_user\n * @example reporting_user\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 * @example example.com\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 * @example 8080\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 \"postgresql\" for attribute {@link ATTR_DB_SYSTEM}.\n */\nexport const DB_SYSTEM_VALUE_POSTGRESQL = 'postgresql' as const;\n"],"names":[],"mappings":";;AAuBO,MAAM,yBAAA,GAA4B;AAUlC,MAAM,YAAA,GAAe;AAUrB,MAAM,iBAAA,GAAoB;AAO1B,MAAM,cAAA,GAAiB;AAUvB,MAAM,YAAA,GAAe;AASrB,MAAM,kBAAA,GAAqB;AAS3B,MAAM,kBAAA,GAAqB;AAK3B,MAAM,0BAAA,GAA6B;;;;;;;;;;;"}
@@ -1,12 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const api = require('@opentelemetry/api');
4
+ const core = require('@sentry/core');
4
5
  const AttributeNames = require('./enums/AttributeNames.js');
5
- const semanticConventions = require('@opentelemetry/semantic-conventions');
6
- const semconv = require('./semconv.js');
7
- const instrumentation = require('@opentelemetry/instrumentation');
8
6
  const SpanNames = require('./enums/SpanNames.js');
7
+ const semconv = require('./semconv.js');
9
8
 
9
+ const ORIGIN = "auto.db.otel.postgres";
10
10
  function getQuerySpanName(dbName, queryConfig) {
11
11
  if (!queryConfig) return SpanNames.SpanNames.QUERY_PREFIX;
12
12
  const command = typeof queryConfig.name === "string" && queryConfig.name ? queryConfig.name : parseNormalizedOperationName(queryConfig.text);
@@ -25,7 +25,7 @@ function parseAndMaskConnectionString(connectionString) {
25
25
  url.username = "";
26
26
  url.password = "";
27
27
  return url.toString();
28
- } catch (e) {
28
+ } catch {
29
29
  return "postgresql://localhost:5432/";
30
30
  }
31
31
  }
@@ -44,203 +44,87 @@ function getPort(port) {
44
44
  }
45
45
  return void 0;
46
46
  }
47
- function getSemanticAttributesFromConnection(params, semconvStability) {
48
- let attributes = {};
49
- if (semconvStability & instrumentation.SemconvStability.OLD) {
50
- attributes = {
51
- ...attributes,
52
- [semconv.ATTR_DB_SYSTEM]: semconv.DB_SYSTEM_VALUE_POSTGRESQL,
53
- [semconv.ATTR_DB_NAME]: params.database,
54
- [semconv.ATTR_DB_CONNECTION_STRING]: getConnectionString(params),
55
- [semconv.ATTR_DB_USER]: params.user,
56
- [semconv.ATTR_NET_PEER_NAME]: params.host,
57
- // required
58
- [semconv.ATTR_NET_PEER_PORT]: getPort(params.port)
59
- };
60
- }
61
- if (semconvStability & instrumentation.SemconvStability.STABLE) {
62
- attributes = {
63
- ...attributes,
64
- [semanticConventions.ATTR_DB_SYSTEM_NAME]: semanticConventions.DB_SYSTEM_NAME_VALUE_POSTGRESQL,
65
- [semanticConventions.ATTR_DB_NAMESPACE]: params.namespace,
66
- [semanticConventions.ATTR_SERVER_ADDRESS]: params.host,
67
- [semanticConventions.ATTR_SERVER_PORT]: getPort(params.port)
68
- };
69
- }
70
- return attributes;
47
+ function getSemanticAttributesFromConnection(params) {
48
+ return {
49
+ [semconv.ATTR_DB_SYSTEM]: semconv.DB_SYSTEM_VALUE_POSTGRESQL,
50
+ [semconv.ATTR_DB_NAME]: params.database,
51
+ [semconv.ATTR_DB_CONNECTION_STRING]: getConnectionString(params),
52
+ [semconv.ATTR_DB_USER]: params.user,
53
+ [semconv.ATTR_NET_PEER_NAME]: params.host,
54
+ // required
55
+ [semconv.ATTR_NET_PEER_PORT]: getPort(params.port)
56
+ };
71
57
  }
72
- function getSemanticAttributesFromPoolConnection(params, semconvStability) {
58
+ function getSemanticAttributesFromPoolConnection(params) {
73
59
  let url;
74
60
  try {
75
61
  url = params.connectionString ? new URL(params.connectionString) : void 0;
76
- } catch (e) {
62
+ } catch {
77
63
  url = void 0;
78
64
  }
79
- let attributes = {
65
+ return {
80
66
  [AttributeNames.AttributeNames.IDLE_TIMEOUT_MILLIS]: params.idleTimeoutMillis,
81
- [AttributeNames.AttributeNames.MAX_CLIENT]: params.maxClient
67
+ [AttributeNames.AttributeNames.MAX_CLIENT]: params.maxClient,
68
+ [semconv.ATTR_DB_SYSTEM]: semconv.DB_SYSTEM_VALUE_POSTGRESQL,
69
+ [semconv.ATTR_DB_NAME]: url?.pathname.slice(1) ?? params.database,
70
+ [semconv.ATTR_DB_CONNECTION_STRING]: getConnectionString(params),
71
+ [semconv.ATTR_NET_PEER_NAME]: url?.hostname ?? params.host,
72
+ [semconv.ATTR_NET_PEER_PORT]: Number(url?.port) || getPort(params.port),
73
+ [semconv.ATTR_DB_USER]: url?.username ?? params.user
82
74
  };
83
- if (semconvStability & instrumentation.SemconvStability.OLD) {
84
- attributes = {
85
- ...attributes,
86
- [semconv.ATTR_DB_SYSTEM]: semconv.DB_SYSTEM_VALUE_POSTGRESQL,
87
- [semconv.ATTR_DB_NAME]: url?.pathname.slice(1) ?? params.database,
88
- [semconv.ATTR_DB_CONNECTION_STRING]: getConnectionString(params),
89
- [semconv.ATTR_NET_PEER_NAME]: url?.hostname ?? params.host,
90
- [semconv.ATTR_NET_PEER_PORT]: Number(url?.port) || getPort(params.port),
91
- [semconv.ATTR_DB_USER]: url?.username ?? params.user
92
- };
93
- }
94
- if (semconvStability & instrumentation.SemconvStability.STABLE) {
95
- attributes = {
96
- ...attributes,
97
- [semanticConventions.ATTR_DB_SYSTEM_NAME]: semanticConventions.DB_SYSTEM_NAME_VALUE_POSTGRESQL,
98
- [semanticConventions.ATTR_DB_NAMESPACE]: params.namespace,
99
- [semanticConventions.ATTR_SERVER_ADDRESS]: url?.hostname ?? params.host,
100
- [semanticConventions.ATTR_SERVER_PORT]: Number(url?.port) || getPort(params.port)
101
- };
102
- }
103
- return attributes;
104
75
  }
105
- function shouldSkipInstrumentation(instrumentationConfig) {
106
- return instrumentationConfig.requireParentSpan === true && api.trace.getSpan(api.context.active()) === void 0;
76
+ function shouldSkipInstrumentation() {
77
+ return core.getActiveSpan() === void 0;
107
78
  }
108
- function handleConfigQuery(tracer, instrumentationConfig, semconvStability, queryConfig) {
79
+ function handleConfigQuery(queryConfig) {
109
80
  const { connectionParameters } = this;
110
81
  const dbName = connectionParameters.database;
111
82
  const spanName = getQuerySpanName(dbName, queryConfig);
112
- const span = tracer.startSpan(spanName, {
83
+ const span = core.startInactiveSpan({
84
+ name: spanName,
113
85
  kind: api.SpanKind.CLIENT,
114
- attributes: getSemanticAttributesFromConnection(connectionParameters, semconvStability)
86
+ attributes: {
87
+ ...getSemanticAttributesFromConnection(connectionParameters),
88
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN
89
+ }
115
90
  });
116
91
  if (!queryConfig) {
117
92
  return span;
118
93
  }
119
94
  if (queryConfig.text) {
120
- if (semconvStability & instrumentation.SemconvStability.OLD) {
121
- span.setAttribute(semconv.ATTR_DB_STATEMENT, queryConfig.text);
122
- }
123
- if (semconvStability & instrumentation.SemconvStability.STABLE) {
124
- span.setAttribute(semanticConventions.ATTR_DB_QUERY_TEXT, queryConfig.text);
125
- }
126
- }
127
- if (instrumentationConfig.enhancedDatabaseReporting && Array.isArray(queryConfig.values)) {
128
- try {
129
- const convertedValues = queryConfig.values.map((value) => {
130
- if (value == null) {
131
- return "null";
132
- } else if (value instanceof Buffer) {
133
- return value.toString();
134
- } else if (typeof value === "object") {
135
- if (typeof value.toPostgres === "function") {
136
- return value.toPostgres();
137
- }
138
- return JSON.stringify(value);
139
- } else {
140
- return value.toString();
141
- }
142
- });
143
- span.setAttribute(AttributeNames.AttributeNames.PG_VALUES, convertedValues);
144
- } catch (e) {
145
- api.diag.error("failed to stringify ", queryConfig.values, e);
146
- }
95
+ span.setAttribute(semconv.ATTR_DB_STATEMENT, queryConfig.text);
147
96
  }
148
97
  if (typeof queryConfig.name === "string") {
149
98
  span.setAttribute(AttributeNames.AttributeNames.PG_PLAN, queryConfig.name);
150
99
  }
151
100
  return span;
152
101
  }
153
- function handleExecutionResult(config, span, pgResult) {
154
- if (typeof config.responseHook === "function") {
155
- instrumentation.safeExecuteInTheMiddle(
156
- () => {
157
- config.responseHook(span, {
158
- data: pgResult
159
- });
160
- },
161
- (err) => {
162
- if (err) {
163
- api.diag.error("Error running response hook", err);
164
- }
165
- },
166
- true
167
- );
168
- }
169
- }
170
- function patchCallback(instrumentationConfig, span, cb, attributes, recordDuration) {
102
+ function patchCallback(span, cb) {
171
103
  return function patchedCallback(err, res) {
172
104
  if (err) {
173
- if (Object.prototype.hasOwnProperty.call(err, "code")) {
174
- attributes[semanticConventions.ATTR_ERROR_TYPE] = err["code"];
175
- }
176
- if (err instanceof Error) {
177
- span.recordException(sanitizedErrorMessage(err));
178
- }
179
- span.setStatus({
180
- code: api.SpanStatusCode.ERROR,
181
- message: err.message
182
- });
183
- } else {
184
- handleExecutionResult(instrumentationConfig, span, res);
105
+ span.setStatus({ code: core.SPAN_STATUS_ERROR, message: err.message });
185
106
  }
186
- recordDuration();
187
107
  span.end();
188
108
  cb.call(this, err, res);
189
109
  };
190
110
  }
191
- function getPoolName(pool) {
192
- let poolName = "";
193
- poolName += (pool?.host ? `${pool.host}` : "unknown_host") + ":";
194
- poolName += (pool?.port ? `${pool.port}` : "unknown_port") + "/";
195
- poolName += pool?.database ? `${pool.database}` : "unknown_database";
196
- return poolName.trim();
197
- }
198
- function updateCounter(poolName, pool, connectionCount, connectionPendingRequests, latestCounter) {
199
- const all = pool.totalCount;
200
- const pending = pool.waitingCount;
201
- const idle = pool.idleCount;
202
- const used = all - idle;
203
- connectionCount.add(used - latestCounter.used, {
204
- [semconv.ATTR_DB_CLIENT_CONNECTION_STATE]: semconv.DB_CLIENT_CONNECTION_STATE_VALUE_USED,
205
- [semconv.ATTR_DB_CLIENT_CONNECTION_POOL_NAME]: poolName
206
- });
207
- connectionCount.add(idle - latestCounter.idle, {
208
- [semconv.ATTR_DB_CLIENT_CONNECTION_STATE]: semconv.DB_CLIENT_CONNECTION_STATE_VALUE_IDLE,
209
- [semconv.ATTR_DB_CLIENT_CONNECTION_POOL_NAME]: poolName
210
- });
211
- connectionPendingRequests.add(pending - latestCounter.pending, {
212
- [semconv.ATTR_DB_CLIENT_CONNECTION_POOL_NAME]: poolName
213
- });
214
- return { used, idle, pending };
215
- }
216
111
  function patchCallbackPGPool(span, cb) {
217
112
  return function patchedCallback(err, res, done) {
218
113
  if (err) {
219
- if (err instanceof Error) {
220
- span.recordException(sanitizedErrorMessage(err));
221
- }
222
- span.setStatus({
223
- code: api.SpanStatusCode.ERROR,
224
- message: err.message
225
- });
114
+ span.setStatus({ code: core.SPAN_STATUS_ERROR, message: err.message });
226
115
  }
227
116
  span.end();
228
117
  cb.call(this, err, res, done);
229
118
  };
230
119
  }
231
120
  function patchClientConnectCallback(span, cb) {
232
- return function patchedClientConnectCallback(err) {
233
- if (err) {
234
- if (err instanceof Error) {
235
- span.recordException(sanitizedErrorMessage(err));
236
- }
237
- span.setStatus({
238
- code: api.SpanStatusCode.ERROR,
239
- message: err.message
240
- });
121
+ return function patchedClientConnectCallback(...args) {
122
+ const err = args[0];
123
+ if (err instanceof Error) {
124
+ span.setStatus({ code: core.SPAN_STATUS_ERROR, message: err.message });
241
125
  }
242
126
  span.end();
243
- cb.apply(this, arguments);
127
+ cb.apply(this, args);
244
128
  };
245
129
  }
246
130
  function getErrorMessage(e) {
@@ -249,27 +133,19 @@ function getErrorMessage(e) {
249
133
  function isObjectWithTextString(it) {
250
134
  return typeof it === "object" && typeof it?.text === "string";
251
135
  }
252
- function sanitizedErrorMessage(error) {
253
- const name = error?.name ?? "PostgreSQLError";
254
- const code = error?.code ?? "UNKNOWN";
255
- return `PostgreSQL error of type '${name}' occurred (code: ${code})`;
256
- }
257
136
 
137
+ exports.ORIGIN = ORIGIN;
258
138
  exports.getConnectionString = getConnectionString;
259
139
  exports.getErrorMessage = getErrorMessage;
260
- exports.getPoolName = getPoolName;
261
140
  exports.getQuerySpanName = getQuerySpanName;
262
141
  exports.getSemanticAttributesFromConnection = getSemanticAttributesFromConnection;
263
142
  exports.getSemanticAttributesFromPoolConnection = getSemanticAttributesFromPoolConnection;
264
143
  exports.handleConfigQuery = handleConfigQuery;
265
- exports.handleExecutionResult = handleExecutionResult;
266
144
  exports.isObjectWithTextString = isObjectWithTextString;
267
145
  exports.parseAndMaskConnectionString = parseAndMaskConnectionString;
268
146
  exports.parseNormalizedOperationName = parseNormalizedOperationName;
269
147
  exports.patchCallback = patchCallback;
270
148
  exports.patchCallbackPGPool = patchCallbackPGPool;
271
149
  exports.patchClientConnectCallback = patchClientConnectCallback;
272
- exports.sanitizedErrorMessage = sanitizedErrorMessage;
273
150
  exports.shouldSkipInstrumentation = shouldSkipInstrumentation;
274
- exports.updateCounter = updateCounter;
275
151
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/postgres/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-pg\n * - Upstream version: @opentelemetry/instrumentation-pg@0.70.0\n * - Types from `pg` package inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments\n */\n/* eslint-disable */\n\nimport {\n context,\n trace,\n Span,\n SpanStatusCode,\n Tracer,\n SpanKind,\n diag,\n UpDownCounter,\n Attributes,\n} from '@opentelemetry/api';\nimport { AttributeNames } from './enums/AttributeNames';\nimport {\n ATTR_ERROR_TYPE,\n ATTR_DB_SYSTEM_NAME,\n ATTR_DB_NAMESPACE,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n ATTR_DB_QUERY_TEXT,\n DB_SYSTEM_NAME_VALUE_POSTGRESQL,\n} from '@opentelemetry/semantic-conventions';\nimport {\n ATTR_DB_CLIENT_CONNECTION_POOL_NAME,\n ATTR_DB_CLIENT_CONNECTION_STATE,\n DB_CLIENT_CONNECTION_STATE_VALUE_USED,\n DB_CLIENT_CONNECTION_STATE_VALUE_IDLE,\n ATTR_DB_SYSTEM,\n ATTR_DB_NAME,\n ATTR_DB_USER,\n DB_SYSTEM_VALUE_POSTGRESQL,\n ATTR_DB_CONNECTION_STRING,\n ATTR_NET_PEER_PORT,\n ATTR_NET_PEER_NAME,\n ATTR_DB_STATEMENT,\n} from './semconv';\nimport {\n PgClientExtended,\n PostgresCallback,\n PgPoolCallback,\n PgPoolExtended,\n PgParsedConnectionParams,\n PgPoolOptionsParams,\n} from './internal-types';\nimport { PgInstrumentationConfig } from './types';\nimport type { PgClient, QueryResult, QueryArrayResult } from './pg-types';\nimport { safeExecuteInTheMiddle, SemconvStability } from '@opentelemetry/instrumentation';\nimport { SpanNames } from './enums/SpanNames';\n\n/**\n * Helper function to get a low cardinality span name from whatever info we have\n * about the query.\n *\n * This is tricky, because we don't have most of the information (table name,\n * operation name, etc) the spec recommends using to build a low-cardinality\n * value w/o parsing. So, we use db.name and assume that, if the query's a named\n * prepared statement, those `name` values will be low cardinality. If we don't\n * have a named prepared statement, we try to parse an operation (despite the\n * spec's warnings).\n *\n * @params dbName The name of the db against which this query is being issued,\n * which could be missing if no db name was given at the time that the\n * connection was established.\n * @params queryConfig Information we have about the query being issued, typed\n * to reflect only the validation we've actually done on the args to\n * `client.query()`. This will be undefined if `client.query()` was called\n * with invalid arguments.\n */\nexport function getQuerySpanName(dbName: string | undefined, queryConfig?: { text: string; name?: unknown }) {\n // NB: when the query config is invalid, we omit the dbName too, so that\n // someone (or some tool) reading the span name doesn't misinterpret the\n // dbName as being a prepared statement or sql commit name.\n if (!queryConfig) return SpanNames.QUERY_PREFIX;\n\n // Either the name of a prepared statement; or an attempted parse\n // of the SQL command, normalized to uppercase; or unknown.\n const command =\n typeof queryConfig.name === 'string' && queryConfig.name\n ? queryConfig.name\n : parseNormalizedOperationName(queryConfig.text);\n\n return `${SpanNames.QUERY_PREFIX}:${command}${dbName ? ` ${dbName}` : ''}`;\n}\n\nexport function parseNormalizedOperationName(queryText: string) {\n // Trim the query text to handle leading/trailing whitespace\n const trimmedQuery = queryText.trim();\n const indexOfFirstSpace = trimmedQuery.indexOf(' ');\n let sqlCommand = indexOfFirstSpace === -1 ? trimmedQuery : trimmedQuery.slice(0, indexOfFirstSpace);\n sqlCommand = sqlCommand.toUpperCase();\n\n // Handle query text being \"COMMIT;\", which has an extra semicolon before the space.\n return sqlCommand.endsWith(';') ? sqlCommand.slice(0, -1) : sqlCommand;\n}\n\nexport function parseAndMaskConnectionString(connectionString: string): string {\n try {\n // Parse the connection string\n const url = new URL(connectionString);\n\n // Remove all auth information (username and password)\n url.username = '';\n url.password = '';\n\n return url.toString();\n } catch (e) {\n // If parsing fails, return a generic connection string\n return 'postgresql://localhost:5432/';\n }\n}\n\nexport function getConnectionString(params: PgParsedConnectionParams | PgPoolOptionsParams) {\n if ('connectionString' in params && params.connectionString) {\n return parseAndMaskConnectionString(params.connectionString);\n }\n const host = params.host || 'localhost';\n const port = params.port || 5432;\n const database = params.database || '';\n return `postgresql://${host}:${port}/${database}`;\n}\n\nfunction getPort(port: number | undefined): number | undefined {\n // Port may be NaN as parseInt() is used on the value, passing null will result in NaN being parsed.\n // https://github.com/brianc/node-postgres/blob/2a8efbee09a284be12748ed3962bc9b816965e36/packages/pg/lib/connection-parameters.js#L66\n if (Number.isInteger(port)) {\n return port;\n }\n\n // Unable to find the default used in pg code, so falling back to 'undefined'.\n return undefined;\n}\n\nexport function getSemanticAttributesFromConnection(\n params: PgParsedConnectionParams,\n semconvStability: SemconvStability,\n) {\n let attributes: Attributes = {};\n\n if (semconvStability & SemconvStability.OLD) {\n attributes = {\n ...attributes,\n [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_POSTGRESQL,\n [ATTR_DB_NAME]: params.database,\n [ATTR_DB_CONNECTION_STRING]: getConnectionString(params),\n [ATTR_DB_USER]: params.user,\n [ATTR_NET_PEER_NAME]: params.host, // required\n [ATTR_NET_PEER_PORT]: getPort(params.port),\n };\n }\n if (semconvStability & SemconvStability.STABLE) {\n attributes = {\n ...attributes,\n [ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_POSTGRESQL,\n [ATTR_DB_NAMESPACE]: params.namespace,\n [ATTR_SERVER_ADDRESS]: params.host,\n [ATTR_SERVER_PORT]: getPort(params.port),\n };\n }\n\n return attributes;\n}\n\nexport function getSemanticAttributesFromPoolConnection(\n params: PgPoolOptionsParams,\n semconvStability: SemconvStability,\n) {\n let url: URL | undefined;\n try {\n url = params.connectionString ? new URL(params.connectionString) : undefined;\n } catch (e) {\n url = undefined;\n }\n let attributes: Attributes = {\n [AttributeNames.IDLE_TIMEOUT_MILLIS]: params.idleTimeoutMillis,\n [AttributeNames.MAX_CLIENT]: params.maxClient,\n };\n\n if (semconvStability & SemconvStability.OLD) {\n attributes = {\n ...attributes,\n [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_POSTGRESQL,\n [ATTR_DB_NAME]: url?.pathname.slice(1) ?? params.database,\n [ATTR_DB_CONNECTION_STRING]: getConnectionString(params),\n [ATTR_NET_PEER_NAME]: url?.hostname ?? params.host,\n [ATTR_NET_PEER_PORT]: Number(url?.port) || getPort(params.port),\n [ATTR_DB_USER]: url?.username ?? params.user,\n };\n }\n if (semconvStability & SemconvStability.STABLE) {\n attributes = {\n ...attributes,\n [ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_POSTGRESQL,\n [ATTR_DB_NAMESPACE]: params.namespace,\n [ATTR_SERVER_ADDRESS]: url?.hostname ?? params.host,\n [ATTR_SERVER_PORT]: Number(url?.port) || getPort(params.port),\n };\n }\n\n return attributes;\n}\n\nexport function shouldSkipInstrumentation(instrumentationConfig: PgInstrumentationConfig) {\n return instrumentationConfig.requireParentSpan === true && trace.getSpan(context.active()) === undefined;\n}\n\n// Create a span from our normalized queryConfig object,\n// or return a basic span if no queryConfig was given/could be created.\nexport function handleConfigQuery(\n this: PgClientExtended,\n tracer: Tracer,\n instrumentationConfig: PgInstrumentationConfig,\n semconvStability: SemconvStability,\n queryConfig?: { text: string; values?: unknown; name?: unknown },\n) {\n // Create child span.\n const { connectionParameters } = this;\n const dbName = connectionParameters.database;\n\n const spanName = getQuerySpanName(dbName, queryConfig);\n const span = tracer.startSpan(spanName, {\n kind: SpanKind.CLIENT,\n attributes: getSemanticAttributesFromConnection(connectionParameters, semconvStability),\n });\n\n if (!queryConfig) {\n return span;\n }\n\n // Set attributes\n if (queryConfig.text) {\n if (semconvStability & SemconvStability.OLD) {\n span.setAttribute(ATTR_DB_STATEMENT, queryConfig.text);\n }\n if (semconvStability & SemconvStability.STABLE) {\n span.setAttribute(ATTR_DB_QUERY_TEXT, queryConfig.text);\n }\n }\n\n if (instrumentationConfig.enhancedDatabaseReporting && Array.isArray(queryConfig.values)) {\n try {\n const convertedValues = queryConfig.values.map(value => {\n if (value == null) {\n return 'null';\n } else if (value instanceof Buffer) {\n return value.toString();\n } else if (typeof value === 'object') {\n if (typeof value.toPostgres === 'function') {\n return value.toPostgres();\n }\n return JSON.stringify(value);\n } else {\n //string, number\n return value.toString();\n }\n });\n span.setAttribute(AttributeNames.PG_VALUES, convertedValues);\n } catch (e) {\n diag.error('failed to stringify ', queryConfig.values, e);\n }\n }\n\n // Set plan name attribute, if present\n if (typeof queryConfig.name === 'string') {\n span.setAttribute(AttributeNames.PG_PLAN, queryConfig.name);\n }\n\n return span;\n}\n\nexport function handleExecutionResult(\n config: PgInstrumentationConfig,\n span: Span,\n pgResult: QueryResult | QueryArrayResult | unknown,\n) {\n if (typeof config.responseHook === 'function') {\n safeExecuteInTheMiddle(\n () => {\n config.responseHook!(span, {\n data: pgResult as QueryResult | QueryArrayResult,\n });\n },\n err => {\n if (err) {\n diag.error('Error running response hook', err);\n }\n },\n true,\n );\n }\n}\n\nexport function patchCallback(\n instrumentationConfig: PgInstrumentationConfig,\n span: Span,\n cb: PostgresCallback,\n attributes: Attributes,\n recordDuration: { (): void },\n): PostgresCallback {\n return function patchedCallback(this: PgClientExtended, err: Error, res: object) {\n if (err) {\n if (Object.prototype.hasOwnProperty.call(err, 'code')) {\n attributes[ATTR_ERROR_TYPE] = (err as any)['code'];\n }\n if (err instanceof Error) {\n span.recordException(sanitizedErrorMessage(err));\n }\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n } else {\n handleExecutionResult(instrumentationConfig, span, res);\n }\n\n recordDuration();\n span.end();\n cb.call(this, err, res);\n };\n}\n\nexport function getPoolName(pool: PgPoolOptionsParams): string {\n let poolName = '';\n poolName += (pool?.host ? `${pool.host}` : 'unknown_host') + ':';\n poolName += (pool?.port ? `${pool.port}` : 'unknown_port') + '/';\n poolName += pool?.database ? `${pool.database}` : 'unknown_database';\n\n return poolName.trim();\n}\n\nexport interface poolConnectionsCounter {\n used: number;\n idle: number;\n pending: number;\n}\n\nexport function updateCounter(\n poolName: string,\n pool: PgPoolExtended,\n connectionCount: UpDownCounter,\n connectionPendingRequests: UpDownCounter,\n latestCounter: poolConnectionsCounter,\n): poolConnectionsCounter {\n const all = pool.totalCount;\n const pending = pool.waitingCount;\n const idle = pool.idleCount;\n const used = all - idle;\n\n connectionCount.add(used - latestCounter.used, {\n [ATTR_DB_CLIENT_CONNECTION_STATE]: DB_CLIENT_CONNECTION_STATE_VALUE_USED,\n [ATTR_DB_CLIENT_CONNECTION_POOL_NAME]: poolName,\n });\n\n connectionCount.add(idle - latestCounter.idle, {\n [ATTR_DB_CLIENT_CONNECTION_STATE]: DB_CLIENT_CONNECTION_STATE_VALUE_IDLE,\n [ATTR_DB_CLIENT_CONNECTION_POOL_NAME]: poolName,\n });\n\n connectionPendingRequests.add(pending - latestCounter.pending, {\n [ATTR_DB_CLIENT_CONNECTION_POOL_NAME]: poolName,\n });\n\n return { used: used, idle: idle, pending: pending };\n}\n\nexport function patchCallbackPGPool(span: Span, cb: PgPoolCallback): PgPoolCallback {\n return function patchedCallback(this: PgPoolExtended, err: Error, res: object, done: any) {\n if (err) {\n if (err instanceof Error) {\n span.recordException(sanitizedErrorMessage(err));\n }\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n }\n span.end();\n cb.call(this, err, res, done);\n };\n}\n\nexport function patchClientConnectCallback(span: Span, cb: Function): Function {\n return function patchedClientConnectCallback(this: PgClient, err: Error) {\n if (err) {\n if (err instanceof Error) {\n span.recordException(sanitizedErrorMessage(err));\n }\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n }\n span.end();\n cb.apply(this, arguments);\n };\n}\n\n/**\n * Attempt to get a message string from a thrown value, while being quite\n * defensive, to recognize the fact that, in JS, any kind of value (even\n * primitives) can be thrown.\n */\nexport function getErrorMessage(e: unknown) {\n return typeof e === 'object' && e !== null && 'message' in e\n ? String((e as { message?: unknown }).message)\n : undefined;\n}\n\nexport function isObjectWithTextString(it: unknown): it is ObjectWithText {\n return typeof it === 'object' && typeof (it as null | { text?: unknown })?.text === 'string';\n}\n\nexport type ObjectWithText = {\n text: string;\n [k: string]: unknown;\n};\n\n/**\n * Generates a sanitized message for the error.\n * Only includes the error type and PostgreSQL error code, omitting any sensitive details.\n */\nexport function sanitizedErrorMessage(error: unknown): string {\n const name = (error as any)?.name ?? 'PostgreSQLError';\n const code = (error as any)?.code ?? 'UNKNOWN';\n\n return `PostgreSQL error of type '${name}' occurred (code: ${code})`;\n}\n"],"names":["SpanNames","SemconvStability","ATTR_DB_SYSTEM","DB_SYSTEM_VALUE_POSTGRESQL","ATTR_DB_NAME","ATTR_DB_CONNECTION_STRING","ATTR_DB_USER","ATTR_NET_PEER_NAME","ATTR_NET_PEER_PORT","ATTR_DB_SYSTEM_NAME","DB_SYSTEM_NAME_VALUE_POSTGRESQL","ATTR_DB_NAMESPACE","ATTR_SERVER_ADDRESS","ATTR_SERVER_PORT","AttributeNames","trace","context","SpanKind","ATTR_DB_STATEMENT","ATTR_DB_QUERY_TEXT","diag","safeExecuteInTheMiddle","ATTR_ERROR_TYPE","SpanStatusCode","ATTR_DB_CLIENT_CONNECTION_STATE","DB_CLIENT_CONNECTION_STATE_VALUE_USED","ATTR_DB_CLIENT_CONNECTION_POOL_NAME","DB_CLIENT_CONNECTION_STATE_VALUE_IDLE"],"mappings":";;;;;;;;;AA0FO,SAAS,gBAAA,CAAiB,QAA4B,WAAA,EAAgD;AAI3G,EAAA,IAAI,CAAC,WAAA,EAAa,OAAOA,mBAAA,CAAU,YAAA;AAInC,EAAA,MAAM,OAAA,GACJ,OAAO,WAAA,CAAY,IAAA,KAAS,QAAA,IAAY,WAAA,CAAY,IAAA,GAChD,WAAA,CAAY,IAAA,GACZ,4BAAA,CAA6B,WAAA,CAAY,IAAI,CAAA;AAEnD,EAAA,OAAO,CAAA,EAAGA,mBAAA,CAAU,YAAY,CAAA,CAAA,EAAI,OAAO,GAAG,MAAA,GAAS,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA;AAC1E;AAEO,SAAS,6BAA6B,SAAA,EAAmB;AAE9D,EAAA,MAAM,YAAA,GAAe,UAAU,IAAA,EAAK;AACpC,EAAA,MAAM,iBAAA,GAAoB,YAAA,CAAa,OAAA,CAAQ,GAAG,CAAA;AAClD,EAAA,IAAI,aAAa,iBAAA,KAAsB,EAAA,GAAK,eAAe,YAAA,CAAa,KAAA,CAAM,GAAG,iBAAiB,CAAA;AAClG,EAAA,UAAA,GAAa,WAAW,WAAA,EAAY;AAGpC,EAAA,OAAO,UAAA,CAAW,SAAS,GAAG,CAAA,GAAI,WAAW,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,GAAI,UAAA;AAC9D;AAEO,SAAS,6BAA6B,g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AA,EAC1B,CAAA;AACF;AAOO,SAAS,gBAAgB,CAAA,EAAY;AAC1C,EAAA,OAAO,OAAO,CAAA,KAAM,QAAA,IAAY,CAAA,KAAM,IAAA,IAAQ,aAAa,CAAA,GACvD,MAAA,CAAQ,CAAA,CAA4B,OAAO,CAAA,GAC3C,MAAA;AACN;AAEO,SAAS,uBAAuB,EAAA,EAAmC;AACxE,EAAA,OAAO,OAAO,EAAA,KAAO,QAAA,IAAY,OAAQ,IAAkC,IAAA,KAAS,QAAA;AACtF;AAWO,SAAS,sBAAsB,KAAA,EAAwB;AAC5D,EAAA,MAAM,IAAA,GAAQ,OAAe,IAAA,IAAQ,iBAAA;AACrC,EAAA,MAAM,IAAA,GAAQ,OAAe,IAAA,IAAQ,SAAA;AAErC,EAAA,OAAO,CAAA,0BAAA,EAA6B,IAAI,CAAA,kBAAA,EAAqB,IAAI,CAAA,CAAA,CAAA;AACnE;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/postgres/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-pg\n * - Upstream version: @opentelemetry/instrumentation-pg@0.70.0\n * - Types from `pg` package inlined as simplified interfaces\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport { SpanKind } from '@opentelemetry/api';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport { getActiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR, startInactiveSpan } from '@sentry/core';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { SpanNames } from './enums/SpanNames';\nimport type {\n PgClientExtended,\n PgParsedConnectionParams,\n PgPoolCallback,\n PgPoolExtended,\n PgPoolOptionsParams,\n PostgresCallback,\n} from './internal-types';\nimport type { PgClient } from './pg-types';\nimport {\n ATTR_DB_CONNECTION_STRING,\n ATTR_DB_NAME,\n ATTR_DB_STATEMENT,\n ATTR_DB_SYSTEM,\n ATTR_DB_USER,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n DB_SYSTEM_VALUE_POSTGRESQL,\n} from './semconv';\n\n/* oxlint-disable typescript/no-deprecated */\n\nexport const ORIGIN = 'auto.db.otel.postgres';\n\n/**\n * Helper function to get a low cardinality span name from whatever info we have\n * about the query.\n *\n * This is tricky, because we don't have most of the information (table name,\n * operation name, etc) the spec recommends using to build a low-cardinality\n * value w/o parsing. So, we use db.name and assume that, if the query's a named\n * prepared statement, those `name` values will be low cardinality. If we don't\n * have a named prepared statement, we try to parse an operation (despite the\n * spec's warnings).\n *\n * @params dbName The name of the db against which this query is being issued,\n * which could be missing if no db name was given at the time that the\n * connection was established.\n * @params queryConfig Information we have about the query being issued, typed\n * to reflect only the validation we've actually done on the args to\n * `client.query()`. This will be undefined if `client.query()` was called\n * with invalid arguments.\n */\nexport function getQuerySpanName(dbName: string | undefined, queryConfig?: { text: string; name?: unknown }): string {\n // NB: when the query config is invalid, we omit the dbName too, so that\n // someone (or some tool) reading the span name doesn't misinterpret the\n // dbName as being a prepared statement or sql commit name.\n if (!queryConfig) return SpanNames.QUERY_PREFIX;\n\n // Either the name of a prepared statement; or an attempted parse\n // of the SQL command, normalized to uppercase; or unknown.\n const command =\n typeof queryConfig.name === 'string' && queryConfig.name\n ? queryConfig.name\n : parseNormalizedOperationName(queryConfig.text);\n\n return `${SpanNames.QUERY_PREFIX}:${command}${dbName ? ` ${dbName}` : ''}`;\n}\n\nexport function parseNormalizedOperationName(queryText: string): string {\n // Trim the query text to handle leading/trailing whitespace\n const trimmedQuery = queryText.trim();\n const indexOfFirstSpace = trimmedQuery.indexOf(' ');\n let sqlCommand = indexOfFirstSpace === -1 ? trimmedQuery : trimmedQuery.slice(0, indexOfFirstSpace);\n sqlCommand = sqlCommand.toUpperCase();\n\n // Handle query text being \"COMMIT;\", which has an extra semicolon before the space.\n return sqlCommand.endsWith(';') ? sqlCommand.slice(0, -1) : sqlCommand;\n}\n\nexport function parseAndMaskConnectionString(connectionString: string): string {\n try {\n // Parse the connection string\n const url = new URL(connectionString);\n\n // Remove all auth information (username and password)\n url.username = '';\n url.password = '';\n\n return url.toString();\n } catch {\n // If parsing fails, return a generic connection string\n return 'postgresql://localhost:5432/';\n }\n}\n\nexport function getConnectionString(params: PgParsedConnectionParams | PgPoolOptionsParams): string {\n if ('connectionString' in params && params.connectionString) {\n return parseAndMaskConnectionString(params.connectionString);\n }\n const host = params.host || 'localhost';\n const port = params.port || 5432;\n const database = params.database || '';\n return `postgresql://${host}:${port}/${database}`;\n}\n\nfunction getPort(port: number | undefined): number | undefined {\n // Port may be NaN as parseInt() is used on the value, passing null will result in NaN being parsed.\n // https://github.com/brianc/node-postgres/blob/2a8efbee09a284be12748ed3962bc9b816965e36/packages/pg/lib/connection-parameters.js#L66\n if (Number.isInteger(port)) {\n return port;\n }\n\n // Unable to find the default used in pg code, so falling back to 'undefined'.\n return undefined;\n}\n\nexport function getSemanticAttributesFromConnection(params: PgParsedConnectionParams): SpanAttributes {\n return {\n [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_POSTGRESQL,\n [ATTR_DB_NAME]: params.database,\n [ATTR_DB_CONNECTION_STRING]: getConnectionString(params),\n [ATTR_DB_USER]: params.user,\n [ATTR_NET_PEER_NAME]: params.host, // required\n [ATTR_NET_PEER_PORT]: getPort(params.port),\n };\n}\n\nexport function getSemanticAttributesFromPoolConnection(params: PgPoolOptionsParams): SpanAttributes {\n let url: URL | undefined;\n try {\n url = params.connectionString ? new URL(params.connectionString) : undefined;\n } catch {\n url = undefined;\n }\n\n return {\n [AttributeNames.IDLE_TIMEOUT_MILLIS]: params.idleTimeoutMillis,\n [AttributeNames.MAX_CLIENT]: params.maxClient,\n [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_POSTGRESQL,\n [ATTR_DB_NAME]: url?.pathname.slice(1) ?? params.database,\n [ATTR_DB_CONNECTION_STRING]: getConnectionString(params),\n [ATTR_NET_PEER_NAME]: url?.hostname ?? params.host,\n [ATTR_NET_PEER_PORT]: Number(url?.port) || getPort(params.port),\n [ATTR_DB_USER]: url?.username ?? params.user,\n };\n}\n\n/**\n * The SDK always requires a parent span (it sets `requireParentSpan: true`), so\n * we only instrument when there is an active span to parent the new span under.\n */\nexport function shouldSkipInstrumentation(): boolean {\n return getActiveSpan() === undefined;\n}\n\n// Create an (inactive) span from our normalized queryConfig object,\n// or return a basic span if no queryConfig was given/could be created.\nexport function handleConfigQuery(\n this: PgClientExtended,\n queryConfig?: { text: string; values?: unknown; name?: unknown },\n): Span {\n // Create child span.\n const { connectionParameters } = this;\n const dbName = connectionParameters.database;\n\n const spanName = getQuerySpanName(dbName, queryConfig);\n const span = startInactiveSpan({\n name: spanName,\n kind: SpanKind.CLIENT,\n attributes: {\n ...getSemanticAttributesFromConnection(connectionParameters),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n },\n });\n\n if (!queryConfig) {\n return span;\n }\n\n // Set attributes\n if (queryConfig.text) {\n span.setAttribute(ATTR_DB_STATEMENT, queryConfig.text);\n }\n\n // Set plan name attribute, if present\n if (typeof queryConfig.name === 'string') {\n span.setAttribute(AttributeNames.PG_PLAN, queryConfig.name);\n }\n\n return span;\n}\n\nexport function patchCallback(span: Span, cb: PostgresCallback): PostgresCallback {\n return function patchedCallback(this: PgClientExtended, err: Error, res: object) {\n if (err) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: err.message });\n }\n span.end();\n cb.call(this, err, res);\n };\n}\n\nexport function patchCallbackPGPool(span: Span, cb: PgPoolCallback): PgPoolCallback {\n return function patchedCallback(this: PgPoolExtended, err: Error, res: object, done: any) {\n if (err) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: err.message });\n }\n span.end();\n cb.call(this, err, res, done);\n };\n}\n\nexport function patchClientConnectCallback(span: Span, cb: (...args: unknown[]) => void): (...args: unknown[]) => void {\n return function patchedClientConnectCallback(this: PgClient, ...args: unknown[]) {\n const err = args[0];\n if (err instanceof Error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: err.message });\n }\n span.end();\n cb.apply(this, args);\n };\n}\n\n/**\n * Attempt to get a message string from a thrown value, while being quite\n * defensive, to recognize the fact that, in JS, any kind of value (even\n * primitives) can be thrown.\n */\nexport function getErrorMessage(e: unknown): string | undefined {\n return typeof e === 'object' && e !== null && 'message' in e\n ? String((e as { message?: unknown }).message)\n : undefined;\n}\n\nexport function isObjectWithTextString(it: unknown): it is ObjectWithText {\n return typeof it === 'object' && typeof (it as null | { text?: unknown })?.text === 'string';\n}\n\nexport type ObjectWithText = {\n text: string;\n [k: string]: unknown;\n};\n"],"names":["SpanNames","ATTR_DB_SYSTEM","DB_SYSTEM_VALUE_POSTGRESQL","ATTR_DB_NAME","ATTR_DB_CONNECTION_STRING","ATTR_DB_USER","ATTR_NET_PEER_NAME","ATTR_NET_PEER_PORT","AttributeNames","getActiveSpan","startInactiveSpan","SpanKind","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","ATTR_DB_STATEMENT","SPAN_STATUS_ERROR"],"mappings":";;;;;;;;AAsCO,MAAM,MAAA,GAAS;AAqBf,SAAS,gBAAA,CAAiB,QAA4B,WAAA,EAAwD;AAInH,EAAA,IAAI,CAAC,WAAA,EAAa,OAAOA,mBAAA,CAAU,YAAA;AAInC,EAAA,MAAM,OAAA,GACJ,OAAO,WAAA,CAAY,IAAA,KAAS,QAAA,IAAY,WAAA,CAAY,IAAA,GAChD,WAAA,CAAY,IAAA,GACZ,4BAAA,CAA6B,WAAA,CAAY,IAAI,CAAA;AAEnD,EAAA,OAAO,CAAA,EAAGA,mBAAA,CAAU,YAAY,CAAA,CAAA,EAAI,OAAO,GAAG,MAAA,GAAS,CAAA,CAAA,EAAI,MAAM,C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