dd-trace 5.83.0 → 5.85.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 (630) hide show
  1. package/LICENSE-3rdparty.csv +0 -1
  2. package/ci/cypress/polyfills.js +1 -1
  3. package/ci/init.js +5 -5
  4. package/ext/exporters.js +1 -1
  5. package/ext/formats.js +1 -1
  6. package/ext/index.js +1 -1
  7. package/ext/kinds.js +1 -1
  8. package/ext/priority.js +1 -1
  9. package/ext/scopes.js +1 -1
  10. package/ext/tags.js +1 -1
  11. package/ext/types.js +1 -1
  12. package/index.d.ts +115 -2
  13. package/initialize.mjs +47 -31
  14. package/loader-hook.mjs +35 -22
  15. package/package.json +36 -33
  16. package/packages/datadog-code-origin/index.js +12 -10
  17. package/packages/datadog-core/src/utils/src/pick.js +2 -2
  18. package/packages/datadog-esbuild/index.js +75 -79
  19. package/packages/datadog-esbuild/src/log.js +32 -0
  20. package/packages/datadog-esbuild/src/utils.js +12 -8
  21. package/packages/datadog-instrumentations/src/aerospike.js +3 -3
  22. package/packages/datadog-instrumentations/src/ai.js +5 -5
  23. package/packages/datadog-instrumentations/src/amqp10.js +1 -1
  24. package/packages/datadog-instrumentations/src/amqplib.js +1 -1
  25. package/packages/datadog-instrumentations/src/anthropic.js +3 -3
  26. package/packages/datadog-instrumentations/src/apollo-server.js +4 -4
  27. package/packages/datadog-instrumentations/src/apollo.js +2 -2
  28. package/packages/datadog-instrumentations/src/avsc.js +1 -1
  29. package/packages/datadog-instrumentations/src/aws-sdk.js +4 -4
  30. package/packages/datadog-instrumentations/src/azure-event-hubs.js +2 -2
  31. package/packages/datadog-instrumentations/src/azure-functions.js +1 -1
  32. package/packages/datadog-instrumentations/src/azure-service-bus.js +1 -1
  33. package/packages/datadog-instrumentations/src/body-parser.js +2 -2
  34. package/packages/datadog-instrumentations/src/bunyan.js +1 -1
  35. package/packages/datadog-instrumentations/src/cassandra-driver.js +1 -1
  36. package/packages/datadog-instrumentations/src/child_process.js +7 -7
  37. package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +17 -16
  38. package/packages/datadog-instrumentations/src/cookie-parser.js +1 -1
  39. package/packages/datadog-instrumentations/src/couchbase.js +8 -6
  40. package/packages/datadog-instrumentations/src/crypto.js +1 -1
  41. package/packages/datadog-instrumentations/src/cucumber.js +19 -19
  42. package/packages/datadog-instrumentations/src/cypress.js +1 -1
  43. package/packages/datadog-instrumentations/src/dns.js +2 -2
  44. package/packages/datadog-instrumentations/src/elasticsearch.js +2 -2
  45. package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +2 -2
  46. package/packages/datadog-instrumentations/src/express-session.js +1 -1
  47. package/packages/datadog-instrumentations/src/express.js +4 -4
  48. package/packages/datadog-instrumentations/src/fastify.js +1 -1
  49. package/packages/datadog-instrumentations/src/fetch.js +2 -2
  50. package/packages/datadog-instrumentations/src/fs.js +7 -7
  51. package/packages/datadog-instrumentations/src/generic-pool.js +2 -2
  52. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +8 -8
  53. package/packages/datadog-instrumentations/src/google-cloud-vertexai.js +4 -4
  54. package/packages/datadog-instrumentations/src/google-genai.js +1 -1
  55. package/packages/datadog-instrumentations/src/graphql.js +10 -10
  56. package/packages/datadog-instrumentations/src/grpc/client.js +9 -13
  57. package/packages/datadog-instrumentations/src/grpc/types.js +1 -1
  58. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +1 -1
  59. package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +1 -1
  60. package/packages/datadog-instrumentations/src/helpers/extract-package-and-module-path.js +2 -2
  61. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -1
  62. package/packages/datadog-instrumentations/src/helpers/register.js +7 -7
  63. package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +6 -0
  64. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +1 -0
  65. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -1
  66. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langchain.js +55 -55
  67. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +74 -17
  68. package/packages/datadog-instrumentations/src/helpers/router-helper.js +7 -7
  69. package/packages/datadog-instrumentations/src/helpers/shared-utils.js +1 -1
  70. package/packages/datadog-instrumentations/src/hono.js +6 -6
  71. package/packages/datadog-instrumentations/src/http/client.js +1 -1
  72. package/packages/datadog-instrumentations/src/http/server.js +4 -4
  73. package/packages/datadog-instrumentations/src/http2/server.js +1 -1
  74. package/packages/datadog-instrumentations/src/ioredis.js +1 -1
  75. package/packages/datadog-instrumentations/src/iovalkey.js +1 -1
  76. package/packages/datadog-instrumentations/src/jest.js +250 -106
  77. package/packages/datadog-instrumentations/src/kafkajs.js +9 -8
  78. package/packages/datadog-instrumentations/src/knex.js +2 -2
  79. package/packages/datadog-instrumentations/src/koa.js +3 -1
  80. package/packages/datadog-instrumentations/src/ldapjs.js +1 -1
  81. package/packages/datadog-instrumentations/src/light-my-request.js +1 -1
  82. package/packages/datadog-instrumentations/src/limitd-client.js +1 -1
  83. package/packages/datadog-instrumentations/src/mariadb.js +1 -1
  84. package/packages/datadog-instrumentations/src/memcached.js +1 -1
  85. package/packages/datadog-instrumentations/src/mocha/common.js +3 -3
  86. package/packages/datadog-instrumentations/src/mocha/main.js +24 -24
  87. package/packages/datadog-instrumentations/src/mocha/utils.js +15 -11
  88. package/packages/datadog-instrumentations/src/mocha/worker.js +4 -4
  89. package/packages/datadog-instrumentations/src/moleculer/server.js +1 -1
  90. package/packages/datadog-instrumentations/src/mongodb-core.js +3 -3
  91. package/packages/datadog-instrumentations/src/mongodb.js +7 -7
  92. package/packages/datadog-instrumentations/src/mongoose.js +10 -10
  93. package/packages/datadog-instrumentations/src/mquery.js +6 -6
  94. package/packages/datadog-instrumentations/src/multer.js +1 -1
  95. package/packages/datadog-instrumentations/src/mysql.js +1 -1
  96. package/packages/datadog-instrumentations/src/net.js +6 -6
  97. package/packages/datadog-instrumentations/src/next.js +6 -6
  98. package/packages/datadog-instrumentations/src/nyc.js +34 -2
  99. package/packages/datadog-instrumentations/src/openai.js +24 -24
  100. package/packages/datadog-instrumentations/src/oracledb.js +2 -2
  101. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +1 -1
  102. package/packages/datadog-instrumentations/src/passport-http.js +1 -1
  103. package/packages/datadog-instrumentations/src/passport-local.js +1 -1
  104. package/packages/datadog-instrumentations/src/passport-utils.js +1 -1
  105. package/packages/datadog-instrumentations/src/passport.js +1 -1
  106. package/packages/datadog-instrumentations/src/pg.js +3 -3
  107. package/packages/datadog-instrumentations/src/pino.js +2 -2
  108. package/packages/datadog-instrumentations/src/playwright.js +71 -67
  109. package/packages/datadog-instrumentations/src/prisma.js +24 -78
  110. package/packages/datadog-instrumentations/src/promise-js.js +1 -1
  111. package/packages/datadog-instrumentations/src/promise.js +1 -1
  112. package/packages/datadog-instrumentations/src/protobufjs.js +6 -6
  113. package/packages/datadog-instrumentations/src/q.js +2 -2
  114. package/packages/datadog-instrumentations/src/redis.js +2 -2
  115. package/packages/datadog-instrumentations/src/rhea.js +5 -5
  116. package/packages/datadog-instrumentations/src/router.js +8 -8
  117. package/packages/datadog-instrumentations/src/selenium.js +3 -3
  118. package/packages/datadog-instrumentations/src/sequelize.js +1 -1
  119. package/packages/datadog-instrumentations/src/sharedb.js +2 -2
  120. package/packages/datadog-instrumentations/src/tedious.js +1 -1
  121. package/packages/datadog-instrumentations/src/undici.js +2 -2
  122. package/packages/datadog-instrumentations/src/url.js +5 -5
  123. package/packages/datadog-instrumentations/src/vitest.js +56 -45
  124. package/packages/datadog-instrumentations/src/when.js +1 -1
  125. package/packages/datadog-instrumentations/src/winston.js +1 -1
  126. package/packages/datadog-instrumentations/src/ws.js +128 -41
  127. package/packages/datadog-plugin-aerospike/src/index.js +4 -4
  128. package/packages/datadog-plugin-ai/src/index.js +1 -1
  129. package/packages/datadog-plugin-ai/src/tracing.js +2 -2
  130. package/packages/datadog-plugin-ai/src/utils.js +1 -1
  131. package/packages/datadog-plugin-amqp10/src/consumer.js +2 -2
  132. package/packages/datadog-plugin-amqp10/src/index.js +1 -1
  133. package/packages/datadog-plugin-amqp10/src/producer.js +2 -2
  134. package/packages/datadog-plugin-amqplib/src/client.js +2 -2
  135. package/packages/datadog-plugin-amqplib/src/consumer.js +2 -2
  136. package/packages/datadog-plugin-amqplib/src/index.js +1 -1
  137. package/packages/datadog-plugin-amqplib/src/producer.js +2 -2
  138. package/packages/datadog-plugin-amqplib/src/util.js +1 -1
  139. package/packages/datadog-plugin-anthropic/src/index.js +1 -1
  140. package/packages/datadog-plugin-anthropic/src/tracing.js +2 -2
  141. package/packages/datadog-plugin-apollo/src/gateway/fetch.js +1 -1
  142. package/packages/datadog-plugin-apollo/src/gateway/index.js +1 -1
  143. package/packages/datadog-plugin-apollo/src/gateway/request.js +5 -5
  144. package/packages/datadog-plugin-apollo/src/index.js +1 -1
  145. package/packages/datadog-plugin-avsc/src/schema_iterator.js +3 -3
  146. package/packages/datadog-plugin-aws-sdk/src/base.js +11 -10
  147. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +1 -1
  148. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +1 -1
  149. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +24 -24
  150. package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
  151. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +1 -1
  152. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +6 -6
  153. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +3 -3
  154. package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +1 -1
  155. package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
  156. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +5 -5
  157. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +12 -12
  158. package/packages/datadog-plugin-aws-sdk/src/util.js +1 -1
  159. package/packages/datadog-plugin-azure-event-hubs/src/index.js +1 -1
  160. package/packages/datadog-plugin-azure-event-hubs/src/producer.js +3 -3
  161. package/packages/datadog-plugin-azure-functions/src/index.js +11 -10
  162. package/packages/datadog-plugin-azure-service-bus/src/index.js +1 -1
  163. package/packages/datadog-plugin-azure-service-bus/src/producer.js +3 -3
  164. package/packages/datadog-plugin-bullmq/src/consumer.js +2 -2
  165. package/packages/datadog-plugin-bullmq/src/index.js +1 -1
  166. package/packages/datadog-plugin-bullmq/src/producer.js +11 -11
  167. package/packages/datadog-plugin-cassandra-driver/src/index.js +2 -2
  168. package/packages/datadog-plugin-child_process/src/index.js +2 -2
  169. package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +5 -5
  170. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +1 -1
  171. package/packages/datadog-plugin-couchbase/src/index.js +3 -3
  172. package/packages/datadog-plugin-cucumber/src/index.js +46 -45
  173. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +68 -55
  174. package/packages/datadog-plugin-cypress/src/plugin.js +1 -1
  175. package/packages/datadog-plugin-cypress/src/support.js +56 -9
  176. package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -1
  177. package/packages/datadog-plugin-dns/src/index.js +1 -1
  178. package/packages/datadog-plugin-dns/src/lookup.js +2 -2
  179. package/packages/datadog-plugin-dns/src/lookup_service.js +3 -3
  180. package/packages/datadog-plugin-dns/src/resolve.js +2 -2
  181. package/packages/datadog-plugin-dns/src/reverse.js +2 -2
  182. package/packages/datadog-plugin-elasticsearch/src/index.js +2 -2
  183. package/packages/datadog-plugin-express/src/index.js +1 -1
  184. package/packages/datadog-plugin-fastify/src/index.js +1 -1
  185. package/packages/datadog-plugin-fs/src/index.js +2 -2
  186. package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +2 -2
  187. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +8 -6
  188. package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -1
  189. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +11 -10
  190. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +6 -6
  191. package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +1 -1
  192. package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +2 -2
  193. package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +1 -1
  194. package/packages/datadog-plugin-google-genai/src/index.js +1 -1
  195. package/packages/datadog-plugin-google-genai/src/tracing.js +2 -2
  196. package/packages/datadog-plugin-graphql/src/execute.js +2 -2
  197. package/packages/datadog-plugin-graphql/src/index.js +2 -2
  198. package/packages/datadog-plugin-graphql/src/parse.js +1 -1
  199. package/packages/datadog-plugin-graphql/src/resolve.js +6 -6
  200. package/packages/datadog-plugin-graphql/src/utils.js +1 -1
  201. package/packages/datadog-plugin-graphql/src/validate.js +2 -2
  202. package/packages/datadog-plugin-grpc/src/client.js +3 -3
  203. package/packages/datadog-plugin-grpc/src/index.js +1 -1
  204. package/packages/datadog-plugin-grpc/src/server.js +3 -3
  205. package/packages/datadog-plugin-grpc/src/util.js +2 -2
  206. package/packages/datadog-plugin-http/src/client.js +10 -10
  207. package/packages/datadog-plugin-http/src/index.js +1 -1
  208. package/packages/datadog-plugin-http2/src/client.js +6 -6
  209. package/packages/datadog-plugin-http2/src/index.js +1 -1
  210. package/packages/datadog-plugin-http2/src/server.js +1 -1
  211. package/packages/datadog-plugin-jest/src/index.js +39 -22
  212. package/packages/datadog-plugin-jest/src/util.js +1 -1
  213. package/packages/datadog-plugin-kafkajs/src/consumer.js +5 -5
  214. package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
  215. package/packages/datadog-plugin-kafkajs/src/producer.js +5 -5
  216. package/packages/datadog-plugin-kafkajs/src/utils.js +1 -1
  217. package/packages/datadog-plugin-langchain/src/tokens.js +2 -2
  218. package/packages/datadog-plugin-langchain/src/tracing.js +4 -4
  219. package/packages/datadog-plugin-memcached/src/index.js +2 -2
  220. package/packages/datadog-plugin-mocha/src/index.js +12 -12
  221. package/packages/datadog-plugin-moleculer/src/client.js +1 -1
  222. package/packages/datadog-plugin-moleculer/src/index.js +1 -1
  223. package/packages/datadog-plugin-moleculer/src/server.js +2 -2
  224. package/packages/datadog-plugin-moleculer/src/util.js +1 -1
  225. package/packages/datadog-plugin-mongodb-core/src/index.js +5 -5
  226. package/packages/datadog-plugin-mysql/src/index.js +2 -2
  227. package/packages/datadog-plugin-net/src/ipc.js +2 -2
  228. package/packages/datadog-plugin-net/src/tcp.js +4 -4
  229. package/packages/datadog-plugin-next/src/index.js +4 -4
  230. package/packages/datadog-plugin-nyc/src/index.js +60 -0
  231. package/packages/datadog-plugin-openai/src/index.js +1 -1
  232. package/packages/datadog-plugin-openai/src/services.js +3 -3
  233. package/packages/datadog-plugin-openai/src/stream-helpers.js +1 -1
  234. package/packages/datadog-plugin-openai/src/tracing.js +10 -10
  235. package/packages/datadog-plugin-oracledb/src/connection-parser.js +1 -1
  236. package/packages/datadog-plugin-oracledb/src/index.js +1 -1
  237. package/packages/datadog-plugin-pg/src/index.js +2 -2
  238. package/packages/datadog-plugin-playwright/src/index.js +42 -42
  239. package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +95 -0
  240. package/packages/datadog-plugin-prisma/src/index.js +129 -10
  241. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +3 -3
  242. package/packages/datadog-plugin-redis/src/index.js +2 -2
  243. package/packages/datadog-plugin-restify/src/index.js +1 -1
  244. package/packages/datadog-plugin-rhea/src/consumer.js +2 -2
  245. package/packages/datadog-plugin-rhea/src/index.js +1 -1
  246. package/packages/datadog-plugin-rhea/src/producer.js +2 -2
  247. package/packages/datadog-plugin-router/src/index.js +3 -3
  248. package/packages/datadog-plugin-selenium/src/index.js +2 -2
  249. package/packages/datadog-plugin-sharedb/src/index.js +2 -2
  250. package/packages/datadog-plugin-tedious/src/index.js +2 -2
  251. package/packages/datadog-plugin-undici/src/index.js +5 -5
  252. package/packages/datadog-plugin-vitest/src/index.js +39 -18
  253. package/packages/datadog-plugin-ws/src/close.js +10 -11
  254. package/packages/datadog-plugin-ws/src/index.js +1 -1
  255. package/packages/datadog-plugin-ws/src/producer.js +8 -9
  256. package/packages/datadog-plugin-ws/src/receiver.js +8 -9
  257. package/packages/datadog-plugin-ws/src/server.js +17 -12
  258. package/packages/datadog-plugin-ws/src/util.js +48 -16
  259. package/packages/datadog-shimmer/src/shimmer.js +5 -8
  260. package/packages/dd-trace/index.js +2 -2
  261. package/packages/dd-trace/src/agent/info.js +57 -0
  262. package/packages/dd-trace/src/agent/url.js +28 -0
  263. package/packages/dd-trace/src/aiguard/client.js +3 -3
  264. package/packages/dd-trace/src/aiguard/sdk.js +6 -6
  265. package/packages/dd-trace/src/aiguard/tags.js +1 -1
  266. package/packages/dd-trace/src/analytics_sampler.js +1 -1
  267. package/packages/dd-trace/src/appsec/activation.js +1 -1
  268. package/packages/dd-trace/src/appsec/addresses.js +1 -1
  269. package/packages/dd-trace/src/appsec/api_security_sampler.js +1 -1
  270. package/packages/dd-trace/src/appsec/blocked_templates.js +1 -1
  271. package/packages/dd-trace/src/appsec/blocking.js +5 -5
  272. package/packages/dd-trace/src/appsec/channels.js +1 -1
  273. package/packages/dd-trace/src/appsec/graphql.js +13 -13
  274. package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +1 -1
  275. package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +1 -1
  276. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +6 -5
  277. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +2 -2
  278. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-rule-type.js +1 -1
  279. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +148 -148
  280. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +148 -148
  281. package/packages/dd-trace/src/appsec/iast/analyzers/index.js +1 -1
  282. package/packages/dd-trace/src/appsec/iast/analyzers/missing-header-analyzer.js +1 -1
  283. package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +7 -8
  284. package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +2 -2
  285. package/packages/dd-trace/src/appsec/iast/analyzers/set-cookies-header-interceptor.js +2 -2
  286. package/packages/dd-trace/src/appsec/iast/analyzers/unvalidated-redirect-analyzer.js +2 -2
  287. package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +3 -3
  288. package/packages/dd-trace/src/appsec/iast/analyzers/weak-cipher-analyzer.js +1 -1
  289. package/packages/dd-trace/src/appsec/iast/analyzers/weak-hash-analyzer.js +2 -2
  290. package/packages/dd-trace/src/appsec/iast/context/context-plugin.js +3 -3
  291. package/packages/dd-trace/src/appsec/iast/iast-context.js +6 -3
  292. package/packages/dd-trace/src/appsec/iast/iast-plugin.js +17 -9
  293. package/packages/dd-trace/src/appsec/iast/index.js +2 -2
  294. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +9 -9
  295. package/packages/dd-trace/src/appsec/iast/path-line.js +6 -6
  296. package/packages/dd-trace/src/appsec/iast/security-controls/index.js +11 -11
  297. package/packages/dd-trace/src/appsec/iast/security-controls/parser.js +49 -17
  298. package/packages/dd-trace/src/appsec/iast/tags.js +1 -1
  299. package/packages/dd-trace/src/appsec/iast/taint-tracking/constants.js +1 -1
  300. package/packages/dd-trace/src/appsec/iast/taint-tracking/csi-methods.js +2 -2
  301. package/packages/dd-trace/src/appsec/iast/taint-tracking/filter.js +1 -1
  302. package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +2 -2
  303. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +3 -6
  304. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +2 -2
  305. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +5 -5
  306. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +4 -4
  307. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +5 -5
  308. package/packages/dd-trace/src/appsec/iast/taint-tracking/secure-marks.js +6 -4
  309. package/packages/dd-trace/src/appsec/iast/taint-tracking/source-types.js +1 -1
  310. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +8 -8
  311. package/packages/dd-trace/src/appsec/iast/telemetry/iast-metric.js +4 -4
  312. package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +2 -2
  313. package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +6 -6
  314. package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +2 -2
  315. package/packages/dd-trace/src/appsec/iast/utils.js +3 -3
  316. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/constants.js +1 -1
  317. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/range-utils.js +1 -1
  318. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/hardcoded-password-analyzer.js +1 -1
  319. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +6 -6
  320. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/tainted-range-based-sensitive-analyzer.js +1 -1
  321. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +8 -8
  322. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +1 -1
  323. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +12 -11
  324. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +5 -5
  325. package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +1 -1
  326. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +4 -4
  327. package/packages/dd-trace/src/appsec/index.js +65 -27
  328. package/packages/dd-trace/src/appsec/rasp/command_injection.js +3 -3
  329. package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +4 -4
  330. package/packages/dd-trace/src/appsec/rasp/index.js +2 -2
  331. package/packages/dd-trace/src/appsec/rasp/lfi.js +5 -5
  332. package/packages/dd-trace/src/appsec/rasp/sql_injection.js +2 -2
  333. package/packages/dd-trace/src/appsec/rasp/ssrf.js +1 -1
  334. package/packages/dd-trace/src/appsec/rasp/utils.js +4 -4
  335. package/packages/dd-trace/src/appsec/rc-products.js +1 -1
  336. package/packages/dd-trace/src/appsec/remote_config.js +3 -3
  337. package/packages/dd-trace/src/appsec/reporter.js +11 -11
  338. package/packages/dd-trace/src/appsec/rule_manager.js +1 -1
  339. package/packages/dd-trace/src/appsec/sdk/index.js +1 -1
  340. package/packages/dd-trace/src/appsec/sdk/set_user.js +2 -2
  341. package/packages/dd-trace/src/appsec/sdk/track_event.js +7 -7
  342. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
  343. package/packages/dd-trace/src/appsec/sdk/utils.js +1 -1
  344. package/packages/dd-trace/src/appsec/stack_trace.js +5 -5
  345. package/packages/dd-trace/src/appsec/telemetry/common.js +3 -3
  346. package/packages/dd-trace/src/appsec/telemetry/index.js +5 -5
  347. package/packages/dd-trace/src/appsec/telemetry/rasp.js +3 -3
  348. package/packages/dd-trace/src/appsec/telemetry/user.js +4 -4
  349. package/packages/dd-trace/src/appsec/telemetry/waf.js +3 -3
  350. package/packages/dd-trace/src/appsec/user_tracking.js +7 -7
  351. package/packages/dd-trace/src/appsec/waf/diagnostics.js +2 -2
  352. package/packages/dd-trace/src/appsec/waf/index.js +1 -1
  353. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
  354. package/packages/dd-trace/src/azure_metadata.js +16 -9
  355. package/packages/dd-trace/src/baggage.js +1 -1
  356. package/packages/dd-trace/src/ci-visibility/coverage-report-discovery.js +82 -0
  357. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +5 -5
  358. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +9 -9
  359. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +8 -8
  360. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +11 -11
  361. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +4 -3
  362. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +8 -6
  363. package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +2 -0
  364. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +4 -3
  365. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +39 -20
  366. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +22 -22
  367. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +1 -1
  368. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +1 -1
  369. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +8 -8
  370. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +3 -3
  371. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +17 -12
  372. package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +92 -0
  373. package/packages/dd-trace/src/ci-visibility/telemetry.js +8 -4
  374. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +1 -1
  375. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +6 -6
  376. package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +61 -0
  377. package/packages/dd-trace/src/config/defaults.js +1 -1
  378. package/packages/dd-trace/src/config/git_properties.js +1 -1
  379. package/packages/dd-trace/src/config/helper.js +2 -2
  380. package/packages/dd-trace/src/config/index.js +645 -641
  381. package/packages/dd-trace/src/config/remote_config.js +2 -1
  382. package/packages/dd-trace/src/config/stable.js +2 -2
  383. package/packages/dd-trace/src/config/supported-configurations.json +2 -1
  384. package/packages/dd-trace/src/constants.js +3 -3
  385. package/packages/dd-trace/src/crashtracking/crashtracker.js +8 -11
  386. package/packages/dd-trace/src/datastreams/checkpointer.js +1 -1
  387. package/packages/dd-trace/src/datastreams/context.js +1 -1
  388. package/packages/dd-trace/src/datastreams/encoding.js +1 -1
  389. package/packages/dd-trace/src/datastreams/fnv.js +1 -1
  390. package/packages/dd-trace/src/datastreams/index.js +8 -8
  391. package/packages/dd-trace/src/datastreams/pathway.js +5 -3
  392. package/packages/dd-trace/src/datastreams/processor.js +14 -12
  393. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +27 -25
  394. package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +1 -1
  395. package/packages/dd-trace/src/datastreams/size.js +3 -3
  396. package/packages/dd-trace/src/datastreams/writer.js +5 -11
  397. package/packages/dd-trace/src/debugger/config.js +2 -1
  398. package/packages/dd-trace/src/debugger/constants.js +7 -0
  399. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +14 -10
  400. package/packages/dd-trace/src/debugger/devtools_client/condition.js +2 -2
  401. package/packages/dd-trace/src/debugger/devtools_client/config.js +6 -12
  402. package/packages/dd-trace/src/debugger/devtools_client/defaults.js +1 -1
  403. package/packages/dd-trace/src/debugger/devtools_client/index.js +32 -25
  404. package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +1 -1
  405. package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +10 -11
  406. package/packages/dd-trace/src/debugger/devtools_client/log.js +1 -1
  407. package/packages/dd-trace/src/debugger/devtools_client/send.js +54 -10
  408. package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +94 -37
  409. package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +4 -4
  410. package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +7 -7
  411. package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +2 -2
  412. package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +1 -1
  413. package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -1
  414. package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +10 -1
  415. package/packages/dd-trace/src/debugger/devtools_client/state.js +65 -8
  416. package/packages/dd-trace/src/debugger/devtools_client/status.js +9 -8
  417. package/packages/dd-trace/src/debugger/index.js +95 -37
  418. package/packages/dd-trace/src/dogstatsd.js +17 -18
  419. package/packages/dd-trace/src/encode/0.4.js +7 -6
  420. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +8 -8
  421. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +3 -3
  422. package/packages/dd-trace/src/encode/span-stats.js +2 -2
  423. package/packages/dd-trace/src/encode/tags-processors.js +1 -1
  424. package/packages/dd-trace/src/exporters/agent/index.js +5 -9
  425. package/packages/dd-trace/src/exporters/agent/writer.js +5 -4
  426. package/packages/dd-trace/src/exporters/common/agents.js +1 -1
  427. package/packages/dd-trace/src/exporters/common/{agent-info-exporter.js → buffering-exporter.js} +12 -39
  428. package/packages/dd-trace/src/exporters/common/docker.js +11 -7
  429. package/packages/dd-trace/src/exporters/common/request.js +28 -8
  430. package/packages/dd-trace/src/exporters/common/url-to-http-options-polyfill.js +2 -2
  431. package/packages/dd-trace/src/exporters/common/writer.js +2 -0
  432. package/packages/dd-trace/src/exporters/span-stats/index.js +4 -11
  433. package/packages/dd-trace/src/exporters/span-stats/writer.js +3 -3
  434. package/packages/dd-trace/src/external-logger/src/index.js +4 -4
  435. package/packages/dd-trace/src/flare/index.js +3 -3
  436. package/packages/dd-trace/src/guardrails/telemetry.js +1 -1
  437. package/packages/dd-trace/src/heap_snapshots.js +1 -1
  438. package/packages/dd-trace/src/id.js +1 -1
  439. package/packages/dd-trace/src/iitm.js +1 -1
  440. package/packages/dd-trace/src/lambda/handler.js +1 -1
  441. package/packages/dd-trace/src/lambda/runtime/errors.js +1 -1
  442. package/packages/dd-trace/src/lambda/runtime/ritm.js +3 -3
  443. package/packages/dd-trace/src/llmobs/constants/tags.js +1 -1
  444. package/packages/dd-trace/src/llmobs/constants/text.js +1 -1
  445. package/packages/dd-trace/src/llmobs/constants/writers.js +1 -1
  446. package/packages/dd-trace/src/llmobs/index.js +2 -4
  447. package/packages/dd-trace/src/llmobs/noop.js +2 -2
  448. package/packages/dd-trace/src/llmobs/plugins/ai/index.js +8 -8
  449. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +2 -2
  450. package/packages/dd-trace/src/llmobs/plugins/anthropic.js +5 -5
  451. package/packages/dd-trace/src/llmobs/plugins/base.js +1 -1
  452. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +8 -8
  453. package/packages/dd-trace/src/llmobs/plugins/genai/index.js +2 -2
  454. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +15 -15
  455. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +2 -2
  456. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +5 -5
  457. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +1 -1
  458. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +3 -3
  459. package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +1 -1
  460. package/packages/dd-trace/src/llmobs/plugins/openai/index.js +17 -17
  461. package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +3 -3
  462. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +6 -6
  463. package/packages/dd-trace/src/llmobs/sdk.js +11 -11
  464. package/packages/dd-trace/src/llmobs/span_processor.js +6 -6
  465. package/packages/dd-trace/src/llmobs/tagger.js +4 -4
  466. package/packages/dd-trace/src/llmobs/telemetry.js +8 -8
  467. package/packages/dd-trace/src/llmobs/util.js +1 -1
  468. package/packages/dd-trace/src/llmobs/writers/base.js +11 -17
  469. package/packages/dd-trace/src/llmobs/writers/evaluations.js +5 -5
  470. package/packages/dd-trace/src/llmobs/writers/spans.js +3 -3
  471. package/packages/dd-trace/src/llmobs/writers/util.js +4 -10
  472. package/packages/dd-trace/src/log/channels.js +2 -2
  473. package/packages/dd-trace/src/log/index.js +46 -31
  474. package/packages/dd-trace/src/log/log.js +1 -1
  475. package/packages/dd-trace/src/log/writer.js +14 -79
  476. package/packages/dd-trace/src/noop/span.js +2 -2
  477. package/packages/dd-trace/src/openfeature/constants/constants.js +1 -1
  478. package/packages/dd-trace/src/openfeature/flagging_provider.js +4 -4
  479. package/packages/dd-trace/src/openfeature/index.js +2 -2
  480. package/packages/dd-trace/src/openfeature/noop.js +3 -3
  481. package/packages/dd-trace/src/openfeature/remote_config.js +1 -1
  482. package/packages/dd-trace/src/openfeature/writers/base.js +14 -20
  483. package/packages/dd-trace/src/openfeature/writers/exposures.js +10 -10
  484. package/packages/dd-trace/src/openfeature/writers/util.js +4 -9
  485. package/packages/dd-trace/src/opentelemetry/context_manager.js +48 -29
  486. package/packages/dd-trace/src/opentelemetry/logs/index.js +2 -2
  487. package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +2 -2
  488. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +10 -10
  489. package/packages/dd-trace/src/opentelemetry/metrics/constants.js +3 -3
  490. package/packages/dd-trace/src/opentelemetry/metrics/index.js +2 -2
  491. package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +3 -3
  492. package/packages/dd-trace/src/opentelemetry/metrics/meter.js +1 -1
  493. package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +11 -11
  494. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +18 -18
  495. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +6 -6
  496. package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +10 -7
  497. package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +3 -3
  498. package/packages/dd-trace/src/opentelemetry/span.js +8 -8
  499. package/packages/dd-trace/src/opentelemetry/span_context.js +1 -1
  500. package/packages/dd-trace/src/opentelemetry/span_processor.js +1 -1
  501. package/packages/dd-trace/src/opentelemetry/tracer.js +4 -4
  502. package/packages/dd-trace/src/opentracing/propagation/log.js +2 -2
  503. package/packages/dd-trace/src/opentracing/propagation/text_map.js +14 -12
  504. package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -0
  505. package/packages/dd-trace/src/opentracing/span.js +20 -20
  506. package/packages/dd-trace/src/opentracing/span_context.js +3 -3
  507. package/packages/dd-trace/src/opentracing/tracer.js +3 -3
  508. package/packages/dd-trace/src/payload-tagging/config/index.js +1 -1
  509. package/packages/dd-trace/src/payload-tagging/index.js +1 -1
  510. package/packages/dd-trace/src/payload-tagging/tagging.js +2 -2
  511. package/packages/dd-trace/src/plugin_manager.js +6 -6
  512. package/packages/dd-trace/src/plugins/apollo.js +4 -4
  513. package/packages/dd-trace/src/plugins/ci_plugin.js +101 -36
  514. package/packages/dd-trace/src/plugins/database.js +1 -1
  515. package/packages/dd-trace/src/plugins/index.js +1 -1
  516. package/packages/dd-trace/src/plugins/log_plugin.js +2 -2
  517. package/packages/dd-trace/src/plugins/outbound.js +9 -8
  518. package/packages/dd-trace/src/plugins/plugin.js +17 -7
  519. package/packages/dd-trace/src/plugins/producer.js +6 -5
  520. package/packages/dd-trace/src/plugins/tracing.js +37 -8
  521. package/packages/dd-trace/src/plugins/util/ci.js +40 -40
  522. package/packages/dd-trace/src/plugins/util/env.js +2 -2
  523. package/packages/dd-trace/src/plugins/util/git-cache.js +2 -2
  524. package/packages/dd-trace/src/plugins/util/git.js +20 -18
  525. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +6 -6
  526. package/packages/dd-trace/src/plugins/util/ip_extractor.js +3 -3
  527. package/packages/dd-trace/src/plugins/util/llm.js +1 -1
  528. package/packages/dd-trace/src/plugins/util/stacktrace.js +3 -3
  529. package/packages/dd-trace/src/plugins/util/tags.js +1 -1
  530. package/packages/dd-trace/src/plugins/util/test.js +46 -40
  531. package/packages/dd-trace/src/plugins/util/url.js +1 -1
  532. package/packages/dd-trace/src/plugins/util/urlfilter.js +1 -1
  533. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
  534. package/packages/dd-trace/src/plugins/util/web.js +12 -12
  535. package/packages/dd-trace/src/priority_sampler.js +4 -4
  536. package/packages/dd-trace/src/process-tags/index.js +2 -2
  537. package/packages/dd-trace/src/profiler.js +1 -1
  538. package/packages/dd-trace/src/profiling/config.js +11 -14
  539. package/packages/dd-trace/src/profiling/constants.js +2 -2
  540. package/packages/dd-trace/src/profiling/exporter_cli.js +3 -3
  541. package/packages/dd-trace/src/profiling/exporters/agent.js +5 -5
  542. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +8 -8
  543. package/packages/dd-trace/src/profiling/index.js +1 -1
  544. package/packages/dd-trace/src/profiling/libuv-size.js +1 -1
  545. package/packages/dd-trace/src/profiling/loggers/console.js +1 -1
  546. package/packages/dd-trace/src/profiling/profiler.js +21 -23
  547. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +1 -1
  548. package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +3 -3
  549. package/packages/dd-trace/src/profiling/profilers/events.js +27 -19
  550. package/packages/dd-trace/src/profiling/profilers/shared.js +2 -2
  551. package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
  552. package/packages/dd-trace/src/profiling/tagger.js +1 -1
  553. package/packages/dd-trace/src/profiling/webspan-utils.js +2 -2
  554. package/packages/dd-trace/src/proxy.js +13 -13
  555. package/packages/dd-trace/src/remote_config/apply_states.js +1 -1
  556. package/packages/dd-trace/src/remote_config/capabilities.js +1 -0
  557. package/packages/dd-trace/src/remote_config/index.js +17 -22
  558. package/packages/dd-trace/src/remote_config/scheduler.js +1 -1
  559. package/packages/dd-trace/src/ritm.js +1 -1
  560. package/packages/dd-trace/src/runtime_metrics/index.js +2 -2
  561. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +3 -3
  562. package/packages/dd-trace/src/serverless.js +1 -1
  563. package/packages/dd-trace/src/service-naming/extra-services.js +1 -1
  564. package/packages/dd-trace/src/service-naming/index.js +1 -1
  565. package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +3 -3
  566. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +25 -25
  567. package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +3 -3
  568. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +18 -18
  569. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +23 -23
  570. package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +9 -9
  571. package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +3 -3
  572. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +21 -21
  573. package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +3 -3
  574. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -17
  575. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +23 -23
  576. package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +9 -9
  577. package/packages/dd-trace/src/span_format.js +4 -4
  578. package/packages/dd-trace/src/span_sampler.js +1 -1
  579. package/packages/dd-trace/src/span_stats.js +11 -11
  580. package/packages/dd-trace/src/spanleak.js +1 -1
  581. package/packages/dd-trace/src/standalone/index.js +1 -1
  582. package/packages/dd-trace/src/standalone/product.js +2 -2
  583. package/packages/dd-trace/src/standalone/tracesource.js +1 -1
  584. package/packages/dd-trace/src/startup-log.js +4 -4
  585. package/packages/dd-trace/src/tagger.js +3 -1
  586. package/packages/dd-trace/src/telemetry/dependencies.js +4 -4
  587. package/packages/dd-trace/src/telemetry/endpoints.js +4 -4
  588. package/packages/dd-trace/src/telemetry/index.js +1 -1
  589. package/packages/dd-trace/src/telemetry/logs/index.js +2 -2
  590. package/packages/dd-trace/src/telemetry/logs/log-collector.js +2 -2
  591. package/packages/dd-trace/src/telemetry/metrics.js +6 -6
  592. package/packages/dd-trace/src/telemetry/send-data.js +5 -5
  593. package/packages/dd-trace/src/telemetry/telemetry.js +10 -10
  594. package/packages/dd-trace/src/tracer.js +3 -2
  595. package/packages/dd-trace/src/util.js +1 -1
  596. package/scripts/preinstall.js +1 -1
  597. package/vendor/dist/@datadog/sketches-js/index.js +1 -1
  598. package/vendor/dist/@datadog/source-map/index.js +1 -1
  599. package/vendor/dist/@isaacs/ttlcache/index.js +1 -1
  600. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  601. package/vendor/dist/@opentelemetry/resources/index.js +1 -1
  602. package/vendor/dist/astring/index.js +1 -1
  603. package/vendor/dist/crypto-randomuuid/index.js +1 -1
  604. package/vendor/dist/escape-string-regexp/index.js +1 -1
  605. package/vendor/dist/esquery/index.js +1 -1
  606. package/vendor/dist/ignore/index.js +1 -1
  607. package/vendor/dist/istanbul-lib-coverage/index.js +1 -1
  608. package/vendor/dist/jest-docblock/index.js +1 -1
  609. package/vendor/dist/jsonpath-plus/index.js +1 -1
  610. package/vendor/dist/limiter/index.js +1 -1
  611. package/vendor/dist/lodash.sortby/index.js +1 -1
  612. package/vendor/dist/lru-cache/index.js +1 -1
  613. package/vendor/dist/meriyah/index.js +1 -1
  614. package/vendor/dist/module-details-from-path/index.js +1 -1
  615. package/vendor/dist/mutexify/promise/index.js +1 -1
  616. package/vendor/dist/opentracing/index.js +1 -1
  617. package/vendor/dist/path-to-regexp/index.js +1 -1
  618. package/vendor/dist/pprof-format/index.js +1 -1
  619. package/vendor/dist/protobufjs/index.js +1 -1
  620. package/vendor/dist/protobufjs/minimal/index.js +1 -1
  621. package/vendor/dist/retry/index.js +1 -1
  622. package/vendor/dist/rfdc/index.js +1 -1
  623. package/vendor/dist/semifies/index.js +1 -1
  624. package/vendor/dist/shell-quote/index.js +1 -1
  625. package/vendor/dist/source-map/index.js +1 -1
  626. package/vendor/dist/source-map/lib/util/index.js +1 -1
  627. package/vendor/dist/tlhunter-sorted-set/index.js +1 -1
  628. package/vendor/dist/ttl-set/index.js +1 -1
  629. package/packages/datadog-plugin-prisma/src/client.js +0 -60
  630. package/packages/datadog-plugin-prisma/src/engine.js +0 -81
@@ -13,17 +13,18 @@ const {
13
13
  getIsFaultyEarlyFlakeDetection,
14
14
  JEST_WORKER_LOGS_PAYLOAD_CODE,
15
15
  getTestEndLine,
16
- isModifiedTest
16
+ isModifiedTest,
17
17
  } = require('../../dd-trace/src/plugins/util/test')
18
18
  const {
19
19
  getFormattedJestTestParameters,
20
20
  getJestTestName,
21
- getJestSuitesToRun
21
+ getJestSuitesToRun,
22
22
  } = require('../../datadog-plugin-jest/src/util')
23
23
  const { addHook, channel } = require('./helpers/instrument')
24
24
 
25
25
  const testSessionStartCh = channel('ci:jest:session:start')
26
26
  const testSessionFinishCh = channel('ci:jest:session:finish')
27
+ const codeCoverageReportCh = channel('ci:jest:coverage-report')
27
28
 
28
29
  const testSessionConfigurationCh = channel('ci:jest:session:configuration')
29
30
 
@@ -91,6 +92,7 @@ const wrappedWorkers = new WeakSet()
91
92
  const testSuiteMockedFiles = new Map()
92
93
  const testsToBeRetried = new Set()
93
94
  const testSuiteAbsolutePathsWithFastCheck = new Set()
95
+ const testSuiteJestObjects = new Map()
94
96
 
95
97
  const BREAKPOINT_HIT_GRACE_PERIOD_MS = 200
96
98
  const ATR_RETRY_SUPPRESSION_FLAG = '_ddDisableAtrRetry'
@@ -237,6 +239,28 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
237
239
  }
238
240
  }
239
241
 
242
+ /**
243
+ * Jest mock state issue during test retries
244
+ *
245
+ * Problem:
246
+ * - Jest tracks mock function calls using internal state (call count, call arguments, etc.)
247
+ * - When a test is retried, the mock state is not automatically reset
248
+ * - This causes assertions like `toHaveBeenCalledTimes(1)` to fail because the call count
249
+ * accumulates across retries
250
+ *
251
+ * The solution is to clear all mocks before each retry attempt.
252
+ */
253
+ resetMockState () {
254
+ try {
255
+ const jestObject = testSuiteJestObjects.get(this.testSuiteAbsolutePath)
256
+ if (jestObject?.clearAllMocks) {
257
+ jestObject.clearAllMocks()
258
+ }
259
+ } catch (e) {
260
+ log.warn('Error resetting mock state', e)
261
+ }
262
+ }
263
+
240
264
  // This function returns an array if the known tests are valid and null otherwise.
241
265
  getKnownTestsForSuite (suiteKnownTests) {
242
266
  // `suiteKnownTests` is `this.testEnvironmentOptions._ddKnownTests`,
@@ -261,7 +285,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
261
285
  return {
262
286
  attemptToFix: [],
263
287
  disabled: [],
264
- quarantined: []
288
+ quarantined: [],
265
289
  }
266
290
  }
267
291
  let testManagementTestsForSuite = testManagementTests
@@ -274,10 +298,10 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
274
298
  const result = {
275
299
  attemptToFix: [],
276
300
  disabled: [],
277
- quarantined: []
301
+ quarantined: [],
278
302
  }
279
303
 
280
- Object.entries(testManagementTestsForSuite).forEach(([testName, { properties }]) => {
304
+ for (const [testName, { properties }] of Object.entries(testManagementTestsForSuite)) {
281
305
  if (properties?.attempt_to_fix) {
282
306
  result.attemptToFix.push(testName)
283
307
  }
@@ -287,7 +311,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
287
311
  if (properties?.quarantined) {
288
312
  result.quarantined.push(testName)
289
313
  }
290
- })
314
+ }
291
315
 
292
316
  return result
293
317
  }
@@ -296,7 +320,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
296
320
  retryTest ({
297
321
  jestEvent,
298
322
  retryCount,
299
- retryType
323
+ retryType,
300
324
  }) {
301
325
  const { testName, fn, timeout } = jestEvent
302
326
  for (let retryIndex = 0; retryIndex < retryCount; retryIndex++) {
@@ -339,8 +363,9 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
339
363
  if (event.name === 'test_start') {
340
364
  const testName = getJestTestName(event.test, this.getShouldStripSeedFromTestName())
341
365
  if (testsToBeRetried.has(testName)) {
342
- // This is needed because we're trying tests with the same name
366
+ // This is needed because we're retrying tests with the same name
343
367
  this.resetSnapshotState()
368
+ this.resetMockState()
344
369
  }
345
370
 
346
371
  let isNewTest = false
@@ -404,7 +429,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
404
429
  isDisabled,
405
430
  isQuarantined,
406
431
  isModified,
407
- testSuiteAbsolutePath: this.testSuiteAbsolutePath
432
+ testSuiteAbsolutePath: this.testSuiteAbsolutePath,
408
433
  }
409
434
  testContexts.set(event.test, ctx)
410
435
 
@@ -451,7 +476,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
451
476
  this.retryTest({
452
477
  jestEvent: event,
453
478
  retryCount: testManagementAttemptToFixRetries,
454
- retryType: 'Test Management (Attempt to Fix)'
479
+ retryType: 'Test Management (Attempt to Fix)',
455
480
  })
456
481
  }
457
482
  if (!isAttemptToFix && this.isImpactedTestsEnabled) {
@@ -470,7 +495,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
470
495
  this.retryTest({
471
496
  jestEvent: event,
472
497
  retryCount: earlyFlakeDetectionNumRetries,
473
- retryType: 'Impacted tests'
498
+ retryType: 'Impacted tests',
474
499
  })
475
500
  }
476
501
  }
@@ -483,7 +508,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
483
508
  this.retryTest({
484
509
  jestEvent: event,
485
510
  retryCount: earlyFlakeDetectionNumRetries,
486
- retryType: 'Early flake detection'
511
+ retryType: 'Early flake detection',
487
512
  })
488
513
  }
489
514
  }
@@ -536,8 +561,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
536
561
 
537
562
  let isEfdRetry = false
538
563
  // We'll store the test statuses of the retries
564
+ const testName = getJestTestName(event.test, this.getShouldStripSeedFromTestName())
539
565
  if (this.isKnownTestsEnabled) {
540
- const testName = getJestTestName(event.test, this.getShouldStripSeedFromTestName())
541
566
  const isNewTest = retriedTestsToNumAttempts.has(testName)
542
567
  if (isNewTest) {
543
568
  if (newTestsTestStatuses.has(testName)) {
@@ -552,18 +577,27 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
552
577
  const promises = {}
553
578
  const numRetries = this.global[RETRY_TIMES]
554
579
  const numTestExecutions = event.test?.invocations
555
- const willBeRetried = numRetries > 0 && numTestExecutions - 1 < numRetries
580
+ const willBeRetriedByFailedTestReplay = numRetries > 0 && numTestExecutions - 1 < numRetries
556
581
  const mightHitBreakpoint = this.isDiEnabled && numTestExecutions >= 2
557
582
 
558
583
  const ctx = testContexts.get(event.test)
559
584
 
585
+ const finalStatus = this.getFinalStatus(testName,
586
+ status,
587
+ !!ctx?.isNew,
588
+ !!ctx?.isModified,
589
+ isEfdRetry,
590
+ isAttemptToFix,
591
+ numTestExecutions)
592
+
560
593
  if (status === 'fail') {
561
- const shouldSetProbe = this.isDiEnabled && willBeRetried && numTestExecutions === 1
594
+ const shouldSetProbe = this.isDiEnabled && willBeRetriedByFailedTestReplay && numTestExecutions === 1
562
595
  testErrCh.publish({
563
596
  ...ctx.currentStore,
564
597
  error: formatJestError(event.test.errors[0]),
565
598
  shouldSetProbe,
566
- promises
599
+ promises,
600
+ finalStatus,
567
601
  })
568
602
  }
569
603
 
@@ -589,7 +623,8 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
589
623
  attemptToFixPassed,
590
624
  failedAllTests,
591
625
  attemptToFixFailed,
592
- isAtrRetry
626
+ isAtrRetry,
627
+ finalStatus,
593
628
  })
594
629
 
595
630
  if (promises.isProbeReady) {
@@ -611,13 +646,102 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
611
646
  testSourceFile: this.testSourceFile,
612
647
  displayName: this.displayName,
613
648
  frameworkVersion: jestVersion,
614
- testStartLine: getTestLineStart(event.test.asyncError, this.testSuite)
649
+ testStartLine: getTestLineStart(event.test.asyncError, this.testSuite),
615
650
  },
616
- isDisabled: this.testManagementTestsForThisSuite?.disabled?.includes(testName)
651
+ isDisabled: this.testManagementTestsForThisSuite?.disabled?.includes(testName),
617
652
  })
618
653
  }
619
654
  }
620
655
 
656
+ getEfdResult ({ testName, isNewTest, isModifiedTest, isEfdRetry, numberOfExecutedRetries }) {
657
+ const isEfdEnabled = this.isEarlyFlakeDetectionEnabled
658
+ const isEfdActive = isEfdEnabled && (isNewTest || isModifiedTest)
659
+ const isLastEfdRetry = isEfdRetry && numberOfExecutedRetries >= (earlyFlakeDetectionNumRetries + 1)
660
+ const isFinalEfdTestExecution = isEfdActive && isLastEfdRetry
661
+
662
+ let finalStatus
663
+ if (isEfdActive && isFinalEfdTestExecution) {
664
+ // For EFD: The framework reports 'pass' if ANY attempt passed (flaky but not failing)
665
+ const testStatuses = newTestsTestStatuses.get(testName)
666
+ finalStatus = testStatuses && testStatuses.includes('pass') ? 'pass' : 'fail'
667
+ }
668
+
669
+ return { isEfdEnabled, isEfdActive, isFinalEfdTestExecution, finalStatus }
670
+ }
671
+
672
+ getAtrResult ({ status, isEfdRetry, isAttemptToFix, numberOfTestInvocations }) {
673
+ const isAtrEnabled =
674
+ this.isFlakyTestRetriesEnabled &&
675
+ !isEfdRetry &&
676
+ !isAttemptToFix &&
677
+ Number.isFinite(this.global[RETRY_TIMES])
678
+ const isLastAtrRetry =
679
+ status === 'pass' || numberOfTestInvocations >= (Number(this.global[RETRY_TIMES]) + 1)
680
+ const isFinalAtrTestExecution = isAtrEnabled && isLastAtrRetry
681
+
682
+ // For ATR: The last execution's status is what the framework reports
683
+ return { isAtrEnabled, isFinalAtrTestExecution, finalStatus: status }
684
+ }
685
+
686
+ getAttemptToFixResult ({ testName, isAttemptToFix, numberOfExecutedRetries }) {
687
+ const isAttemptToFixEnabled =
688
+ this.isTestManagementTestsEnabled &&
689
+ isAttemptToFix &&
690
+ Number.isFinite(testManagementAttemptToFixRetries)
691
+ const isFinalAttemptToFixExecution = isAttemptToFixEnabled &&
692
+ numberOfExecutedRetries >= (testManagementAttemptToFixRetries + 1)
693
+
694
+ let finalStatus
695
+ if (isAttemptToFixEnabled && isFinalAttemptToFixExecution) {
696
+ // For Attempt to Fix: 'pass' only if ALL attempts passed, 'fail' if ANY failed
697
+ const testStatuses = attemptToFixRetriedTestsStatuses.get(testName)
698
+ finalStatus = testStatuses && testStatuses.every(status => status === 'pass') ? 'pass' : 'fail'
699
+ }
700
+
701
+ return { isAttemptToFixEnabled, isFinalAttemptToFixExecution, finalStatus }
702
+ }
703
+
704
+ getFinalStatus (testName, status, isNewTest, isModifiedTest, isEfdRetry, isAttemptToFix, numberOfTestInvocations) {
705
+ const numberOfExecutedRetries = retriedTestsToNumAttempts.get(testName) ?? 0
706
+
707
+ const efdResult = this.getEfdResult({
708
+ testName,
709
+ isNewTest,
710
+ isModifiedTest,
711
+ isEfdRetry,
712
+ numberOfExecutedRetries,
713
+ })
714
+ const atrResult = this.getAtrResult({ status, isEfdRetry, isAttemptToFix, numberOfTestInvocations })
715
+ const attemptToFixResult = this.getAttemptToFixResult({
716
+ testName,
717
+ isAttemptToFix,
718
+ numberOfExecutedRetries,
719
+ })
720
+
721
+ // When no retry features are active, every test execution is final
722
+ const noRetryFeaturesActive =
723
+ !efdResult.isEfdActive &&
724
+ !atrResult.isAtrEnabled &&
725
+ !attemptToFixResult.isAttemptToFixEnabled
726
+ const isFinalTestExecution = noRetryFeaturesActive ||
727
+ efdResult.isFinalEfdTestExecution ||
728
+ atrResult.isFinalAtrTestExecution ||
729
+ attemptToFixResult.isFinalAttemptToFixExecution
730
+
731
+ if (!isFinalTestExecution) {
732
+ return
733
+ }
734
+
735
+ // If the test is quarantined, regardless of its actual execution result,
736
+ // the final status of its last execution should be reported as 'skip'.
737
+ if (this.isTestManagementTestsEnabled &&
738
+ this.testManagementTestsForThisSuite?.quarantined?.includes(testName)) {
739
+ return 'skip'
740
+ }
741
+
742
+ return efdResult.finalStatus || attemptToFixResult.finalStatus || atrResult.finalStatus
743
+ }
744
+
621
745
  teardown () {
622
746
  if (this._globalProxy?.propertyToValue) {
623
747
  for (const [key] of this._globalProxy.propertyToValue) {
@@ -643,7 +767,7 @@ function getTestEnvironment (pkg, jestVersion) {
643
767
  return wrappedTestEnvironment
644
768
  }
645
769
  return target[prop]
646
- }
770
+ },
647
771
  })
648
772
  }
649
773
  return getWrappedEnvironment(pkg, jestVersion)
@@ -652,9 +776,7 @@ function getTestEnvironment (pkg, jestVersion) {
652
776
  function applySuiteSkipping (originalTests, rootDir, frameworkVersion) {
653
777
  const jestSuitesToRun = getJestSuitesToRun(skippableSuites, originalTests, rootDir || process.cwd())
654
778
  hasFilteredSkippableSuites = true
655
- log.debug(
656
- () => `${jestSuitesToRun.suitesToRun.length} out of ${originalTests.length} suites are going to run.`
657
- )
779
+ log.debug('%d out of %d suites are going to run.', jestSuitesToRun.suitesToRun.length, originalTests.length)
658
780
  hasUnskippableSuites = jestSuitesToRun.hasUnskippableSuites
659
781
  hasForcedToRunSuites = jestSuitesToRun.hasForcedToRunSuites
660
782
 
@@ -668,17 +790,17 @@ function applySuiteSkipping (originalTests, rootDir, frameworkVersion) {
668
790
 
669
791
  addHook({
670
792
  name: 'jest-environment-node',
671
- versions: ['>=24.8.0']
793
+ versions: ['>=24.8.0'],
672
794
  }, getTestEnvironment)
673
795
 
674
796
  addHook({
675
797
  name: 'jest-environment-jsdom',
676
- versions: ['>=24.8.0']
798
+ versions: ['>=24.8.0'],
677
799
  }, getTestEnvironment)
678
800
 
679
801
  addHook({
680
802
  name: '@happy-dom/jest-environment',
681
- versions: ['>=10.0.0']
803
+ versions: ['>=10.0.0'],
682
804
  }, getTestEnvironment)
683
805
 
684
806
  function getWrappedScheduleTests (scheduleTests, frameworkVersion) {
@@ -864,13 +986,12 @@ function getCliWrapper (isNewJestVersion) {
864
986
 
865
987
  const {
866
988
  results: {
867
- success,
868
989
  coverageMap,
869
990
  numFailedTestSuites,
870
991
  numFailedTests,
871
992
  numTotalTests,
872
- numTotalTestSuites
873
- }
993
+ numTotalTestSuites,
994
+ },
874
995
  } = result
875
996
 
876
997
  let testCodeCoverageLinesTotal
@@ -883,53 +1004,6 @@ function getCliWrapper (isNewJestVersion) {
883
1004
  // ignore errors
884
1005
  }
885
1006
  }
886
- let status, error
887
-
888
- if (success) {
889
- status = numTotalTests === 0 && numTotalTestSuites === 0 ? 'skip' : 'pass'
890
- } else {
891
- status = 'fail'
892
- error = new Error(`Failed test suites: ${numFailedTestSuites}. Failed tests: ${numFailedTests}`)
893
- }
894
- let timeoutId
895
-
896
- // Pass the resolve callback to defer it to DC listener
897
- const flushPromise = new Promise((resolve) => {
898
- onDone = () => {
899
- clearTimeout(timeoutId)
900
- resolve()
901
- }
902
- })
903
-
904
- const timeoutPromise = new Promise((resolve) => {
905
- timeoutId = setTimeout(() => {
906
- resolve('timeout')
907
- }, FLUSH_TIMEOUT).unref()
908
- })
909
-
910
- testSessionFinishCh.publish({
911
- status,
912
- isSuitesSkipped,
913
- isSuitesSkippingEnabled,
914
- isCodeCoverageEnabled,
915
- testCodeCoverageLinesTotal,
916
- numSkippedSuites,
917
- hasUnskippableSuites,
918
- hasForcedToRunSuites,
919
- error,
920
- isEarlyFlakeDetectionEnabled,
921
- isEarlyFlakeDetectionFaulty,
922
- isTestManagementTestsEnabled,
923
- onDone
924
- })
925
-
926
- const waitingResult = await Promise.race([flushPromise, timeoutPromise])
927
-
928
- if (waitingResult === 'timeout') {
929
- log.error('Timeout waiting for the tracer to flush')
930
- }
931
-
932
- numSkippedSuites = 0
933
1007
 
934
1008
  /**
935
1009
  * If Early Flake Detection (EFD) is enabled the logic is as follows:
@@ -938,7 +1012,6 @@ function getCliWrapper (isNewJestVersion) {
938
1012
  * The rationale behind is the following: you may still be able to block your CI pipeline by gating
939
1013
  * on flakiness (the test will be considered flaky), but you may choose to unblock the pipeline too.
940
1014
  */
941
-
942
1015
  if (isEarlyFlakeDetectionEnabled) {
943
1016
  let numFailedTestsToIgnore = 0
944
1017
  for (const testStatuses of newTestsTestStatuses.values()) {
@@ -996,9 +1069,65 @@ function getCliWrapper (isNewJestVersion) {
996
1069
  }
997
1070
  }
998
1071
 
1072
+ // Determine session status after EFD and quarantine checks have potentially modified success
1073
+ let status, error
1074
+ if (result.results.success) {
1075
+ status = numTotalTests === 0 && numTotalTestSuites === 0 ? 'skip' : 'pass'
1076
+ } else {
1077
+ status = 'fail'
1078
+ error = new Error(`Failed test suites: ${numFailedTestSuites}. Failed tests: ${numFailedTests}`)
1079
+ }
1080
+
1081
+ let timeoutId
1082
+
1083
+ // Pass the resolve callback to defer it to DC listener
1084
+ const flushPromise = new Promise((resolve) => {
1085
+ onDone = () => {
1086
+ clearTimeout(timeoutId)
1087
+ resolve()
1088
+ }
1089
+ })
1090
+
1091
+ const timeoutPromise = new Promise((resolve) => {
1092
+ timeoutId = setTimeout(() => {
1093
+ resolve('timeout')
1094
+ }, FLUSH_TIMEOUT).unref()
1095
+ })
1096
+
1097
+ testSessionFinishCh.publish({
1098
+ status,
1099
+ isSuitesSkipped,
1100
+ isSuitesSkippingEnabled,
1101
+ isCodeCoverageEnabled,
1102
+ testCodeCoverageLinesTotal,
1103
+ numSkippedSuites,
1104
+ hasUnskippableSuites,
1105
+ hasForcedToRunSuites,
1106
+ error,
1107
+ isEarlyFlakeDetectionEnabled,
1108
+ isEarlyFlakeDetectionFaulty,
1109
+ isTestManagementTestsEnabled,
1110
+ onDone,
1111
+ })
1112
+
1113
+ const waitingResult = await Promise.race([flushPromise, timeoutPromise])
1114
+
1115
+ if (waitingResult === 'timeout') {
1116
+ log.error('Timeout waiting for the tracer to flush')
1117
+ }
1118
+
1119
+ if (codeCoverageReportCh.hasSubscribers) {
1120
+ const rootDir = result.globalConfig?.rootDir || process.cwd()
1121
+ await new Promise((resolve) => {
1122
+ codeCoverageReportCh.publish({ rootDir, onDone: resolve })
1123
+ })
1124
+ }
1125
+
1126
+ numSkippedSuites = 0
1127
+
999
1128
  return result
1000
1129
  }, {
1001
- replaceGetter: true
1130
+ replaceGetter: true,
1002
1131
  })
1003
1132
  }
1004
1133
  }
@@ -1027,7 +1156,7 @@ function coverageReporterWrapper (coverageReporter) {
1027
1156
  addHook({
1028
1157
  name: '@jest/core',
1029
1158
  file: 'build/TestScheduler.js',
1030
- versions: ['>=27.0.0']
1159
+ versions: ['>=27.0.0'],
1031
1160
  }, (testSchedulerPackage, frameworkVersion) => {
1032
1161
  const oldCreateTestScheduler = testSchedulerPackage.createTestScheduler
1033
1162
  const newCreateTestScheduler = async function () {
@@ -1046,7 +1175,7 @@ addHook({
1046
1175
  addHook({
1047
1176
  name: '@jest/core',
1048
1177
  file: 'build/TestScheduler.js',
1049
- versions: ['>=24.8.0 <27.0.0']
1178
+ versions: ['>=24.8.0 <27.0.0'],
1050
1179
  }, (testSchedulerPackage, frameworkVersion) => {
1051
1180
  shimmer.wrap(
1052
1181
  testSchedulerPackage.default.prototype,
@@ -1057,7 +1186,7 @@ addHook({
1057
1186
 
1058
1187
  addHook({
1059
1188
  name: '@jest/test-sequencer',
1060
- versions: ['>=28']
1189
+ versions: ['>=28'],
1061
1190
  }, (sequencerPackage, frameworkVersion) => {
1062
1191
  shimmer.wrap(sequencerPackage.default.prototype, 'shard', shard => function () {
1063
1192
  const shardedTests = shard.apply(this, arguments)
@@ -1076,18 +1205,18 @@ addHook({
1076
1205
  addHook({
1077
1206
  name: '@jest/reporters',
1078
1207
  file: 'build/coverage_reporter.js',
1079
- versions: ['>=24.8.0 <26.6.2']
1208
+ versions: ['>=24.8.0 <26.6.2'],
1080
1209
  }, coverageReporterWrapper)
1081
1210
 
1082
1211
  addHook({
1083
1212
  name: '@jest/reporters',
1084
1213
  file: 'build/CoverageReporter.js',
1085
- versions: ['>=26.6.2']
1214
+ versions: ['>=26.6.2'],
1086
1215
  }, coverageReporterWrapper)
1087
1216
 
1088
1217
  addHook({
1089
1218
  name: '@jest/reporters',
1090
- versions: ['>=30.0.0']
1219
+ versions: ['>=30.0.0'],
1091
1220
  }, (reporters) => {
1092
1221
  return shimmer.wrap(reporters, 'CoverageReporter', coverageReporterWrapper, { replaceGetter: true })
1093
1222
  })
@@ -1095,12 +1224,12 @@ addHook({
1095
1224
  addHook({
1096
1225
  name: '@jest/core',
1097
1226
  file: 'build/cli/index.js',
1098
- versions: ['>=24.8.0 <30.0.0']
1227
+ versions: ['>=24.8.0 <30.0.0'],
1099
1228
  }, getCliWrapper(false))
1100
1229
 
1101
1230
  addHook({
1102
1231
  name: '@jest/core',
1103
- versions: ['>=30.0.0']
1232
+ versions: ['>=30.0.0'],
1104
1233
  }, getCliWrapper(true))
1105
1234
 
1106
1235
  function jestAdapterWrapper (jestAdapter, jestVersion) {
@@ -1116,7 +1245,7 @@ function jestAdapterWrapper (jestAdapter, jestVersion) {
1116
1245
  testSourceFile: environment.testSourceFile,
1117
1246
  displayName: environment.displayName,
1118
1247
  frameworkVersion: jestVersion,
1119
- testSuiteAbsolutePath: environment.testSuiteAbsolutePath
1248
+ testSuiteAbsolutePath: environment.testSuiteAbsolutePath,
1120
1249
  })
1121
1250
  return adapter.apply(this, arguments).then(suiteResults => {
1122
1251
  const { numFailingTests, skipped, failureMessage: errorMessage } = suiteResults
@@ -1144,13 +1273,23 @@ function jestAdapterWrapper (jestAdapter, jestVersion) {
1144
1273
  coverageFiles,
1145
1274
  testSuite: environment.testSourceFile,
1146
1275
  mockedFiles,
1147
- testSuiteAbsolutePath: environment.testSuiteAbsolutePath
1276
+ testSuiteAbsolutePath: environment.testSuiteAbsolutePath,
1148
1277
  })
1149
1278
  }
1150
1279
  testSuiteFinishCh.publish({ status, errorMessage, testSuiteAbsolutePath: environment.testSuiteAbsolutePath })
1280
+
1281
+ // Cleanup per-suite state to avoid memory leaks
1282
+ testSuiteMockedFiles.delete(environment.testSuiteAbsolutePath)
1283
+ testSuiteJestObjects.delete(environment.testSuiteAbsolutePath)
1284
+
1151
1285
  return suiteResults
1152
1286
  }).catch(error => {
1153
1287
  testSuiteFinishCh.publish({ status: 'fail', error, testSuiteAbsolutePath: environment.testSuiteAbsolutePath })
1288
+
1289
+ // Cleanup per-suite state to avoid memory leaks
1290
+ testSuiteMockedFiles.delete(environment.testSuiteAbsolutePath)
1291
+ testSuiteJestObjects.delete(environment.testSuiteAbsolutePath)
1292
+
1154
1293
  throw error
1155
1294
  })
1156
1295
  })
@@ -1166,13 +1305,13 @@ function jestAdapterWrapper (jestAdapter, jestVersion) {
1166
1305
  addHook({
1167
1306
  name: 'jest-circus',
1168
1307
  file: 'build/runner.js',
1169
- versions: ['>=30.0.0']
1308
+ versions: ['>=30.0.0'],
1170
1309
  }, jestAdapterWrapper)
1171
1310
 
1172
1311
  addHook({
1173
1312
  name: 'jest-circus',
1174
1313
  file: 'build/legacy-code-todo-rewrite/jestAdapter.js',
1175
- versions: ['>=24.8.0']
1314
+ versions: ['>=24.8.0'],
1176
1315
  }, jestAdapterWrapper)
1177
1316
 
1178
1317
  function configureTestEnvironment (readConfigsResult) {
@@ -1180,9 +1319,9 @@ function configureTestEnvironment (readConfigsResult) {
1180
1319
  testSessionConfigurationCh.publish(configs.map(config => config.testEnvironmentOptions))
1181
1320
  // We can't directly use isCodeCoverageEnabled when reporting coverage in `jestAdapterWrapper`
1182
1321
  // because `jestAdapterWrapper` runs in a different process. We have to go through `testEnvironmentOptions`
1183
- configs.forEach(config => {
1322
+ for (const config of configs) {
1184
1323
  config.testEnvironmentOptions._ddTestCodeCoverageEnabled = isCodeCoverageEnabled
1185
- })
1324
+ }
1186
1325
 
1187
1326
  isUserCodeCoverageEnabled = !!readConfigsResult.globalConfig.collectCoverage
1188
1327
 
@@ -1193,7 +1332,7 @@ function configureTestEnvironment (readConfigsResult) {
1193
1332
  if (isCodeCoverageEnabled) {
1194
1333
  const globalConfig = {
1195
1334
  ...readConfigsResult.globalConfig,
1196
- collectCoverage: true
1335
+ collectCoverage: true,
1197
1336
  }
1198
1337
  readConfigsResult.globalConfig = globalConfig
1199
1338
  }
@@ -1204,7 +1343,7 @@ function configureTestEnvironment (readConfigsResult) {
1204
1343
  const globalConfig = {
1205
1344
  ...readConfigsResult.globalConfig,
1206
1345
  coverageReporters: ['none'],
1207
- passWithNoTests: true
1346
+ passWithNoTests: true,
1208
1347
  }
1209
1348
  readConfigsResult.globalConfig = globalConfig
1210
1349
  }
@@ -1231,7 +1370,7 @@ function jestConfigSyncWrapper (jestConfig) {
1231
1370
  addHook({
1232
1371
  name: '@jest/transform',
1233
1372
  versions: ['>=24.8.0'],
1234
- file: 'build/ScriptTransformer.js'
1373
+ file: 'build/ScriptTransformer.js',
1235
1374
  }, transformPackage => {
1236
1375
  const originalCreateScriptTransformer = transformPackage.createScriptTransformer
1237
1376
 
@@ -1277,18 +1416,18 @@ addHook({
1277
1416
  addHook({
1278
1417
  name: '@jest/core',
1279
1418
  versions: ['>=24.8.0 <30.0.0'],
1280
- file: 'build/SearchSource.js'
1419
+ file: 'build/SearchSource.js',
1281
1420
  }, searchSourceWrapper)
1282
1421
 
1283
1422
  // from 25.1.0 on, readConfigs becomes async
1284
1423
  addHook({
1285
1424
  name: 'jest-config',
1286
- versions: ['>=25.1.0']
1425
+ versions: ['>=25.1.0'],
1287
1426
  }, jestConfigAsyncWrapper)
1288
1427
 
1289
1428
  addHook({
1290
1429
  name: 'jest-config',
1291
- versions: ['24.8.0 - 24.9.0']
1430
+ versions: ['24.8.0 - 24.9.0'],
1292
1431
  }, jestConfigSyncWrapper)
1293
1432
 
1294
1433
  const LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE = new Set([
@@ -1299,12 +1438,12 @@ const LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE = new Set([
1299
1438
  'selenium-webdriver/firefox',
1300
1439
  'selenium-webdriver/ie',
1301
1440
  'selenium-webdriver/chromium',
1302
- 'winston'
1441
+ 'winston',
1303
1442
  ])
1304
1443
 
1305
1444
  addHook({
1306
1445
  name: 'jest-runtime',
1307
- versions: ['>=24.8.0']
1446
+ versions: ['>=24.8.0'],
1308
1447
  }, (runtimePackage) => {
1309
1448
  const Runtime = runtimePackage.default ?? runtimePackage
1310
1449
 
@@ -1312,6 +1451,11 @@ addHook({
1312
1451
  const result = _createJestObjectFor.apply(this, arguments)
1313
1452
  const suiteFilePath = this._testPath || from
1314
1453
 
1454
+ // Store the jest object so we can access it later for resetting mock state
1455
+ if (suiteFilePath) {
1456
+ testSuiteJestObjects.set(suiteFilePath, result)
1457
+ }
1458
+
1315
1459
  shimmer.wrap(result, 'mock', mock => function (moduleName) {
1316
1460
  // If the library is mocked with `jest.mock`, we don't want to bypass jest's own require engine
1317
1461
  if (LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE.has(moduleName)) {
@@ -1356,12 +1500,12 @@ addHook({
1356
1500
  const errorMessage = [...this.loggedReferenceErrors][0]
1357
1501
  testSuiteErrorCh.publish({
1358
1502
  errorMessage,
1359
- testSuiteAbsolutePath: this._testPath
1503
+ testSuiteAbsolutePath: this._testPath,
1360
1504
  })
1361
1505
  } else {
1362
1506
  testSuiteErrorCh.publish({
1363
1507
  errorMessage: 'An error occurred while importing a module',
1364
- testSuiteAbsolutePath: this._testPath
1508
+ testSuiteAbsolutePath: this._testPath,
1365
1509
  })
1366
1510
  }
1367
1511
  }
@@ -1427,8 +1571,8 @@ function sendWrapper (send) {
1427
1571
  _ddTestManagementTests: suiteTestManagementTests,
1428
1572
  // TODO: figure out if we can reduce the size of the modified files object
1429
1573
  // Can we use `testSuite` (it'd have to be relative to repository root though)
1430
- _ddModifiedFiles: modifiedFiles
1431
- }
1574
+ _ddModifiedFiles: modifiedFiles,
1575
+ },
1432
1576
  }
1433
1577
  }
1434
1578
  return send.apply(this, arguments)
@@ -1460,7 +1604,7 @@ function enqueueWrapper (enqueue) {
1460
1604
  addHook({
1461
1605
  name: 'jest-worker',
1462
1606
  versions: ['>=24.9.0 <30.0.0'],
1463
- file: 'build/workers/ChildProcessWorker.js'
1607
+ file: 'build/workers/ChildProcessWorker.js',
1464
1608
  }, (childProcessWorker) => {
1465
1609
  const ChildProcessWorker = childProcessWorker.default
1466
1610
  shimmer.wrap(ChildProcessWorker.prototype, 'send', sendWrapper)
@@ -1474,7 +1618,7 @@ addHook({
1474
1618
 
1475
1619
  addHook({
1476
1620
  name: 'jest-worker',
1477
- versions: ['>=30.0.0']
1621
+ versions: ['>=30.0.0'],
1478
1622
  }, (jestWorkerPackage) => {
1479
1623
  shimmer.wrap(jestWorkerPackage.FifoQueue.prototype, 'enqueue', enqueueWrapper)
1480
1624
  shimmer.wrap(jestWorkerPackage.PriorityQueue.prototype, 'enqueue', enqueueWrapper)