dd-trace 5.52.0 → 5.54.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 (332) hide show
  1. package/LICENSE-3rdparty.csv +2 -1
  2. package/README.md +5 -0
  3. package/index.d.ts +87 -22
  4. package/initialize.mjs +3 -4
  5. package/package.json +36 -34
  6. package/packages/datadog-core/src/utils/src/get.js +1 -1
  7. package/packages/datadog-core/src/utils/src/has.js +1 -1
  8. package/packages/datadog-core/src/utils/src/kebabcase.js +4 -6
  9. package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
  10. package/packages/datadog-core/src/utils/src/pick.js +2 -2
  11. package/packages/datadog-core/src/utils/src/set.js +1 -1
  12. package/packages/datadog-core/src/utils/src/uniq.js +1 -1
  13. package/packages/datadog-instrumentations/src/amqp10.js +19 -17
  14. package/packages/datadog-instrumentations/src/amqplib.js +57 -37
  15. package/packages/datadog-instrumentations/src/apollo.js +2 -2
  16. package/packages/datadog-instrumentations/src/aws-sdk.js +1 -1
  17. package/packages/datadog-instrumentations/src/cassandra-driver.js +5 -4
  18. package/packages/datadog-instrumentations/src/child_process.js +3 -3
  19. package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +92 -62
  20. package/packages/datadog-instrumentations/src/couchbase.js +5 -4
  21. package/packages/datadog-instrumentations/src/cucumber.js +126 -84
  22. package/packages/datadog-instrumentations/src/cypress.js +2 -1
  23. package/packages/datadog-instrumentations/src/dns.js +1 -1
  24. package/packages/datadog-instrumentations/src/express.js +2 -6
  25. package/packages/datadog-instrumentations/src/fs.js +7 -6
  26. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +28 -34
  27. package/packages/datadog-instrumentations/src/graphql.js +7 -10
  28. package/packages/datadog-instrumentations/src/grpc/client.js +11 -23
  29. package/packages/datadog-instrumentations/src/grpc/server.js +7 -20
  30. package/packages/datadog-instrumentations/src/helpers/extract-package-and-module-path.js +16 -10
  31. package/packages/datadog-instrumentations/src/helpers/hook.js +1 -1
  32. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -1
  33. package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -41
  34. package/packages/datadog-instrumentations/src/helpers/register.js +21 -18
  35. package/packages/datadog-instrumentations/src/http/client.js +16 -21
  36. package/packages/datadog-instrumentations/src/iovalkey.js +51 -0
  37. package/packages/datadog-instrumentations/src/jest.js +184 -87
  38. package/packages/datadog-instrumentations/src/kafkajs.js +65 -44
  39. package/packages/datadog-instrumentations/src/knex.js +4 -4
  40. package/packages/datadog-instrumentations/src/ldapjs.js +3 -4
  41. package/packages/datadog-instrumentations/src/mariadb.js +38 -61
  42. package/packages/datadog-instrumentations/src/mocha/main.js +85 -59
  43. package/packages/datadog-instrumentations/src/mocha/utils.js +103 -82
  44. package/packages/datadog-instrumentations/src/mocha/worker.js +6 -0
  45. package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
  46. package/packages/datadog-instrumentations/src/mysql.js +20 -36
  47. package/packages/datadog-instrumentations/src/mysql2.js +55 -47
  48. package/packages/datadog-instrumentations/src/net.js +4 -2
  49. package/packages/datadog-instrumentations/src/next.js +7 -14
  50. package/packages/datadog-instrumentations/src/nyc.js +1 -1
  51. package/packages/datadog-instrumentations/src/openai.js +21 -23
  52. package/packages/datadog-instrumentations/src/oracledb.js +1 -1
  53. package/packages/datadog-instrumentations/src/pg.js +6 -13
  54. package/packages/datadog-instrumentations/src/playwright.js +170 -136
  55. package/packages/datadog-instrumentations/src/redis.js +3 -3
  56. package/packages/datadog-instrumentations/src/restify.js +2 -2
  57. package/packages/datadog-instrumentations/src/rhea.js +42 -54
  58. package/packages/datadog-instrumentations/src/router.js +22 -25
  59. package/packages/datadog-instrumentations/src/tedious.js +1 -1
  60. package/packages/datadog-instrumentations/src/url.js +9 -17
  61. package/packages/datadog-instrumentations/src/vitest.js +126 -97
  62. package/packages/datadog-plugin-amqp10/src/consumer.js +7 -3
  63. package/packages/datadog-plugin-amqp10/src/producer.js +7 -3
  64. package/packages/datadog-plugin-amqplib/src/client.js +6 -2
  65. package/packages/datadog-plugin-amqplib/src/consumer.js +7 -3
  66. package/packages/datadog-plugin-amqplib/src/producer.js +7 -3
  67. package/packages/datadog-plugin-amqplib/src/util.js +1 -1
  68. package/packages/datadog-plugin-apollo/src/gateway/request.js +5 -6
  69. package/packages/datadog-plugin-apollo/src/gateway/validate.js +2 -3
  70. package/packages/datadog-plugin-aws-sdk/src/base.js +3 -2
  71. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +2 -2
  72. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +13 -13
  73. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +24 -31
  74. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
  75. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +6 -6
  76. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +1 -1
  77. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -1
  78. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -5
  79. package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +1 -1
  80. package/packages/datadog-plugin-aws-sdk/src/util.js +5 -6
  81. package/packages/datadog-plugin-cassandra-driver/src/index.js +1 -1
  82. package/packages/datadog-plugin-child_process/src/index.js +4 -4
  83. package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +23 -23
  84. package/packages/datadog-plugin-cucumber/src/index.js +86 -20
  85. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +97 -27
  86. package/packages/datadog-plugin-cypress/src/plugin.js +11 -1
  87. package/packages/datadog-plugin-cypress/src/support.js +24 -5
  88. package/packages/datadog-plugin-express/src/code_origin.js +30 -0
  89. package/packages/datadog-plugin-express/src/index.js +10 -12
  90. package/packages/datadog-plugin-express/src/tracing.js +19 -0
  91. package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +7 -3
  92. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +12 -7
  93. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +6 -2
  94. package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +26 -9
  95. package/packages/datadog-plugin-graphql/src/execute.js +2 -2
  96. package/packages/datadog-plugin-graphql/src/index.js +7 -6
  97. package/packages/datadog-plugin-graphql/src/resolve.js +2 -2
  98. package/packages/datadog-plugin-graphql/src/tools/index.js +1 -0
  99. package/packages/datadog-plugin-graphql/src/tools/signature.js +1 -0
  100. package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
  101. package/packages/datadog-plugin-grpc/src/client.js +2 -2
  102. package/packages/datadog-plugin-grpc/src/util.js +2 -2
  103. package/packages/datadog-plugin-http/src/client.js +18 -7
  104. package/packages/datadog-plugin-http2/src/client.js +20 -20
  105. package/packages/datadog-plugin-iovalkey/src/index.js +18 -0
  106. package/packages/datadog-plugin-jest/src/index.js +36 -28
  107. package/packages/datadog-plugin-jest/src/util.js +8 -8
  108. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +3 -1
  109. package/packages/datadog-plugin-kafkajs/src/consumer.js +9 -5
  110. package/packages/datadog-plugin-kafkajs/src/producer.js +15 -7
  111. package/packages/datadog-plugin-kafkajs/src/utils.js +1 -1
  112. package/packages/datadog-plugin-langchain/src/handlers/chain.js +7 -7
  113. package/packages/datadog-plugin-langchain/src/handlers/embedding.js +2 -2
  114. package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +6 -4
  115. package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +5 -4
  116. package/packages/datadog-plugin-langchain/src/tracing.js +11 -10
  117. package/packages/datadog-plugin-mariadb/src/index.js +3 -9
  118. package/packages/datadog-plugin-mocha/src/index.js +88 -48
  119. package/packages/datadog-plugin-mongodb-core/src/index.js +1 -1
  120. package/packages/datadog-plugin-mysql/src/index.js +11 -9
  121. package/packages/datadog-plugin-mysql2/src/index.js +16 -0
  122. package/packages/datadog-plugin-net/src/tcp.js +1 -1
  123. package/packages/datadog-plugin-next/src/index.js +6 -5
  124. package/packages/datadog-plugin-openai/src/services.js +6 -10
  125. package/packages/datadog-plugin-openai/src/tracing.js +10 -14
  126. package/packages/datadog-plugin-oracledb/src/index.js +1 -1
  127. package/packages/datadog-plugin-playwright/src/index.js +48 -22
  128. package/packages/datadog-plugin-redis/src/index.js +9 -4
  129. package/packages/datadog-plugin-rhea/src/consumer.js +8 -6
  130. package/packages/datadog-plugin-rhea/src/producer.js +5 -2
  131. package/packages/datadog-plugin-router/src/index.js +1 -1
  132. package/packages/datadog-plugin-selenium/src/index.js +1 -6
  133. package/packages/datadog-plugin-vitest/src/index.js +99 -72
  134. package/packages/datadog-shimmer/src/shimmer.js +163 -36
  135. package/packages/dd-trace/src/appsec/api_security_sampler.js +2 -2
  136. package/packages/dd-trace/src/appsec/blocked_templates.js +1 -1
  137. package/packages/dd-trace/src/appsec/blocking.js +6 -20
  138. package/packages/dd-trace/src/appsec/graphql.js +2 -2
  139. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
  140. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +1 -1
  141. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +1 -1
  142. package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +4 -6
  143. package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +7 -12
  144. package/packages/dd-trace/src/appsec/iast/analyzers/missing-header-analyzer.js +4 -6
  145. package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +4 -0
  146. package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +9 -12
  147. package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +5 -4
  148. package/packages/dd-trace/src/appsec/iast/context/context-plugin.js +2 -3
  149. package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
  150. package/packages/dd-trace/src/appsec/iast/index.js +1 -0
  151. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +102 -7
  152. package/packages/dd-trace/src/appsec/iast/path-line.js +7 -8
  153. package/packages/dd-trace/src/appsec/iast/security-controls/index.js +6 -13
  154. package/packages/dd-trace/src/appsec/iast/security-controls/parser.js +6 -6
  155. package/packages/dd-trace/src/appsec/iast/taint-tracking/filter.js +2 -2
  156. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +3 -3
  157. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +4 -28
  158. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -7
  159. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +3 -4
  160. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -1
  161. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +5 -7
  162. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
  163. package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +6 -6
  164. package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +1 -1
  165. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/command-sensitive-analyzer.js +1 -1
  166. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +1 -1
  167. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +7 -7
  168. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +23 -24
  169. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +3 -3
  170. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +4 -4
  171. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +6 -11
  172. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +9 -11
  173. package/packages/dd-trace/src/appsec/index.js +15 -12
  174. package/packages/dd-trace/src/appsec/rasp/index.js +19 -17
  175. package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -1
  176. package/packages/dd-trace/src/appsec/rasp/utils.js +11 -6
  177. package/packages/dd-trace/src/appsec/reporter.js +233 -40
  178. package/packages/dd-trace/src/appsec/rule_manager.js +2 -2
  179. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +2 -2
  180. package/packages/dd-trace/src/appsec/stack_trace.js +2 -4
  181. package/packages/dd-trace/src/appsec/telemetry/index.js +1 -2
  182. package/packages/dd-trace/src/appsec/telemetry/rasp.js +3 -14
  183. package/packages/dd-trace/src/appsec/telemetry/waf.js +3 -5
  184. package/packages/dd-trace/src/appsec/user_tracking.js +3 -5
  185. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +8 -8
  186. package/packages/dd-trace/src/azure_metadata.js +2 -7
  187. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +1 -1
  188. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +2 -2
  189. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +1 -1
  190. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +3 -3
  191. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +1 -1
  192. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +1 -1
  193. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +1 -1
  194. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +6 -4
  195. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +2 -2
  196. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +0 -2
  197. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -1
  198. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +1 -1
  199. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +8 -5
  200. package/packages/dd-trace/src/ci-visibility/telemetry.js +4 -0
  201. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
  202. package/packages/dd-trace/src/config.js +82 -51
  203. package/packages/dd-trace/src/config_stable.js +3 -3
  204. package/packages/dd-trace/src/datastreams/encoding.js +9 -9
  205. package/packages/dd-trace/src/datastreams/fnv.js +1 -1
  206. package/packages/dd-trace/src/datastreams/pathway.js +4 -4
  207. package/packages/dd-trace/src/datastreams/processor.js +5 -7
  208. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -1
  209. package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +4 -6
  210. package/packages/dd-trace/src/datastreams/size.js +1 -1
  211. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +131 -72
  212. package/packages/dd-trace/src/debugger/devtools_client/condition.js +6 -8
  213. package/packages/dd-trace/src/debugger/devtools_client/defaults.js +1 -1
  214. package/packages/dd-trace/src/debugger/devtools_client/index.js +17 -27
  215. package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +18 -38
  216. package/packages/dd-trace/src/debugger/devtools_client/send.js +8 -7
  217. package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +16 -8
  218. package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +8 -10
  219. package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +3 -3
  220. package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +2 -10
  221. package/packages/dd-trace/src/debugger/devtools_client/state.js +31 -4
  222. package/packages/dd-trace/src/dogstatsd.js +7 -4
  223. package/packages/dd-trace/src/encode/0.4.js +9 -9
  224. package/packages/dd-trace/src/encode/0.5.js +1 -1
  225. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +3 -3
  226. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
  227. package/packages/dd-trace/src/encode/tags-processors.js +1 -1
  228. package/packages/dd-trace/src/exporter.js +6 -6
  229. package/packages/dd-trace/src/exporters/agent/writer.js +1 -5
  230. package/packages/dd-trace/src/exporters/common/docker.js +1 -1
  231. package/packages/dd-trace/src/exporters/common/form-data.js +6 -4
  232. package/packages/dd-trace/src/exporters/common/request.js +1 -1
  233. package/packages/dd-trace/src/exporters/common/util.js +1 -1
  234. package/packages/dd-trace/src/external-logger/src/index.js +5 -5
  235. package/packages/dd-trace/src/flare/file.js +1 -5
  236. package/packages/dd-trace/src/format.js +1 -1
  237. package/packages/dd-trace/src/git_properties.js +1 -1
  238. package/packages/dd-trace/src/id.js +12 -6
  239. package/packages/dd-trace/src/iitm.js +10 -22
  240. package/packages/dd-trace/src/lambda/handler.js +6 -6
  241. package/packages/dd-trace/src/lambda/runtime/patch.js +4 -4
  242. package/packages/dd-trace/src/lambda/runtime/ritm.js +1 -1
  243. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +6 -6
  244. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +2 -6
  245. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -3
  246. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +6 -6
  247. package/packages/dd-trace/src/llmobs/plugins/openai.js +1 -1
  248. package/packages/dd-trace/src/llmobs/sdk.js +2 -2
  249. package/packages/dd-trace/src/llmobs/tagger.js +113 -99
  250. package/packages/dd-trace/src/llmobs/util.js +9 -9
  251. package/packages/dd-trace/src/llmobs/writers/base.js +1 -1
  252. package/packages/dd-trace/src/llmobs/writers/util.js +1 -1
  253. package/packages/dd-trace/src/log/index.js +4 -4
  254. package/packages/dd-trace/src/log/log.js +1 -1
  255. package/packages/dd-trace/src/log/writer.js +2 -2
  256. package/packages/dd-trace/src/msgpack/chunk.js +3 -3
  257. package/packages/dd-trace/src/msgpack/encoder.js +28 -28
  258. package/packages/dd-trace/src/noop/dogstatsd.js +6 -6
  259. package/packages/dd-trace/src/noop/span.js +3 -5
  260. package/packages/dd-trace/src/noop/tracer.js +1 -2
  261. package/packages/dd-trace/src/opentelemetry/span_processor.js +2 -2
  262. package/packages/dd-trace/src/opentelemetry/tracer.js +6 -5
  263. package/packages/dd-trace/src/opentracing/propagation/log.js +6 -8
  264. package/packages/dd-trace/src/opentracing/propagation/text_map.js +27 -23
  265. package/packages/dd-trace/src/opentracing/propagation/tracestate.js +8 -4
  266. package/packages/dd-trace/src/opentracing/span.js +9 -14
  267. package/packages/dd-trace/src/opentracing/tracer.js +9 -6
  268. package/packages/dd-trace/src/payload-tagging/index.js +1 -1
  269. package/packages/dd-trace/src/payload-tagging/tagging.js +6 -6
  270. package/packages/dd-trace/src/pkg.js +1 -1
  271. package/packages/dd-trace/src/plugins/ci_plugin.js +62 -10
  272. package/packages/dd-trace/src/plugins/consumer.js +2 -2
  273. package/packages/dd-trace/src/plugins/inbound.js +5 -1
  274. package/packages/dd-trace/src/plugins/index.js +1 -1
  275. package/packages/dd-trace/src/plugins/outbound.js +4 -5
  276. package/packages/dd-trace/src/plugins/plugin.js +1 -1
  277. package/packages/dd-trace/src/plugins/producer.js +2 -2
  278. package/packages/dd-trace/src/plugins/storage.js +2 -2
  279. package/packages/dd-trace/src/plugins/util/ci.js +23 -15
  280. package/packages/dd-trace/src/plugins/util/git.js +165 -11
  281. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +1 -1
  282. package/packages/dd-trace/src/plugins/util/ip_extractor.js +1 -1
  283. package/packages/dd-trace/src/plugins/util/llm.js +27 -10
  284. package/packages/dd-trace/src/plugins/util/stacktrace.js +1 -1
  285. package/packages/dd-trace/src/plugins/util/test.js +311 -48
  286. package/packages/dd-trace/src/plugins/util/url.js +1 -1
  287. package/packages/dd-trace/src/plugins/util/urlfilter.js +13 -17
  288. package/packages/dd-trace/src/plugins/util/user-provided-git.js +12 -3
  289. package/packages/dd-trace/src/plugins/util/web.js +5 -4
  290. package/packages/dd-trace/src/priority_sampler.js +22 -22
  291. package/packages/dd-trace/src/profiling/config.js +44 -8
  292. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +5 -5
  293. package/packages/dd-trace/src/profiling/exporters/file.js +2 -1
  294. package/packages/dd-trace/src/profiling/profiler.js +37 -2
  295. package/packages/dd-trace/src/profiling/profilers/events.js +14 -17
  296. package/packages/dd-trace/src/profiling/profilers/shared.js +6 -1
  297. package/packages/dd-trace/src/profiling/profilers/space.js +3 -3
  298. package/packages/dd-trace/src/profiling/profilers/wall.js +6 -7
  299. package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -5
  300. package/packages/dd-trace/src/profiling/tagger.js +3 -5
  301. package/packages/dd-trace/src/profiling/webspan-utils.js +1 -1
  302. package/packages/dd-trace/src/proxy.js +7 -13
  303. package/packages/dd-trace/src/random_sampler.js +40 -0
  304. package/packages/dd-trace/src/rate_limiter.js +4 -4
  305. package/packages/dd-trace/src/remote_config/index.js +3 -7
  306. package/packages/dd-trace/src/remote_config/manager.js +25 -13
  307. package/packages/dd-trace/src/require-package-json.js +1 -1
  308. package/packages/dd-trace/src/ritm.js +4 -4
  309. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +2 -2
  310. package/packages/dd-trace/src/sampler.js +33 -4
  311. package/packages/dd-trace/src/sampling_rule.js +12 -3
  312. package/packages/dd-trace/src/scope.js +1 -1
  313. package/packages/dd-trace/src/serverless.js +0 -48
  314. package/packages/dd-trace/src/service-naming/schemas/util.js +1 -1
  315. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +8 -0
  316. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -3
  317. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +4 -0
  318. package/packages/dd-trace/src/span_processor.js +3 -3
  319. package/packages/dd-trace/src/span_sampler.js +4 -1
  320. package/packages/dd-trace/src/standalone/tracesource.js +1 -1
  321. package/packages/dd-trace/src/startup-log.js +2 -2
  322. package/packages/dd-trace/src/telemetry/dependencies.js +4 -4
  323. package/packages/dd-trace/src/telemetry/logs/log-collector.js +9 -10
  324. package/packages/dd-trace/src/telemetry/metrics.js +10 -5
  325. package/packages/dd-trace/src/telemetry/send-data.js +1 -1
  326. package/packages/dd-trace/src/telemetry/telemetry.js +23 -24
  327. package/packages/dd-trace/src/util.js +1 -1
  328. package/version.js +1 -0
  329. package/packages/datadog-instrumentations/src/paperplane.js +0 -77
  330. package/packages/datadog-plugin-paperplane/src/index.js +0 -25
  331. package/packages/datadog-plugin-paperplane/src/logger.js +0 -11
  332. package/packages/datadog-plugin-paperplane/src/server.js +0 -24
@@ -15,7 +15,9 @@ const {
15
15
  getIsFaultyEarlyFlakeDetection,
16
16
  JEST_WORKER_LOGS_PAYLOAD_CODE,
17
17
  addAttemptToFixStringToTestName,
18
- removeAttemptToFixStringFromTestName
18
+ removeAttemptToFixStringFromTestName,
19
+ getTestEndLine,
20
+ isModifiedTest
19
21
  } = require('../../dd-trace/src/plugins/util/test')
20
22
  const {
21
23
  getFormattedJestTestParameters,
@@ -41,11 +43,13 @@ const testStartCh = channel('ci:jest:test:start')
41
43
  const testSkippedCh = channel('ci:jest:test:skip')
42
44
  const testFinishCh = channel('ci:jest:test:finish')
43
45
  const testErrCh = channel('ci:jest:test:err')
46
+ const testFnCh = channel('ci:jest:test:fn')
44
47
 
45
48
  const skippableSuitesCh = channel('ci:jest:test-suite:skippable')
46
49
  const libraryConfigurationCh = channel('ci:jest:library-configuration')
47
50
  const knownTestsCh = channel('ci:jest:known-tests')
48
51
  const testManagementTestsCh = channel('ci:jest:test-management-tests')
52
+ const impactedTestsCh = channel('ci:jest:modified-tests')
49
53
 
50
54
  const itrSkippedSuitesCh = channel('ci:jest:itr:skipped-suites')
51
55
 
@@ -53,8 +57,8 @@ const itrSkippedSuitesCh = channel('ci:jest:itr:skipped-suites')
53
57
  // https://github.com/jestjs/jest/blob/1d682f21c7a35da4d3ab3a1436a357b980ebd0fa/packages/jest-worker/src/types.ts#L37
54
58
  const CHILD_MESSAGE_CALL = 1
55
59
  // Maximum time we'll wait for the tracer to flush
56
- const FLUSH_TIMEOUT = 10000
57
- // eslint-disable-next-line
60
+ const FLUSH_TIMEOUT = 10_000
61
+
58
62
  // https://github.com/jestjs/jest/blob/41f842a46bb2691f828c3a5f27fc1d6290495b82/packages/jest-circus/src/types.ts#L9C8-L9C54
59
63
  const RETRY_TIMES = Symbol.for('RETRY_TIMES')
60
64
 
@@ -76,10 +80,12 @@ let isKnownTestsEnabled = false
76
80
  let isTestManagementTestsEnabled = false
77
81
  let testManagementTests = {}
78
82
  let testManagementAttemptToFixRetries = 0
83
+ let isImpactedTestsEnabled = false
84
+ let modifiedTests = {}
79
85
 
80
86
  const sessionAsyncResource = new AsyncResource('bound-anonymous-fn')
81
87
 
82
- const asyncResources = new WeakMap()
88
+ const testContexts = new WeakMap()
83
89
  const originalTestFns = new WeakMap()
84
90
  const originalHookFns = new WeakMap()
85
91
  const retriedTestsToNumAttempts = new Map()
@@ -149,6 +155,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
149
155
  this.isDiEnabled = this.testEnvironmentOptions._ddIsDiEnabled
150
156
  this.isKnownTestsEnabled = this.testEnvironmentOptions._ddIsKnownTestsEnabled
151
157
  this.isTestManagementTestsEnabled = this.testEnvironmentOptions._ddIsTestManagementTestsEnabled
158
+ this.isImpactedTestsEnabled = this.testEnvironmentOptions._ddIsImpactedTestsEnabled
152
159
 
153
160
  if (this.isKnownTestsEnabled) {
154
161
  try {
@@ -157,7 +164,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
157
164
  this.knownTestsForThisSuite = hasKnownTests
158
165
  ? (knownTests?.jest?.[this.testSuite] || [])
159
166
  : this.getKnownTestsForSuite(this.testEnvironmentOptions._ddKnownTests)
160
- } catch (e) {
167
+ } catch {
161
168
  // If there has been an error parsing the tests, we'll disable Early Flake Deteciton
162
169
  this.isEarlyFlakeDetectionEnabled = false
163
170
  this.isKnownTestsEnabled = false
@@ -183,6 +190,18 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
183
190
  this.isTestManagementTestsEnabled = false
184
191
  }
185
192
  }
193
+
194
+ if (this.isImpactedTestsEnabled) {
195
+ try {
196
+ const hasImpactedTests = Object.keys(modifiedTests).length > 0
197
+ this.modifiedTestsForThisSuite = hasImpactedTests
198
+ ? this.getModifiedTestForThisSuite(modifiedTests)
199
+ : this.getModifiedTestForThisSuite(this.testEnvironmentOptions._ddModifiedTests)
200
+ } catch (e) {
201
+ log.error('Error parsing impacted tests', e)
202
+ this.isImpactedTestsEnabled = false
203
+ }
204
+ }
186
205
  }
187
206
 
188
207
  getHasSnapshotTests () {
@@ -193,7 +212,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
193
212
  try {
194
213
  const { _snapshotData } = this.getVmContext().expect.getState().snapshotState
195
214
  hasSnapshotTests = Object.keys(_snapshotData).length > 0
196
- } catch (e) {
215
+ } catch {
197
216
  // if we can't be sure, we'll err on the side of caution and assume it has snapshots
198
217
  }
199
218
  this.hasSnapshotTests = hasSnapshotTests
@@ -254,6 +273,19 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
254
273
  return result
255
274
  }
256
275
 
276
+ getModifiedTestForThisSuite (modifiedTests) {
277
+ if (this.modifiedTestsForThisSuite) {
278
+ return this.modifiedTestsForThisSuite
279
+ }
280
+ let modifiedTestsForThisSuite = modifiedTests
281
+ // If jest is using workers, modified tests are serialized to json.
282
+ // If jest runs in band, they are not.
283
+ if (typeof modifiedTestsForThisSuite === 'string') {
284
+ modifiedTestsForThisSuite = JSON.parse(modifiedTestsForThisSuite)
285
+ }
286
+ return modifiedTestsForThisSuite
287
+ }
288
+
257
289
  // Generic function to handle test retries
258
290
  retryTest (testName, retryCount, addRetryStringToTestName, retryType, event) {
259
291
  // Retrying snapshots has proven to be problematic, so we'll skip them for now
@@ -287,18 +319,16 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
287
319
 
288
320
  const setNameToParams = (name, params) => { this.nameToParams[name] = [...params] }
289
321
 
290
- if (event.name === 'setup') {
291
- if (this.global.test) {
292
- shimmer.wrap(this.global.test, 'each', each => function () {
293
- const testParameters = getFormattedJestTestParameters(arguments)
294
- const eachBind = each.apply(this, arguments)
295
- return function () {
296
- const [testName] = arguments
297
- setNameToParams(testName, testParameters)
298
- return eachBind.apply(this, arguments)
299
- }
300
- })
301
- }
322
+ if (event.name === 'setup' && this.global.test) {
323
+ shimmer.wrap(this.global.test, 'each', each => function () {
324
+ const testParameters = getFormattedJestTestParameters(arguments)
325
+ const eachBind = each.apply(this, arguments)
326
+ return function () {
327
+ const [testName] = arguments
328
+ setNameToParams(testName, testParameters)
329
+ return eachBind.apply(this, arguments)
330
+ }
331
+ })
302
332
  }
303
333
  if (event.name === 'test_start') {
304
334
  let isNewTest = false
@@ -307,8 +337,6 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
307
337
  const testParameters = getTestParametersString(this.nameToParams, event.test.name)
308
338
  // Async resource for this test is created here
309
339
  // It is used later on by the test_done handler
310
- const asyncResource = new AsyncResource('bound-anonymous-fn')
311
- asyncResources.set(event.test, asyncResource)
312
340
  const testName = getJestTestName(event.test)
313
341
  const originalTestName = removeEfdStringFromTestName(removeAttemptToFixStringFromTestName(testName))
314
342
 
@@ -327,42 +355,72 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
327
355
  }
328
356
  }
329
357
 
358
+ let isModified = false
359
+ if (this.isImpactedTestsEnabled) {
360
+ const testStartLine = getTestLineStart(event.test.asyncError, this.testSuite)
361
+ const testEndLine = getTestEndLine(event.test.fn, testStartLine)
362
+ isModified = isModifiedTest(
363
+ this.testSourceFile,
364
+ testStartLine,
365
+ testEndLine,
366
+ this.modifiedTestsForThisSuite,
367
+ 'jest'
368
+ )
369
+ }
370
+
330
371
  if (this.isKnownTestsEnabled) {
331
372
  isNewTest = retriedTestsToNumAttempts.has(originalTestName)
332
- if (isNewTest) {
333
- numEfdRetry = retriedTestsToNumAttempts.get(originalTestName)
334
- retriedTestsToNumAttempts.set(originalTestName, numEfdRetry + 1)
335
- }
373
+ }
374
+
375
+ if (this.isEarlyFlakeDetectionEnabled && (isNewTest || isModified)) {
376
+ numEfdRetry = retriedTestsToNumAttempts.get(originalTestName)
377
+ retriedTestsToNumAttempts.set(originalTestName, numEfdRetry + 1)
336
378
  }
337
379
 
338
380
  const isJestRetry = event.test?.invocations > 1
339
- asyncResource.runInAsyncScope(() => {
340
- testStartCh.publish({
341
- name: originalTestName,
342
- suite: this.testSuite,
343
- testSourceFile: this.testSourceFile,
344
- displayName: this.displayName,
345
- testParameters,
346
- frameworkVersion: jestVersion,
347
- isNew: isNewTest,
348
- isEfdRetry: numEfdRetry > 0,
349
- isAttemptToFix,
350
- isAttemptToFixRetry: numOfAttemptsToFixRetries > 0,
351
- isJestRetry,
352
- isDisabled,
353
- isQuarantined
354
- })
381
+ const ctx = {
382
+ name: originalTestName,
383
+ suite: this.testSuite,
384
+ testSourceFile: this.testSourceFile,
385
+ displayName: this.displayName,
386
+ testParameters,
387
+ frameworkVersion: jestVersion,
388
+ isNew: isNewTest,
389
+ isEfdRetry: numEfdRetry > 0,
390
+ isAttemptToFix,
391
+ isAttemptToFixRetry: numOfAttemptsToFixRetries > 0,
392
+ isJestRetry,
393
+ isDisabled,
394
+ isQuarantined,
395
+ isModified
396
+ }
397
+ testContexts.set(event.test, ctx)
398
+
399
+ testStartCh.runStores(ctx, () => {
355
400
  for (const hook of event.test.parent.hooks) {
356
401
  let hookFn = hook.fn
357
- if (!originalHookFns.has(hook)) {
358
- originalHookFns.set(hook, hookFn)
359
- } else {
402
+ if (originalHookFns.has(hook)) {
360
403
  hookFn = originalHookFns.get(hook)
404
+ } else {
405
+ originalHookFns.set(hook, hookFn)
406
+ }
407
+ // The rule has a bug, see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2164
408
+ // eslint-disable-next-line unicorn/consistent-function-scoping
409
+ const wrapperHook = function () {
410
+ return testFnCh.runStores(ctx, () => hookFn.apply(this, arguments))
361
411
  }
362
- hook.fn = asyncResource.bind(hookFn)
412
+ // If we don't do this, the timeout will not be triggered
413
+ Object.defineProperty(wrapperHook, 'length', { value: hookFn.length })
414
+ hook.fn = wrapperHook
363
415
  }
364
- originalTestFns.set(event.test, event.test.fn)
365
- event.test.fn = asyncResource.bind(event.test.fn)
416
+ const originalFn = event.test.fn
417
+ originalTestFns.set(event.test, originalFn)
418
+ const wrapper = function () {
419
+ return testFnCh.runStores(ctx, () => originalFn.apply(this, arguments))
420
+ }
421
+ // If we don't do this, the timeout will be not be triggered
422
+ Object.defineProperty(wrapper, 'length', { value: originalFn.length })
423
+ event.test.fn = wrapper
366
424
  })
367
425
  }
368
426
 
@@ -383,6 +441,27 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
383
441
  )
384
442
  }
385
443
  }
444
+ if (this.isImpactedTestsEnabled) {
445
+ const testStartLine = getTestLineStart(event.asyncError, this.testSuite)
446
+ const testEndLine = getTestEndLine(event.fn, testStartLine)
447
+ const isModified = isModifiedTest(
448
+ this.testSourceFile,
449
+ testStartLine,
450
+ testEndLine,
451
+ this.modifiedTestsForThisSuite,
452
+ 'jest'
453
+ )
454
+ if (isModified && !retriedTestsToNumAttempts.has(originalTestName) && this.isEarlyFlakeDetectionEnabled) {
455
+ retriedTestsToNumAttempts.set(originalTestName, 0)
456
+ this.retryTest(
457
+ event.testName,
458
+ earlyFlakeDetectionNumRetries,
459
+ addEfdStringToTestName,
460
+ 'Early flake detection',
461
+ event
462
+ )
463
+ }
464
+ }
386
465
  if (this.isKnownTestsEnabled) {
387
466
  const isNew = !this.knownTestsForThisSuite?.includes(originalTestName)
388
467
  if (isNew && !isSkipped && !retriedTestsToNumAttempts.has(originalTestName)) {
@@ -426,7 +505,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
426
505
  // If it is, we'll set the failedAllTests flag to true if all the tests failed
427
506
  // If all tests passed, we'll set the attemptToFixPassed flag to true
428
507
  if (testStatuses.length === testManagementAttemptToFixRetries + 1) {
429
- if (testStatuses.some(status => status === 'fail')) {
508
+ if (testStatuses.includes('fail')) {
430
509
  attemptToFixFailed = true
431
510
  }
432
511
  if (testStatuses.every(status => status === 'fail')) {
@@ -460,16 +539,15 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
460
539
  const willBeRetried = numRetries > 0 && numTestExecutions - 1 < numRetries
461
540
  const mightHitBreakpoint = this.isDiEnabled && numTestExecutions >= 2
462
541
 
463
- const asyncResource = asyncResources.get(event.test)
542
+ const ctx = testContexts.get(event.test)
464
543
 
465
544
  if (status === 'fail') {
466
545
  const shouldSetProbe = this.isDiEnabled && willBeRetried && numTestExecutions === 1
467
- asyncResource.runInAsyncScope(() => {
468
- testErrCh.publish({
469
- error: formatJestError(event.test.errors[0]),
470
- shouldSetProbe,
471
- promises
472
- })
546
+ testErrCh.publish({
547
+ ...ctx.currentStore,
548
+ error: formatJestError(event.test.errors[0]),
549
+ shouldSetProbe,
550
+ promises
473
551
  })
474
552
  }
475
553
 
@@ -488,15 +566,14 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
488
566
  isAtrRetry = true
489
567
  }
490
568
 
491
- asyncResource.runInAsyncScope(() => {
492
- testFinishCh.publish({
493
- status,
494
- testStartLine: getTestLineStart(event.test.asyncError, this.testSuite),
495
- attemptToFixPassed,
496
- failedAllTests,
497
- attemptToFixFailed,
498
- isAtrRetry
499
- })
569
+ testFinishCh.publish({
570
+ ...ctx.currentStore,
571
+ status,
572
+ testStartLine: getTestLineStart(event.test.asyncError, this.testSuite),
573
+ attemptToFixPassed,
574
+ failedAllTests,
575
+ attemptToFixFailed,
576
+ isAtrRetry
500
577
  })
501
578
 
502
579
  if (promises.isProbeReady) {
@@ -625,7 +702,7 @@ addHook({
625
702
  })
626
703
 
627
704
  function cliWrapper (cli, jestVersion) {
628
- const wrapped = shimmer.wrap(cli, 'runCLI', runCLI => async function () {
705
+ shimmer.wrap(cli, 'runCLI', runCLI => async function () {
629
706
  let onDone
630
707
  const configurationPromise = new Promise((resolve) => {
631
708
  onDone = resolve
@@ -649,6 +726,7 @@ function cliWrapper (cli, jestVersion) {
649
726
  isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
650
727
  isTestManagementTestsEnabled = libraryConfig.isTestManagementEnabled
651
728
  testManagementAttemptToFixRetries = libraryConfig.testManagementAttemptToFixRetries
729
+ isImpactedTestsEnabled = libraryConfig.isImpactedTestsEnabled
652
730
  }
653
731
  } catch (err) {
654
732
  log.error('Jest library configuration error', err)
@@ -665,12 +743,12 @@ function cliWrapper (cli, jestVersion) {
665
743
 
666
744
  try {
667
745
  const { err, knownTests: receivedKnownTests } = await knownTestsPromise
668
- if (!err) {
669
- knownTests = receivedKnownTests
670
- } else {
746
+ if (err) {
671
747
  // We disable EFD if there has been an error in the known tests request
672
748
  isEarlyFlakeDetectionEnabled = false
673
749
  isKnownTestsEnabled = false
750
+ } else {
751
+ knownTests = receivedKnownTests
674
752
  }
675
753
  } catch (err) {
676
754
  log.error('Jest known tests error', err)
@@ -715,6 +793,25 @@ function cliWrapper (cli, jestVersion) {
715
793
  }
716
794
  }
717
795
 
796
+ if (isImpactedTestsEnabled) {
797
+ const impactedTestsPromise = new Promise((resolve) => {
798
+ onDone = resolve
799
+ })
800
+
801
+ sessionAsyncResource.runInAsyncScope(() => {
802
+ impactedTestsCh.publish({ onDone })
803
+ })
804
+
805
+ try {
806
+ const { err, modifiedTests: receivedModifiedTests } = await impactedTestsPromise
807
+ if (!err) {
808
+ modifiedTests = receivedModifiedTests
809
+ }
810
+ } catch (err) {
811
+ log.error('Jest impacted tests error', err)
812
+ }
813
+ }
814
+
718
815
  const processArgv = process.argv.slice(2).join(' ')
719
816
  sessionAsyncResource.runInAsyncScope(() => {
720
817
  testSessionStartCh.publish({ command: `jest ${processArgv}`, frameworkVersion: jestVersion })
@@ -738,19 +835,15 @@ function cliWrapper (cli, jestVersion) {
738
835
  if (isUserCodeCoverageEnabled) {
739
836
  try {
740
837
  const { pct, total } = coverageMap.getCoverageSummary().lines
741
- testCodeCoverageLinesTotal = total !== 0 ? pct : 0
742
- } catch (e) {
838
+ testCodeCoverageLinesTotal = total === 0 ? 0 : pct
839
+ } catch {
743
840
  // ignore errors
744
841
  }
745
842
  }
746
843
  let status, error
747
844
 
748
845
  if (success) {
749
- if (numTotalTests === 0 && numTotalTestSuites === 0) {
750
- status = 'skip'
751
- } else {
752
- status = 'pass'
753
- }
846
+ status = numTotalTests === 0 && numTotalTestSuites === 0 ? 'skip' : 'pass'
754
847
  } else {
755
848
  status = 'fail'
756
849
  error = new Error(`Failed test suites: ${numFailedTestSuites}. Failed tests: ${numFailedTests}`)
@@ -864,13 +957,11 @@ function cliWrapper (cli, jestVersion) {
864
957
  return result
865
958
  })
866
959
 
867
- cli.runCLI = wrapped.runCLI
868
-
869
960
  return cli
870
961
  }
871
962
 
872
963
  function coverageReporterWrapper (coverageReporter) {
873
- const CoverageReporter = coverageReporter.default ? coverageReporter.default : coverageReporter
964
+ const CoverageReporter = coverageReporter.default ?? coverageReporter
874
965
 
875
966
  /**
876
967
  * If ITR is active, we're running fewer tests, so of course the total code coverage is reduced.
@@ -909,7 +1000,7 @@ addHook({
909
1000
  }, cliWrapper)
910
1001
 
911
1002
  function jestAdapterWrapper (jestAdapter, jestVersion) {
912
- const adapter = jestAdapter.default ? jestAdapter.default : jestAdapter
1003
+ const adapter = jestAdapter.default ?? jestAdapter
913
1004
  const newAdapter = shimmer.wrapFunction(adapter, adapter => function () {
914
1005
  const environment = arguments[2]
915
1006
  if (!environment) {
@@ -1057,6 +1148,7 @@ addHook({
1057
1148
  _ddIsTestManagementTestsEnabled,
1058
1149
  _ddTestManagementTests,
1059
1150
  _ddTestManagementAttemptToFixRetries,
1151
+ _ddModifiedTests,
1060
1152
  ...restOfTestEnvironmentOptions
1061
1153
  } = testEnvironmentOptions
1062
1154
 
@@ -1078,7 +1170,7 @@ addHook({
1078
1170
  versions: ['>=24.8.0'],
1079
1171
  file: 'build/SearchSource.js'
1080
1172
  }, (searchSourcePackage, frameworkVersion) => {
1081
- const SearchSource = searchSourcePackage.default ? searchSourcePackage.default : searchSourcePackage
1173
+ const SearchSource = searchSourcePackage.default ?? searchSourcePackage
1082
1174
 
1083
1175
  shimmer.wrap(SearchSource.prototype, 'getTestPaths', getTestPaths => async function () {
1084
1176
  const testPaths = await getTestPaths.apply(this, arguments)
@@ -1132,7 +1224,7 @@ addHook({
1132
1224
  versions: ['24.8.0 - 24.9.0']
1133
1225
  }, jestConfigSyncWrapper)
1134
1226
 
1135
- const LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE = [
1227
+ const LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE = new Set([
1136
1228
  'selenium-webdriver',
1137
1229
  'selenium-webdriver/chrome',
1138
1230
  'selenium-webdriver/edge',
@@ -1141,11 +1233,11 @@ const LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE = [
1141
1233
  'selenium-webdriver/ie',
1142
1234
  'selenium-webdriver/chromium',
1143
1235
  'winston'
1144
- ]
1236
+ ])
1145
1237
 
1146
1238
  function shouldBypassJestRequireEngine (moduleName) {
1147
1239
  return (
1148
- LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE.includes(moduleName)
1240
+ LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE.has(moduleName)
1149
1241
  )
1150
1242
  }
1151
1243
 
@@ -1153,7 +1245,7 @@ addHook({
1153
1245
  name: 'jest-runtime',
1154
1246
  versions: ['>=24.8.0']
1155
1247
  }, (runtimePackage) => {
1156
- const Runtime = runtimePackage.default ? runtimePackage.default : runtimePackage
1248
+ const Runtime = runtimePackage.default ?? runtimePackage
1157
1249
 
1158
1250
  shimmer.wrap(Runtime.prototype, 'requireModuleOrMock', requireModuleOrMock => function (from, moduleName) {
1159
1251
  // TODO: do this for every library that we instrument
@@ -1180,17 +1272,17 @@ addHook({
1180
1272
  }, (childProcessWorker) => {
1181
1273
  const ChildProcessWorker = childProcessWorker.default
1182
1274
  shimmer.wrap(ChildProcessWorker.prototype, 'send', send => function (request) {
1183
- if (!isKnownTestsEnabled && !isTestManagementTestsEnabled) {
1275
+ if (!isKnownTestsEnabled && !isTestManagementTestsEnabled && !isImpactedTestsEnabled) {
1184
1276
  return send.apply(this, arguments)
1185
1277
  }
1186
1278
  const [type] = request
1187
- // eslint-disable-next-line
1279
+
1188
1280
  // https://github.com/jestjs/jest/blob/1d682f21c7a35da4d3ab3a1436a357b980ebd0fa/packages/jest-worker/src/workers/ChildProcessWorker.ts#L424
1189
1281
  if (type === CHILD_MESSAGE_CALL) {
1190
1282
  // This is the message that the main process sends to the worker to run a test suite (=test file).
1191
1283
  // In here we modify the config.testEnvironmentOptions to include the known tests for the suite.
1192
1284
  // This way the suite only knows about the tests that are part of it.
1193
- const args = request[request.length - 1]
1285
+ const args = request.at(-1)
1194
1286
  if (args.length > 1) {
1195
1287
  return send.apply(this, arguments)
1196
1288
  }
@@ -1203,12 +1295,17 @@ addHook({
1203
1295
 
1204
1296
  const suiteTestManagementTests = testManagementTests?.jest?.suites?.[testSuite]?.tests || {}
1205
1297
 
1298
+ const suiteModifiedTests = Object.keys(modifiedTests).length > 0
1299
+ ? modifiedTests
1300
+ : {}
1301
+
1206
1302
  args[0].config = {
1207
1303
  ...config,
1208
1304
  testEnvironmentOptions: {
1209
1305
  ...config.testEnvironmentOptions,
1210
1306
  _ddKnownTests: suiteKnownTests,
1211
- _ddTestManagementTests: suiteTestManagementTests
1307
+ _ddTestManagementTests: suiteTestManagementTests,
1308
+ _ddModifiedTests: suiteModifiedTests
1212
1309
  }
1213
1310
  }
1214
1311
  }