dd-trace 6.23.0 → 6.25.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 (353) hide show
  1. package/LICENSE-3rdparty.csv +0 -1
  2. package/ci/cypress/support.js +15 -1
  3. package/ci/init.js +2 -22
  4. package/ci/test-annotations.d.ts +5 -0
  5. package/ci/test-annotations.js +5 -0
  6. package/ci/vitest-no-worker-init-annotations.mjs +4 -0
  7. package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
  8. package/ci/vitest-no-worker-init-runner-setup.mjs +7 -32
  9. package/ci/vitest-no-worker-init-setup.mjs +34 -12
  10. package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
  11. package/ext/exporters.js +1 -1
  12. package/index.d.ts +124 -5
  13. package/initialize.mjs +5 -2
  14. package/lambda.d.ts +39 -0
  15. package/lambda.js +3 -0
  16. package/loader-hook.mjs +53 -0
  17. package/openfeature/exposure-hook.d.ts +66 -0
  18. package/openfeature/exposure-hook.js +5 -0
  19. package/package.json +19 -15
  20. package/packages/datadog-core/src/storage.js +1 -1
  21. package/packages/datadog-esbuild/index.js +78 -62
  22. package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
  23. package/packages/datadog-instrumentations/src/cucumber.js +56 -19
  24. package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
  25. package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
  26. package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
  27. package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
  28. package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
  29. package/packages/datadog-instrumentations/src/graphql.js +29 -20
  30. package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
  31. package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
  32. package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
  33. package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
  34. package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
  35. package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
  36. package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
  37. package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -8
  38. package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
  39. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +18 -6
  40. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
  41. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
  42. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
  46. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
  47. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
  48. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
  49. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
  50. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
  51. package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +58 -0
  52. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
  53. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +25 -3
  54. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
  55. package/packages/datadog-instrumentations/src/ioredis.js +101 -3
  56. package/packages/datadog-instrumentations/src/jest.js +265 -82
  57. package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
  58. package/packages/datadog-instrumentations/src/mariadb.js +13 -6
  59. package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
  60. package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
  61. package/packages/datadog-instrumentations/src/mocha/utils.js +58 -12
  62. package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
  63. package/packages/datadog-instrumentations/src/next.js +19 -6
  64. package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
  65. package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
  66. package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
  67. package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
  68. package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
  69. package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
  70. package/packages/datadog-instrumentations/src/oracledb.js +33 -0
  71. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
  72. package/packages/datadog-instrumentations/src/pg.js +2 -1
  73. package/packages/datadog-instrumentations/src/playwright.js +81 -28
  74. package/packages/datadog-instrumentations/src/react-router.js +106 -0
  75. package/packages/datadog-instrumentations/src/typesafe.js +89 -0
  76. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -48
  77. package/packages/datadog-instrumentations/src/vitest-main.js +26 -0
  78. package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
  79. package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
  80. package/packages/datadog-instrumentations/src/vitest.js +10 -8
  81. package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
  82. package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
  83. package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
  84. package/packages/datadog-plugin-cucumber/src/index.js +5 -0
  85. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +296 -55
  86. package/packages/datadog-plugin-cypress/src/index.js +1 -1
  87. package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
  88. package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
  89. package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
  90. package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
  91. package/packages/datadog-plugin-cypress/src/support.js +1217 -439
  92. package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
  93. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
  94. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
  95. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
  96. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
  97. package/packages/datadog-plugin-graphql/src/execute.js +2 -2
  98. package/packages/datadog-plugin-graphql/src/utils.js +5 -5
  99. package/packages/datadog-plugin-http/src/client.js +32 -9
  100. package/packages/datadog-plugin-http2/src/client.js +38 -13
  101. package/packages/datadog-plugin-jest/src/index.js +25 -3
  102. package/packages/datadog-plugin-mocha/src/index.js +47 -6
  103. package/packages/datadog-plugin-next/src/index.js +112 -14
  104. package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
  105. package/packages/datadog-plugin-playwright/src/index.js +4 -0
  106. package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
  107. package/packages/datadog-plugin-react-router/src/index.js +118 -0
  108. package/packages/datadog-plugin-trpc/src/index.js +15 -0
  109. package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
  110. package/packages/datadog-plugin-trpc/src/request.js +81 -0
  111. package/packages/datadog-plugin-typesafe/src/index.js +17 -0
  112. package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
  113. package/packages/datadog-plugin-undici/src/index.js +22 -7
  114. package/packages/datadog-plugin-vitest/src/index.js +8 -0
  115. package/packages/datadog-turbopack/index.js +4 -28
  116. package/packages/datadog-turbopack/src/loader.js +14 -452
  117. package/packages/datadog-webpack/index.js +3 -55
  118. package/packages/dd-trace/src/agent/info.js +2 -1
  119. package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
  120. package/packages/dd-trace/src/aiguard/sdk.js +8 -13
  121. package/packages/dd-trace/src/aiguard/tags.js +2 -0
  122. package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
  123. package/packages/dd-trace/src/appsec/graphql.js +91 -6
  124. package/packages/dd-trace/src/appsec/recommended.json +1287 -90
  125. package/packages/dd-trace/src/before-exit.js +32 -0
  126. package/packages/dd-trace/src/bootstrap.js +5 -3
  127. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +24 -18
  128. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +16 -36
  129. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
  130. package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
  131. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -18
  132. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +10 -15
  133. package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
  134. package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
  135. package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
  136. package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
  137. package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
  138. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +10 -17
  139. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
  140. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
  141. package/packages/dd-trace/src/config/config-types.d.ts +3 -0
  142. package/packages/dd-trace/src/config/defaults.js +9 -3
  143. package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -2
  144. package/packages/dd-trace/src/config/index.js +111 -43
  145. package/packages/dd-trace/src/config/parsers.js +18 -1
  146. package/packages/dd-trace/src/config/supported-configurations.json +174 -4
  147. package/packages/dd-trace/src/constants.js +1 -0
  148. package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
  149. package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
  150. package/packages/dd-trace/src/encode/0.4.js +2 -2
  151. package/packages/dd-trace/src/esm-module-load.js +58 -0
  152. package/packages/dd-trace/src/exporter.js +23 -15
  153. package/packages/dd-trace/src/exporters/agent/index.js +3 -1
  154. package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
  155. package/packages/dd-trace/src/exporters/common/request.js +83 -50
  156. package/packages/dd-trace/src/exporters/common/retry.js +12 -7
  157. package/packages/dd-trace/src/exporters/common/url.js +1 -1
  158. package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
  159. package/packages/dd-trace/src/exporters/log/index.js +4 -3
  160. package/packages/dd-trace/src/id.js +1 -1
  161. package/packages/dd-trace/src/lambda/facade.js +74 -0
  162. package/packages/dd-trace/src/lambda/handler.js +3 -41
  163. package/packages/dd-trace/src/lambda/index.js +38 -15
  164. package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
  165. package/packages/dd-trace/src/lambda/wrap.js +44 -0
  166. package/packages/dd-trace/src/llmobs/constants/tags.js +3 -0
  167. package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
  168. package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
  169. package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
  170. package/packages/dd-trace/src/llmobs/index.js +13 -2
  171. package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
  172. package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
  173. package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
  174. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +27 -10
  175. package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
  176. package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
  177. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
  178. package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
  179. package/packages/dd-trace/src/llmobs/sdk.js +21 -1
  180. package/packages/dd-trace/src/llmobs/span_processor.js +219 -12
  181. package/packages/dd-trace/src/llmobs/tagger.js +25 -0
  182. package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
  183. package/packages/dd-trace/src/log/channels.js +4 -0
  184. package/packages/dd-trace/src/log/writer.js +13 -2
  185. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +68 -6
  186. package/packages/dd-trace/src/openfeature/configuration_source.js +41 -17
  187. package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
  188. package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
  189. package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
  190. package/packages/dd-trace/src/openfeature/flagging_provider.js +58 -14
  191. package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
  192. package/packages/dd-trace/src/openfeature/writers/base.js +63 -30
  193. package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
  194. package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
  195. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
  196. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
  197. package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
  198. package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
  199. package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
  200. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
  201. package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
  202. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
  203. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
  204. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
  205. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
  206. package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
  207. package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
  208. package/packages/dd-trace/src/opentelemetry/span.js +2 -2
  209. package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
  210. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
  211. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
  212. package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
  213. package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
  214. package/packages/dd-trace/src/opentracing/tracer.js +33 -13
  215. package/packages/dd-trace/src/otel-thread-ctx.js +72 -49
  216. package/packages/dd-trace/src/plugin_manager.js +34 -7
  217. package/packages/dd-trace/src/plugins/ci_plugin.js +45 -14
  218. package/packages/dd-trace/src/plugins/index.js +9 -0
  219. package/packages/dd-trace/src/plugins/plugin.js +4 -2
  220. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  221. package/packages/dd-trace/src/plugins/util/ci.js +18 -1
  222. package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
  223. package/packages/dd-trace/src/plugins/util/git.js +273 -86
  224. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +77 -50
  225. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
  226. package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
  227. package/packages/dd-trace/src/plugins/util/tags.js +6 -0
  228. package/packages/dd-trace/src/plugins/util/test.js +90 -45
  229. package/packages/dd-trace/src/plugins/util/url.js +10 -2
  230. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
  231. package/packages/dd-trace/src/plugins/util/web.js +81 -10
  232. package/packages/dd-trace/src/process-tags/index.js +1 -1
  233. package/packages/dd-trace/src/profiling/config.js +6 -3
  234. package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
  235. package/packages/dd-trace/src/proxy.js +48 -57
  236. package/packages/dd-trace/src/serverless.js +3 -2
  237. package/packages/dd-trace/src/span_processor.js +41 -9
  238. package/packages/dd-trace/src/span_stats.js +28 -2
  239. package/packages/dd-trace/src/startup-log.js +8 -5
  240. package/packages/dd-trace/src/tagger.js +7 -5
  241. package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
  242. package/packages/dd-trace/src/telemetry/index.js +3 -0
  243. package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
  244. package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -0
  245. package/packages/dd-trace/src/telemetry/metrics.js +2 -1
  246. package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
  247. package/packages/dd-trace/src/tracer.js +0 -2
  248. package/packages/dd-trace/src/util.js +1 -1
  249. package/packages/dd-trace/src/web-tags-cache.js +8 -9
  250. package/register.js +4 -2
  251. package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
  252. package/vendor/dist/{@opentelemetry/resources → @datadog/flagging-core}/LICENSE +22 -2
  253. package/vendor/dist/@datadog/flagging-core/index.js +1 -0
  254. package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
  255. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
  256. package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
  257. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
  258. package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
  259. package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
  260. package/vendor/dist/@datadog/source-map/LICENSE +1 -0
  261. package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
  262. package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
  263. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  264. package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
  265. package/vendor/dist/escape-string-regexp/LICENSE +13 -0
  266. package/vendor/dist/esquery/LICENSE +2 -0
  267. package/vendor/dist/https-proxy-agent/LICENSE +80 -1
  268. package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
  269. package/vendor/dist/jest-docblock/LICENSE +16 -0
  270. package/vendor/dist/jsonpath-plus/LICENSE +13 -0
  271. package/vendor/dist/limiter/LICENSE +2 -0
  272. package/vendor/dist/lodash.sortby/LICENSE +2 -0
  273. package/vendor/dist/lru-cache/LICENSE +13 -0
  274. package/vendor/dist/meriyah/LICENSE +13 -0
  275. package/vendor/dist/module-details-from-path/LICENSE +2 -0
  276. package/vendor/dist/mutexify/promise/LICENSE +28 -0
  277. package/vendor/dist/pprof-format/LICENSE +13 -0
  278. package/vendor/dist/pprof-format/index.js +1 -1
  279. package/vendor/dist/protobufjs/LICENSE +219 -0
  280. package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
  281. package/vendor/dist/proxy-from-env/LICENSE +13 -0
  282. package/vendor/dist/retry/LICENSE +2 -0
  283. package/vendor/dist/rfdc/LICENSE +2 -0
  284. package/vendor/dist/semifies/LICENSE +3 -1
  285. package/vendor/dist/shell-quote/LICENSE +3 -1
  286. package/vendor/dist/source-map/LICENSE +1 -0
  287. package/vendor/dist/source-map/lib/util/LICENSE +1 -0
  288. package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
  289. package/vendor/dist/ttl-set/LICENSE +28 -0
  290. package/ci/diagnose.js +0 -2215
  291. package/ci/runbook.md +0 -299
  292. package/ci/test-optimization-validation/approval-artifacts.js +0 -175
  293. package/ci/test-optimization-validation/approval.js +0 -386
  294. package/ci/test-optimization-validation/artifact-id.js +0 -19
  295. package/ci/test-optimization-validation/blocker-category.js +0 -24
  296. package/ci/test-optimization-validation/bounded-json.js +0 -120
  297. package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
  298. package/ci/test-optimization-validation/ci-discovery.js +0 -192
  299. package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
  300. package/ci/test-optimization-validation/ci-remediation.js +0 -283
  301. package/ci/test-optimization-validation/cli.js +0 -954
  302. package/ci/test-optimization-validation/command-blocker.js +0 -377
  303. package/ci/test-optimization-validation/command-output-policy.js +0 -188
  304. package/ci/test-optimization-validation/command-runner.js +0 -650
  305. package/ci/test-optimization-validation/environment.js +0 -88
  306. package/ci/test-optimization-validation/executable-approval.js +0 -47
  307. package/ci/test-optimization-validation/executable.js +0 -244
  308. package/ci/test-optimization-validation/execution-lock.js +0 -70
  309. package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
  310. package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
  311. package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
  312. package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
  313. package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
  314. package/ci/test-optimization-validation/generated-file-policy.js +0 -63
  315. package/ci/test-optimization-validation/generated-files.js +0 -425
  316. package/ci/test-optimization-validation/generated-test-contract.js +0 -284
  317. package/ci/test-optimization-validation/generated-verifier.js +0 -235
  318. package/ci/test-optimization-validation/literal-environment.js +0 -56
  319. package/ci/test-optimization-validation/literal-glob.js +0 -52
  320. package/ci/test-optimization-validation/manifest-loader.js +0 -116
  321. package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
  322. package/ci/test-optimization-validation/manifest-schema.js +0 -695
  323. package/ci/test-optimization-validation/offline-fixtures.js +0 -335
  324. package/ci/test-optimization-validation/offline-output.js +0 -406
  325. package/ci/test-optimization-validation/package-check.js +0 -97
  326. package/ci/test-optimization-validation/payload-normalizer.js +0 -72
  327. package/ci/test-optimization-validation/plan-writer.js +0 -541
  328. package/ci/test-optimization-validation/preflight-runner.js +0 -186
  329. package/ci/test-optimization-validation/project-build-artifact.js +0 -31
  330. package/ci/test-optimization-validation/redaction.js +0 -319
  331. package/ci/test-optimization-validation/report-writer.js +0 -666
  332. package/ci/test-optimization-validation/result-semantics.js +0 -103
  333. package/ci/test-optimization-validation/runner-command.js +0 -264
  334. package/ci/test-optimization-validation/runner-contract.js +0 -695
  335. package/ci/test-optimization-validation/safe-files.js +0 -202
  336. package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
  337. package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
  338. package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
  339. package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
  340. package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
  341. package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
  342. package/ci/test-optimization-validation/source-text.js +0 -84
  343. package/ci/test-optimization-validation/static-diagnosis.js +0 -166
  344. package/ci/test-optimization-validation/test-output.js +0 -120
  345. package/ci/test-optimization-validation/validation-blocker.js +0 -21
  346. package/ci/validate-test-optimization.js +0 -3
  347. package/packages/datadog-esbuild/src/resolver.js +0 -284
  348. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
  349. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
  350. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
  351. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
  352. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
  353. package/vendor/dist/@opentelemetry/resources/index.js +0 -1
@@ -1,88 +0,0 @@
1
- 'use strict'
2
-
3
- /**
4
- * Compares environment variable names using the child platform's semantics.
5
- *
6
- * @param {string} left first variable name
7
- * @param {string} right second variable name
8
- * @param {string} [platform] target platform
9
- */
10
- function environmentNamesEqual (left, right, platform = process.platform) {
11
- return platform === 'win32' ? left.toUpperCase() === right.toUpperCase() : left === right
12
- }
13
-
14
- /**
15
- * Finds an environment entry without inventing a second spelling on Windows.
16
- *
17
- * @param {Record<string, string|undefined>} environment environment object
18
- * @param {string} name variable name
19
- * @param {string} [platform] target platform
20
- * @returns {[string, string|undefined]|undefined} matching entry
21
- */
22
- function findEnvironmentEntry (environment, name, platform = process.platform) {
23
- return Object.entries(environment || {}).find(([candidate]) => {
24
- return environmentNamesEqual(candidate, name, platform)
25
- })
26
- }
27
-
28
- /**
29
- * Reads an environment value using platform name semantics.
30
- *
31
- * @param {Record<string, string|undefined>} environment environment object
32
- * @param {string} name variable name
33
- * @param {string} [platform] target platform
34
- * @returns {string|undefined} environment value
35
- */
36
- function getEnvironmentValue (environment, name, platform = process.platform) {
37
- return findEnvironmentEntry(environment, name, platform)?.[1]
38
- }
39
-
40
- /**
41
- * Replaces every equivalent spelling with one canonical entry.
42
- *
43
- * @param {Record<string, string|undefined>} environment environment object
44
- * @param {string} name canonical variable name
45
- * @param {string|undefined} value environment value
46
- * @param {string} [platform] target platform
47
- */
48
- function setEnvironmentValue (environment, name, value, platform = process.platform) {
49
- for (const candidate of Object.keys(environment)) {
50
- if (environmentNamesEqual(candidate, name, platform)) delete environment[candidate]
51
- }
52
- environment[name] = value
53
- }
54
-
55
- /**
56
- * Applies environment entries with Windows-compatible replacement semantics.
57
- *
58
- * @param {Record<string, string|undefined>} target destination environment
59
- * @param {Record<string, string|undefined>} source overriding entries
60
- * @param {string} [platform] target platform
61
- */
62
- function mergeEnvironment (target, source, platform = process.platform) {
63
- if (source) {
64
- for (const [name, value] of Object.entries(source)) {
65
- setEnvironmentValue(target, name, value, platform)
66
- }
67
- }
68
- }
69
-
70
- /**
71
- * Reports whether a name belongs to the private or public Datadog environment namespace.
72
- *
73
- * @param {string} name variable name
74
- * @param {string} [platform] target platform
75
- */
76
- function isDatadogEnvironmentName (name, platform = process.platform) {
77
- const normalized = platform === 'win32' ? name.toUpperCase() : name
78
- return normalized.startsWith('DD_') || normalized.startsWith('_DD_')
79
- }
80
-
81
- module.exports = {
82
- environmentNamesEqual,
83
- findEnvironmentEntry,
84
- getEnvironmentValue,
85
- isDatadogEnvironmentName,
86
- mergeEnvironment,
87
- setEnvironmentValue,
88
- }
@@ -1,47 +0,0 @@
1
- 'use strict'
2
-
3
- const APPROVED_EXECUTABLE = Symbol('approvedValidationExecutable')
4
-
5
- /**
6
- * Binds a command to the executable identity covered by the approved plan.
7
- *
8
- * @param {object} command command to bind
9
- * @param {object} identity approved executable identity
10
- */
11
- function bindApprovedExecutable (command, identity) {
12
- Object.defineProperty(command, APPROVED_EXECUTABLE, {
13
- configurable: true,
14
- enumerable: false,
15
- value: identity,
16
- writable: false,
17
- })
18
- }
19
-
20
- /**
21
- * Returns the executable identity bound to a command.
22
- *
23
- * @param {object} command command to inspect
24
- * @returns {object|undefined} approved executable identity
25
- */
26
- function getApprovedExecutable (command) {
27
- return command?.[APPROVED_EXECUTABLE]
28
- }
29
-
30
- /**
31
- * Carries an approved executable identity onto a derived command.
32
- *
33
- * @param {object} source source command
34
- * @param {object} derived derived command
35
- * @returns {object} derived command
36
- */
37
- function inheritApprovedExecutable (source, derived) {
38
- const identity = getApprovedExecutable(source)
39
- if (identity && source !== derived) bindApprovedExecutable(derived, identity)
40
- return derived
41
- }
42
-
43
- module.exports = {
44
- bindApprovedExecutable,
45
- getApprovedExecutable,
46
- inheritApprovedExecutable,
47
- }
@@ -1,244 +0,0 @@
1
- 'use strict'
2
-
3
- const crypto = require('node:crypto')
4
- const fs = require('node:fs')
5
- const path = require('node:path')
6
-
7
- const { bindApprovedExecutable, getApprovedExecutable } = require('./executable-approval')
8
- const { getManifestCommands } = require('./runner-command')
9
-
10
- /**
11
- * Returns the unavailable file for a direct command.
12
- *
13
- * @param {object} command validator-owned command
14
- * @returns {string|undefined} unavailable executable
15
- */
16
- function getUnavailableExecutable (command) {
17
- if (!isDirectRunnerCommand(command)) return command?.argv?.[0] || 'invalid direct-runner command'
18
- for (const filename of [process.execPath, command.argv[1]]) {
19
- if (!isRegularFile(filename)) return filename
20
- }
21
- }
22
-
23
- /**
24
- * Returns the trusted Node.js executable used for every validation command.
25
- *
26
- * @param {object} command validator-owned command
27
- * @returns {string|undefined} Node.js executable
28
- */
29
- function getResolvedExecutable (command) {
30
- return isDirectRunnerCommand(command) && isRegularFile(process.execPath)
31
- ? fs.realpathSync(process.execPath)
32
- : undefined
33
- }
34
-
35
- /**
36
- * Fingerprints and binds every runnable framework's Node.js and runner files.
37
- *
38
- * @param {object} manifest normalized manifest
39
- * @returns {object[]} executable identities
40
- */
41
- function bindManifestExecutables (manifest) {
42
- const identities = []
43
- if (manifest.frameworks) {
44
- for (const framework of manifest.frameworks) {
45
- if (framework.status !== 'runnable') continue
46
- const command = getManifestCommands({ frameworks: [framework] })[0]?.[1]
47
- try {
48
- const identity = getCommandExecutableIdentity(command, manifest.repository.root)
49
- bindApprovedExecutable(framework.validation, identity)
50
- identities.push({ id: `framework:${framework.id}`, ...identity })
51
- } catch (error) {
52
- identities.push({
53
- id: `framework:${framework.id}`,
54
- unavailable: true,
55
- reason: error?.message || String(error),
56
- })
57
- }
58
- }
59
- }
60
- return identities
61
- }
62
-
63
- /**
64
- * Resolves a checksum-approved executable immediately before spawn.
65
- *
66
- * @param {object} command validator-owned command
67
- * @param {object} [options] resolution options
68
- * @param {boolean} [options.requireApproval] whether approval is mandatory
69
- * @returns {{argv0: string, path: string}} spawn executable
70
- */
71
- function getExecutableForSpawn (command, options = {}) {
72
- const approved = getApprovedExecutable(command)
73
- if (options.requireApproval && !approved) {
74
- throw new Error('Direct-runner command is not bound to the approved execution plan.')
75
- }
76
- const current = getCommandExecutableIdentity(command, approved?.repositoryRoot)
77
- if (approved && !areExecutableIdentitiesEqual(current, approved)) {
78
- throw new Error('The approved Node.js or test-runner executable changed after approval.')
79
- }
80
- return { argv0: process.execPath, path: current.path }
81
- }
82
-
83
- /**
84
- * Builds the executable identity for one direct-runner command.
85
- *
86
- * @param {object} command validator-owned command
87
- * @param {string} repositoryRoot repository root
88
- * @returns {object} executable identity
89
- */
90
- function getCommandExecutableIdentity (command, repositoryRoot) {
91
- if (!isDirectRunnerCommand(command)) {
92
- throw new Error('Only validator-owned `node <contained-runner> ...` commands may execute.')
93
- }
94
-
95
- repositoryRoot ||= command.cwd
96
- const root = fs.realpathSync(repositoryRoot)
97
- const node = getFileIdentity(process.execPath)
98
- const runner = getFileIdentity(command.argv[1])
99
- if (!isPathInside(root, runner.path)) {
100
- throw new Error(`Test-runner executable resolves outside repository.root: ${command.argv[1]}`)
101
- }
102
- return {
103
- argv0: process.execPath,
104
- path: node.path,
105
- sha256: node.sha256,
106
- repositoryRoot,
107
- entrypoints: [runner],
108
- }
109
- }
110
-
111
- /**
112
- * Compares current and approved executable identities.
113
- *
114
- * @param {object} current current identity
115
- * @param {object} approved approved identity
116
- */
117
- function areExecutableIdentitiesEqual (current, approved) {
118
- return current.argv0 === approved.argv0 &&
119
- current.path === approved.path &&
120
- current.sha256 === approved.sha256 &&
121
- current.entrypoints?.length === approved.entrypoints?.length &&
122
- current.entrypoints.every((entrypoint, index) => {
123
- const expected = approved.entrypoints[index]
124
- return entrypoint.path === expected.path && entrypoint.sha256 === expected.sha256
125
- })
126
- }
127
-
128
- /**
129
- * Splits NODE_OPTIONS without invoking a shell or expanding variables.
130
- *
131
- * @param {string} source NODE_OPTIONS source
132
- * @returns {string[]} Node.js arguments
133
- */
134
- function splitNodeOptions (source) {
135
- const args = []
136
- let value = ''
137
- let started = false
138
- let quote
139
-
140
- for (let index = 0; index < String(source).length; index++) {
141
- const character = source[index]
142
- if (character === '\0') throw new Error('NODE_OPTIONS contains a null byte.')
143
- if (!quote && /\s/.test(character)) {
144
- if (started) args.push(value)
145
- value = ''
146
- started = false
147
- continue
148
- }
149
- if (character === '"' || character === "'") {
150
- if (!quote) {
151
- quote = character
152
- started = true
153
- continue
154
- }
155
- if (quote === character) {
156
- quote = undefined
157
- continue
158
- }
159
- }
160
- const next = source[index + 1]
161
- value += character === '\\' && next && (next === quote || /[\s'"\\]/.test(next)) ? source[++index] : character
162
- started = true
163
- }
164
- if (quote) throw new Error('NODE_OPTIONS contains an unterminated quoted value.')
165
- if (started) args.push(value)
166
- return args
167
- }
168
-
169
- /**
170
- * Returns whether a value is an explicit filesystem executable path.
171
- *
172
- * @param {string} value candidate value
173
- * @param {string} [platform] target platform
174
- */
175
- function isExplicitExecutablePath (value, platform = process.platform) {
176
- if (typeof value !== 'string') return false
177
- if (path.isAbsolute(value) || value.startsWith('.')) return true
178
- return platform === 'win32' ? /[\\/]/.test(value) : value.includes('/')
179
- }
180
-
181
- /**
182
- * Returns whether a command has the only executable shape the validator supports.
183
- *
184
- * @param {object} command command candidate
185
- */
186
- function isDirectRunnerCommand (command) {
187
- return command?.usesShell === false &&
188
- Array.isArray(command.argv) &&
189
- command.argv.length >= 3 &&
190
- command.argv[0] === process.execPath &&
191
- path.isAbsolute(command.argv[1])
192
- }
193
-
194
- /**
195
- * Fingerprints a regular file.
196
- *
197
- * @param {string} filename file path
198
- * @returns {{path: string, sha256: string}} file identity
199
- */
200
- function getFileIdentity (filename) {
201
- const physical = fs.realpathSync(filename)
202
- const stat = fs.lstatSync(physical)
203
- if (!stat.isFile() || stat.isSymbolicLink()) throw new Error(`Executable must be a regular file: ${filename}`)
204
- return {
205
- path: physical,
206
- sha256: crypto.createHash('sha256').update(fs.readFileSync(physical)).digest('hex'),
207
- }
208
- }
209
-
210
- /**
211
- * Returns whether a path resolves to a regular file.
212
- *
213
- * @param {string} filename candidate path
214
- */
215
- function isRegularFile (filename) {
216
- try {
217
- return fs.statSync(filename).isFile()
218
- } catch {
219
- return false
220
- }
221
- }
222
-
223
- /**
224
- * Checks path containment.
225
- *
226
- * @param {string} root root path
227
- * @param {string} filename candidate path
228
- */
229
- function isPathInside (root, filename) {
230
- const relative = path.relative(path.resolve(root), path.resolve(filename))
231
- return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative))
232
- }
233
-
234
- module.exports = {
235
- areExecutableIdentitiesEqual,
236
- bindManifestExecutables,
237
- getCommandExecutableIdentity,
238
- getExecutableForSpawn,
239
- getManifestCommands,
240
- getResolvedExecutable,
241
- getUnavailableExecutable,
242
- isExplicitExecutablePath,
243
- splitNodeOptions,
244
- }
@@ -1,70 +0,0 @@
1
- 'use strict'
2
-
3
- const fs = require('node:fs')
4
- const path = require('node:path')
5
-
6
- const { createFileSafely } = require('./safe-files')
7
- const { createValidationBlocker } = require('./validation-blocker')
8
-
9
- const EXECUTION_LOCK_FILENAME = '.dd-test-optimization-validation.lock'
10
-
11
- function getExecutionLockPath (out) {
12
- return path.join(path.resolve(out), EXECUTION_LOCK_FILENAME)
13
- }
14
-
15
- // Locks are never reclaimed automatically; only the creator may release the exact file identity.
16
- function acquireExecutionLock ({ out, approvedPlanSha256 }) {
17
- const lockPath = getExecutionLockPath(out)
18
- const content = `${JSON.stringify({
19
- approvedPlanSha256,
20
- pid: process.pid,
21
- startedAt: new Date().toISOString(),
22
- }, null, 2)}\n`
23
- try {
24
- createFileSafely(out, lockPath, content, 'validation execution lock')
25
- } catch (error) {
26
- if (error.code === 'EEXIST') throw getExistingLockError(lockPath)
27
- throw error
28
- }
29
-
30
- const stat = fs.lstatSync(lockPath, { bigint: true })
31
- if (!stat.isFile() || stat.isSymbolicLink()) {
32
- throw new Error(`Validation execution lock is not a regular file: ${lockPath}`)
33
- }
34
- return { dev: stat.dev, ino: stat.ino, path: lockPath }
35
- }
36
-
37
- function releaseExecutionLock (lock) {
38
- let stat
39
- try {
40
- stat = fs.lstatSync(lock.path, { bigint: true })
41
- } catch (error) {
42
- if (error.code === 'ENOENT') {
43
- throw new Error(`Validation execution lock disappeared before safe cleanup: ${lock.path}`)
44
- }
45
- throw error
46
- }
47
- if (!stat.isFile() || stat.isSymbolicLink() || stat.dev !== lock.dev || stat.ino !== lock.ino) {
48
- throw new Error(`Refusing to remove a changed validation execution lock: ${lock.path}`)
49
- }
50
- fs.unlinkSync(lock.path)
51
- }
52
-
53
- function getExistingLockError (lockPath) {
54
- return createValidationBlocker(
55
- `Another validation may be active, or an interrupted run left its execution lock: ${lockPath}.`,
56
- {
57
- kind: 'execution-lock-exists',
58
- recommendation: `Inspect ${lockPath}. Remove only that lock after confirming no validation process is active, ` +
59
- 'then render and approve a fresh plan.',
60
- suppressReport: true,
61
- }
62
- )
63
- }
64
-
65
- module.exports = {
66
- EXECUTION_LOCK_FILENAME,
67
- acquireExecutionLock,
68
- getExecutionLockPath,
69
- releaseExecutionLock,
70
- }