@sentry/node 7.105.0 → 8.0.0-alpha.2

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 (429) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +114 -38
  3. package/cjs/cron/index.js +15 -0
  4. package/cjs/cron/index.js.map +1 -0
  5. package/cjs/index.js +79 -99
  6. package/cjs/index.js.map +1 -1
  7. package/cjs/integrations/anr/index.js +5 -32
  8. package/cjs/integrations/anr/index.js.map +1 -1
  9. package/cjs/integrations/anr/worker-script.js +2 -2
  10. package/cjs/integrations/console.js +2 -13
  11. package/cjs/integrations/console.js.map +1 -1
  12. package/cjs/integrations/context.js +2 -16
  13. package/cjs/integrations/context.js.map +1 -1
  14. package/cjs/integrations/contextlines.js +6 -23
  15. package/cjs/integrations/contextlines.js.map +1 -1
  16. package/cjs/integrations/http.js +103 -354
  17. package/cjs/integrations/http.js.map +1 -1
  18. package/cjs/integrations/local-variables/index.js +0 -10
  19. package/cjs/integrations/local-variables/index.js.map +1 -1
  20. package/cjs/integrations/local-variables/local-variables-sync.js +31 -41
  21. package/cjs/integrations/local-variables/local-variables-sync.js.map +1 -1
  22. package/cjs/integrations/modules.js +19 -30
  23. package/cjs/integrations/modules.js.map +1 -1
  24. package/cjs/integrations/node-fetch.js +82 -0
  25. package/cjs/integrations/node-fetch.js.map +1 -0
  26. package/cjs/integrations/onuncaughtexception.js +15 -30
  27. package/cjs/integrations/onuncaughtexception.js.map +1 -1
  28. package/cjs/integrations/onunhandledrejection.js +3 -17
  29. package/cjs/integrations/onunhandledrejection.js.map +1 -1
  30. package/cjs/integrations/spotlight.js +4 -22
  31. package/cjs/integrations/spotlight.js.map +1 -1
  32. package/cjs/integrations/tracing/express.js +103 -0
  33. package/cjs/integrations/tracing/express.js.map +1 -0
  34. package/cjs/integrations/tracing/fastify.js +33 -0
  35. package/cjs/integrations/tracing/fastify.js.map +1 -0
  36. package/cjs/integrations/tracing/graphql.js +34 -0
  37. package/cjs/integrations/tracing/graphql.js.map +1 -0
  38. package/cjs/integrations/tracing/hapi/index.js +81 -0
  39. package/cjs/integrations/tracing/hapi/index.js.map +1 -0
  40. package/cjs/integrations/tracing/index.js +37 -0
  41. package/cjs/integrations/tracing/index.js.map +1 -0
  42. package/cjs/integrations/tracing/koa.js +21 -0
  43. package/cjs/integrations/tracing/koa.js.map +1 -0
  44. package/cjs/integrations/tracing/mongo.js +33 -0
  45. package/cjs/integrations/tracing/mongo.js.map +1 -0
  46. package/cjs/integrations/tracing/mongoose.js +33 -0
  47. package/cjs/integrations/tracing/mongoose.js.map +1 -0
  48. package/cjs/integrations/tracing/mysql.js +26 -0
  49. package/cjs/integrations/tracing/mysql.js.map +1 -0
  50. package/cjs/integrations/tracing/mysql2.js +33 -0
  51. package/cjs/integrations/tracing/mysql2.js.map +1 -0
  52. package/cjs/integrations/tracing/nest.js +26 -0
  53. package/cjs/integrations/tracing/nest.js.map +1 -0
  54. package/cjs/integrations/tracing/postgres.js +34 -0
  55. package/cjs/integrations/tracing/postgres.js.map +1 -0
  56. package/cjs/integrations/tracing/prisma.js +33 -0
  57. package/cjs/integrations/tracing/prisma.js.map +1 -0
  58. package/cjs/nodeVersion.js +5 -1
  59. package/cjs/nodeVersion.js.map +1 -1
  60. package/cjs/otel/contextManager.js +16 -0
  61. package/cjs/otel/contextManager.js.map +1 -0
  62. package/cjs/proxy/index.js +1 -2
  63. package/cjs/proxy/index.js.map +1 -1
  64. package/cjs/sdk/api.js +74 -0
  65. package/cjs/sdk/api.js.map +1 -0
  66. package/cjs/sdk/client.js +57 -0
  67. package/cjs/sdk/client.js.map +1 -0
  68. package/cjs/sdk/hub.js +104 -0
  69. package/cjs/sdk/hub.js.map +1 -0
  70. package/cjs/sdk/init.js +252 -0
  71. package/cjs/sdk/init.js.map +1 -0
  72. package/cjs/sdk/initOtel.js +70 -0
  73. package/cjs/sdk/initOtel.js.map +1 -0
  74. package/cjs/sdk/scope.js +18 -0
  75. package/cjs/sdk/scope.js.map +1 -0
  76. package/cjs/transports/http.js +2 -3
  77. package/cjs/transports/http.js.map +1 -1
  78. package/cjs/utils/addOriginToSpan.js +11 -0
  79. package/cjs/utils/addOriginToSpan.js.map +1 -0
  80. package/cjs/{integrations/utils → utils}/errorhandling.js +2 -1
  81. package/cjs/utils/errorhandling.js.map +1 -0
  82. package/cjs/utils/getRequestUrl.js +18 -0
  83. package/cjs/utils/getRequestUrl.js.map +1 -0
  84. package/cjs/utils/module.js.map +1 -0
  85. package/esm/cron/index.js +13 -0
  86. package/esm/cron/index.js.map +1 -0
  87. package/esm/index.js +28 -48
  88. package/esm/index.js.map +1 -1
  89. package/esm/integrations/anr/index.js +8 -34
  90. package/esm/integrations/anr/index.js.map +1 -1
  91. package/esm/integrations/anr/worker-script.js +2 -2
  92. package/esm/integrations/console.js +4 -14
  93. package/esm/integrations/console.js.map +1 -1
  94. package/esm/integrations/context.js +4 -17
  95. package/esm/integrations/context.js.map +1 -1
  96. package/esm/integrations/contextlines.js +8 -25
  97. package/esm/integrations/contextlines.js.map +1 -1
  98. package/esm/integrations/http.js +105 -353
  99. package/esm/integrations/http.js.map +1 -1
  100. package/esm/integrations/local-variables/index.js +2 -11
  101. package/esm/integrations/local-variables/index.js.map +1 -1
  102. package/esm/integrations/local-variables/local-variables-sync.js +32 -41
  103. package/esm/integrations/local-variables/local-variables-sync.js.map +1 -1
  104. package/esm/integrations/modules.js +21 -31
  105. package/esm/integrations/modules.js.map +1 -1
  106. package/esm/integrations/node-fetch.js +80 -0
  107. package/esm/integrations/node-fetch.js.map +1 -0
  108. package/esm/integrations/onuncaughtexception.js +17 -31
  109. package/esm/integrations/onuncaughtexception.js.map +1 -1
  110. package/esm/integrations/onunhandledrejection.js +5 -18
  111. package/esm/integrations/onunhandledrejection.js.map +1 -1
  112. package/esm/integrations/spotlight.js +3 -20
  113. package/esm/integrations/spotlight.js.map +1 -1
  114. package/esm/integrations/tracing/express.js +96 -0
  115. package/esm/integrations/tracing/express.js.map +1 -0
  116. package/esm/integrations/tracing/fastify.js +31 -0
  117. package/esm/integrations/tracing/fastify.js.map +1 -0
  118. package/esm/integrations/tracing/graphql.js +32 -0
  119. package/esm/integrations/tracing/graphql.js.map +1 -0
  120. package/esm/integrations/tracing/hapi/index.js +77 -0
  121. package/esm/integrations/tracing/hapi/index.js.map +1 -0
  122. package/esm/integrations/tracing/index.js +35 -0
  123. package/esm/integrations/tracing/index.js.map +1 -0
  124. package/esm/integrations/tracing/koa.js +19 -0
  125. package/esm/integrations/tracing/koa.js.map +1 -0
  126. package/esm/integrations/tracing/mongo.js +31 -0
  127. package/esm/integrations/tracing/mongo.js.map +1 -0
  128. package/esm/integrations/tracing/mongoose.js +31 -0
  129. package/esm/integrations/tracing/mongoose.js.map +1 -0
  130. package/esm/integrations/tracing/mysql.js +24 -0
  131. package/esm/integrations/tracing/mysql.js.map +1 -0
  132. package/esm/integrations/tracing/mysql2.js +31 -0
  133. package/esm/integrations/tracing/mysql2.js.map +1 -0
  134. package/esm/integrations/tracing/nest.js +24 -0
  135. package/esm/integrations/tracing/nest.js.map +1 -0
  136. package/esm/integrations/tracing/postgres.js +32 -0
  137. package/esm/integrations/tracing/postgres.js.map +1 -0
  138. package/esm/integrations/tracing/prisma.js +31 -0
  139. package/esm/integrations/tracing/prisma.js.map +1 -0
  140. package/esm/nodeVersion.js +5 -2
  141. package/esm/nodeVersion.js.map +1 -1
  142. package/esm/otel/contextManager.js +14 -0
  143. package/esm/otel/contextManager.js.map +1 -0
  144. package/esm/proxy/index.js +0 -1
  145. package/esm/proxy/index.js.map +1 -1
  146. package/esm/sdk/api.js +69 -0
  147. package/esm/sdk/api.js.map +1 -0
  148. package/esm/sdk/client.js +52 -0
  149. package/esm/sdk/client.js.map +1 -0
  150. package/esm/sdk/hub.js +102 -0
  151. package/esm/sdk/hub.js.map +1 -0
  152. package/esm/sdk/init.js +249 -0
  153. package/esm/sdk/init.js.map +1 -0
  154. package/esm/sdk/initOtel.js +67 -0
  155. package/esm/sdk/initOtel.js.map +1 -0
  156. package/esm/sdk/scope.js +16 -0
  157. package/esm/sdk/scope.js.map +1 -0
  158. package/esm/transports/http.js +0 -1
  159. package/esm/transports/http.js.map +1 -1
  160. package/esm/utils/addOriginToSpan.js +9 -0
  161. package/esm/utils/addOriginToSpan.js.map +1 -0
  162. package/esm/{integrations/utils → utils}/errorhandling.js +2 -1
  163. package/esm/utils/errorhandling.js.map +1 -0
  164. package/esm/utils/getRequestUrl.js +16 -0
  165. package/esm/utils/getRequestUrl.js.map +1 -0
  166. package/esm/utils/module.js.map +1 -0
  167. package/package.json +31 -23
  168. package/types/cron/index.d.ts +10 -0
  169. package/types/cron/index.d.ts.map +1 -0
  170. package/types/index.d.ts +30 -145
  171. package/types/index.d.ts.map +1 -1
  172. package/types/integrations/anr/index.d.ts +0 -15
  173. package/types/integrations/anr/index.d.ts.map +1 -1
  174. package/types/integrations/console.d.ts +2 -8
  175. package/types/integrations/console.d.ts.map +1 -1
  176. package/types/integrations/context.d.ts +3 -18
  177. package/types/integrations/context.d.ts.map +1 -1
  178. package/types/integrations/contextlines.d.ts +8 -10
  179. package/types/integrations/contextlines.d.ts.map +1 -1
  180. package/types/integrations/http.d.ts +8 -89
  181. package/types/integrations/http.d.ts.map +1 -1
  182. package/types/integrations/local-variables/common.d.ts +1 -0
  183. package/types/integrations/local-variables/common.d.ts.map +1 -1
  184. package/types/integrations/local-variables/index.d.ts +0 -11
  185. package/types/integrations/local-variables/index.d.ts.map +1 -1
  186. package/types/integrations/local-variables/local-variables-sync.d.ts +2 -1
  187. package/types/integrations/local-variables/local-variables-sync.d.ts.map +1 -1
  188. package/types/integrations/modules.d.ts +1 -7
  189. package/types/integrations/modules.d.ts.map +1 -1
  190. package/types/integrations/node-fetch.d.ts +15 -0
  191. package/types/integrations/node-fetch.d.ts.map +1 -0
  192. package/types/integrations/onuncaughtexception.d.ts +3 -12
  193. package/types/integrations/onuncaughtexception.d.ts.map +1 -1
  194. package/types/integrations/onunhandledrejection.d.ts +3 -10
  195. package/types/integrations/onunhandledrejection.d.ts.map +1 -1
  196. package/types/integrations/spotlight.d.ts +1 -10
  197. package/types/integrations/spotlight.d.ts.map +1 -1
  198. package/types/integrations/tracing/express.d.ts +37 -0
  199. package/types/integrations/tracing/express.d.ts.map +1 -0
  200. package/types/integrations/tracing/fastify.d.ts +7 -0
  201. package/types/integrations/tracing/fastify.d.ts.map +1 -0
  202. package/types/integrations/tracing/graphql.d.ts +7 -0
  203. package/types/integrations/tracing/graphql.d.ts.map +1 -0
  204. package/types/integrations/tracing/hapi/index.d.ts +18 -0
  205. package/types/integrations/tracing/hapi/index.d.ts.map +1 -0
  206. package/types/integrations/{hapi → tracing/hapi}/types.d.ts +1 -2
  207. package/types/integrations/tracing/hapi/types.d.ts.map +1 -0
  208. package/types/integrations/tracing/index.d.ts +6 -0
  209. package/types/integrations/tracing/index.d.ts.map +1 -0
  210. package/types/integrations/tracing/koa.d.ts +2 -0
  211. package/types/integrations/tracing/koa.d.ts.map +1 -0
  212. package/types/integrations/tracing/mongo.d.ts +7 -0
  213. package/types/integrations/tracing/mongo.d.ts.map +1 -0
  214. package/types/integrations/tracing/mongoose.d.ts +7 -0
  215. package/types/integrations/tracing/mongoose.d.ts.map +1 -0
  216. package/types/integrations/tracing/mysql.d.ts +7 -0
  217. package/types/integrations/tracing/mysql.d.ts.map +1 -0
  218. package/types/integrations/tracing/mysql2.d.ts +7 -0
  219. package/types/integrations/tracing/mysql2.d.ts.map +1 -0
  220. package/types/integrations/tracing/nest.d.ts +7 -0
  221. package/types/integrations/tracing/nest.d.ts.map +1 -0
  222. package/types/integrations/tracing/postgres.d.ts +7 -0
  223. package/types/integrations/tracing/postgres.d.ts.map +1 -0
  224. package/types/integrations/tracing/prisma.d.ts +11 -0
  225. package/types/integrations/tracing/prisma.d.ts.map +1 -0
  226. package/types/nodeVersion.d.ts +3 -3
  227. package/types/nodeVersion.d.ts.map +1 -1
  228. package/types/otel/contextManager.d.ts +10 -0
  229. package/types/otel/contextManager.d.ts.map +1 -0
  230. package/types/proxy/helpers.d.ts +0 -1
  231. package/types/proxy/helpers.d.ts.map +1 -1
  232. package/types/proxy/index.d.ts +0 -1
  233. package/types/proxy/index.d.ts.map +1 -1
  234. package/types/sdk/api.d.ts +18 -0
  235. package/types/sdk/api.d.ts.map +1 -0
  236. package/types/sdk/client.d.ts +17 -0
  237. package/types/sdk/client.d.ts.map +1 -0
  238. package/types/sdk/globals.d.ts +6 -0
  239. package/types/sdk/globals.d.ts.map +1 -0
  240. package/types/sdk/hub.d.ts +7 -0
  241. package/types/sdk/hub.d.ts.map +1 -0
  242. package/types/sdk/init.d.ts +9 -0
  243. package/types/sdk/init.d.ts.map +1 -0
  244. package/types/sdk/initOtel.d.ts +9 -0
  245. package/types/sdk/initOtel.d.ts.map +1 -0
  246. package/types/sdk/scope.d.ts +7 -0
  247. package/types/sdk/scope.d.ts.map +1 -0
  248. package/types/transports/http-module.d.ts +2 -5
  249. package/types/transports/http-module.d.ts.map +1 -1
  250. package/types/transports/http.d.ts.map +1 -1
  251. package/types/types.d.ts +25 -23
  252. package/types/types.d.ts.map +1 -1
  253. package/types/utils/addOriginToSpan.d.ts +5 -0
  254. package/types/utils/addOriginToSpan.d.ts.map +1 -0
  255. package/types/utils/errorhandling.d.ts.map +1 -0
  256. package/types/utils/getRequestUrl.d.ts +5 -0
  257. package/types/utils/getRequestUrl.d.ts.map +1 -0
  258. package/types/utils/module.d.ts.map +1 -0
  259. package/types/utils/prepareEvent.d.ts +17 -0
  260. package/types/utils/prepareEvent.d.ts.map +1 -0
  261. package/types-ts3.8/cron/index.d.ts +10 -0
  262. package/types-ts3.8/index.d.ts +30 -145
  263. package/types-ts3.8/integrations/anr/index.d.ts +0 -15
  264. package/types-ts3.8/integrations/console.d.ts +2 -8
  265. package/types-ts3.8/integrations/context.d.ts +3 -18
  266. package/types-ts3.8/integrations/contextlines.d.ts +8 -10
  267. package/types-ts3.8/integrations/http.d.ts +8 -89
  268. package/types-ts3.8/integrations/local-variables/common.d.ts +1 -0
  269. package/types-ts3.8/integrations/local-variables/index.d.ts +0 -11
  270. package/types-ts3.8/integrations/local-variables/local-variables-sync.d.ts +2 -1
  271. package/types-ts3.8/integrations/modules.d.ts +1 -7
  272. package/types-ts3.8/integrations/node-fetch.d.ts +15 -0
  273. package/types-ts3.8/integrations/onuncaughtexception.d.ts +3 -12
  274. package/types-ts3.8/integrations/onunhandledrejection.d.ts +3 -10
  275. package/types-ts3.8/integrations/spotlight.d.ts +1 -10
  276. package/types-ts3.8/integrations/tracing/express.d.ts +37 -0
  277. package/types-ts3.8/integrations/tracing/fastify.d.ts +7 -0
  278. package/types-ts3.8/integrations/tracing/graphql.d.ts +7 -0
  279. package/types-ts3.8/integrations/tracing/hapi/index.d.ts +18 -0
  280. package/types-ts3.8/integrations/{hapi → tracing/hapi}/types.d.ts +1 -2
  281. package/types-ts3.8/integrations/tracing/index.d.ts +6 -0
  282. package/types-ts3.8/integrations/tracing/koa.d.ts +2 -0
  283. package/types-ts3.8/integrations/tracing/mongo.d.ts +7 -0
  284. package/types-ts3.8/integrations/tracing/mongoose.d.ts +7 -0
  285. package/types-ts3.8/integrations/tracing/mysql.d.ts +7 -0
  286. package/types-ts3.8/integrations/tracing/mysql2.d.ts +7 -0
  287. package/types-ts3.8/integrations/tracing/nest.d.ts +7 -0
  288. package/types-ts3.8/integrations/tracing/postgres.d.ts +7 -0
  289. package/types-ts3.8/integrations/tracing/prisma.d.ts +11 -0
  290. package/types-ts3.8/nodeVersion.d.ts +3 -3
  291. package/types-ts3.8/otel/contextManager.d.ts +10 -0
  292. package/types-ts3.8/proxy/helpers.d.ts +0 -1
  293. package/types-ts3.8/proxy/index.d.ts +0 -1
  294. package/types-ts3.8/sdk/api.d.ts +18 -0
  295. package/types-ts3.8/sdk/client.d.ts +17 -0
  296. package/types-ts3.8/sdk/globals.d.ts +6 -0
  297. package/types-ts3.8/sdk/hub.d.ts +7 -0
  298. package/types-ts3.8/sdk/init.d.ts +9 -0
  299. package/types-ts3.8/sdk/initOtel.d.ts +9 -0
  300. package/types-ts3.8/sdk/scope.d.ts +7 -0
  301. package/types-ts3.8/transports/http-module.d.ts +2 -4
  302. package/types-ts3.8/types.d.ts +25 -23
  303. package/types-ts3.8/utils/addOriginToSpan.d.ts +5 -0
  304. package/types-ts3.8/utils/getRequestUrl.d.ts +5 -0
  305. package/types-ts3.8/utils/prepareEvent.d.ts +17 -0
  306. package/cjs/async/domain.js +0 -61
  307. package/cjs/async/domain.js.map +0 -1
  308. package/cjs/async/hooks.js +0 -50
  309. package/cjs/async/hooks.js.map +0 -1
  310. package/cjs/async/index.js +0 -22
  311. package/cjs/async/index.js.map +0 -1
  312. package/cjs/client.js +0 -39
  313. package/cjs/client.js.map +0 -1
  314. package/cjs/handlers.js +0 -340
  315. package/cjs/handlers.js.map +0 -1
  316. package/cjs/integrations/anr/legacy.js +0 -29
  317. package/cjs/integrations/anr/legacy.js.map +0 -1
  318. package/cjs/integrations/hapi/index.js +0 -161
  319. package/cjs/integrations/hapi/index.js.map +0 -1
  320. package/cjs/integrations/index.js +0 -32
  321. package/cjs/integrations/index.js.map +0 -1
  322. package/cjs/integrations/undici/index.js +0 -307
  323. package/cjs/integrations/undici/index.js.map +0 -1
  324. package/cjs/integrations/utils/errorhandling.js.map +0 -1
  325. package/cjs/integrations/utils/http.js +0 -225
  326. package/cjs/integrations/utils/http.js.map +0 -1
  327. package/cjs/module.js.map +0 -1
  328. package/cjs/requestDataDeprecated.js +0 -45
  329. package/cjs/requestDataDeprecated.js.map +0 -1
  330. package/cjs/sdk.js +0 -284
  331. package/cjs/sdk.js.map +0 -1
  332. package/cjs/tracing/index.js +0 -29
  333. package/cjs/tracing/index.js.map +0 -1
  334. package/cjs/tracing/integrations.js +0 -14
  335. package/cjs/tracing/integrations.js.map +0 -1
  336. package/cjs/utils.js +0 -45
  337. package/cjs/utils.js.map +0 -1
  338. package/esm/async/domain.js +0 -56
  339. package/esm/async/domain.js.map +0 -1
  340. package/esm/async/hooks.js +0 -45
  341. package/esm/async/hooks.js.map +0 -1
  342. package/esm/async/index.js +0 -20
  343. package/esm/async/index.js.map +0 -1
  344. package/esm/client.js +0 -37
  345. package/esm/client.js.map +0 -1
  346. package/esm/handlers.js +0 -330
  347. package/esm/handlers.js.map +0 -1
  348. package/esm/integrations/anr/legacy.js +0 -27
  349. package/esm/integrations/anr/legacy.js.map +0 -1
  350. package/esm/integrations/hapi/index.js +0 -156
  351. package/esm/integrations/hapi/index.js.map +0 -1
  352. package/esm/integrations/index.js +0 -16
  353. package/esm/integrations/index.js.map +0 -1
  354. package/esm/integrations/undici/index.js +0 -301
  355. package/esm/integrations/undici/index.js.map +0 -1
  356. package/esm/integrations/utils/errorhandling.js.map +0 -1
  357. package/esm/integrations/utils/http.js +0 -216
  358. package/esm/integrations/utils/http.js.map +0 -1
  359. package/esm/module.js.map +0 -1
  360. package/esm/requestDataDeprecated.js +0 -42
  361. package/esm/requestDataDeprecated.js.map +0 -1
  362. package/esm/sdk.js +0 -274
  363. package/esm/sdk.js.map +0 -1
  364. package/esm/tracing/index.js +0 -27
  365. package/esm/tracing/index.js.map +0 -1
  366. package/esm/tracing/integrations.js +0 -2
  367. package/esm/tracing/integrations.js.map +0 -1
  368. package/esm/utils.js +0 -43
  369. package/esm/utils.js.map +0 -1
  370. package/types/async/domain.d.ts +0 -5
  371. package/types/async/domain.d.ts.map +0 -1
  372. package/types/async/hooks.d.ts +0 -5
  373. package/types/async/hooks.d.ts.map +0 -1
  374. package/types/async/index.d.ts +0 -8
  375. package/types/async/index.d.ts.map +0 -1
  376. package/types/client.d.ts +0 -16
  377. package/types/client.d.ts.map +0 -1
  378. package/types/handlers.d.ts +0 -57
  379. package/types/handlers.d.ts.map +0 -1
  380. package/types/integrations/anr/legacy.d.ts +0 -22
  381. package/types/integrations/anr/legacy.d.ts.map +0 -1
  382. package/types/integrations/hapi/index.d.ts +0 -22
  383. package/types/integrations/hapi/index.d.ts.map +0 -1
  384. package/types/integrations/hapi/types.d.ts.map +0 -1
  385. package/types/integrations/index.d.ts +0 -14
  386. package/types/integrations/index.d.ts.map +0 -1
  387. package/types/integrations/local-variables/local-variables-async.d.ts +0 -14
  388. package/types/integrations/local-variables/local-variables-async.d.ts.map +0 -1
  389. package/types/integrations/undici/index.d.ts +0 -58
  390. package/types/integrations/undici/index.d.ts.map +0 -1
  391. package/types/integrations/undici/types.d.ts +0 -224
  392. package/types/integrations/undici/types.d.ts.map +0 -1
  393. package/types/integrations/utils/errorhandling.d.ts.map +0 -1
  394. package/types/integrations/utils/http.d.ts +0 -70
  395. package/types/integrations/utils/http.d.ts.map +0 -1
  396. package/types/module.d.ts.map +0 -1
  397. package/types/requestDataDeprecated.d.ts +0 -45
  398. package/types/requestDataDeprecated.d.ts.map +0 -1
  399. package/types/sdk.d.ts +0 -74
  400. package/types/sdk.d.ts.map +0 -1
  401. package/types/tracing/index.d.ts +0 -6
  402. package/types/tracing/index.d.ts.map +0 -1
  403. package/types/tracing/integrations.d.ts +0 -2
  404. package/types/tracing/integrations.d.ts.map +0 -1
  405. package/types/utils.d.ts +0 -10
  406. package/types/utils.d.ts.map +0 -1
  407. package/types-ts3.8/async/domain.d.ts +0 -5
  408. package/types-ts3.8/async/hooks.d.ts +0 -5
  409. package/types-ts3.8/async/index.d.ts +0 -8
  410. package/types-ts3.8/client.d.ts +0 -16
  411. package/types-ts3.8/handlers.d.ts +0 -57
  412. package/types-ts3.8/integrations/anr/legacy.d.ts +0 -22
  413. package/types-ts3.8/integrations/hapi/index.d.ts +0 -22
  414. package/types-ts3.8/integrations/index.d.ts +0 -14
  415. package/types-ts3.8/integrations/local-variables/local-variables-async.d.ts +0 -14
  416. package/types-ts3.8/integrations/undici/index.d.ts +0 -58
  417. package/types-ts3.8/integrations/undici/types.d.ts +0 -223
  418. package/types-ts3.8/integrations/utils/http.d.ts +0 -80
  419. package/types-ts3.8/requestDataDeprecated.d.ts +0 -45
  420. package/types-ts3.8/sdk.d.ts +0 -74
  421. package/types-ts3.8/tracing/index.d.ts +0 -6
  422. package/types-ts3.8/tracing/integrations.d.ts +0 -2
  423. package/types-ts3.8/utils.d.ts +0 -10
  424. /package/cjs/{module.js → utils/module.js} +0 -0
  425. /package/esm/{module.js → utils/module.js} +0 -0
  426. /package/types/{integrations/utils → utils}/errorhandling.d.ts +0 -0
  427. /package/types/{module.d.ts → utils/module.d.ts} +0 -0
  428. /package/types-ts3.8/{integrations/utils → utils}/errorhandling.d.ts +0 -0
  429. /package/types-ts3.8/{module.d.ts → utils/module.d.ts} +0 -0
@@ -4,385 +4,134 @@ var {
4
4
 
5
5
  Object.defineProperty(exports, '__esModule', { value: true });
6
6
 
7
+ const api = require('@opentelemetry/api');
8
+ const instrumentation = require('@opentelemetry/instrumentation');
9
+ const instrumentationHttp = require('@opentelemetry/instrumentation-http');
7
10
  const core = require('@sentry/core');
8
- const utils = require('@sentry/utils');
9
- const debugBuild = require('../debug-build.js');
10
- const nodeVersion = require('../nodeVersion.js');
11
- const http = require('./utils/http.js');
11
+ const opentelemetry = require('@sentry/opentelemetry');
12
+ const scope = require('../sdk/scope.js');
13
+ const addOriginToSpan = require('../utils/addOriginToSpan.js');
14
+ const getRequestUrl = require('../utils/getRequestUrl.js');
12
15
 
13
16
  const _httpIntegration = ((options = {}) => {
14
- const { breadcrumbs, tracing, shouldCreateSpanForRequest } = options;
15
-
16
- const convertedOptions = {
17
- breadcrumbs,
18
- tracing:
19
- tracing === false
20
- ? false
21
- : utils.dropUndefinedKeys({
22
- // If tracing is forced to `true`, we don't want to set `enableIfHasTracingEnabled`
23
- enableIfHasTracingEnabled: tracing === true ? undefined : true,
24
- shouldCreateSpanForRequest,
25
- }),
26
- };
27
-
28
- // eslint-disable-next-line deprecation/deprecation
29
- return new Http(convertedOptions) ;
30
- }) ;
31
-
32
- /**
33
- * The http module integration instruments Node's internal http module. It creates breadcrumbs, spans for outgoing
34
- * http requests, and attaches trace data when tracing is enabled via its `tracing` option.
35
- *
36
- * By default, this will always create breadcrumbs, and will create spans if tracing is enabled.
37
- */
38
- const httpIntegration = core.defineIntegration(_httpIntegration);
39
-
40
- /**
41
- * The http module integration instruments Node's internal http module. It creates breadcrumbs, transactions for outgoing
42
- * http requests and attaches trace data when tracing is enabled via its `tracing` option.
43
- *
44
- * @deprecated Use `httpIntegration()` instead.
45
- */
46
- class Http {
47
- /**
48
- * @inheritDoc
49
- */
50
- static __initStatic() {this.id = 'Http';}
51
-
52
- /**
53
- * @inheritDoc
54
- */
55
- // eslint-disable-next-line deprecation/deprecation
56
- __init() {this.name = Http.id;}
57
-
58
- /**
59
- * @inheritDoc
60
- */
61
- constructor(options = {}) {Http.prototype.__init.call(this);
62
- this._breadcrumbs = typeof options.breadcrumbs === 'undefined' ? true : options.breadcrumbs;
63
- this._tracing = !options.tracing ? undefined : options.tracing === true ? {} : options.tracing;
64
- }
65
-
66
- /**
67
- * @inheritDoc
68
- */
69
- setupOnce(
70
- _addGlobalEventProcessor,
71
- setupOnceGetCurrentHub,
72
- ) {
73
- // eslint-disable-next-line deprecation/deprecation
74
- const clientOptions = _optionalChain([setupOnceGetCurrentHub, 'call', _ => _(), 'access', _2 => _2.getClient, 'call', _3 => _3(), 'optionalAccess', _4 => _4.getOptions, 'call', _5 => _5()]);
75
-
76
- // If `tracing` is not explicitly set, we default this based on whether or not tracing is enabled.
77
- // But for compatibility, we only do that if `enableIfHasTracingEnabled` is set.
78
- const shouldCreateSpans = _shouldCreateSpans(this._tracing, clientOptions);
79
-
80
- // No need to instrument if we don't want to track anything
81
- if (!this._breadcrumbs && !shouldCreateSpans) {
82
- return;
83
- }
84
-
85
- // Do not auto-instrument for other instrumenter
86
- if (clientOptions && clientOptions.instrumenter !== 'sentry') {
87
- debugBuild.DEBUG_BUILD && utils.logger.log('HTTP Integration is skipped because of instrumenter configuration.');
88
- return;
89
- }
90
-
91
- const shouldCreateSpanForRequest = _getShouldCreateSpanForRequest(shouldCreateSpans, this._tracing, clientOptions);
92
-
93
- // eslint-disable-next-line deprecation/deprecation
94
- const tracePropagationTargets = _optionalChain([clientOptions, 'optionalAccess', _6 => _6.tracePropagationTargets]) || _optionalChain([this, 'access', _7 => _7._tracing, 'optionalAccess', _8 => _8.tracePropagationTargets]);
95
-
96
- // eslint-disable-next-line @typescript-eslint/no-var-requires
97
- const httpModule = require('http');
98
- const wrappedHttpHandlerMaker = _createWrappedRequestMethodFactory(
99
- httpModule,
100
- this._breadcrumbs,
101
- shouldCreateSpanForRequest,
102
- tracePropagationTargets,
103
- );
104
- utils.fill(httpModule, 'get', wrappedHttpHandlerMaker);
105
- utils.fill(httpModule, 'request', wrappedHttpHandlerMaker);
106
-
107
- // NOTE: Prior to Node 9, `https` used internals of `http` module, thus we don't patch it.
108
- // If we do, we'd get double breadcrumbs and double spans for `https` calls.
109
- // It has been changed in Node 9, so for all versions equal and above, we patch `https` separately.
110
- if (nodeVersion.NODE_VERSION.major > 8) {
111
- // eslint-disable-next-line @typescript-eslint/no-var-requires
112
- const httpsModule = require('https');
113
- const wrappedHttpsHandlerMaker = _createWrappedRequestMethodFactory(
114
- httpsModule,
115
- this._breadcrumbs,
116
- shouldCreateSpanForRequest,
117
- tracePropagationTargets,
118
- );
119
- utils.fill(httpsModule, 'get', wrappedHttpsHandlerMaker);
120
- utils.fill(httpsModule, 'request', wrappedHttpsHandlerMaker);
121
- }
122
- }
123
- }Http.__initStatic();
124
-
125
- // for ease of reading below
126
-
127
- /**
128
- * Function which creates a function which creates wrapped versions of internal `request` and `get` calls within `http`
129
- * and `https` modules. (NB: Not a typo - this is a creator^2!)
130
- *
131
- * @param breadcrumbsEnabled Whether or not to record outgoing requests as breadcrumbs
132
- * @param tracingEnabled Whether or not to record outgoing requests as tracing spans
133
- *
134
- * @returns A function which accepts the exiting handler and returns a wrapped handler
135
- */
136
- function _createWrappedRequestMethodFactory(
137
- httpModule,
138
- breadcrumbsEnabled,
139
- shouldCreateSpanForRequest,
140
- tracePropagationTargets,
141
- ) {
142
- // We're caching results so we don't have to recompute regexp every time we create a request.
143
- const createSpanUrlMap = new utils.LRUMap(100);
144
- const headersUrlMap = new utils.LRUMap(100);
145
-
146
- const shouldCreateSpan = (url) => {
147
- if (shouldCreateSpanForRequest === undefined) {
148
- return true;
149
- }
150
-
151
- const cachedDecision = createSpanUrlMap.get(url);
152
- if (cachedDecision !== undefined) {
153
- return cachedDecision;
154
- }
155
-
156
- const decision = shouldCreateSpanForRequest(url);
157
- createSpanUrlMap.set(url, decision);
158
- return decision;
159
- };
160
-
161
- const shouldAttachTraceData = (url) => {
162
- if (tracePropagationTargets === undefined) {
163
- return true;
164
- }
165
-
166
- const cachedDecision = headersUrlMap.get(url);
167
- if (cachedDecision !== undefined) {
168
- return cachedDecision;
169
- }
170
-
171
- const decision = utils.stringMatchesSomePattern(url, tracePropagationTargets);
172
- headersUrlMap.set(url, decision);
173
- return decision;
174
- };
175
-
176
- /**
177
- * Captures Breadcrumb based on provided request/response pair
178
- */
179
- function addRequestBreadcrumb(
180
- event,
181
- requestSpanData,
182
- req,
183
- res,
184
- ) {
185
- // eslint-disable-next-line deprecation/deprecation
186
- if (!core.getCurrentHub().getIntegration(Http)) {
187
- return;
188
- }
189
-
190
- core.addBreadcrumb(
191
- {
192
- category: 'http',
193
- data: {
194
- status_code: res && res.statusCode,
195
- ...requestSpanData,
196
- },
197
- type: 'http',
198
- },
199
- {
200
- event,
201
- request: req,
202
- response: res,
203
- },
204
- );
205
- }
17
+ const _breadcrumbs = typeof options.breadcrumbs === 'undefined' ? true : options.breadcrumbs;
18
+ const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;
19
+ const _ignoreIncomingRequests = options.ignoreIncomingRequests;
20
+
21
+ return {
22
+ name: 'Http',
23
+ setupOnce() {
24
+ const instrumentations = [
25
+ new instrumentationHttp.HttpInstrumentation({
26
+ ignoreOutgoingRequestHook: request => {
27
+ const url = getRequestUrl.getRequestUrl(request);
28
+
29
+ if (!url) {
30
+ return false;
31
+ }
206
32
 
207
- return function wrappedRequestMethodFactory(originalRequestMethod) {
208
- return function wrappedMethod( ...args) {
209
- const requestArgs = http.normalizeRequestArgs(httpModule, args);
210
- const requestOptions = requestArgs[0];
211
- // eslint-disable-next-line deprecation/deprecation
212
- const rawRequestUrl = http.extractRawUrl(requestOptions);
213
- const requestUrl = http.extractUrl(requestOptions);
214
- const client = core.getClient();
33
+ if (core.isSentryRequestUrl(url, opentelemetry.getClient())) {
34
+ return true;
35
+ }
215
36
 
216
- // we don't want to record requests to Sentry as either breadcrumbs or spans, so just use the original method
217
- if (core.isSentryRequestUrl(requestUrl, client)) {
218
- return originalRequestMethod.apply(httpModule, requestArgs);
219
- }
37
+ if (_ignoreOutgoingRequests && _ignoreOutgoingRequests(url)) {
38
+ return true;
39
+ }
220
40
 
221
- const scope = core.getCurrentScope();
222
- const isolationScope = core.getIsolationScope();
223
- const parentSpan = core.getActiveSpan();
41
+ return false;
42
+ },
224
43
 
225
- const data = getRequestSpanData(requestUrl, requestOptions);
44
+ ignoreIncomingRequestHook: request => {
45
+ const url = getRequestUrl.getRequestUrl(request);
226
46
 
227
- const requestSpan = shouldCreateSpan(rawRequestUrl)
228
- ? // eslint-disable-next-line deprecation/deprecation
229
- _optionalChain([parentSpan, 'optionalAccess', _9 => _9.startChild, 'call', _10 => _10({
230
- op: 'http.client',
231
- origin: 'auto.http.node.http',
232
- description: `${data['http.method']} ${data.url}`,
233
- data,
234
- })])
235
- : undefined;
47
+ const method = _optionalChain([request, 'access', _ => _.method, 'optionalAccess', _2 => _2.toUpperCase, 'call', _3 => _3()]);
48
+ // We do not capture OPTIONS/HEAD requests as transactions
49
+ if (method === 'OPTIONS' || method === 'HEAD') {
50
+ return true;
51
+ }
236
52
 
237
- if (client && shouldAttachTraceData(rawRequestUrl)) {
238
- const { traceId, spanId, sampled, dsc } = {
239
- ...isolationScope.getPropagationContext(),
240
- ...scope.getPropagationContext(),
241
- };
53
+ if (_ignoreIncomingRequests && _ignoreIncomingRequests(url)) {
54
+ return true;
55
+ }
242
56
 
243
- const sentryTraceHeader = requestSpan
244
- ? core.spanToTraceHeader(requestSpan)
245
- : utils.generateSentryTraceHeader(traceId, spanId, sampled);
57
+ return false;
58
+ },
246
59
 
247
- const sentryBaggageHeader = utils.dynamicSamplingContextToSentryBaggageHeader(
248
- dsc ||
249
- (requestSpan
250
- ? core.getDynamicSamplingContextFromSpan(requestSpan)
251
- : core.getDynamicSamplingContextFromClient(traceId, client, scope)),
252
- );
60
+ requireParentforOutgoingSpans: true,
61
+ requireParentforIncomingSpans: false,
62
+ requestHook: (span, req) => {
63
+ _updateSpan(span, req);
253
64
 
254
- addHeadersToRequestOptions(requestOptions, requestUrl, sentryTraceHeader, sentryBaggageHeader);
255
- } else {
256
- debugBuild.DEBUG_BUILD &&
257
- utils.logger.log(
258
- `[Tracing] Not adding sentry-trace header to outgoing request (${requestUrl}) due to mismatching tracePropagationTargets option.`,
259
- );
260
- }
65
+ // Update the isolation scope, isolate this request
66
+ if (opentelemetry.getSpanKind(span) === api.SpanKind.SERVER) {
67
+ const isolationScope = core.getIsolationScope().clone();
68
+ isolationScope.setSDKProcessingMetadata({ request: req });
261
69
 
262
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
263
- return originalRequestMethod
264
- .apply(httpModule, requestArgs)
265
- .once('response', function ( res) {
266
- // eslint-disable-next-line @typescript-eslint/no-this-alias
267
- const req = this;
268
- if (breadcrumbsEnabled) {
269
- addRequestBreadcrumb('response', data, req, res);
270
- }
271
- if (requestSpan) {
272
- if (res.statusCode) {
273
- core.setHttpStatus(requestSpan, res.statusCode);
70
+ const client = opentelemetry.getClient();
71
+ if (client && client.getOptions().autoSessionTracking) {
72
+ isolationScope.setRequestSession({ status: 'ok' });
73
+ }
74
+ scope.setIsolationScope(isolationScope);
75
+ }
76
+ },
77
+ responseHook: (span, res) => {
78
+ if (_breadcrumbs) {
79
+ _addRequestBreadcrumb(span, res);
274
80
  }
275
- requestSpan.updateName(
276
- http.cleanSpanDescription(core.spanToJSON(requestSpan).description || '', requestOptions, req) || '',
277
- );
278
- requestSpan.end();
279
- }
280
- })
281
- .once('error', function () {
282
- // eslint-disable-next-line @typescript-eslint/no-this-alias
283
- const req = this;
284
81
 
285
- if (breadcrumbsEnabled) {
286
- addRequestBreadcrumb('error', data, req);
287
- }
288
- if (requestSpan) {
289
- core.setHttpStatus(requestSpan, 500);
290
- requestSpan.updateName(
291
- http.cleanSpanDescription(core.spanToJSON(requestSpan).description || '', requestOptions, req) || '',
292
- );
293
- requestSpan.end();
294
- }
295
- });
296
- };
82
+ const client = opentelemetry.getClient();
83
+ if (client && client.getOptions().autoSessionTracking) {
84
+ setImmediate(() => {
85
+ client['_captureRequestSession']();
86
+ });
87
+ }
88
+ },
89
+ }),
90
+ ];
91
+
92
+ instrumentation.registerInstrumentations({
93
+ instrumentations,
94
+ });
95
+ },
297
96
  };
298
- }
299
-
300
- function addHeadersToRequestOptions(
301
- requestOptions,
302
- requestUrl,
303
- sentryTraceHeader,
304
- sentryBaggageHeader,
305
- ) {
306
- // Don't overwrite sentry-trace and baggage header if it's already set.
307
- const headers = requestOptions.headers || {};
308
- if (headers['sentry-trace']) {
309
- return;
310
- }
97
+ }) ;
311
98
 
312
- debugBuild.DEBUG_BUILD &&
313
- utils.logger.log(`[Tracing] Adding sentry-trace header ${sentryTraceHeader} to outgoing request to "${requestUrl}": `);
99
+ const httpIntegration = core.defineIntegration(_httpIntegration);
314
100
 
315
- requestOptions.headers = {
316
- ...requestOptions.headers,
317
- 'sentry-trace': sentryTraceHeader,
318
- // Setting a header to `undefined` will crash in node so we only set the baggage header when it's defined
319
- ...(sentryBaggageHeader &&
320
- sentryBaggageHeader.length > 0 && { baggage: normalizeBaggageHeader(requestOptions, sentryBaggageHeader) }),
321
- };
322
- }
101
+ /** Update the span with data we need. */
102
+ function _updateSpan(span, request) {
103
+ addOriginToSpan.addOriginToSpan(span, 'auto.http.otel.http');
323
104
 
324
- function getRequestSpanData(requestUrl, requestOptions) {
325
- const method = requestOptions.method || 'GET';
326
- const data = {
327
- url: requestUrl,
328
- 'http.method': method,
329
- };
330
- if (requestOptions.hash) {
331
- // strip leading "#"
332
- data['http.fragment'] = requestOptions.hash.substring(1);
105
+ if (opentelemetry.getSpanKind(span) === api.SpanKind.SERVER) {
106
+ opentelemetry.setSpanMetadata(span, { request: request });
333
107
  }
334
- if (requestOptions.search) {
335
- // strip leading "?"
336
- data['http.query'] = requestOptions.search.substring(1);
337
- }
338
- return data;
339
108
  }
340
109
 
341
- function normalizeBaggageHeader(
342
- requestOptions,
343
- sentryBaggageHeader,
344
- ) {
345
- if (!requestOptions.headers || !requestOptions.headers.baggage) {
346
- return sentryBaggageHeader;
347
- } else if (!sentryBaggageHeader) {
348
- return requestOptions.headers.baggage ;
349
- } else if (Array.isArray(requestOptions.headers.baggage)) {
350
- return [...requestOptions.headers.baggage, sentryBaggageHeader];
110
+ /** Add a breadcrumb for outgoing requests. */
111
+ function _addRequestBreadcrumb(span, response) {
112
+ if (opentelemetry.getSpanKind(span) !== api.SpanKind.CLIENT) {
113
+ return;
351
114
  }
352
- // Type-cast explanation:
353
- // Technically this the following could be of type `(number | string)[]` but for the sake of simplicity
354
- // we say this is undefined behaviour, since it would not be baggage spec conform if the user did this.
355
- return [requestOptions.headers.baggage, sentryBaggageHeader] ;
356
- }
357
115
 
358
- /** Exported for tests only. */
359
- function _shouldCreateSpans(
360
- tracingOptions,
361
- clientOptions,
362
- ) {
363
- return tracingOptions === undefined
364
- ? false
365
- : tracingOptions.enableIfHasTracingEnabled
366
- ? core.hasTracingEnabled(clientOptions)
367
- : true;
368
- }
369
-
370
- /** Exported for tests only. */
371
- function _getShouldCreateSpanForRequest(
372
- shouldCreateSpans,
373
- tracingOptions,
374
- clientOptions,
375
- ) {
376
- const handler = shouldCreateSpans
377
- ? // eslint-disable-next-line deprecation/deprecation
378
- _optionalChain([tracingOptions, 'optionalAccess', _11 => _11.shouldCreateSpanForRequest]) || _optionalChain([clientOptions, 'optionalAccess', _12 => _12.shouldCreateSpanForRequest])
379
- : () => false;
380
-
381
- return handler;
116
+ const data = opentelemetry._INTERNAL.getRequestSpanData(span);
117
+ core.addBreadcrumb(
118
+ {
119
+ category: 'http',
120
+ data: {
121
+ status_code: response.statusCode,
122
+ ...data,
123
+ },
124
+ type: 'http',
125
+ },
126
+ {
127
+ event: 'response',
128
+ // TODO FN: Do we need access to `request` here?
129
+ // If we do, we'll have to use the `applyCustomAttributesOnSpan` hook instead,
130
+ // but this has worse context semantics than request/responseHook.
131
+ response,
132
+ },
133
+ );
382
134
  }
383
135
 
384
- exports.Http = Http;
385
- exports._getShouldCreateSpanForRequest = _getShouldCreateSpanForRequest;
386
- exports._shouldCreateSpans = _shouldCreateSpans;
387
136
  exports.httpIntegration = httpIntegration;
388
137
  //# sourceMappingURL=http.js.map