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
@@ -8,6 +8,7 @@ const log = require('../../dd-trace/src/log')
8
8
  const testStartCh = channel('ci:cucumber:test:start')
9
9
  const testRetryCh = channel('ci:cucumber:test:retry')
10
10
  const testFinishCh = channel('ci:cucumber:test:finish') // used for test steps too
11
+ const testFnCh = channel('ci:cucumber:test:fn')
11
12
 
12
13
  const testStepStartCh = channel('ci:cucumber:test-step:start')
13
14
 
@@ -23,6 +24,8 @@ const skippableSuitesCh = channel('ci:cucumber:test-suite:skippable')
23
24
  const sessionStartCh = channel('ci:cucumber:session:start')
24
25
  const sessionFinishCh = channel('ci:cucumber:session:finish')
25
26
  const testManagementTestsCh = channel('ci:cucumber:test-management-tests')
27
+ const impactedTestsCh = channel('ci:cucumber:modified-tests')
28
+ const isModifiedCh = channel('ci:cucumber:is-modified-test')
26
29
 
27
30
  const workerReportTraceCh = channel('ci:cucumber:worker-report:trace')
28
31
 
@@ -41,7 +44,7 @@ const {
41
44
  } = require('../../dd-trace/src/plugins/util/test')
42
45
 
43
46
  const isMarkedAsUnskippable = (pickle) => {
44
- return !!pickle.tags.find(tag => tag.name === '@datadog:unskippable')
47
+ return pickle.tags.some(tag => tag.name === '@datadog:unskippable')
45
48
  }
46
49
 
47
50
  // We'll preserve the original coverage here
@@ -52,8 +55,9 @@ const patched = new WeakSet()
52
55
 
53
56
  const lastStatusByPickleId = new Map()
54
57
  const numRetriesByPickleId = new Map()
55
- const numAttemptToAsyncResource = new Map()
58
+ const numAttemptToCtx = new Map()
56
59
  const newTestsByTestFullname = new Map()
60
+ const modifiedTestsByPickleId = new Map()
57
61
 
58
62
  let eventDataCollector = null
59
63
  let pickleByFile = {}
@@ -73,15 +77,17 @@ let isEarlyFlakeDetectionFaulty = false
73
77
  let isFlakyTestRetriesEnabled = false
74
78
  let isKnownTestsEnabled = false
75
79
  let isTestManagementTestsEnabled = false
80
+ let isImpactedTestsEnabled = false
76
81
  let testManagementAttemptToFixRetries = 0
77
82
  let testManagementTests = {}
83
+ let modifiedTests = {}
78
84
  let numTestRetries = 0
79
85
  let knownTests = []
80
86
  let skippedSuites = []
81
87
  let isSuitesSkipped = false
82
88
 
83
89
  function getSuiteStatusFromTestStatuses (testStatuses) {
84
- if (testStatuses.some(status => status === 'fail')) {
90
+ if (testStatuses.includes('fail')) {
85
91
  return 'fail'
86
92
  }
87
93
  if (testStatuses.every(status => status === 'skip')) {
@@ -132,7 +138,7 @@ function getTestStatusFromRetries (testStatuses) {
132
138
  if (testStatuses.every(status => status === 'fail')) {
133
139
  return 'fail'
134
140
  }
135
- if (testStatuses.some(status => status === 'pass')) {
141
+ if (testStatuses.includes('pass')) {
136
142
  return 'pass'
137
143
  }
138
144
  return 'pass'
@@ -227,16 +233,12 @@ function wrapRun (pl, isLatestVersion) {
227
233
  patched.add(pl)
228
234
 
229
235
  shimmer.wrap(pl.prototype, 'run', run => function () {
230
- if (!testStartCh.hasSubscribers) {
236
+ if (!testFinishCh.hasSubscribers) {
231
237
  return run.apply(this, arguments)
232
238
  }
233
239
 
234
240
  let numAttempt = 0
235
241
 
236
- const asyncResource = new AsyncResource('bound-anonymous-fn')
237
-
238
- numAttemptToAsyncResource.set(numAttempt, asyncResource)
239
-
240
242
  const testFileAbsolutePath = this.pickle.uri
241
243
 
242
244
  const testSourceLine = this.gherkinDocument?.feature?.location?.line
@@ -247,9 +249,9 @@ function wrapRun (pl, isLatestVersion) {
247
249
  testSourceLine,
248
250
  isParallel: !!process.env.CUCUMBER_WORKER_ID
249
251
  }
250
- asyncResource.runInAsyncScope(() => {
251
- testStartCh.publish(testStartPayload)
252
- })
252
+ const ctx = testStartPayload
253
+ numAttemptToCtx.set(numAttempt, ctx)
254
+ testStartCh.runStores(ctx, () => {})
253
255
  const promises = {}
254
256
  try {
255
257
  this.eventBroadcaster.on('envelope', shimmer.wrapFunction(null, () => async (testCase) => {
@@ -261,11 +263,11 @@ function wrapRun (pl, isLatestVersion) {
261
263
  try {
262
264
  const cucumberResult = this.getWorstStepResult()
263
265
  error = getErrorFromCucumberResult(cucumberResult)
264
- } catch (e) {
266
+ } catch {
265
267
  // ignore error
266
268
  }
267
269
 
268
- const failedAttemptAsyncResource = numAttemptToAsyncResource.get(numAttempt)
270
+ const failedAttemptCtx = numAttemptToCtx.get(numAttempt)
269
271
  const isFirstAttempt = numAttempt++ === 0
270
272
  const isAtrRetry = !isFirstAttempt && isFlakyTestRetriesEnabled
271
273
 
@@ -273,23 +275,19 @@ function wrapRun (pl, isLatestVersion) {
273
275
  await promises.hitBreakpointPromise
274
276
  }
275
277
 
276
- failedAttemptAsyncResource.runInAsyncScope(() => {
277
- // the current span will be finished and a new one will be created
278
- testRetryCh.publish({ isFirstAttempt, error, isAtrRetry })
279
- })
278
+ // the current span will be finished and a new one will be created
279
+ testRetryCh.publish({ isFirstAttempt, error, isAtrRetry, ...failedAttemptCtx.currentStore })
280
280
 
281
- const newAsyncResource = new AsyncResource('bound-anonymous-fn')
282
- numAttemptToAsyncResource.set(numAttempt, newAsyncResource)
281
+ const newCtx = { ...testStartPayload, promises }
282
+ numAttemptToCtx.set(numAttempt, newCtx)
283
283
 
284
- newAsyncResource.runInAsyncScope(() => {
285
- testStartCh.publish({ ...testStartPayload, promises }) // a new span will be created
286
- })
284
+ testStartCh.runStores(newCtx, () => {})
287
285
  }
288
286
  }
289
287
  }))
290
288
  let promise
291
289
 
292
- asyncResource.runInAsyncScope(() => {
290
+ testFnCh.runStores(ctx, () => {
293
291
  promise = run.apply(this, arguments)
294
292
  })
295
293
  promise.finally(async () => {
@@ -312,6 +310,7 @@ function wrapRun (pl, isLatestVersion) {
312
310
  let hasFailedAttemptToFix = false
313
311
  let isDisabled = false
314
312
  let isQuarantined = false
313
+ let isModified = false
315
314
 
316
315
  if (isTestManagementTestsEnabled) {
317
316
  const testSuitePath = getTestSuitePath(testFileAbsolutePath, process.cwd())
@@ -336,46 +335,55 @@ function wrapRun (pl, isLatestVersion) {
336
335
  }
337
336
  }
338
337
 
339
- if (isKnownTestsEnabled && status !== 'skip' && !isAttemptToFix) {
340
- const numRetries = numRetriesByPickleId.get(this.pickle.id)
338
+ const numRetries = numRetriesByPickleId.get(this.pickle.id)
339
+
340
+ if (isImpactedTestsEnabled) {
341
+ isModified = modifiedTestsByPickleId.get(this.pickle.id)
342
+ }
341
343
 
344
+ if (isKnownTestsEnabled && status !== 'skip') {
342
345
  isNew = numRetries !== undefined
346
+ }
347
+
348
+ if (isNew || isModified) {
343
349
  isEfdRetry = numRetries > 0
344
350
  }
345
351
 
346
- const attemptAsyncResource = numAttemptToAsyncResource.get(numAttempt)
352
+ const attemptCtx = numAttemptToCtx.get(numAttempt)
347
353
 
348
354
  const error = getErrorFromCucumberResult(result)
349
355
 
350
356
  if (promises.hitBreakpointPromise) {
351
357
  await promises.hitBreakpointPromise
352
358
  }
353
- attemptAsyncResource.runInAsyncScope(() => {
354
- testFinishCh.publish({
355
- status,
356
- skipReason,
357
- error,
358
- isNew,
359
- isEfdRetry,
360
- isFlakyRetry: numAttempt > 0,
361
- isAttemptToFix,
362
- isAttemptToFixRetry,
363
- hasFailedAllRetries,
364
- hasPassedAllRetries,
365
- hasFailedAttemptToFix,
366
- isDisabled,
367
- isQuarantined
368
- })
359
+ testFinishCh.publish({
360
+ status,
361
+ skipReason,
362
+ error,
363
+ isNew,
364
+ isEfdRetry,
365
+ isFlakyRetry: numAttempt > 0,
366
+ isAttemptToFix,
367
+ isAttemptToFixRetry,
368
+ hasFailedAllRetries,
369
+ hasPassedAllRetries,
370
+ hasFailedAttemptToFix,
371
+ isDisabled,
372
+ isQuarantined,
373
+ isModified,
374
+ ...attemptCtx.currentStore
369
375
  })
370
376
  })
371
377
  return promise
372
378
  } catch (err) {
373
- errorCh.publish(err)
374
- throw err
379
+ ctx.err = err
380
+ errorCh.runStores(ctx, () => {
381
+ throw err
382
+ })
375
383
  }
376
384
  })
377
385
  shimmer.wrap(pl.prototype, 'runStep', runStep => function () {
378
- if (!testStepStartCh.hasSubscribers) {
386
+ if (!testFinishCh.hasSubscribers) {
379
387
  return runStep.apply(this, arguments)
380
388
  }
381
389
  const testStep = arguments[0]
@@ -387,9 +395,8 @@ function wrapRun (pl, isLatestVersion) {
387
395
  resource = testStep.isHook ? 'hook' : testStep.pickleStep.text
388
396
  }
389
397
 
390
- const asyncResource = new AsyncResource('bound-anonymous-fn')
391
- return asyncResource.runInAsyncScope(() => {
392
- testStepStartCh.publish({ resource })
398
+ const ctx = { resource }
399
+ return testStepStartCh.runStores(ctx, () => {
393
400
  try {
394
401
  const promise = runStep.apply(this, arguments)
395
402
 
@@ -398,12 +405,14 @@ function wrapRun (pl, isLatestVersion) {
398
405
  ? getStatusFromResultLatest(result)
399
406
  : getStatusFromResult(result)
400
407
 
401
- testFinishCh.publish({ isStep: true, status, skipReason, errorMessage })
408
+ testFinishCh.publish({ isStep: true, status, skipReason, errorMessage, ...ctx.currentStore })
402
409
  })
403
410
  return promise
404
411
  } catch (err) {
405
- errorCh.publish(err)
406
- throw err
412
+ ctx.err = err
413
+ errorCh.runStores(ctx, () => {
414
+ throw err
415
+ })
407
416
  }
408
417
  })
409
418
  })
@@ -456,14 +465,15 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
456
465
  isKnownTestsEnabled = configurationResponse.libraryConfig?.isKnownTestsEnabled
457
466
  isTestManagementTestsEnabled = configurationResponse.libraryConfig?.isTestManagementEnabled
458
467
  testManagementAttemptToFixRetries = configurationResponse.libraryConfig?.testManagementAttemptToFixRetries
468
+ isImpactedTestsEnabled = configurationResponse.libraryConfig?.isImpactedTestsEnabled
459
469
 
460
470
  if (isKnownTestsEnabled) {
461
471
  const knownTestsResponse = await getChannelPromise(knownTestsCh)
462
- if (!knownTestsResponse.err) {
463
- knownTests = knownTestsResponse.knownTests
464
- } else {
472
+ if (knownTestsResponse.err) {
465
473
  isEarlyFlakeDetectionEnabled = false
466
474
  isKnownTestsEnabled = false
475
+ } else {
476
+ knownTests = knownTestsResponse.knownTests
467
477
  }
468
478
  }
469
479
 
@@ -493,7 +503,7 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
493
503
  this.pickleIds = picklesToRun
494
504
  }
495
505
 
496
- skippedSuites = Array.from(filteredPickles.skippedSuites)
506
+ skippedSuites = [...filteredPickles.skippedSuites]
497
507
  itrCorrelationId = skippableResponse.itrCorrelationId
498
508
  }
499
509
  }
@@ -515,10 +525,17 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
515
525
 
516
526
  if (isTestManagementTestsEnabled) {
517
527
  const testManagementTestsResponse = await getChannelPromise(testManagementTestsCh)
518
- if (!testManagementTestsResponse.err) {
519
- testManagementTests = testManagementTestsResponse.testManagementTests
520
- } else {
528
+ if (testManagementTestsResponse.err) {
521
529
  isTestManagementTestsEnabled = false
530
+ } else {
531
+ testManagementTests = testManagementTestsResponse.testManagementTests
532
+ }
533
+ }
534
+
535
+ if (isImpactedTestsEnabled) {
536
+ const impactedTestsResponse = await getChannelPromise(impactedTestsCh)
537
+ if (!impactedTestsResponse.err) {
538
+ modifiedTests = impactedTestsResponse.modifiedTests
522
539
  }
523
540
  }
524
541
 
@@ -552,7 +569,7 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
552
569
  originalCoverageMap.merge(fromCoverageMapToCoverage(untestedCoverage))
553
570
  }
554
571
  testCodeCoverageLinesTotal = originalCoverageMap.getCoverageSummary().lines.pct
555
- } catch (e) {
572
+ } catch {
556
573
  // ignore errors
557
574
  }
558
575
  // restore the original coverage
@@ -582,12 +599,15 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
582
599
  // Handles EFD in both the main process and the worker process.
583
600
  function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = false, isWorker = false) {
584
601
  return async function () {
585
- let pickle
586
- if (isNewerCucumberVersion) {
587
- pickle = arguments[0].pickle
588
- } else {
589
- pickle = this.eventDataCollector.getPickle(arguments[0])
590
- }
602
+ const pickle = isNewerCucumberVersion
603
+ ? arguments[0].pickle
604
+ : this.eventDataCollector.getPickle(arguments[0])
605
+ const testCase = isNewerCucumberVersion
606
+ ? arguments[0].testCase
607
+ : arguments[1]
608
+ const gherkinDocument = isNewerCucumberVersion
609
+ ? arguments[0].gherkinDocument
610
+ : this.eventDataCollector.getGherkinDocument(pickle.uri)
591
611
 
592
612
  const testFileAbsolutePath = pickle.uri
593
613
  const testSuitePath = getTestSuitePath(testFileAbsolutePath, process.cwd())
@@ -609,6 +629,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
609
629
  let isAttemptToFix = false
610
630
  let isDisabled = false
611
631
  let isQuarantined = false
632
+ let isModified = false
612
633
 
613
634
  if (isTestManagementTestsEnabled) {
614
635
  const testProperties = getTestProperties(testSuitePath, pickle.name)
@@ -621,6 +642,24 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
621
642
  }
622
643
  }
623
644
 
645
+ if (isImpactedTestsEnabled) {
646
+ const setIsModified = (receivedIsModified) => { isModified = receivedIsModified }
647
+ const scenarios = gherkinDocument.feature?.children?.filter(
648
+ children => pickle.astNodeIds.includes(children.scenario.id)
649
+ ).map(scenario => scenario.scenario)
650
+ const stepIds = testCase?.testSteps?.flatMap(testStep => testStep.stepDefinitionIds)
651
+
652
+ isModifiedCh.publish({
653
+ scenarios,
654
+ testFileAbsolutePath: gherkinDocument.uri,
655
+ modifiedTests,
656
+ stepIds,
657
+ stepDefinitions: this.supportCodeLibrary.stepDefinitions,
658
+ setIsModified
659
+ })
660
+ modifiedTestsByPickleId.set(pickle.id, isModified)
661
+ }
662
+
624
663
  if (isKnownTestsEnabled && !isAttemptToFix) {
625
664
  isNew = isNewTest(testSuitePath, pickle.name)
626
665
  if (isNew) {
@@ -631,7 +670,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
631
670
  let runTestCaseResult = await runTestCaseFunction.apply(this, arguments)
632
671
 
633
672
  const testStatuses = lastStatusByPickleId.get(pickle.id)
634
- const lastTestStatus = testStatuses[testStatuses.length - 1]
673
+ const lastTestStatus = testStatuses.at(-1)
635
674
 
636
675
  // New tests should not be marked as attempt to fix, so EFD + Attempt to fix should not be enabled at the same time
637
676
  if (isAttemptToFix && lastTestStatus !== 'skip') {
@@ -642,7 +681,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
642
681
  }
643
682
 
644
683
  // If it's a new test and it hasn't been skipped, we run it again
645
- if (isEarlyFlakeDetectionEnabled && lastTestStatus !== 'skip' && isNew) {
684
+ if (isEarlyFlakeDetectionEnabled && lastTestStatus !== 'skip' && (isNew || isModified)) {
646
685
  for (let retryIndex = 0; retryIndex < earlyFlakeDetectionNumRetries; retryIndex++) {
647
686
  numRetriesByPickleId.set(pickle.id, retryIndex + 1)
648
687
  runTestCaseResult = await runTestCaseFunction.apply(this, arguments)
@@ -651,7 +690,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
651
690
  let testStatus = lastTestStatus
652
691
  let shouldBePassedByEFD = false
653
692
  let shouldBePassedByTestManagement = false
654
- if (isNew && isEarlyFlakeDetectionEnabled) {
693
+ if ((isNew || isModified) && isEarlyFlakeDetectionEnabled) {
655
694
  /**
656
695
  * If Early Flake Detection (EFD) is enabled the logic is as follows:
657
696
  * - If all attempts for a test are failing, the test has failed and we will let the test process fail.
@@ -672,10 +711,10 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
672
711
  shouldBePassedByTestManagement = true
673
712
  }
674
713
 
675
- if (!pickleResultByFile[testFileAbsolutePath]) {
676
- pickleResultByFile[testFileAbsolutePath] = [testStatus]
677
- } else {
714
+ if (pickleResultByFile[testFileAbsolutePath]) {
678
715
  pickleResultByFile[testFileAbsolutePath].push(testStatus)
716
+ } else {
717
+ pickleResultByFile[testFileAbsolutePath] = [testStatus]
679
718
  }
680
719
 
681
720
  // If it's a worker, suite events are handled in `getWrappedParseWorkerMessage`
@@ -699,7 +738,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
699
738
  testSuiteFinishCh.publish({ status: testSuiteStatus, testSuitePath })
700
739
  }
701
740
 
702
- if (isNewerCucumberVersion && isEarlyFlakeDetectionEnabled && isNew) {
741
+ if (isNewerCucumberVersion && isEarlyFlakeDetectionEnabled && (isNew || isModified)) {
703
742
  return shouldBePassedByEFD
704
743
  }
705
744
 
@@ -726,13 +765,7 @@ function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion)
726
765
  }
727
766
  }
728
767
 
729
- let envelope
730
-
731
- if (isNewVersion) {
732
- envelope = message.envelope
733
- } else {
734
- envelope = message.jsonEnvelope
735
- }
768
+ const envelope = isNewVersion ? message.envelope : message.jsonEnvelope
736
769
 
737
770
  if (!envelope) {
738
771
  return parseWorkerMessageFunction.apply(this, arguments)
@@ -742,7 +775,7 @@ function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion)
742
775
  if (typeof parsed === 'string') {
743
776
  try {
744
777
  parsed = JSON.parse(envelope)
745
- } catch (e) {
778
+ } catch {
746
779
  // ignore errors and continue
747
780
  return parseWorkerMessageFunction.apply(this, arguments)
748
781
  }
@@ -795,11 +828,11 @@ function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion)
795
828
  if (isEarlyFlakeDetectionEnabled && isNew) {
796
829
  const testFullname = `${pickle.uri}:${pickle.name}`
797
830
  let testStatuses = newTestsByTestFullname.get(testFullname)
798
- if (!testStatuses) {
831
+ if (testStatuses) {
832
+ testStatuses.push(status)
833
+ } else {
799
834
  testStatuses = [status]
800
835
  newTestsByTestFullname.set(testFullname, testStatuses)
801
- } else {
802
- testStatuses.push(status)
803
836
  }
804
837
  // We have finished all retries
805
838
  if (testStatuses.length === earlyFlakeDetectionNumRetries + 1) {
@@ -952,6 +985,11 @@ addHook({
952
985
  this.options.worldParameters._ddEarlyFlakeDetectionNumRetries = earlyFlakeDetectionNumRetries
953
986
  }
954
987
 
988
+ if (isImpactedTestsEnabled) {
989
+ this.options.worldParameters._ddImpactedTestsEnabled = isImpactedTestsEnabled
990
+ this.options.worldParameters._ddModifiedTests = modifiedTests
991
+ }
992
+
955
993
  return startWorker.apply(this, arguments)
956
994
  })
957
995
  return adapterPackage
@@ -978,6 +1016,10 @@ addHook({
978
1016
  if (isEarlyFlakeDetectionEnabled) {
979
1017
  earlyFlakeDetectionNumRetries = this.options.worldParameters._ddEarlyFlakeDetectionNumRetries
980
1018
  }
1019
+ isImpactedTestsEnabled = !!this.options.worldParameters._ddImpactedTestsEnabled
1020
+ if (isImpactedTestsEnabled) {
1021
+ modifiedTests = this.options.worldParameters._ddModifiedTests
1022
+ }
981
1023
  }
982
1024
  )
983
1025
  return workerPackage
@@ -1,8 +1,9 @@
1
1
  const { addHook } = require('./helpers/instrument')
2
+ const { DD_MAJOR } = require('../../../version')
2
3
 
3
4
  // No handler because this is only useful for testing.
4
5
  // Cypress plugin does not patch any library.
5
6
  addHook({
6
7
  name: 'cypress',
7
- versions: ['>=6.7.0']
8
+ versions: DD_MAJOR >= 6 ? ['>=10.2.0'] : ['>=6.7.0']
8
9
  }, lib => lib)
@@ -62,7 +62,7 @@ function wrap (prefix, fn, expectedArgs, rrtype) {
62
62
  return fn.apply(this, arguments)
63
63
  }
64
64
 
65
- const args = Array.from(arguments)
65
+ const args = [...arguments]
66
66
  args.pop() // gets rid of the callback
67
67
  if (rrtype) {
68
68
  args.push(rrtype)
@@ -149,11 +149,9 @@ addHook({ name: 'express', versions: ['>=4.3.0 <5.0.0'] }, express => {
149
149
  const queryReadCh = channel('datadog:express:query:finish')
150
150
 
151
151
  addHook({ name: 'express', file: ['lib/request.js'], versions: ['>=5.0.0'] }, request => {
152
- const requestDescriptor = Object.getOwnPropertyDescriptor(request, 'query')
153
-
154
- shimmer.wrap(requestDescriptor, 'get', function (originalGet) {
152
+ shimmer.wrap(request, 'query', function (originalGet) {
155
153
  return function wrappedGet () {
156
- const query = originalGet.apply(this, arguments)
154
+ const query = originalGet.call(this)
157
155
 
158
156
  if (queryReadCh.hasSubscribers && query) {
159
157
  queryReadCh.publish({ query })
@@ -163,7 +161,5 @@ addHook({ name: 'express', file: ['lib/request.js'], versions: ['>=5.0.0'] }, re
163
161
  }
164
162
  })
165
163
 
166
- Object.defineProperty(request, 'query', requestDescriptor)
167
-
168
164
  return request
169
165
  })
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
 
3
+ const { errorMonitor } = require('events')
3
4
  const { channel, addHook } = require('./helpers/instrument')
4
5
  const shimmer = require('../../datadog-shimmer')
5
6
 
@@ -199,16 +200,16 @@ function wrapCreateStream (original) {
199
200
  }
200
201
  const onFinish = () => {
201
202
  finishChannel.runStores(ctx, () => {})
202
- stream.off('close', onFinish)
203
- stream.off('end', onFinish)
204
- stream.off('finish', onFinish)
205
- stream.off('error', onError)
203
+ stream.removeListener('close', onFinish)
204
+ stream.removeListener('end', onFinish)
205
+ stream.removeListener('finish', onFinish)
206
+ stream.removeListener(errorMonitor, onError)
206
207
  }
207
208
 
208
209
  stream.once('close', onFinish)
209
210
  stream.once('end', onFinish)
210
211
  stream.once('finish', onFinish)
211
- stream.once('error', onError)
212
+ stream.once(errorMonitor, onError)
212
213
 
213
214
  return stream
214
215
  } catch (error) {
@@ -365,7 +366,7 @@ function massWrap (target, methods, wrapper) {
365
366
  function wrap (target, method, wrapper) {
366
367
  try {
367
368
  shimmer.wrap(target, method, wrapper)
368
- } catch (e) {
369
+ } catch {
369
370
  // skip unavailable method
370
371
  }
371
372
  }
@@ -2,8 +2,7 @@
2
2
 
3
3
  const {
4
4
  channel,
5
- addHook,
6
- AsyncResource
5
+ addHook
7
6
  } = require('./helpers/instrument')
8
7
  const shimmer = require('../../datadog-shimmer')
9
8
 
@@ -65,38 +64,32 @@ function wrapMethod (method) {
65
64
  return function (request) {
66
65
  if (!requestStartCh.hasSubscribers) return method.apply(this, arguments)
67
66
 
68
- const innerAsyncResource = new AsyncResource('bound-anonymous-fn')
69
-
70
- return innerAsyncResource.runInAsyncScope(() => {
71
- const projectId = this.auth._cachedProjectId
67
+ const ctx = { request, api, projectId: this.auth._cachedProjectId }
68
+ return requestStartCh.runStores(ctx, () => {
72
69
  const cb = arguments[arguments.length - 1]
73
70
 
74
- requestStartCh.publish({ request, api, projectId })
75
-
76
71
  if (typeof cb === 'function') {
77
- const outerAsyncResource = new AsyncResource('bound-anonymous-fn')
78
-
79
- arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => innerAsyncResource.bind(function (error) {
72
+ arguments[arguments.length - 1] = shimmer.wrapFunction(cb, cb => function (error) {
80
73
  if (error) {
81
- requestErrorCh.publish(error)
74
+ ctx.error = error
75
+ requestErrorCh.publish(ctx)
82
76
  }
83
77
 
84
- requestFinishCh.publish()
85
-
86
- return outerAsyncResource.runInAsyncScope(() => cb.apply(this, arguments))
87
- }))
78
+ return requestFinishCh.runStores(ctx, cb, this, ...arguments)
79
+ })
88
80
 
89
81
  return method.apply(this, arguments)
90
82
  } else {
91
83
  return method.apply(this, arguments)
92
84
  .then(
93
85
  response => {
94
- requestFinishCh.publish()
86
+ requestFinishCh.publish(ctx)
95
87
  return response
96
88
  },
97
89
  error => {
98
- requestErrorCh.publish(error)
99
- requestFinishCh.publish()
90
+ ctx.error = error
91
+ requestErrorCh.publish(ctx)
92
+ requestFinishCh.publish(ctx)
100
93
  throw error
101
94
  }
102
95
  )
@@ -119,16 +112,14 @@ addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'] }, (obj) => {
119
112
  shimmer.wrap(Subscription.prototype, 'emit', emit => function (eventName, message) {
120
113
  if (eventName !== 'message' || !message) return emit.apply(this, arguments)
121
114
 
122
- const asyncResource = new AsyncResource('bound-anonymous-fn')
123
-
124
- return asyncResource.runInAsyncScope(() => {
125
- try {
126
- return emit.apply(this, arguments)
127
- } catch (err) {
128
- receiveErrorCh.publish(err)
129
- throw err
130
- }
131
- })
115
+ const ctx = {}
116
+ try {
117
+ return emit.apply(this, arguments)
118
+ } catch (err) {
119
+ ctx.error = err
120
+ receiveErrorCh.publish(ctx)
121
+ throw err
122
+ }
132
123
  })
133
124
 
134
125
  return obj
@@ -136,22 +127,25 @@ addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'] }, (obj) => {
136
127
 
137
128
  addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'], file: 'build/src/lease-manager.js' }, (obj) => {
138
129
  const LeaseManager = obj.LeaseManager
130
+ const ctx = {}
139
131
 
140
132
  shimmer.wrap(LeaseManager.prototype, '_dispense', dispense => function (message) {
141
133
  if (receiveStartCh.hasSubscribers) {
142
- receiveStartCh.publish({ message })
134
+ ctx.message = message
135
+ return receiveStartCh.runStores(ctx, dispense, this, ...arguments)
136
+ } else {
137
+ return dispense.apply(this, arguments)
143
138
  }
144
- return dispense.apply(this, arguments)
145
139
  })
146
140
 
147
141
  shimmer.wrap(LeaseManager.prototype, 'remove', remove => function (message) {
148
- receiveFinishCh.publish({ message })
149
- return remove.apply(this, arguments)
142
+ return receiveFinishCh.runStores(ctx, remove, this, ...arguments)
150
143
  })
151
144
 
152
145
  shimmer.wrap(LeaseManager.prototype, 'clear', clear => function () {
153
146
  for (const message of this._messages) {
154
- receiveFinishCh.publish({ message })
147
+ ctx.message = message
148
+ receiveFinishCh.publish(ctx)
155
149
  }
156
150
  return clear.apply(this, arguments)
157
151
  })