@sentry/node 8.54.0 → 9.0.0-alpha.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 (282) hide show
  1. package/build/cjs/cron/common.js +1 -1
  2. package/build/cjs/cron/cron.js +1 -1
  3. package/build/cjs/cron/index.js +1 -1
  4. package/build/cjs/cron/node-cron.js +10 -11
  5. package/build/cjs/cron/node-cron.js.map +1 -1
  6. package/build/cjs/cron/node-schedule.js +2 -6
  7. package/build/cjs/cron/node-schedule.js.map +1 -1
  8. package/build/cjs/debug-build.js +1 -1
  9. package/build/cjs/index.js +3 -15
  10. package/build/cjs/index.js.map +1 -1
  11. package/build/cjs/integrations/anr/index.js +8 -13
  12. package/build/cjs/integrations/anr/index.js.map +1 -1
  13. package/build/cjs/integrations/childProcess.js +19 -24
  14. package/build/cjs/integrations/childProcess.js.map +1 -1
  15. package/build/cjs/integrations/console.js +1 -1
  16. package/build/cjs/integrations/context.js +16 -19
  17. package/build/cjs/integrations/context.js.map +1 -1
  18. package/build/cjs/integrations/contextlines.js +6 -10
  19. package/build/cjs/integrations/contextlines.js.map +1 -1
  20. package/build/cjs/integrations/fs.js +1 -1
  21. package/build/cjs/integrations/http/SentryHttpInstrumentation.js +99 -19
  22. package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -1
  23. package/build/cjs/integrations/http/index.js +32 -46
  24. package/build/cjs/integrations/http/index.js.map +1 -1
  25. package/build/cjs/integrations/http/vendor/getRequestInfo.js +1 -1
  26. package/build/cjs/integrations/http/vendor/getRequestInfo.js.map +1 -1
  27. package/build/cjs/integrations/local-variables/common.js +1 -1
  28. package/build/cjs/integrations/local-variables/index.js +1 -1
  29. package/build/cjs/integrations/local-variables/local-variables-async.js +4 -8
  30. package/build/cjs/integrations/local-variables/local-variables-async.js.map +1 -1
  31. package/build/cjs/integrations/local-variables/local-variables-sync.js +18 -22
  32. package/build/cjs/integrations/local-variables/local-variables-sync.js.map +1 -1
  33. package/build/cjs/integrations/modules.js +2 -2
  34. package/build/cjs/integrations/modules.js.map +1 -1
  35. package/build/cjs/integrations/node-fetch.js +3 -7
  36. package/build/cjs/integrations/node-fetch.js.map +1 -1
  37. package/build/cjs/integrations/onuncaughtexception.js +1 -1
  38. package/build/cjs/integrations/onunhandledrejection.js +1 -1
  39. package/build/cjs/integrations/processSession.js +36 -0
  40. package/build/cjs/integrations/processSession.js.map +1 -0
  41. package/build/cjs/integrations/spotlight.js +2 -2
  42. package/build/cjs/integrations/spotlight.js.map +1 -1
  43. package/build/cjs/integrations/tracing/amqplib.js +1 -1
  44. package/build/cjs/integrations/tracing/connect.js +2 -2
  45. package/build/cjs/integrations/tracing/connect.js.map +1 -1
  46. package/build/cjs/integrations/tracing/dataloader.js +2 -6
  47. package/build/cjs/integrations/tracing/dataloader.js.map +1 -1
  48. package/build/cjs/integrations/tracing/express.js +4 -31
  49. package/build/cjs/integrations/tracing/express.js.map +1 -1
  50. package/build/cjs/integrations/tracing/fastify.js +3 -7
  51. package/build/cjs/integrations/tracing/fastify.js.map +1 -1
  52. package/build/cjs/integrations/tracing/genericPool.js +1 -1
  53. package/build/cjs/integrations/tracing/graphql.js +5 -5
  54. package/build/cjs/integrations/tracing/graphql.js.map +1 -1
  55. package/build/cjs/integrations/tracing/hapi/index.js +5 -9
  56. package/build/cjs/integrations/tracing/hapi/index.js.map +1 -1
  57. package/build/cjs/integrations/tracing/index.js +1 -6
  58. package/build/cjs/integrations/tracing/index.js.map +1 -1
  59. package/build/cjs/integrations/tracing/kafka.js +1 -1
  60. package/build/cjs/integrations/tracing/knex.js +2 -2
  61. package/build/cjs/integrations/tracing/knex.js.map +1 -1
  62. package/build/cjs/integrations/tracing/koa.js +4 -8
  63. package/build/cjs/integrations/tracing/koa.js.map +1 -1
  64. package/build/cjs/integrations/tracing/lrumemoizer.js +1 -1
  65. package/build/cjs/integrations/tracing/mongo.js +1 -1
  66. package/build/cjs/integrations/tracing/mongoose.js +1 -1
  67. package/build/cjs/integrations/tracing/mysql.js +1 -1
  68. package/build/cjs/integrations/tracing/mysql2.js +1 -1
  69. package/build/cjs/integrations/tracing/postgres.js +1 -1
  70. package/build/cjs/integrations/tracing/prisma.js +21 -67
  71. package/build/cjs/integrations/tracing/prisma.js.map +1 -1
  72. package/build/cjs/integrations/tracing/redis.js +4 -8
  73. package/build/cjs/integrations/tracing/redis.js.map +1 -1
  74. package/build/cjs/integrations/tracing/tedious.js +3 -7
  75. package/build/cjs/integrations/tracing/tedious.js.map +1 -1
  76. package/build/cjs/integrations/tracing/vercelai/index.js +14 -20
  77. package/build/cjs/integrations/tracing/vercelai/index.js.map +1 -1
  78. package/build/cjs/integrations/tracing/vercelai/instrumentation.js +1 -1
  79. package/build/cjs/nodeVersion.js +1 -1
  80. package/build/cjs/otel/contextManager.js +2 -2
  81. package/build/cjs/otel/contextManager.js.map +1 -1
  82. package/build/cjs/otel/instrument.js +1 -1
  83. package/build/cjs/proxy/base.js +30 -33
  84. package/build/cjs/proxy/base.js.map +1 -1
  85. package/build/cjs/proxy/index.js +3 -8
  86. package/build/cjs/proxy/index.js.map +1 -1
  87. package/build/cjs/proxy/parse-proxy-response.js +2 -2
  88. package/build/cjs/proxy/parse-proxy-response.js.map +1 -1
  89. package/build/cjs/sdk/api.js +2 -2
  90. package/build/cjs/sdk/api.js.map +1 -1
  91. package/build/cjs/sdk/client.js +3 -8
  92. package/build/cjs/sdk/client.js.map +1 -1
  93. package/build/cjs/sdk/index.js +5 -58
  94. package/build/cjs/sdk/index.js.map +1 -1
  95. package/build/cjs/sdk/initOtel.js +8 -22
  96. package/build/cjs/sdk/initOtel.js.map +1 -1
  97. package/build/cjs/transports/http.js +10 -16
  98. package/build/cjs/transports/http.js.map +1 -1
  99. package/build/cjs/utils/addOriginToSpan.js +1 -1
  100. package/build/cjs/utils/commonjs.js +1 -1
  101. package/build/cjs/utils/createMissingInstrumentationContext.js +1 -1
  102. package/build/cjs/utils/debug.js +1 -1
  103. package/build/cjs/utils/ensureIsWrapped.js +2 -6
  104. package/build/cjs/utils/ensureIsWrapped.js.map +1 -1
  105. package/build/cjs/utils/envToBool.js +2 -2
  106. package/build/cjs/utils/envToBool.js.map +1 -1
  107. package/build/cjs/utils/errorhandling.js +2 -3
  108. package/build/cjs/utils/errorhandling.js.map +1 -1
  109. package/build/cjs/utils/getRequestUrl.js +1 -1
  110. package/build/cjs/utils/module.js +1 -1
  111. package/build/cjs/utils/module.js.map +1 -1
  112. package/build/cjs/utils/redisCache.js +1 -4
  113. package/build/cjs/utils/redisCache.js.map +1 -1
  114. package/build/esm/cron/node-cron.js +9 -7
  115. package/build/esm/cron/node-cron.js.map +1 -1
  116. package/build/esm/cron/node-schedule.js +1 -2
  117. package/build/esm/cron/node-schedule.js.map +1 -1
  118. package/build/esm/index.js +3 -4
  119. package/build/esm/index.js.map +1 -1
  120. package/build/esm/integrations/anr/index.js +8 -9
  121. package/build/esm/integrations/anr/index.js.map +1 -1
  122. package/build/esm/integrations/anr/worker-script.js +2 -2
  123. package/build/esm/integrations/childProcess.js +20 -24
  124. package/build/esm/integrations/childProcess.js.map +1 -1
  125. package/build/esm/integrations/context.js +15 -15
  126. package/build/esm/integrations/context.js.map +1 -1
  127. package/build/esm/integrations/contextlines.js +5 -6
  128. package/build/esm/integrations/contextlines.js.map +1 -1
  129. package/build/esm/integrations/http/SentryHttpInstrumentation.js +99 -20
  130. package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -1
  131. package/build/esm/integrations/http/index.js +32 -43
  132. package/build/esm/integrations/http/index.js.map +1 -1
  133. package/build/esm/integrations/http/vendor/getRequestInfo.js.map +1 -1
  134. package/build/esm/integrations/local-variables/local-variables-async.js +3 -4
  135. package/build/esm/integrations/local-variables/local-variables-async.js.map +1 -1
  136. package/build/esm/integrations/local-variables/local-variables-sync.js +17 -18
  137. package/build/esm/integrations/local-variables/local-variables-sync.js.map +1 -1
  138. package/build/esm/integrations/local-variables/worker-script.js +2 -2
  139. package/build/esm/integrations/modules.js +1 -1
  140. package/build/esm/integrations/modules.js.map +1 -1
  141. package/build/esm/integrations/node-fetch.js +3 -4
  142. package/build/esm/integrations/node-fetch.js.map +1 -1
  143. package/build/esm/integrations/processSession.js +34 -0
  144. package/build/esm/integrations/processSession.js.map +1 -0
  145. package/build/esm/integrations/spotlight.js +1 -1
  146. package/build/esm/integrations/spotlight.js.map +1 -1
  147. package/build/esm/integrations/tracing/connect.js +1 -1
  148. package/build/esm/integrations/tracing/connect.js.map +1 -1
  149. package/build/esm/integrations/tracing/dataloader.js +1 -2
  150. package/build/esm/integrations/tracing/dataloader.js.map +1 -1
  151. package/build/esm/integrations/tracing/express.js +4 -28
  152. package/build/esm/integrations/tracing/express.js.map +1 -1
  153. package/build/esm/integrations/tracing/fastify.js +2 -3
  154. package/build/esm/integrations/tracing/fastify.js.map +1 -1
  155. package/build/esm/integrations/tracing/graphql.js +4 -4
  156. package/build/esm/integrations/tracing/graphql.js.map +1 -1
  157. package/build/esm/integrations/tracing/hapi/index.js +4 -5
  158. package/build/esm/integrations/tracing/hapi/index.js.map +1 -1
  159. package/build/esm/integrations/tracing/index.js +0 -5
  160. package/build/esm/integrations/tracing/index.js.map +1 -1
  161. package/build/esm/integrations/tracing/knex.js +1 -1
  162. package/build/esm/integrations/tracing/knex.js.map +1 -1
  163. package/build/esm/integrations/tracing/koa.js +3 -4
  164. package/build/esm/integrations/tracing/koa.js.map +1 -1
  165. package/build/esm/integrations/tracing/prisma.js +21 -64
  166. package/build/esm/integrations/tracing/prisma.js.map +1 -1
  167. package/build/esm/integrations/tracing/redis.js +4 -5
  168. package/build/esm/integrations/tracing/redis.js.map +1 -1
  169. package/build/esm/integrations/tracing/tedious.js +2 -3
  170. package/build/esm/integrations/tracing/tedious.js.map +1 -1
  171. package/build/esm/integrations/tracing/vercelai/index.js +13 -16
  172. package/build/esm/integrations/tracing/vercelai/index.js.map +1 -1
  173. package/build/esm/otel/contextManager.js +1 -1
  174. package/build/esm/otel/contextManager.js.map +1 -1
  175. package/build/esm/package.json +1 -1
  176. package/build/esm/proxy/base.js +29 -29
  177. package/build/esm/proxy/base.js.map +1 -1
  178. package/build/esm/proxy/index.js +2 -3
  179. package/build/esm/proxy/index.js.map +1 -1
  180. package/build/esm/proxy/parse-proxy-response.js +1 -1
  181. package/build/esm/proxy/parse-proxy-response.js.map +1 -1
  182. package/build/esm/sdk/api.js +1 -1
  183. package/build/esm/sdk/api.js.map +1 -1
  184. package/build/esm/sdk/client.js +2 -3
  185. package/build/esm/sdk/client.js.map +1 -1
  186. package/build/esm/sdk/index.js +5 -58
  187. package/build/esm/sdk/index.js.map +1 -1
  188. package/build/esm/sdk/initOtel.js +7 -18
  189. package/build/esm/sdk/initOtel.js.map +1 -1
  190. package/build/esm/transports/http.js +9 -12
  191. package/build/esm/transports/http.js.map +1 -1
  192. package/build/esm/utils/ensureIsWrapped.js +1 -2
  193. package/build/esm/utils/ensureIsWrapped.js.map +1 -1
  194. package/build/esm/utils/envToBool.js +1 -1
  195. package/build/esm/utils/envToBool.js.map +1 -1
  196. package/build/esm/utils/errorhandling.js +1 -2
  197. package/build/esm/utils/errorhandling.js.map +1 -1
  198. package/build/esm/utils/module.js.map +1 -1
  199. package/build/esm/utils/redisCache.js +0 -3
  200. package/build/esm/utils/redisCache.js.map +1 -1
  201. package/build/types/cron/node-cron.d.ts +1 -1
  202. package/build/types/cron/node-cron.d.ts.map +1 -1
  203. package/build/types/index.d.ts +4 -6
  204. package/build/types/index.d.ts.map +1 -1
  205. package/build/types/integrations/childProcess.d.ts +7 -7
  206. package/build/types/integrations/childProcess.d.ts.map +1 -1
  207. package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +30 -0
  208. package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
  209. package/build/types/integrations/http/index.d.ts +11 -8
  210. package/build/types/integrations/http/index.d.ts.map +1 -1
  211. package/build/types/integrations/processSession.d.ts +5 -0
  212. package/build/types/integrations/processSession.d.ts.map +1 -0
  213. package/build/types/integrations/tracing/express.d.ts.map +1 -1
  214. package/build/types/integrations/tracing/hapi/types.d.ts +1 -0
  215. package/build/types/integrations/tracing/hapi/types.d.ts.map +1 -1
  216. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  217. package/build/types/integrations/tracing/prisma.d.ts +11 -12
  218. package/build/types/integrations/tracing/prisma.d.ts.map +1 -1
  219. package/build/types/integrations/tracing/vercelai/index.d.ts.map +1 -1
  220. package/build/types/otel/contextManager.d.ts +1 -1
  221. package/build/types/proxy/helpers.d.ts +1 -0
  222. package/build/types/proxy/helpers.d.ts.map +1 -1
  223. package/build/types/proxy/parse-proxy-response.d.ts +1 -0
  224. package/build/types/proxy/parse-proxy-response.d.ts.map +1 -1
  225. package/build/types/sdk/index.d.ts.map +1 -1
  226. package/build/types/sdk/initOtel.d.ts +1 -3
  227. package/build/types/sdk/initOtel.d.ts.map +1 -1
  228. package/build/types/transports/http-module.d.ts +1 -0
  229. package/build/types/transports/http-module.d.ts.map +1 -1
  230. package/build/types/transports/http.d.ts +1 -0
  231. package/build/types/transports/http.d.ts.map +1 -1
  232. package/build/types/types.d.ts +2 -48
  233. package/build/types/types.d.ts.map +1 -1
  234. package/build/types/utils/errorhandling.d.ts.map +1 -1
  235. package/build/types-ts3.8/cron/node-cron.d.ts +1 -1
  236. package/build/types-ts3.8/index.d.ts +4 -6
  237. package/build/types-ts3.8/integrations/childProcess.d.ts +7 -7
  238. package/build/types-ts3.8/integrations/http/SentryHttpInstrumentation.d.ts +29 -0
  239. package/build/types-ts3.8/integrations/http/index.d.ts +11 -8
  240. package/build/types-ts3.8/integrations/processSession.d.ts +5 -0
  241. package/build/types-ts3.8/integrations/tracing/prisma.d.ts +11 -12
  242. package/build/types-ts3.8/otel/contextManager.d.ts +1 -1
  243. package/build/types-ts3.8/sdk/initOtel.d.ts +1 -3
  244. package/build/types-ts3.8/types.d.ts +2 -48
  245. package/package.json +8 -9
  246. package/build/cjs/integrations/tracing/nest/helpers.js +0 -100
  247. package/build/cjs/integrations/tracing/nest/helpers.js.map +0 -1
  248. package/build/cjs/integrations/tracing/nest/nest.js +0 -148
  249. package/build/cjs/integrations/tracing/nest/nest.js.map +0 -1
  250. package/build/cjs/integrations/tracing/nest/sentry-nest-event-instrumentation.js +0 -117
  251. package/build/cjs/integrations/tracing/nest/sentry-nest-event-instrumentation.js.map +0 -1
  252. package/build/cjs/integrations/tracing/nest/sentry-nest-instrumentation.js +0 -301
  253. package/build/cjs/integrations/tracing/nest/sentry-nest-instrumentation.js.map +0 -1
  254. package/build/esm/integrations/tracing/nest/helpers.js +0 -91
  255. package/build/esm/integrations/tracing/nest/helpers.js.map +0 -1
  256. package/build/esm/integrations/tracing/nest/nest.js +0 -141
  257. package/build/esm/integrations/tracing/nest/nest.js.map +0 -1
  258. package/build/esm/integrations/tracing/nest/sentry-nest-event-instrumentation.js +0 -115
  259. package/build/esm/integrations/tracing/nest/sentry-nest-event-instrumentation.js.map +0 -1
  260. package/build/esm/integrations/tracing/nest/sentry-nest-instrumentation.js +0 -295
  261. package/build/esm/integrations/tracing/nest/sentry-nest-instrumentation.js.map +0 -1
  262. package/build/types/integrations/tracing/nest/helpers.d.ts +0 -36
  263. package/build/types/integrations/tracing/nest/helpers.d.ts.map +0 -1
  264. package/build/types/integrations/tracing/nest/nest.d.ts +0 -19
  265. package/build/types/integrations/tracing/nest/nest.d.ts.map +0 -1
  266. package/build/types/integrations/tracing/nest/sentry-nest-event-instrumentation.d.ts +0 -27
  267. package/build/types/integrations/tracing/nest/sentry-nest-event-instrumentation.d.ts.map +0 -1
  268. package/build/types/integrations/tracing/nest/sentry-nest-instrumentation.d.ts +0 -37
  269. package/build/types/integrations/tracing/nest/sentry-nest-instrumentation.d.ts.map +0 -1
  270. package/build/types/integrations/tracing/nest/types.d.ts +0 -84
  271. package/build/types/integrations/tracing/nest/types.d.ts.map +0 -1
  272. package/build/types/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts +0 -38
  273. package/build/types/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts.map +0 -1
  274. package/build/types/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts +0 -31
  275. package/build/types/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts.map +0 -1
  276. package/build/types-ts3.8/integrations/tracing/nest/helpers.d.ts +0 -36
  277. package/build/types-ts3.8/integrations/tracing/nest/nest.d.ts +0 -19
  278. package/build/types-ts3.8/integrations/tracing/nest/sentry-nest-event-instrumentation.d.ts +0 -27
  279. package/build/types-ts3.8/integrations/tracing/nest/sentry-nest-instrumentation.d.ts +0 -37
  280. package/build/types-ts3.8/integrations/tracing/nest/types.d.ts +0 -84
  281. package/build/types-ts3.8/integrations/tracing/prisma/vendor/v5-tracing-helper.d.ts +0 -44
  282. package/build/types-ts3.8/integrations/tracing/prisma/vendor/v6-tracing-helper.d.ts +0 -34
@@ -1,6 +1,6 @@
1
1
  import { VERSION } from '@opentelemetry/core';
2
2
  import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
3
- import { getIsolationScope, httpRequestToRequestData, getClient, stripUrlQueryAndFragment, withIsolationScope, getBreadcrumbLogLevelFromHttpStatusCode, addBreadcrumb, parseUrl, getSanitizedUrlString, logger } from '@sentry/core';
3
+ import { getIsolationScope, httpRequestToRequestData, stripUrlQueryAndFragment, withIsolationScope, withScope, generateSpanId, getBreadcrumbLogLevelFromHttpStatusCode, addBreadcrumb, parseUrl, getSanitizedUrlString, logger, getClient } from '@sentry/core';
4
4
  import { DEBUG_BUILD } from '../../debug-build.js';
5
5
  import { getRequestUrl } from '../../utils/getRequestUrl.js';
6
6
  import { getRequestInfo } from './vendor/getRequestInfo.js';
@@ -95,24 +95,17 @@ class SentryHttpInstrumentation extends InstrumentationBase {
95
95
 
96
96
  const isolationScope = getIsolationScope().clone();
97
97
  const request = args[0] ;
98
+ const response = args[1] ;
98
99
 
99
100
  const normalizedRequest = httpRequestToRequestData(request);
100
101
 
102
+ // request.ip is non-standard but some frameworks set this
103
+ const ipAddress = (request ).ip || request.socket?.remoteAddress;
104
+
101
105
  patchRequestToCaptureBody(request, isolationScope);
102
106
 
103
107
  // Update the isolation scope, isolate this request
104
- // TODO(v9): Stop setting `request`, we only rely on normalizedRequest anymore
105
- isolationScope.setSDKProcessingMetadata({
106
- request,
107
- normalizedRequest,
108
- });
109
-
110
- const client = getClient();
111
- // eslint-disable-next-line deprecation/deprecation
112
- if (client && client.getOptions().autoSessionTracking) {
113
- // eslint-disable-next-line deprecation/deprecation
114
- isolationScope.setRequestSession({ status: 'ok' });
115
- }
108
+ isolationScope.setSDKProcessingMetadata({ normalizedRequest, ipAddress });
116
109
 
117
110
  // attempt to update the scope's `transactionName` based on the request URL
118
111
  // Ideally, framework instrumentations coming after the HttpInstrumentation
@@ -124,8 +117,20 @@ class SentryHttpInstrumentation extends InstrumentationBase {
124
117
 
125
118
  isolationScope.setTransactionName(bestEffortTransactionName);
126
119
 
120
+ if (instrumentation.getConfig().trackIncomingRequestsAsSessions !== false) {
121
+ recordRequestSession({
122
+ requestIsolationScope: isolationScope,
123
+ response,
124
+ sessionFlushingDelayMS: instrumentation.getConfig().sessionFlushingDelayMS ?? 60000,
125
+ });
126
+ }
127
+
127
128
  return withIsolationScope(isolationScope, () => {
128
- return original.apply(this, [event, ...args]);
129
+ return withScope(scope => {
130
+ // Set a new propagationSpanId for this request
131
+ scope.getPropagationContext().propagationSpanId = generateSpanId();
132
+ return original.apply(this, [event, ...args]);
133
+ });
129
134
  });
130
135
  };
131
136
  };
@@ -289,7 +294,7 @@ function getBreadcrumbData(request) {
289
294
  }
290
295
 
291
296
  return data;
292
- } catch (e) {
297
+ } catch {
293
298
  return {};
294
299
  }
295
300
  }
@@ -323,8 +328,8 @@ function patchRequestToCaptureBody(req, isolationScope) {
323
328
  if (event === 'data') {
324
329
  const callback = new Proxy(listener, {
325
330
  apply: (target, thisArg, args) => {
326
- // If we have already read more than the max body length, we stop addiing chunks
327
- // To avoid growing the memory indefinitely if a respons is e.g. streamed
331
+ // If we have already read more than the max body length, we stop adding chunks
332
+ // To avoid growing the memory indefinitely if a response is e.g. streamed
328
333
  if (getChunksSize() < MAX_BODY_BYTE_LENGTH) {
329
334
  const chunk = args[0] ;
330
335
  chunks.push(chunk);
@@ -353,7 +358,7 @@ function patchRequestToCaptureBody(req, isolationScope) {
353
358
  const normalizedRequest = { data: body } ;
354
359
  isolationScope.setSDKProcessingMetadata({ normalizedRequest });
355
360
  }
356
- } catch (e2) {
361
+ } catch {
357
362
  // ignore errors here
358
363
  }
359
364
 
@@ -388,10 +393,84 @@ function patchRequestToCaptureBody(req, isolationScope) {
388
393
  return Reflect.apply(target, thisArg, args);
389
394
  },
390
395
  });
391
- } catch (e3) {
396
+ } catch {
392
397
  // ignore errors if we can't patch stuff
393
398
  }
394
399
  }
395
400
 
396
- export { SentryHttpInstrumentation };
401
+ /**
402
+ * Starts a session and tracks it in the context of a given isolation scope.
403
+ * When the passed response is finished, the session is put into a task and is
404
+ * aggregated with other sessions that may happen in a certain time window
405
+ * (sessionFlushingDelayMs).
406
+ *
407
+ * The sessions are always aggregated by the client that is on the current scope
408
+ * at the time of ending the response (if there is one).
409
+ */
410
+ // Exported for unit tests
411
+ function recordRequestSession({
412
+ requestIsolationScope,
413
+ response,
414
+ sessionFlushingDelayMS,
415
+ }) {
416
+ requestIsolationScope.setSDKProcessingMetadata({
417
+ requestSession: { status: 'ok' },
418
+ });
419
+ response.once('close', () => {
420
+ // We need to grab the client off the current scope instead of the isolation scope because the isolation scope doesn't hold any client out of the box.
421
+ const client = getClient();
422
+ const requestSession = requestIsolationScope.getScopeData().sdkProcessingMetadata.requestSession;
423
+
424
+ if (client && requestSession) {
425
+ DEBUG_BUILD && logger.debug(`Recorded request session with status: ${requestSession.status}`);
426
+
427
+ const roundedDate = new Date();
428
+ roundedDate.setSeconds(0, 0);
429
+ const dateBucketKey = roundedDate.toISOString();
430
+
431
+ const existingClientAggregate = clientToRequestSessionAggregatesMap.get(client);
432
+ const bucket = existingClientAggregate?.[dateBucketKey] || { exited: 0, crashed: 0, errored: 0 };
433
+ bucket[({ ok: 'exited', crashed: 'crashed', errored: 'errored' } )[requestSession.status]]++;
434
+
435
+ if (existingClientAggregate) {
436
+ existingClientAggregate[dateBucketKey] = bucket;
437
+ } else {
438
+ DEBUG_BUILD && logger.debug('Opened new request session aggregate.');
439
+ const newClientAggregate = { [dateBucketKey]: bucket };
440
+ clientToRequestSessionAggregatesMap.set(client, newClientAggregate);
441
+
442
+ const flushPendingClientAggregates = () => {
443
+ clearTimeout(timeout);
444
+ unregisterClientFlushHook();
445
+ clientToRequestSessionAggregatesMap.delete(client);
446
+
447
+ const aggregatePayload = Object.entries(newClientAggregate).map(
448
+ ([timestamp, value]) => ({
449
+ started: timestamp,
450
+ exited: value.exited,
451
+ errored: value.errored,
452
+ crashed: value.crashed,
453
+ }),
454
+ );
455
+ client.sendSession({ aggregates: aggregatePayload });
456
+ };
457
+
458
+ const unregisterClientFlushHook = client.on('flush', () => {
459
+ DEBUG_BUILD && logger.debug('Sending request session aggregate due to client flush');
460
+ flushPendingClientAggregates();
461
+ });
462
+ const timeout = setTimeout(() => {
463
+ DEBUG_BUILD && logger.debug('Sending request session aggregate due to flushing schedule');
464
+ flushPendingClientAggregates();
465
+ }, sessionFlushingDelayMS).unref();
466
+ }
467
+ }
468
+ });
469
+ }
470
+
471
+ const clientToRequestSessionAggregatesMap = new Map
472
+
473
+ ();
474
+
475
+ export { SentryHttpInstrumentation, recordRequestSession };
397
476
  //# sourceMappingURL=SentryHttpInstrumentation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SentryHttpInstrumentation.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"sourcesContent":["import type * as http from 'node:http';\nimport type { IncomingMessage, RequestOptions } from 'node:http';\nimport type * as https from 'node:https';\nimport { VERSION } from '@opentelemetry/core';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport type { RequestEventData, SanitizedRequestData, Scope } from '@sentry/core';\nimport {\n addBreadcrumb,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n getIsolationScope,\n getSanitizedUrlString,\n httpRequestToRequestData,\n logger,\n parseUrl,\n stripUrlQueryAndFragment,\n withIsolationScope,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport type { NodeClient } from '../../sdk/client';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport { getRequestInfo } from './vendor/getRequestInfo';\ntype Http = typeof http;\ntype Https = typeof https;\n\ntype SentryHttpInstrumentationOptions = InstrumentationConfig & {\n /**\n * Whether breadcrumbs should be recorded for requests.\n *\n * @default `true`\n */\n breadcrumbs?: boolean;\n\n /**\n * Do not capture breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * For the scope of this instrumentation, this callback only controls breadcrumb creation.\n * The same option can be passed to the top-level httpIntegration where it controls both, breadcrumb and\n * span creation.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * @param request Contains the {@type RequestOptions} object used to make the outgoing request.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n};\n\n// We only want to capture request bodies up to 1mb.\nconst MAX_BODY_BYTE_LENGTH = 1024 * 1024;\n\n/**\n * This custom HTTP instrumentation is used to isolate incoming requests and annotate them with additional information.\n * It does not emit any spans.\n *\n * The reason this is isolated from the OpenTelemetry instrumentation is that users may overwrite this,\n * which would lead to Sentry not working as expected.\n *\n * Important note: Contrary to other OTEL instrumentation, this one cannot be unwrapped.\n * It only does minimal things though and does not emit any spans.\n *\n * This is heavily inspired & adapted from:\n * https://github.com/open-telemetry/opentelemetry-js/blob/f8ab5592ddea5cba0a3b33bf8d74f27872c0367f/experimental/packages/opentelemetry-instrumentation-http/src/http.ts\n */\nexport class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpInstrumentationOptions> {\n public constructor(config: SentryHttpInstrumentationOptions = {}) {\n super('@sentry/instrumentation-http', VERSION, config);\n }\n\n /** @inheritdoc */\n public init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition] {\n return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];\n }\n\n /** Get the instrumentation for the http module. */\n private _getHttpInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition(\n 'http',\n ['*'],\n (moduleExports: Http): Http => {\n // Patch incoming requests for request isolation\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n // Patch outgoing requests for breadcrumbs\n const patchedRequest = stealthWrap(moduleExports, 'request', this._getPatchOutgoingRequestFunction());\n stealthWrap(moduleExports, 'get', this._getPatchOutgoingGetFunction(patchedRequest));\n\n return moduleExports;\n },\n () => {\n // no unwrap here\n },\n );\n }\n\n /** Get the instrumentation for the https module. */\n private _getHttpsInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition(\n 'https',\n ['*'],\n (moduleExports: Https): Https => {\n // Patch incoming requests for request isolation\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n // Patch outgoing requests for breadcrumbs\n const patchedRequest = stealthWrap(moduleExports, 'request', this._getPatchOutgoingRequestFunction());\n stealthWrap(moduleExports, 'get', this._getPatchOutgoingGetFunction(patchedRequest));\n\n return moduleExports;\n },\n () => {\n // no unwrap here\n },\n );\n }\n\n /**\n * Patch the incoming request function for request isolation.\n */\n private _getPatchIncomingRequestFunction(): (\n original: (event: string, ...args: unknown[]) => boolean,\n ) => (this: unknown, event: string, ...args: unknown[]) => boolean {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n return (\n original: (event: string, ...args: unknown[]) => boolean,\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return function incomingRequest(this: unknown, event: string, ...args: unknown[]): boolean {\n // Only traces request events\n if (event !== 'request') {\n return original.apply(this, [event, ...args]);\n }\n\n instrumentation._diag.debug('http instrumentation for incoming request');\n\n const isolationScope = getIsolationScope().clone();\n const request = args[0] as http.IncomingMessage;\n\n const normalizedRequest = httpRequestToRequestData(request);\n\n patchRequestToCaptureBody(request, isolationScope);\n\n // Update the isolation scope, isolate this request\n // TODO(v9): Stop setting `request`, we only rely on normalizedRequest anymore\n isolationScope.setSDKProcessingMetadata({\n request,\n normalizedRequest,\n });\n\n const client = getClient<NodeClient>();\n // eslint-disable-next-line deprecation/deprecation\n if (client && client.getOptions().autoSessionTracking) {\n // eslint-disable-next-line deprecation/deprecation\n isolationScope.setRequestSession({ status: 'ok' });\n }\n\n // attempt to update the scope's `transactionName` based on the request URL\n // Ideally, framework instrumentations coming after the HttpInstrumentation\n // update the transactionName once we get a parameterized route.\n const httpMethod = (request.method || 'GET').toUpperCase();\n const httpTarget = stripUrlQueryAndFragment(request.url || '/');\n\n const bestEffortTransactionName = `${httpMethod} ${httpTarget}`;\n\n isolationScope.setTransactionName(bestEffortTransactionName);\n\n return withIsolationScope(isolationScope, () => {\n return original.apply(this, [event, ...args]);\n });\n };\n };\n }\n\n /**\n * Patch the outgoing request function for breadcrumbs.\n */\n private _getPatchOutgoingRequestFunction(): (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n original: (...args: any[]) => http.ClientRequest,\n ) => (options: URL | http.RequestOptions | string, ...args: unknown[]) => http.ClientRequest {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n return (original: (...args: unknown[]) => http.ClientRequest): ((...args: unknown[]) => http.ClientRequest) => {\n return function outgoingRequest(this: unknown, ...args: unknown[]): http.ClientRequest {\n instrumentation._diag.debug('http instrumentation for outgoing requests');\n\n // Making a copy to avoid mutating the original args array\n // We need to access and reconstruct the request options object passed to `ignoreOutgoingRequests`\n // so that it matches what Otel instrumentation passes to `ignoreOutgoingRequestHook`.\n // @see https://github.com/open-telemetry/opentelemetry-js/blob/7293e69c1e55ca62e15d0724d22605e61bd58952/experimental/packages/opentelemetry-instrumentation-http/src/http.ts#L756-L789\n const argsCopy = [...args];\n\n const options = argsCopy.shift() as URL | http.RequestOptions | string;\n\n const extraOptions =\n typeof argsCopy[0] === 'object' && (typeof options === 'string' || options instanceof URL)\n ? (argsCopy.shift() as http.RequestOptions)\n : undefined;\n\n const { optionsParsed } = getRequestInfo(instrumentation._diag, options, extraOptions);\n\n const request = original.apply(this, args) as ReturnType<typeof http.request>;\n\n request.prependListener('response', (response: http.IncomingMessage) => {\n const _breadcrumbs = instrumentation.getConfig().breadcrumbs;\n const breadCrumbsEnabled = typeof _breadcrumbs === 'undefined' ? true : _breadcrumbs;\n\n const _ignoreOutgoingRequests = instrumentation.getConfig().ignoreOutgoingRequests;\n const shouldCreateBreadcrumb =\n typeof _ignoreOutgoingRequests === 'function'\n ? !_ignoreOutgoingRequests(getRequestUrl(request), optionsParsed)\n : true;\n\n if (breadCrumbsEnabled && shouldCreateBreadcrumb) {\n addRequestBreadcrumb(request, response);\n }\n });\n\n return request;\n };\n };\n }\n\n /** Path the outgoing get function for breadcrumbs. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _getPatchOutgoingGetFunction(clientRequest: (...args: any[]) => http.ClientRequest) {\n return (_original: unknown): ((...args: unknown[]) => http.ClientRequest) => {\n // Re-implement http.get. This needs to be done (instead of using\n // getPatchOutgoingRequestFunction to patch it) because we need to\n // set the trace context header before the returned http.ClientRequest is\n // ended. The Node.js docs state that the only differences between\n // request and get are that (1) get defaults to the HTTP GET method and\n // (2) the returned request object is ended immediately. The former is\n // already true (at least in supported Node versions up to v10), so we\n // simply follow the latter. Ref:\n // https://nodejs.org/dist/latest/docs/api/http.html#http_http_get_options_callback\n // https://github.com/googleapis/cloud-trace-nodejs/blob/master/src/instrumentations/instrumentation-http.ts#L198\n return function outgoingGetRequest(...args: unknown[]): http.ClientRequest {\n const req = clientRequest(...args);\n req.end();\n return req;\n };\n };\n }\n}\n\n/**\n * This is a minimal version of `wrap` from shimmer:\n * https://github.com/othiym23/shimmer/blob/master/index.js\n *\n * In contrast to the original implementation, this version does not allow to unwrap,\n * and does not make it clear that the method is wrapped.\n * This is necessary because we want to wrap the http module with our own code,\n * while still allowing to use the HttpInstrumentation from OTEL.\n *\n * Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,\n * because it only allows any module to be wrapped a single time.\n */\nfunction stealthWrap<Nodule extends object, FieldName extends keyof Nodule>(\n nodule: Nodule,\n name: FieldName,\n wrapper: (original: Nodule[FieldName]) => Nodule[FieldName],\n): Nodule[FieldName] {\n const original = nodule[name];\n const wrapped = wrapper(original);\n\n defineProperty(nodule, name, wrapped);\n return wrapped;\n}\n\n// Sets a property on an object, preserving its enumerability.\nfunction defineProperty<Nodule extends object, FieldName extends keyof Nodule>(\n obj: Nodule,\n name: FieldName,\n value: Nodule[FieldName],\n): void {\n const enumerable = !!obj[name] && Object.prototype.propertyIsEnumerable.call(obj, name);\n\n Object.defineProperty(obj, name, {\n configurable: true,\n enumerable: enumerable,\n writable: true,\n value: value,\n });\n}\n\n/** Add a breadcrumb for outgoing requests. */\nfunction addRequestBreadcrumb(request: http.ClientRequest, response: http.IncomingMessage): void {\n const data = getBreadcrumbData(request);\n\n const statusCode = response.statusCode;\n const level = getBreadcrumbLogLevelFromHttpStatusCode(statusCode);\n\n addBreadcrumb(\n {\n category: 'http',\n data: {\n status_code: statusCode,\n ...data,\n },\n type: 'http',\n level,\n },\n {\n event: 'response',\n request,\n response,\n },\n );\n}\n\nfunction getBreadcrumbData(request: http.ClientRequest): Partial<SanitizedRequestData> {\n try {\n // `request.host` does not contain the port, but the host header does\n const host = request.getHeader('host') || request.host;\n const url = new URL(request.path, `${request.protocol}//${host}`);\n const parsedUrl = parseUrl(url.toString());\n\n const data: Partial<SanitizedRequestData> = {\n url: getSanitizedUrlString(parsedUrl),\n 'http.method': request.method || 'GET',\n };\n\n if (parsedUrl.search) {\n data['http.query'] = parsedUrl.search;\n }\n if (parsedUrl.hash) {\n data['http.fragment'] = parsedUrl.hash;\n }\n\n return data;\n } catch {\n return {};\n }\n}\n\n/**\n * This method patches the request object to capture the body.\n * Instead of actually consuming the streamed body ourselves, which has potential side effects,\n * we monkey patch `req.on('data')` to intercept the body chunks.\n * This way, we only read the body if the user also consumes the body, ensuring we do not change any behavior in unexpected ways.\n */\nfunction patchRequestToCaptureBody(req: IncomingMessage, isolationScope: Scope): void {\n const chunks: Buffer[] = [];\n\n function getChunksSize(): number {\n return chunks.reduce((acc, chunk) => acc + chunk.byteLength, 0);\n }\n\n /**\n * We need to keep track of the original callbacks, in order to be able to remove listeners again.\n * Since `off` depends on having the exact same function reference passed in, we need to be able to map\n * original listeners to our wrapped ones.\n */\n const callbackMap = new WeakMap();\n\n try {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n req.on = new Proxy(req.on, {\n apply: (target, thisArg, args: Parameters<typeof req.on>) => {\n const [event, listener, ...restArgs] = args;\n\n if (event === 'data') {\n const callback = new Proxy(listener, {\n apply: (target, thisArg, args: Parameters<typeof listener>) => {\n // If we have already read more than the max body length, we stop addiing chunks\n // To avoid growing the memory indefinitely if a respons is e.g. streamed\n if (getChunksSize() < MAX_BODY_BYTE_LENGTH) {\n const chunk = args[0] as Buffer;\n chunks.push(chunk);\n } else if (DEBUG_BUILD) {\n logger.log(\n `Dropping request body chunk because it maximum body length of ${MAX_BODY_BYTE_LENGTH}b is exceeded.`,\n );\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n callbackMap.set(listener, callback);\n\n return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);\n }\n\n if (event === 'end') {\n const callback = new Proxy(listener, {\n apply: (target, thisArg, args) => {\n try {\n const body = Buffer.concat(chunks).toString('utf-8');\n\n if (body) {\n const normalizedRequest = { data: body } satisfies RequestEventData;\n isolationScope.setSDKProcessingMetadata({ normalizedRequest });\n }\n } catch {\n // ignore errors here\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n callbackMap.set(listener, callback);\n\n return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n // Ensure we also remove callbacks correctly\n // eslint-disable-next-line @typescript-eslint/unbound-method\n req.off = new Proxy(req.off, {\n apply: (target, thisArg, args: Parameters<typeof req.off>) => {\n const [, listener] = args;\n\n const callback = callbackMap.get(listener);\n if (callback) {\n callbackMap.delete(listener);\n\n const modifiedArgs = args.slice();\n modifiedArgs[1] = callback;\n return Reflect.apply(target, thisArg, modifiedArgs);\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n } catch {\n // ignore errors if we can't patch stuff\n }\n}\n"],"names":[],"mappings":";;;;;;;AA8CA;AACA,MAAM,oBAAqB,GAAE,IAAK,GAAE,IAAI;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,yBAAA,SAAkC,mBAAmB,CAAmC;AACrG,GAAS,WAAW,CAAC,MAAM,GAAqC,EAAE,EAAE;AACpE,IAAI,KAAK,CAAC,8BAA8B,EAAE,OAAO,EAAE,MAAM,CAAC;AAC1D;;AAEA;AACA,GAAS,IAAI,GAA+E;AAC5F,IAAI,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,IAAI,CAAC,uBAAuB,EAAE,CAAC;AAC5E;;AAEA;AACA,GAAU,uBAAuB,GAAwC;AACzE,IAAI,OAAO,IAAI,mCAAmC;AAClD,MAAM,MAAM;AACZ,MAAM,CAAC,GAAG,CAAC;AACX,MAAM,CAAC,aAAa,KAAiB;AACrC;AACA,QAAQ,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC;;AAEpG;AACA,QAAQ,MAAM,cAAA,GAAiB,WAAW,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC;AAC7G,QAAQ,WAAW,CAAC,aAAa,EAAE,KAAK,EAA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AAA,OAAA,CAAA,KAAA,CAAA,MAAA,EAAA,OAAA,EAAA,YAAA,CAAA;AACA;;AAEA,QAAA,OAAA,OAAA,CAAA,KAAA,CAAA,MAAA,EAAA,OAAA,EAAA,IAAA,CAAA;AACA,OAAA;AACA,KAAA,CAAA;AACA,GAAA,CAAA,OAAA,EAAA,EAAA;AACA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"SentryHttpInstrumentation.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport type * as http from 'node:http';\nimport type { IncomingMessage, RequestOptions } from 'node:http';\nimport type * as https from 'node:https';\nimport type { EventEmitter } from 'node:stream';\nimport { VERSION } from '@opentelemetry/core';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport type { AggregationCounts, Client, RequestEventData, SanitizedRequestData, Scope } from '@sentry/core';\nimport {\n addBreadcrumb,\n generateSpanId,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n getIsolationScope,\n getSanitizedUrlString,\n httpRequestToRequestData,\n logger,\n parseUrl,\n stripUrlQueryAndFragment,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport { getRequestInfo } from './vendor/getRequestInfo';\n\ntype Http = typeof http;\ntype Https = typeof https;\n\ntype SentryHttpInstrumentationOptions = InstrumentationConfig & {\n /**\n * Whether breadcrumbs should be recorded for requests.\n *\n * @default `true`\n */\n breadcrumbs?: boolean;\n\n /**\n * Do not capture breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * For the scope of this instrumentation, this callback only controls breadcrumb creation.\n * The same option can be passed to the top-level httpIntegration where it controls both, breadcrumb and\n * span creation.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * @param request Contains the {@type RequestOptions} object used to make the outgoing request.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n};\n\n// We only want to capture request bodies up to 1mb.\nconst MAX_BODY_BYTE_LENGTH = 1024 * 1024;\n\n/**\n * This custom HTTP instrumentation is used to isolate incoming requests and annotate them with additional information.\n * It does not emit any spans.\n *\n * The reason this is isolated from the OpenTelemetry instrumentation is that users may overwrite this,\n * which would lead to Sentry not working as expected.\n *\n * Important note: Contrary to other OTEL instrumentation, this one cannot be unwrapped.\n * It only does minimal things though and does not emit any spans.\n *\n * This is heavily inspired & adapted from:\n * https://github.com/open-telemetry/opentelemetry-js/blob/f8ab5592ddea5cba0a3b33bf8d74f27872c0367f/experimental/packages/opentelemetry-instrumentation-http/src/http.ts\n */\nexport class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpInstrumentationOptions> {\n public constructor(config: SentryHttpInstrumentationOptions = {}) {\n super('@sentry/instrumentation-http', VERSION, config);\n }\n\n /** @inheritdoc */\n public init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition] {\n return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];\n }\n\n /** Get the instrumentation for the http module. */\n private _getHttpInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition(\n 'http',\n ['*'],\n (moduleExports: Http): Http => {\n // Patch incoming requests for request isolation\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n // Patch outgoing requests for breadcrumbs\n const patchedRequest = stealthWrap(moduleExports, 'request', this._getPatchOutgoingRequestFunction());\n stealthWrap(moduleExports, 'get', this._getPatchOutgoingGetFunction(patchedRequest));\n\n return moduleExports;\n },\n () => {\n // no unwrap here\n },\n );\n }\n\n /** Get the instrumentation for the https module. */\n private _getHttpsInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition(\n 'https',\n ['*'],\n (moduleExports: Https): Https => {\n // Patch incoming requests for request isolation\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n // Patch outgoing requests for breadcrumbs\n const patchedRequest = stealthWrap(moduleExports, 'request', this._getPatchOutgoingRequestFunction());\n stealthWrap(moduleExports, 'get', this._getPatchOutgoingGetFunction(patchedRequest));\n\n return moduleExports;\n },\n () => {\n // no unwrap here\n },\n );\n }\n\n /**\n * Patch the incoming request function for request isolation.\n */\n private _getPatchIncomingRequestFunction(): (\n original: (event: string, ...args: unknown[]) => boolean,\n ) => (this: unknown, event: string, ...args: unknown[]) => boolean {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n return (\n original: (event: string, ...args: unknown[]) => boolean,\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return function incomingRequest(this: unknown, event: string, ...args: unknown[]): boolean {\n // Only traces request events\n if (event !== 'request') {\n return original.apply(this, [event, ...args]);\n }\n\n instrumentation._diag.debug('http instrumentation for incoming request');\n\n const isolationScope = getIsolationScope().clone();\n const request = args[0] as http.IncomingMessage;\n const response = args[1] as http.OutgoingMessage;\n\n const normalizedRequest = httpRequestToRequestData(request);\n\n // request.ip is non-standard but some frameworks set this\n const ipAddress = (request as { ip?: string }).ip || request.socket?.remoteAddress;\n\n patchRequestToCaptureBody(request, isolationScope);\n\n // Update the isolation scope, isolate this request\n isolationScope.setSDKProcessingMetadata({ normalizedRequest, ipAddress });\n\n // attempt to update the scope's `transactionName` based on the request URL\n // Ideally, framework instrumentations coming after the HttpInstrumentation\n // update the transactionName once we get a parameterized route.\n const httpMethod = (request.method || 'GET').toUpperCase();\n const httpTarget = stripUrlQueryAndFragment(request.url || '/');\n\n const bestEffortTransactionName = `${httpMethod} ${httpTarget}`;\n\n isolationScope.setTransactionName(bestEffortTransactionName);\n\n if (instrumentation.getConfig().trackIncomingRequestsAsSessions !== false) {\n recordRequestSession({\n requestIsolationScope: isolationScope,\n response,\n sessionFlushingDelayMS: instrumentation.getConfig().sessionFlushingDelayMS ?? 60_000,\n });\n }\n\n return withIsolationScope(isolationScope, () => {\n return withScope(scope => {\n // Set a new propagationSpanId for this request\n scope.getPropagationContext().propagationSpanId = generateSpanId();\n return original.apply(this, [event, ...args]);\n });\n });\n };\n };\n }\n\n /**\n * Patch the outgoing request function for breadcrumbs.\n */\n private _getPatchOutgoingRequestFunction(): (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n original: (...args: any[]) => http.ClientRequest,\n ) => (options: URL | http.RequestOptions | string, ...args: unknown[]) => http.ClientRequest {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n return (original: (...args: unknown[]) => http.ClientRequest): ((...args: unknown[]) => http.ClientRequest) => {\n return function outgoingRequest(this: unknown, ...args: unknown[]): http.ClientRequest {\n instrumentation._diag.debug('http instrumentation for outgoing requests');\n\n // Making a copy to avoid mutating the original args array\n // We need to access and reconstruct the request options object passed to `ignoreOutgoingRequests`\n // so that it matches what Otel instrumentation passes to `ignoreOutgoingRequestHook`.\n // @see https://github.com/open-telemetry/opentelemetry-js/blob/7293e69c1e55ca62e15d0724d22605e61bd58952/experimental/packages/opentelemetry-instrumentation-http/src/http.ts#L756-L789\n const argsCopy = [...args];\n\n const options = argsCopy.shift() as URL | http.RequestOptions | string;\n\n const extraOptions =\n typeof argsCopy[0] === 'object' && (typeof options === 'string' || options instanceof URL)\n ? (argsCopy.shift() as http.RequestOptions)\n : undefined;\n\n const { optionsParsed } = getRequestInfo(instrumentation._diag, options, extraOptions);\n\n const request = original.apply(this, args) as ReturnType<typeof http.request>;\n\n request.prependListener('response', (response: http.IncomingMessage) => {\n const _breadcrumbs = instrumentation.getConfig().breadcrumbs;\n const breadCrumbsEnabled = typeof _breadcrumbs === 'undefined' ? true : _breadcrumbs;\n\n const _ignoreOutgoingRequests = instrumentation.getConfig().ignoreOutgoingRequests;\n const shouldCreateBreadcrumb =\n typeof _ignoreOutgoingRequests === 'function'\n ? !_ignoreOutgoingRequests(getRequestUrl(request), optionsParsed)\n : true;\n\n if (breadCrumbsEnabled && shouldCreateBreadcrumb) {\n addRequestBreadcrumb(request, response);\n }\n });\n\n return request;\n };\n };\n }\n\n /** Path the outgoing get function for breadcrumbs. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _getPatchOutgoingGetFunction(clientRequest: (...args: any[]) => http.ClientRequest) {\n return (_original: unknown): ((...args: unknown[]) => http.ClientRequest) => {\n // Re-implement http.get. This needs to be done (instead of using\n // getPatchOutgoingRequestFunction to patch it) because we need to\n // set the trace context header before the returned http.ClientRequest is\n // ended. The Node.js docs state that the only differences between\n // request and get are that (1) get defaults to the HTTP GET method and\n // (2) the returned request object is ended immediately. The former is\n // already true (at least in supported Node versions up to v10), so we\n // simply follow the latter. Ref:\n // https://nodejs.org/dist/latest/docs/api/http.html#http_http_get_options_callback\n // https://github.com/googleapis/cloud-trace-nodejs/blob/master/src/instrumentations/instrumentation-http.ts#L198\n return function outgoingGetRequest(...args: unknown[]): http.ClientRequest {\n const req = clientRequest(...args);\n req.end();\n return req;\n };\n };\n }\n}\n\n/**\n * This is a minimal version of `wrap` from shimmer:\n * https://github.com/othiym23/shimmer/blob/master/index.js\n *\n * In contrast to the original implementation, this version does not allow to unwrap,\n * and does not make it clear that the method is wrapped.\n * This is necessary because we want to wrap the http module with our own code,\n * while still allowing to use the HttpInstrumentation from OTEL.\n *\n * Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,\n * because it only allows any module to be wrapped a single time.\n */\nfunction stealthWrap<Nodule extends object, FieldName extends keyof Nodule>(\n nodule: Nodule,\n name: FieldName,\n wrapper: (original: Nodule[FieldName]) => Nodule[FieldName],\n): Nodule[FieldName] {\n const original = nodule[name];\n const wrapped = wrapper(original);\n\n defineProperty(nodule, name, wrapped);\n return wrapped;\n}\n\n// Sets a property on an object, preserving its enumerability.\nfunction defineProperty<Nodule extends object, FieldName extends keyof Nodule>(\n obj: Nodule,\n name: FieldName,\n value: Nodule[FieldName],\n): void {\n const enumerable = !!obj[name] && Object.prototype.propertyIsEnumerable.call(obj, name);\n\n Object.defineProperty(obj, name, {\n configurable: true,\n enumerable: enumerable,\n writable: true,\n value: value,\n });\n}\n\n/** Add a breadcrumb for outgoing requests. */\nfunction addRequestBreadcrumb(request: http.ClientRequest, response: http.IncomingMessage): void {\n const data = getBreadcrumbData(request);\n\n const statusCode = response.statusCode;\n const level = getBreadcrumbLogLevelFromHttpStatusCode(statusCode);\n\n addBreadcrumb(\n {\n category: 'http',\n data: {\n status_code: statusCode,\n ...data,\n },\n type: 'http',\n level,\n },\n {\n event: 'response',\n request,\n response,\n },\n );\n}\n\nfunction getBreadcrumbData(request: http.ClientRequest): Partial<SanitizedRequestData> {\n try {\n // `request.host` does not contain the port, but the host header does\n const host = request.getHeader('host') || request.host;\n const url = new URL(request.path, `${request.protocol}//${host}`);\n const parsedUrl = parseUrl(url.toString());\n\n const data: Partial<SanitizedRequestData> = {\n url: getSanitizedUrlString(parsedUrl),\n 'http.method': request.method || 'GET',\n };\n\n if (parsedUrl.search) {\n data['http.query'] = parsedUrl.search;\n }\n if (parsedUrl.hash) {\n data['http.fragment'] = parsedUrl.hash;\n }\n\n return data;\n } catch {\n return {};\n }\n}\n\n/**\n * This method patches the request object to capture the body.\n * Instead of actually consuming the streamed body ourselves, which has potential side effects,\n * we monkey patch `req.on('data')` to intercept the body chunks.\n * This way, we only read the body if the user also consumes the body, ensuring we do not change any behavior in unexpected ways.\n */\nfunction patchRequestToCaptureBody(req: IncomingMessage, isolationScope: Scope): void {\n const chunks: Buffer[] = [];\n\n function getChunksSize(): number {\n return chunks.reduce((acc, chunk) => acc + chunk.byteLength, 0);\n }\n\n /**\n * We need to keep track of the original callbacks, in order to be able to remove listeners again.\n * Since `off` depends on having the exact same function reference passed in, we need to be able to map\n * original listeners to our wrapped ones.\n */\n const callbackMap = new WeakMap();\n\n try {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n req.on = new Proxy(req.on, {\n apply: (target, thisArg, args: Parameters<typeof req.on>) => {\n const [event, listener, ...restArgs] = args;\n\n if (event === 'data') {\n const callback = new Proxy(listener, {\n apply: (target, thisArg, args: Parameters<typeof listener>) => {\n // If we have already read more than the max body length, we stop adding chunks\n // To avoid growing the memory indefinitely if a response is e.g. streamed\n if (getChunksSize() < MAX_BODY_BYTE_LENGTH) {\n const chunk = args[0] as Buffer;\n chunks.push(chunk);\n } else if (DEBUG_BUILD) {\n logger.log(\n `Dropping request body chunk because it maximum body length of ${MAX_BODY_BYTE_LENGTH}b is exceeded.`,\n );\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n callbackMap.set(listener, callback);\n\n return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);\n }\n\n if (event === 'end') {\n const callback = new Proxy(listener, {\n apply: (target, thisArg, args) => {\n try {\n const body = Buffer.concat(chunks).toString('utf-8');\n\n if (body) {\n const normalizedRequest = { data: body } satisfies RequestEventData;\n isolationScope.setSDKProcessingMetadata({ normalizedRequest });\n }\n } catch {\n // ignore errors here\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n callbackMap.set(listener, callback);\n\n return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n // Ensure we also remove callbacks correctly\n // eslint-disable-next-line @typescript-eslint/unbound-method\n req.off = new Proxy(req.off, {\n apply: (target, thisArg, args: Parameters<typeof req.off>) => {\n const [, listener] = args;\n\n const callback = callbackMap.get(listener);\n if (callback) {\n callbackMap.delete(listener);\n\n const modifiedArgs = args.slice();\n modifiedArgs[1] = callback;\n return Reflect.apply(target, thisArg, modifiedArgs);\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n } catch {\n // ignore errors if we can't patch stuff\n }\n}\n\n/**\n * Starts a session and tracks it in the context of a given isolation scope.\n * When the passed response is finished, the session is put into a task and is\n * aggregated with other sessions that may happen in a certain time window\n * (sessionFlushingDelayMs).\n *\n * The sessions are always aggregated by the client that is on the current scope\n * at the time of ending the response (if there is one).\n */\n// Exported for unit tests\nexport function recordRequestSession({\n requestIsolationScope,\n response,\n sessionFlushingDelayMS,\n}: { requestIsolationScope: Scope; response: EventEmitter; sessionFlushingDelayMS?: number }): void {\n requestIsolationScope.setSDKProcessingMetadata({\n requestSession: { status: 'ok' },\n });\n response.once('close', () => {\n // We need to grab the client off the current scope instead of the isolation scope because the isolation scope doesn't hold any client out of the box.\n const client = getClient();\n const requestSession = requestIsolationScope.getScopeData().sdkProcessingMetadata.requestSession;\n\n if (client && requestSession) {\n DEBUG_BUILD && logger.debug(`Recorded request session with status: ${requestSession.status}`);\n\n const roundedDate = new Date();\n roundedDate.setSeconds(0, 0);\n const dateBucketKey = roundedDate.toISOString();\n\n const existingClientAggregate = clientToRequestSessionAggregatesMap.get(client);\n const bucket = existingClientAggregate?.[dateBucketKey] || { exited: 0, crashed: 0, errored: 0 };\n bucket[({ ok: 'exited', crashed: 'crashed', errored: 'errored' } as const)[requestSession.status]]++;\n\n if (existingClientAggregate) {\n existingClientAggregate[dateBucketKey] = bucket;\n } else {\n DEBUG_BUILD && logger.debug('Opened new request session aggregate.');\n const newClientAggregate = { [dateBucketKey]: bucket };\n clientToRequestSessionAggregatesMap.set(client, newClientAggregate);\n\n const flushPendingClientAggregates = (): void => {\n clearTimeout(timeout);\n unregisterClientFlushHook();\n clientToRequestSessionAggregatesMap.delete(client);\n\n const aggregatePayload: AggregationCounts[] = Object.entries(newClientAggregate).map(\n ([timestamp, value]) => ({\n started: timestamp,\n exited: value.exited,\n errored: value.errored,\n crashed: value.crashed,\n }),\n );\n client.sendSession({ aggregates: aggregatePayload });\n };\n\n const unregisterClientFlushHook = client.on('flush', () => {\n DEBUG_BUILD && logger.debug('Sending request session aggregate due to client flush');\n flushPendingClientAggregates();\n });\n const timeout = setTimeout(() => {\n DEBUG_BUILD && logger.debug('Sending request session aggregate due to flushing schedule');\n flushPendingClientAggregates();\n }, sessionFlushingDelayMS).unref();\n }\n }\n });\n}\n\nconst clientToRequestSessionAggregatesMap = new Map<\n Client,\n { [timestampRoundedToSeconds: string]: { exited: number; crashed: number; errored: number } }\n>();\n"],"names":[],"mappings":";;;;;;;AAiEA;AACA,MAAM,oBAAqB,GAAE,IAAK,GAAE,IAAI;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,yBAAA,SAAkC,mBAAmB,CAAmC;AACrG,GAAS,WAAW,CAAC,MAAM,GAAqC,EAAE,EAAE;AACpE,IAAI,KAAK,CAAC,8BAA8B,EAAE,OAAO,EAAE,MAAM,CAAC;AAC1D;;AAEA;AACA,GAAS,IAAI,GAA+E;AAC5F,IAAI,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,IAAI,CAAC,uBAAuB,EAAE,CAAC;AAC5E;;AAEA;AACA,GAAU,uBAAuB,GAAwC;AACzE,IAAI,OAAO,IAAI,mCAAmC;AAClD,MAAM,MAAM;AACZ,MAAM,CAAC,GAAG,CAAC;AACX,MAAM,CAAC,aAAa,KAAiB;AACrC;AACA,QAAQ,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC;;AAEpG;AACA,QAAQ,MAAM,cAAA,GAAiB,WAAW,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC;AAC7G,QAAQ,WAAW,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,4BAA4B,CAAC,cAAc,CAA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A,CAAA,KAAA,CAAA,uDAAA,CAAA;AACA,UAAA,4BAAA,EAAA;AACA,SAAA,CAAA;AACA,QAAA,MAAA,OAAA,GAAA,UAAA,CAAA,MAAA;AACA,UAAA,WAAA,IAAA,MAAA,CAAA,KAAA,CAAA,4DAAA,CAAA;AACA,UAAA,4BAAA,EAAA;AACA,SAAA,EAAA,sBAAA,CAAA,CAAA,KAAA,EAAA;AACA;AACA;AACA,GAAA,CAAA;AACA;;AAEA,MAAA,mCAAA,GAAA,IAAA;;AAGA,EAAA;;;;"}
@@ -1,8 +1,6 @@
1
- import { _optionalChain } from '@sentry/core';
2
1
  import { diag } from '@opentelemetry/api';
3
2
  import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
4
- import { defineIntegration } from '@sentry/core';
5
- import { getClient } from '@sentry/opentelemetry';
3
+ import { defineIntegration, getClient } from '@sentry/core';
6
4
  import { generateInstrumentOnce } from '../../otel/instrument.js';
7
5
  import { addOriginToSpan } from '../../utils/addOriginToSpan.js';
8
6
  import { getRequestUrl } from '../../utils/getRequestUrl.js';
@@ -16,8 +14,10 @@ const instrumentSentryHttp = generateInstrumentOnce
16
14
 
17
15
  (`${INTEGRATION_NAME}.sentry`, options => {
18
16
  return new SentryHttpInstrumentation({
19
- breadcrumbs: _optionalChain([options, 'optionalAccess', _ => _.breadcrumbs]),
20
- ignoreOutgoingRequests: _optionalChain([options, 'optionalAccess', _2 => _2.ignoreOutgoingRequests]),
17
+ breadcrumbs: options?.breadcrumbs,
18
+ ignoreOutgoingRequests: options?.ignoreOutgoingRequests,
19
+ trackIncomingRequestsAsSessions: options?.trackIncomingRequestsAsSessions,
20
+ sessionFlushingDelayMS: options?.sessionFlushingDelayMS,
21
21
  });
22
22
  });
23
23
 
@@ -31,28 +31,19 @@ const instrumentOtelHttp = generateInstrumentOnce(INTEGRATION_NAME, config => {
31
31
  });
32
32
  // @ts-expect-error We are writing a read-only property here...
33
33
  instrumentation.instrumentationName = INSTRUMENTATION_NAME;
34
- } catch (e) {
34
+ } catch {
35
35
  // ignore errors here...
36
36
  }
37
37
 
38
38
  return instrumentation;
39
39
  });
40
40
 
41
- /**
42
- * Instrument the HTTP and HTTPS modules.
43
- */
44
- const instrumentHttp = (options = {}) => {
45
- // This is the "regular" OTEL instrumentation that emits spans
46
- if (options.spans !== false) {
47
- const instrumentationConfig = getConfigWithDefaults(options);
48
- instrumentOtelHttp(instrumentationConfig);
49
- }
50
-
51
- // This is the Sentry-specific instrumentation that isolates requests & creates breadcrumbs
52
- // Note that this _has_ to be wrapped after the OTEL instrumentation,
53
- // otherwise the isolation will not work correctly
54
- instrumentSentryHttp(options);
55
- };
41
+ /** Exported only for tests. */
42
+ function _shouldInstrumentSpans(options, clientOptions = {}) {
43
+ // If `spans` is passed in, it takes precedence
44
+ // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true`
45
+ return typeof options.spans === 'boolean' ? options.spans : !clientOptions.skipOpenTelemetrySetup;
46
+ }
56
47
 
57
48
  /**
58
49
  * The http integration instruments Node's internal http and https modules.
@@ -62,7 +53,18 @@ const httpIntegration = defineIntegration((options = {}) => {
62
53
  return {
63
54
  name: INTEGRATION_NAME,
64
55
  setupOnce() {
65
- instrumentHttp(options);
56
+ const instrumentSpans = _shouldInstrumentSpans(options, getClient()?.getOptions());
57
+
58
+ // This is the "regular" OTEL instrumentation that emits spans
59
+ if (instrumentSpans) {
60
+ const instrumentationConfig = getConfigWithDefaults(options);
61
+ instrumentOtelHttp(instrumentationConfig);
62
+ }
63
+
64
+ // This is the Sentry-specific instrumentation that isolates requests & creates breadcrumbs
65
+ // Note that this _has_ to be wrapped after the OTEL instrumentation,
66
+ // otherwise the isolation will not work correctly
67
+ instrumentSentryHttp(options);
66
68
  },
67
69
  };
68
70
  });
@@ -86,7 +88,7 @@ function isKnownPrefetchRequest(req) {
86
88
 
87
89
  function getConfigWithDefaults(options = {}) {
88
90
  const instrumentationConfig = {
89
- ..._optionalChain([options, 'access', _3 => _3.instrumentation, 'optionalAccess', _4 => _4._experimentalConfig]),
91
+ ...options.instrumentation?._experimentalConfig,
90
92
 
91
93
  disableIncomingRequestInstrumentation: options.disableIncomingRequestSpans,
92
94
 
@@ -98,7 +100,7 @@ function getConfigWithDefaults(options = {}) {
98
100
  }
99
101
 
100
102
  const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;
101
- if (_ignoreOutgoingRequests && _ignoreOutgoingRequests(url, request)) {
103
+ if (_ignoreOutgoingRequests?.(url, request)) {
102
104
  return true;
103
105
  }
104
106
 
@@ -110,14 +112,14 @@ function getConfigWithDefaults(options = {}) {
110
112
  // it only consists of the URL path and query string (if any)
111
113
  const urlPath = request.url;
112
114
 
113
- const method = _optionalChain([request, 'access', _5 => _5.method, 'optionalAccess', _6 => _6.toUpperCase, 'call', _7 => _7()]);
115
+ const method = request.method?.toUpperCase();
114
116
  // We do not capture OPTIONS/HEAD requests as transactions
115
117
  if (method === 'OPTIONS' || method === 'HEAD') {
116
118
  return true;
117
119
  }
118
120
 
119
121
  const _ignoreIncomingRequests = options.ignoreIncomingRequests;
120
- if (urlPath && _ignoreIncomingRequests && _ignoreIncomingRequests(urlPath, request)) {
122
+ if (urlPath && _ignoreIncomingRequests?.(urlPath, request)) {
121
123
  return true;
122
124
  }
123
125
 
@@ -132,35 +134,22 @@ function getConfigWithDefaults(options = {}) {
132
134
  span.setAttribute('sentry.http.prefetch', true);
133
135
  }
134
136
 
135
- _optionalChain([options, 'access', _8 => _8.instrumentation, 'optionalAccess', _9 => _9.requestHook, 'optionalCall', _10 => _10(span, req)]);
137
+ options.instrumentation?.requestHook?.(span, req);
136
138
  },
137
139
  responseHook: (span, res) => {
138
- const client = getClient();
139
-
140
- if (
141
- client &&
142
- // eslint-disable-next-line deprecation/deprecation
143
- client.getOptions().autoSessionTracking !== false &&
144
- options.trackIncomingRequestsAsSessions !== false
145
- ) {
146
- setImmediate(() => {
147
- client['_captureRequestSession']();
148
- });
149
- }
150
-
151
- _optionalChain([options, 'access', _11 => _11.instrumentation, 'optionalAccess', _12 => _12.responseHook, 'optionalCall', _13 => _13(span, res)]);
140
+ options.instrumentation?.responseHook?.(span, res);
152
141
  },
153
142
  applyCustomAttributesOnSpan: (
154
143
  span,
155
144
  request,
156
145
  response,
157
146
  ) => {
158
- _optionalChain([options, 'access', _14 => _14.instrumentation, 'optionalAccess', _15 => _15.applyCustomAttributesOnSpan, 'optionalCall', _16 => _16(span, request, response)]);
147
+ options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);
159
148
  },
160
149
  } ;
161
150
 
162
151
  return instrumentationConfig;
163
152
  }
164
153
 
165
- export { httpIntegration, instrumentOtelHttp, instrumentSentryHttp };
154
+ export { _shouldInstrumentSpans, httpIntegration, instrumentOtelHttp };
166
155
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/integrations/http/index.ts"],"sourcesContent":["import type { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'node:http';\nimport { diag } from '@opentelemetry/api';\nimport type { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport type { Span } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { getClient } from '@sentry/opentelemetry';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport type { NodeClient } from '../../sdk/client';\nimport type { HTTPModuleRequestIncomingMessage } from '../../transports/http-module';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport { SentryHttpInstrumentation } from './SentryHttpInstrumentation';\n\nconst INTEGRATION_NAME = 'Http';\n\nconst INSTRUMENTATION_NAME = '@opentelemetry_sentry-patched/instrumentation-http';\n\ninterface HttpOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default HttpInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for request isolation is applied.\n */\n spans?: boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n *\n * Note: If `autoSessionTracking` is set to `false` in `Sentry.init()` or the Client owning this integration, this option will be ignored.\n */\n // TODO(v9): Remove the note above.\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n *\n * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * For example: `'https://someService.com/users/details?id=123'`\n *\n * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests to URLs where the given callback returns `true`.\n * Spans will be non recording if tracing is disabled.\n *\n * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.\n * For example: `'/users/details?id=123'`\n *\n * The `request` param contains the original {@type IncomingMessage} object of the incoming request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;\n\n /**\n * If true, do not generate spans for incoming requests at all.\n * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.\n */\n disableIncomingRequestSpans?: boolean;\n\n /**\n * Additional instrumentation options that are passed to the underlying HttpInstrumentation.\n */\n instrumentation?: {\n requestHook?: (span: Span, req: ClientRequest | HTTPModuleRequestIncomingMessage) => void;\n responseHook?: (span: Span, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => void;\n\n /**\n * You can pass any configuration through to the underlying instrumentation.\n * Note that there are no semver guarantees for this!\n */\n _experimentalConfig?: ConstructorParameters<typeof HttpInstrumentation>[0];\n };\n}\n\nexport const instrumentSentryHttp = generateInstrumentOnce<{\n breadcrumbs?: HttpOptions['breadcrumbs'];\n ignoreOutgoingRequests?: HttpOptions['ignoreOutgoingRequests'];\n}>(`${INTEGRATION_NAME}.sentry`, options => {\n return new SentryHttpInstrumentation({\n breadcrumbs: options?.breadcrumbs,\n ignoreOutgoingRequests: options?.ignoreOutgoingRequests,\n });\n});\n\nexport const instrumentOtelHttp = generateInstrumentOnce<HttpInstrumentationConfig>(INTEGRATION_NAME, config => {\n const instrumentation = new HttpInstrumentation(config);\n\n // We want to update the logger namespace so we can better identify what is happening here\n try {\n instrumentation['_diag'] = diag.createComponentLogger({\n namespace: INSTRUMENTATION_NAME,\n });\n // @ts-expect-error We are writing a read-only property here...\n instrumentation.instrumentationName = INSTRUMENTATION_NAME;\n } catch {\n // ignore errors here...\n }\n\n return instrumentation;\n});\n\n/**\n * Instrument the HTTP and HTTPS modules.\n */\nconst instrumentHttp = (options: HttpOptions = {}): void => {\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (options.spans !== false) {\n const instrumentationConfig = getConfigWithDefaults(options);\n instrumentOtelHttp(instrumentationConfig);\n }\n\n // This is the Sentry-specific instrumentation that isolates requests & creates breadcrumbs\n // Note that this _has_ to be wrapped after the OTEL instrumentation,\n // otherwise the isolation will not work correctly\n instrumentSentryHttp(options);\n};\n\n/**\n * The http integration instruments Node's internal http and https modules.\n * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.\n */\nexport const httpIntegration = defineIntegration((options: HttpOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentHttp(options);\n },\n };\n});\n\n/**\n * Determines if @param req is a ClientRequest, meaning the request was created within the express app\n * and it's an outgoing request.\n * Checking for properties instead of using `instanceOf` to avoid importing the request classes.\n */\nfunction _isClientRequest(req: ClientRequest | HTTPModuleRequestIncomingMessage): req is ClientRequest {\n return 'outputData' in req && 'outputSize' in req && !('client' in req) && !('statusCode' in req);\n}\n\n/**\n * Detects if an incoming request is a prefetch request.\n */\nfunction isKnownPrefetchRequest(req: HTTPModuleRequestIncomingMessage): boolean {\n // Currently only handles Next.js prefetch requests but may check other frameworks in the future.\n return req.headers['next-router-prefetch'] === '1';\n}\n\nfunction getConfigWithDefaults(options: Partial<HttpOptions> = {}): HttpInstrumentationConfig {\n const instrumentationConfig = {\n ...options.instrumentation?._experimentalConfig,\n\n disableIncomingRequestInstrumentation: options.disableIncomingRequestSpans,\n\n ignoreOutgoingRequestHook: request => {\n const url = getRequestUrl(request);\n\n if (!url) {\n return false;\n }\n\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n if (_ignoreOutgoingRequests && _ignoreOutgoingRequests(url, request)) {\n return true;\n }\n\n return false;\n },\n\n ignoreIncomingRequestHook: request => {\n // request.url is the only property that holds any information about the url\n // it only consists of the URL path and query string (if any)\n const urlPath = request.url;\n\n const method = request.method?.toUpperCase();\n // We do not capture OPTIONS/HEAD requests as transactions\n if (method === 'OPTIONS' || method === 'HEAD') {\n return true;\n }\n\n const _ignoreIncomingRequests = options.ignoreIncomingRequests;\n if (urlPath && _ignoreIncomingRequests && _ignoreIncomingRequests(urlPath, request)) {\n return true;\n }\n\n return false;\n },\n\n requireParentforOutgoingSpans: false,\n requireParentforIncomingSpans: false,\n requestHook: (span, req) => {\n addOriginToSpan(span, 'auto.http.otel.http');\n if (!_isClientRequest(req) && isKnownPrefetchRequest(req)) {\n span.setAttribute('sentry.http.prefetch', true);\n }\n\n options.instrumentation?.requestHook?.(span, req);\n },\n responseHook: (span, res) => {\n const client = getClient<NodeClient>();\n\n if (\n client &&\n // eslint-disable-next-line deprecation/deprecation\n client.getOptions().autoSessionTracking !== false &&\n options.trackIncomingRequestsAsSessions !== false\n ) {\n setImmediate(() => {\n client['_captureRequestSession']();\n });\n }\n\n options.instrumentation?.responseHook?.(span, res);\n },\n applyCustomAttributesOnSpan: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => {\n options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);\n },\n } satisfies HttpInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAcA,CAAM,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAmB,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA;;AAE/B,CAAM,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAuB,CAAoD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;AA6E1E,CAAA,CAAA,CAAA,CAAA,EAAM,qBAAuB,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;AAGpC,CAAG,CAAC,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,OAAA,CAAA,EAAA,Q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CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,EAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,IAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;IACA,CAAA;EACA,EAAA;;EAEA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/integrations/http/index.ts"],"sourcesContent":["import type { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'node:http';\nimport { diag } from '@opentelemetry/api';\nimport type { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport type { Span } from '@sentry/core';\nimport { defineIntegration, getClient } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport type { NodeClient } from '../../sdk/client';\nimport type { HTTPModuleRequestIncomingMessage } from '../../transports/http-module';\nimport type { NodeClientOptions } from '../../types';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport { SentryHttpInstrumentation } from './SentryHttpInstrumentation';\n\nconst INTEGRATION_NAME = 'Http';\n\nconst INSTRUMENTATION_NAME = '@opentelemetry_sentry-patched/instrumentation-http';\n\ninterface HttpOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default HttpInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for request isolation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n *\n * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * For example: `'https://someService.com/users/details?id=123'`\n *\n * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests to URLs where the given callback returns `true`.\n * Spans will be non recording if tracing is disabled.\n *\n * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.\n * For example: `'/users/details?id=123'`\n *\n * The `request` param contains the original {@type IncomingMessage} object of the incoming request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;\n\n /**\n * If true, do not generate spans for incoming requests at all.\n * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.\n */\n disableIncomingRequestSpans?: boolean;\n\n /**\n * Additional instrumentation options that are passed to the underlying HttpInstrumentation.\n */\n instrumentation?: {\n requestHook?: (span: Span, req: ClientRequest | HTTPModuleRequestIncomingMessage) => void;\n responseHook?: (span: Span, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => void;\n\n /**\n * You can pass any configuration through to the underlying instrumentation.\n * Note that there are no semver guarantees for this!\n */\n _experimentalConfig?: ConstructorParameters<typeof HttpInstrumentation>[0];\n };\n}\n\nconst instrumentSentryHttp = generateInstrumentOnce<{\n breadcrumbs?: HttpOptions['breadcrumbs'];\n ignoreOutgoingRequests?: HttpOptions['ignoreOutgoingRequests'];\n trackIncomingRequestsAsSessions?: HttpOptions['trackIncomingRequestsAsSessions'];\n sessionFlushingDelayMS?: HttpOptions['sessionFlushingDelayMS'];\n}>(`${INTEGRATION_NAME}.sentry`, options => {\n return new SentryHttpInstrumentation({\n breadcrumbs: options?.breadcrumbs,\n ignoreOutgoingRequests: options?.ignoreOutgoingRequests,\n trackIncomingRequestsAsSessions: options?.trackIncomingRequestsAsSessions,\n sessionFlushingDelayMS: options?.sessionFlushingDelayMS,\n });\n});\n\nexport const instrumentOtelHttp = generateInstrumentOnce<HttpInstrumentationConfig>(INTEGRATION_NAME, config => {\n const instrumentation = new HttpInstrumentation(config);\n\n // We want to update the logger namespace so we can better identify what is happening here\n try {\n instrumentation['_diag'] = diag.createComponentLogger({\n namespace: INSTRUMENTATION_NAME,\n });\n // @ts-expect-error We are writing a read-only property here...\n instrumentation.instrumentationName = INSTRUMENTATION_NAME;\n } catch {\n // ignore errors here...\n }\n\n return instrumentation;\n});\n\n/** Exported only for tests. */\nexport function _shouldInstrumentSpans(options: HttpOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true`\n return typeof options.spans === 'boolean' ? options.spans : !clientOptions.skipOpenTelemetrySetup;\n}\n\n/**\n * The http integration instruments Node's internal http and https modules.\n * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.\n */\nexport const httpIntegration = defineIntegration((options: HttpOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n const instrumentationConfig = getConfigWithDefaults(options);\n instrumentOtelHttp(instrumentationConfig);\n }\n\n // This is the Sentry-specific instrumentation that isolates requests & creates breadcrumbs\n // Note that this _has_ to be wrapped after the OTEL instrumentation,\n // otherwise the isolation will not work correctly\n instrumentSentryHttp(options);\n },\n };\n});\n\n/**\n * Determines if @param req is a ClientRequest, meaning the request was created within the express app\n * and it's an outgoing request.\n * Checking for properties instead of using `instanceOf` to avoid importing the request classes.\n */\nfunction _isClientRequest(req: ClientRequest | HTTPModuleRequestIncomingMessage): req is ClientRequest {\n return 'outputData' in req && 'outputSize' in req && !('client' in req) && !('statusCode' in req);\n}\n\n/**\n * Detects if an incoming request is a prefetch request.\n */\nfunction isKnownPrefetchRequest(req: HTTPModuleRequestIncomingMessage): boolean {\n // Currently only handles Next.js prefetch requests but may check other frameworks in the future.\n return req.headers['next-router-prefetch'] === '1';\n}\n\nfunction getConfigWithDefaults(options: Partial<HttpOptions> = {}): HttpInstrumentationConfig {\n const instrumentationConfig = {\n ...options.instrumentation?._experimentalConfig,\n\n disableIncomingRequestInstrumentation: options.disableIncomingRequestSpans,\n\n ignoreOutgoingRequestHook: request => {\n const url = getRequestUrl(request);\n\n if (!url) {\n return false;\n }\n\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n if (_ignoreOutgoingRequests?.(url, request)) {\n return true;\n }\n\n return false;\n },\n\n ignoreIncomingRequestHook: request => {\n // request.url is the only property that holds any information about the url\n // it only consists of the URL path and query string (if any)\n const urlPath = request.url;\n\n const method = request.method?.toUpperCase();\n // We do not capture OPTIONS/HEAD requests as transactions\n if (method === 'OPTIONS' || method === 'HEAD') {\n return true;\n }\n\n const _ignoreIncomingRequests = options.ignoreIncomingRequests;\n if (urlPath && _ignoreIncomingRequests?.(urlPath, request)) {\n return true;\n }\n\n return false;\n },\n\n requireParentforOutgoingSpans: false,\n requireParentforIncomingSpans: false,\n requestHook: (span, req) => {\n addOriginToSpan(span, 'auto.http.otel.http');\n if (!_isClientRequest(req) && isKnownPrefetchRequest(req)) {\n span.setAttribute('sentry.http.prefetch', true);\n }\n\n options.instrumentation?.requestHook?.(span, req);\n },\n responseHook: (span, res) => {\n options.instrumentation?.responseHook?.(span, res);\n },\n applyCustomAttributesOnSpan: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => {\n options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);\n },\n } satisfies HttpInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":[],"mappings":";;;;;;;;AAcA,MAAM,gBAAA,GAAmB,MAAM;;AAE/B,MAAM,oBAAA,GAAuB,oDAAoD;;AAmFjF,MAAM,oBAAA,GAAuB;;AAK7B,CAAG,CAAC,EAAA,gBAAA,CAAA,OAAA,CAAA,EAAA,OAAA,IAAA;AACA,EAAA,OAAA,IAAA,yBAAA,CAAA;AACA,IAAA,WAAA,EAAA,OAAA,EAAA,WAAA;AACA,IAAA,sBAA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;;AAEA,IAAA,6BAAA,EAAA,KAAA;AACA,IAAA,6BAAA,EAAA,KAAA;AACA,IAAA,WAAA,EAAA,CAAA,IAAA,EAAA,GAAA,KAAA;AACA,MAAA,eAAA,CAAA,IAAA,EAAA,qBAAA,CAAA;AACA,MAAA,IAAA,CAAA,gBAAA,CAAA,GAAA,CAAA,IAAA,sBAAA,CAAA,GAAA,CAAA,EAAA;AACA,QAAA,IAAA,CAAA,YAAA,CAAA,sBAAA,EAAA,IAAA,CAAA;AACA;;AAEA,MAAA,OAAA,CAAA,eAAA,EAAA,WAAA,GAAA,IAAA,EAAA,GAAA,CAAA;AACA,KAAA;AACA,IAAA,YAAA,EAAA,CAAA,IAAA,EAAA,GAAA,KAAA;AACA,MAAA,OAAA,CAAA,eAAA,EAAA,YAAA,GAAA,IAAA,EAAA,GAAA,CAAA;AACA,KAAA;AACA,IAAA,2BAAA,EAAA;AACA,MAAA,IAAA;AACA,MAAA,OAAA;AACA,MAAA,QAAA;AACA,SAAA;AACA,MAAA,OAAA,CAAA,eAAA,EAAA,2BAAA,GAAA,IAAA,EAAA,OAAA,EAAA,QAAA,CAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAA,OAAA,qBAAA;AACA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getRequestInfo.js","sources":["../../../../../src/integrations/http/vendor/getRequestInfo.ts"],"sourcesContent":["/* eslint-disable complexity */\n\n/**\n * Vendored in from https://github.com/open-telemetry/opentelemetry-js/commit/87bd98edd24c98a5fbb9a56fed4b673b7f17a724\n */\n\n/*\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 */\nimport type { RequestOptions } from 'node:http';\nimport * as url from 'url';\nimport type { DiagLogger } from '@opentelemetry/api';\n\n/**\n * Makes sure options is an url object\n * return an object with default value and parsed options\n * @param logger component logger\n * @param options original options for the request\n * @param [extraOptions] additional options for the request\n */\nexport const getRequestInfo = (\n logger: DiagLogger,\n options: url.URL | RequestOptions | string,\n extraOptions?: RequestOptions,\n): {\n origin: string;\n pathname: string;\n method: string;\n invalidUrl: boolean;\n optionsParsed: RequestOptions;\n} => {\n let pathname: string;\n let origin: string;\n let optionsParsed: RequestOptions;\n let invalidUrl = false;\n if (typeof options === 'string') {\n try {\n const convertedOptions = stringUrlToHttpOptions(options);\n optionsParsed = convertedOptions;\n pathname = convertedOptions.pathname || '/';\n } catch (e) {\n invalidUrl = true;\n logger.verbose(\n 'Unable to parse URL provided to HTTP request, using fallback to determine path. Original error:',\n e,\n );\n // for backward compatibility with how url.parse() behaved.\n optionsParsed = {\n path: options,\n };\n pathname = optionsParsed.path || '/';\n }\n\n origin = `${optionsParsed.protocol || 'http:'}//${optionsParsed.host}`;\n if (extraOptions !== undefined) {\n Object.assign(optionsParsed, extraOptions);\n }\n } else if (options instanceof url.URL) {\n optionsParsed = {\n protocol: options.protocol,\n hostname:\n typeof options.hostname === 'string' && options.hostname.startsWith('[')\n ? options.hostname.slice(1, -1)\n : options.hostname,\n path: `${options.pathname || ''}${options.search || ''}`,\n };\n if (options.port !== '') {\n optionsParsed.port = Number(options.port);\n }\n if (options.username || options.password) {\n optionsParsed.auth = `${options.username}:${options.password}`;\n }\n pathname = options.pathname;\n origin = options.origin;\n if (extraOptions !== undefined) {\n Object.assign(optionsParsed, extraOptions);\n }\n } else {\n optionsParsed = Object.assign({ protocol: options.host ? 'http:' : undefined }, options);\n\n const hostname =\n optionsParsed.host ||\n (optionsParsed.port != null ? `${optionsParsed.hostname}${optionsParsed.port}` : optionsParsed.hostname);\n origin = `${optionsParsed.protocol || 'http:'}//${hostname}`;\n\n pathname = (options as url.URL).pathname;\n if (!pathname && optionsParsed.path) {\n try {\n const parsedUrl = new URL(optionsParsed.path, origin);\n pathname = parsedUrl.pathname || '/';\n } catch (e) {\n pathname = '/';\n }\n }\n }\n\n // some packages return method in lowercase..\n // ensure upperCase for consistency\n const method = optionsParsed.method ? optionsParsed.method.toUpperCase() : 'GET';\n\n return { origin, pathname, method, optionsParsed, invalidUrl };\n};\n\n/**\n * Mimics Node.js conversion of URL strings to RequestOptions expected by\n * `http.request` and `https.request` APIs.\n *\n * See https://github.com/nodejs/node/blob/2505e217bba05fc581b572c685c5cf280a16c5a3/lib/internal/url.js#L1415-L1437\n *\n * @param stringUrl\n * @throws TypeError if the URL is not valid.\n */\nfunction stringUrlToHttpOptions(stringUrl: string): RequestOptions & { pathname: string } {\n // This is heavily inspired by Node.js handling of the same situation, trying\n // to follow it as closely as possible while keeping in mind that we only\n // deal with string URLs, not URL objects.\n const { hostname, pathname, port, username, password, search, protocol, hash, href, origin, host } = new URL(\n stringUrl,\n );\n\n const options: RequestOptions & {\n pathname: string;\n hash: string;\n search: string;\n href: string;\n origin: string;\n } = {\n protocol: protocol,\n hostname: hostname && hostname[0] === '[' ? hostname.slice(1, -1) : hostname,\n hash: hash,\n search: search,\n pathname: pathname,\n path: `${pathname || ''}${search || ''}`,\n href: href,\n origin: origin,\n host: host,\n };\n if (port !== '') {\n options.port = Number(port);\n }\n if (username || password) {\n options.auth = `${decodeURIComponent(username)}:${decodeURIComponent(password)}`;\n }\n return options;\n}\n"],"names":[],"mappings":";;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,iBAAiB;AAC9B,EAAE,MAAM;AACR,EAAE,OAAO;AACT,EAAE,YAAY;;AAOd,KAAK;AACL,EAAE,IAAI,QAAQ;AACd,EAAE,IAAI,MAAM;AACZ,EAAE,IAAI,aAAa;AACnB,EAAE,IAAI,UAAW,GAAE,KAAK;AACxB,EAAE,IAAI,OAAO,OAAQ,KAAI,QAAQ,EAAE;AACnC,IAAI,I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"version":3,"file":"getRequestInfo.js","sources":["../../../../../src/integrations/http/vendor/getRequestInfo.ts"],"sourcesContent":["/* eslint-disable complexity */\n\n/**\n * Vendored in from https://github.com/open-telemetry/opentelemetry-js/commit/87bd98edd24c98a5fbb9a56fed4b673b7f17a724\n */\n\n/*\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 */\nimport type { RequestOptions } from 'node:http';\nimport * as url from 'url';\nimport type { DiagLogger } from '@opentelemetry/api';\n\n/**\n * Makes sure options is an url object\n * return an object with default value and parsed options\n * @param logger component logger\n * @param options original options for the request\n * @param [extraOptions] additional options for the request\n */\nexport const getRequestInfo = (\n logger: DiagLogger,\n options: url.URL | RequestOptions | string,\n extraOptions?: RequestOptions,\n): {\n origin: string;\n pathname: string;\n method: string;\n invalidUrl: boolean;\n optionsParsed: RequestOptions;\n} => {\n let pathname: string;\n let origin: string;\n let optionsParsed: RequestOptions;\n let invalidUrl = false;\n if (typeof options === 'string') {\n try {\n const convertedOptions = stringUrlToHttpOptions(options);\n optionsParsed = convertedOptions;\n pathname = convertedOptions.pathname || '/';\n } catch (e) {\n invalidUrl = true;\n logger.verbose(\n 'Unable to parse URL provided to HTTP request, using fallback to determine path. Original error:',\n e,\n );\n // for backward compatibility with how url.parse() behaved.\n optionsParsed = {\n path: options,\n };\n pathname = optionsParsed.path || '/';\n }\n\n origin = `${optionsParsed.protocol || 'http:'}//${optionsParsed.host}`;\n if (extraOptions !== undefined) {\n Object.assign(optionsParsed, extraOptions);\n }\n } else if (options instanceof url.URL) {\n optionsParsed = {\n protocol: options.protocol,\n hostname:\n typeof options.hostname === 'string' && options.hostname.startsWith('[')\n ? options.hostname.slice(1, -1)\n : options.hostname,\n path: `${options.pathname || ''}${options.search || ''}`,\n };\n if (options.port !== '') {\n optionsParsed.port = Number(options.port);\n }\n if (options.username || options.password) {\n optionsParsed.auth = `${options.username}:${options.password}`;\n }\n pathname = options.pathname;\n origin = options.origin;\n if (extraOptions !== undefined) {\n Object.assign(optionsParsed, extraOptions);\n }\n } else {\n optionsParsed = Object.assign({ protocol: options.host ? 'http:' : undefined }, options);\n\n const hostname =\n optionsParsed.host ||\n (optionsParsed.port != null ? `${optionsParsed.hostname}${optionsParsed.port}` : optionsParsed.hostname);\n origin = `${optionsParsed.protocol || 'http:'}//${hostname}`;\n\n pathname = (options as url.URL).pathname;\n if (!pathname && optionsParsed.path) {\n try {\n const parsedUrl = new URL(optionsParsed.path, origin);\n pathname = parsedUrl.pathname || '/';\n } catch (e) {\n pathname = '/';\n }\n }\n }\n\n // some packages return method in lowercase..\n // ensure upperCase for consistency\n const method = optionsParsed.method ? optionsParsed.method.toUpperCase() : 'GET';\n\n return { origin, pathname, method, optionsParsed, invalidUrl };\n};\n\n/**\n * Mimics Node.js conversion of URL strings to RequestOptions expected by\n * `http.request` and `https.request` APIs.\n *\n * See https://github.com/nodejs/node/blob/2505e217bba05fc581b572c685c5cf280a16c5a3/lib/internal/url.js#L1415-L1437\n *\n * @param stringUrl\n * @throws TypeError if the URL is not valid.\n */\nfunction stringUrlToHttpOptions(stringUrl: string): RequestOptions & { pathname: string } {\n // This is heavily inspired by Node.js handling of the same situation, trying\n // to follow it as closely as possible while keeping in mind that we only\n // deal with string URLs, not URL objects.\n const { hostname, pathname, port, username, password, search, protocol, hash, href, origin, host } = new URL(\n stringUrl,\n );\n\n const options: RequestOptions & {\n pathname: string;\n hash: string;\n search: string;\n href: string;\n origin: string;\n } = {\n protocol: protocol,\n hostname: hostname && hostname[0] === '[' ? hostname.slice(1, -1) : hostname,\n hash: hash,\n search: search,\n pathname: pathname,\n path: `${pathname || ''}${search || ''}`,\n href: href,\n origin: origin,\n host: host,\n };\n if (port !== '') {\n options.port = Number(port);\n }\n if (username || password) {\n options.auth = `${decodeURIComponent(username)}:${decodeURIComponent(password)}`;\n }\n return options;\n}\n"],"names":[],"mappings":";;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,iBAAiB;AAC9B,EAAE,MAAM;AACR,EAAE,OAAO;AACT,EAAE,YAAY;;AAOd,KAAK;AACL,EAAE,IAAI,QAAQ;AACd,EAAE,IAAI,MAAM;AACZ,EAAE,IAAI,aAAa;AACnB,EAAE,IAAI,UAAW,GAAE,KAAK;AACxB,EAAE,IAAI,OAAO,OAAQ,KAAI,QAAQ,EAAE;AACnC,IAAI,IAAI;AACR,MAAM,MAAM,gBAAiB,GAAE,sBAAsB,CAAC,OAAO,CAAC;AAC9D,MAAM,aAAA,GAAgB,gBAAgB;AACtC,MAAM,WAAW,gBAAgB,CAAC,QAAA,IAAY,GAAG;AACjD,KAAM,CAAA,OAAO,CAAC,EAAE;AAChB,MAAM,UAAA,GAAa,IAAI;AACvB,MAAM,MAAM,CAAC,OAAO;AACpB,QAAQ,iGAAiG;AACzG,QAAQ,CAAC;AACT,OAAO;AACP;AACA,MAAM,gBAAgB;AACtB,QAAQ,IAAI,EAAE,OAAO;AACrB,OAAO;AACP,MAAM,WAAW,aAAa,CAAC,IAAA,IAAQ,GAAG;AAC1C;;AAEA,IAAI,MAAA,GAAS,CAAC,EAAA,aAAA,CAAA,QAAA,IAAA,OAAA,CAAA,EAAA,EAAA,aAAA,CAAA,IAAA,CAAA,CAAA;AACA,IAAA,IAAA,YAAA,KAAA,SAAA,EAAA;AACA,MAAA,MAAA,CAAA,MAAA,CAAA,aAAA,EAAA,YAAA,CAAA;AACA;AACA,GAAA,MAAA,IAAA,OAAA,YAAA,GAAA,CAAA,GAAA,EAAA;AACA,IAAA,aAAA,GAAA;AACA,MAAA,QAAA,EAAA,OAAA,CAAA,QAAA;AACA,MAAA,QAAA;AACA,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