dd-trace 6.24.0 → 6.26.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 (352) hide show
  1. package/README.md +3 -0
  2. package/ci/cypress/support.js +2 -1
  3. package/ci/init.js +2 -22
  4. package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
  5. package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
  6. package/ci/vitest-no-worker-init-setup.mjs +729 -724
  7. package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
  8. package/ext/exporters.js +0 -1
  9. package/index.d.ts +105 -5
  10. package/initialize.mjs +5 -2
  11. package/package.json +41 -36
  12. package/packages/datadog-esbuild/index.js +16 -70
  13. package/packages/datadog-esbuild/src/log.js +2 -29
  14. package/packages/datadog-instrumentations/src/ai.js +6 -1
  15. package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
  16. package/packages/datadog-instrumentations/src/cucumber.js +5 -2
  17. package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
  18. package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
  19. package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
  20. package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
  21. package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
  22. package/packages/datadog-instrumentations/src/graphql.js +20 -17
  23. package/packages/datadog-instrumentations/src/helpers/bundler-esm-exports.js +582 -0
  24. package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
  25. package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +576 -0
  26. package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
  27. package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
  28. package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
  29. package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
  30. package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
  31. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +8 -0
  32. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
  33. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
  34. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
  35. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
  36. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-client.js +30 -0
  37. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
  38. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +61 -0
  39. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
  40. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
  41. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
  42. package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +80 -0
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +23 -3
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
  46. package/packages/datadog-instrumentations/src/ioredis.js +101 -3
  47. package/packages/datadog-instrumentations/src/microgateway-core.js +1 -2
  48. package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
  49. package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -1
  50. package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +41 -0
  51. package/packages/datadog-instrumentations/src/next.js +203 -26
  52. package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
  53. package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
  54. package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
  55. package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
  56. package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
  57. package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
  58. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
  59. package/packages/datadog-instrumentations/src/router.js +35 -12
  60. package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
  61. package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
  62. package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
  63. package/packages/datadog-plugin-aws-lambda/src/arn.js +41 -0
  64. package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
  65. package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
  66. package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
  67. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
  68. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
  69. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
  70. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
  71. package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
  72. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -13
  73. package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
  74. package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
  75. package/packages/datadog-plugin-express/src/code_origin.js +2 -2
  76. package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
  77. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +20 -7
  78. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +21 -52
  79. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +11 -2
  80. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
  81. package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
  82. package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
  83. package/packages/datadog-plugin-http/src/client.js +34 -10
  84. package/packages/datadog-plugin-http2/src/client.js +40 -14
  85. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
  86. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
  87. package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
  88. package/packages/datadog-plugin-next/src/index.js +112 -14
  89. package/packages/datadog-plugin-postgres/src/index.js +118 -41
  90. package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
  91. package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
  92. package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
  93. package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
  94. package/packages/datadog-plugin-trpc/src/index.js +15 -0
  95. package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
  96. package/packages/datadog-plugin-trpc/src/request.js +81 -0
  97. package/packages/datadog-plugin-undici/src/index.js +22 -7
  98. package/packages/datadog-plugin-vitest/src/index.js +3 -2
  99. package/packages/datadog-plugin-ws/src/close.js +3 -5
  100. package/packages/datadog-plugin-ws/src/producer.js +1 -4
  101. package/packages/datadog-plugin-ws/src/receiver.js +3 -5
  102. package/packages/datadog-plugin-ws/src/server.js +44 -13
  103. package/packages/datadog-turbopack/index.js +4 -28
  104. package/packages/datadog-turbopack/src/loader.js +14 -452
  105. package/packages/datadog-vite/index.js +537 -0
  106. package/packages/datadog-vite/src/log.js +5 -0
  107. package/packages/datadog-webpack/index.js +3 -55
  108. package/packages/datadog-webpack/src/log.js +2 -29
  109. package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
  110. package/packages/dd-trace/src/aiguard/index.js +1 -1
  111. package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
  112. package/packages/dd-trace/src/aiguard/sdk.js +8 -2
  113. package/packages/dd-trace/src/aiguard/tags.js +2 -0
  114. package/packages/dd-trace/src/appsec/blocking/index.js +21 -1
  115. package/packages/dd-trace/src/appsec/channels.js +7 -0
  116. package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
  117. package/packages/dd-trace/src/appsec/graphql.js +89 -7
  118. package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
  119. package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
  120. package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
  121. package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
  122. package/packages/dd-trace/src/appsec/index.js +6 -0
  123. package/packages/dd-trace/src/appsec/lambda.js +17 -17
  124. package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
  125. package/packages/dd-trace/src/appsec/rasp/index.js +8 -1
  126. package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
  127. package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
  128. package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
  129. package/packages/dd-trace/src/appsec/rasp/utils.js +33 -3
  130. package/packages/dd-trace/src/appsec/recommended.json +1358 -94
  131. package/packages/dd-trace/src/appsec/reporter.js +9 -0
  132. package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
  133. package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
  134. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
  135. package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
  136. package/packages/dd-trace/src/appsec/waf/index.js +65 -6
  137. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
  138. package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
  139. package/packages/dd-trace/src/before-exit.js +32 -0
  140. package/packages/dd-trace/src/bootstrap.js +5 -3
  141. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
  142. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
  143. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
  144. package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
  145. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
  146. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
  147. package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
  148. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
  149. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
  150. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
  151. package/packages/dd-trace/src/config/config-types.d.ts +3 -0
  152. package/packages/dd-trace/src/config/defaults.js +5 -0
  153. package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -4
  154. package/packages/dd-trace/src/config/index.js +63 -31
  155. package/packages/dd-trace/src/config/parsers.js +44 -0
  156. package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
  157. package/packages/dd-trace/src/config/remote_config.js +2 -1
  158. package/packages/dd-trace/src/config/supported-configurations.json +172 -10
  159. package/packages/dd-trace/src/constants.js +1 -0
  160. package/packages/dd-trace/src/datastreams/fnv.js +27 -0
  161. package/packages/dd-trace/src/datastreams/pathway.js +113 -28
  162. package/packages/dd-trace/src/datastreams/processor.js +5 -4
  163. package/packages/dd-trace/src/debugger/config.js +1 -1
  164. package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
  165. package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
  166. package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
  167. package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
  168. package/packages/dd-trace/src/debugger/index.js +2 -2
  169. package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
  170. package/packages/dd-trace/src/debugger/pause-duration-histogram.js +6 -2
  171. package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
  172. package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
  173. package/packages/dd-trace/src/exporter.js +0 -11
  174. package/packages/dd-trace/src/exporters/common/request.js +81 -48
  175. package/packages/dd-trace/src/exporters/common/retry.js +12 -7
  176. package/packages/dd-trace/src/exporters/common/url.js +1 -1
  177. package/packages/dd-trace/src/git_metadata.js +2 -1
  178. package/packages/dd-trace/src/id.js +1 -1
  179. package/packages/dd-trace/src/index.js +6 -3
  180. package/packages/dd-trace/src/lambda/facade.js +75 -0
  181. package/packages/dd-trace/src/lambda/handler.js +3 -41
  182. package/packages/dd-trace/src/lambda/index.js +38 -15
  183. package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
  184. package/packages/dd-trace/src/lambda/wrap.js +44 -0
  185. package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
  186. package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
  187. package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
  188. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
  189. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +54 -3
  190. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +81 -1
  191. package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
  192. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
  193. package/packages/dd-trace/src/llmobs/sdk.js +19 -0
  194. package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
  195. package/packages/dd-trace/src/llmobs/tagger.js +22 -0
  196. package/packages/dd-trace/src/log/channels.js +4 -0
  197. package/packages/dd-trace/src/log/writer.js +6 -1
  198. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +7 -0
  199. package/packages/dd-trace/src/openfeature/configuration_source.js +55 -27
  200. package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
  201. package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
  202. package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
  203. package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
  204. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
  205. package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
  206. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
  207. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
  208. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
  209. package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
  210. package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
  211. package/packages/dd-trace/src/opentelemetry/span.js +2 -2
  212. package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
  213. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
  214. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
  215. package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
  216. package/packages/dd-trace/src/opentracing/tracer.js +24 -0
  217. package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
  218. package/packages/dd-trace/src/plugin_manager.js +34 -7
  219. package/packages/dd-trace/src/plugins/ci_plugin.js +143 -17
  220. package/packages/dd-trace/src/plugins/index.js +8 -0
  221. package/packages/dd-trace/src/plugins/plugin.js +4 -2
  222. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  223. package/packages/dd-trace/src/plugins/util/ci.js +52 -1
  224. package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
  225. package/packages/dd-trace/src/plugins/util/git.js +263 -82
  226. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +80 -56
  227. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
  228. package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
  229. package/packages/dd-trace/src/plugins/util/tags.js +6 -0
  230. package/packages/dd-trace/src/plugins/util/test.js +92 -40
  231. package/packages/dd-trace/src/plugins/util/url.js +18 -7
  232. package/packages/dd-trace/src/plugins/util/user-provided-git.js +6 -6
  233. package/packages/dd-trace/src/plugins/util/web.js +65 -10
  234. package/packages/dd-trace/src/process-tags/index.js +1 -1
  235. package/packages/dd-trace/src/profiler.js +74 -12
  236. package/packages/dd-trace/src/profiling/profiler.js +30 -2
  237. package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
  238. package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
  239. package/packages/dd-trace/src/profiling/remote-config.js +354 -0
  240. package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
  241. package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
  242. package/packages/dd-trace/src/propagation-hash/index.js +7 -0
  243. package/packages/dd-trace/src/proxy.js +46 -54
  244. package/packages/dd-trace/src/span_processor.js +20 -0
  245. package/packages/dd-trace/src/startup-log.js +8 -6
  246. package/packages/dd-trace/src/telemetry/metrics.js +2 -1
  247. package/packages/dd-trace/src/tracer.js +0 -2
  248. package/packages/dd-trace/src/web-tags-cache.js +8 -9
  249. package/register.js +2 -1
  250. package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
  251. package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
  252. package/vendor/dist/@datadog/flagging-core/index.js +1 -0
  253. package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
  254. package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
  255. package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
  256. package/vendor/dist/@datadog/source-map/LICENSE +1 -0
  257. package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
  258. package/vendor/dist/@opentelemetry/core/LICENSE +220 -1
  259. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  260. package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
  261. package/vendor/dist/escape-string-regexp/LICENSE +13 -0
  262. package/vendor/dist/esquery/LICENSE +2 -0
  263. package/vendor/dist/https-proxy-agent/LICENSE +80 -1
  264. package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
  265. package/vendor/dist/jest-docblock/LICENSE +16 -0
  266. package/vendor/dist/jsonpath-plus/LICENSE +13 -0
  267. package/vendor/dist/limiter/LICENSE +2 -0
  268. package/vendor/dist/lodash.sortby/LICENSE +2 -0
  269. package/vendor/dist/lru-cache/LICENSE +13 -0
  270. package/vendor/dist/meriyah/LICENSE +13 -0
  271. package/vendor/dist/module-details-from-path/LICENSE +2 -0
  272. package/vendor/dist/mutexify/promise/LICENSE +28 -0
  273. package/vendor/dist/pprof-format/LICENSE +13 -0
  274. package/vendor/dist/pprof-format/index.js +1 -1
  275. package/vendor/dist/protobufjs/LICENSE +219 -0
  276. package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
  277. package/vendor/dist/proxy-from-env/LICENSE +13 -0
  278. package/vendor/dist/retry/LICENSE +2 -0
  279. package/vendor/dist/rfdc/LICENSE +2 -0
  280. package/vendor/dist/semifies/LICENSE +3 -1
  281. package/vendor/dist/shell-quote/LICENSE +3 -1
  282. package/vendor/dist/source-map/LICENSE +1 -0
  283. package/vendor/dist/source-map/lib/util/LICENSE +1 -0
  284. package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
  285. package/vendor/dist/ttl-set/LICENSE +28 -0
  286. package/vite.d.ts +7 -0
  287. package/vite.js +3 -0
  288. package/ci/diagnose.js +0 -2215
  289. package/ci/runbook.md +0 -299
  290. package/ci/test-optimization-validation/approval-artifacts.js +0 -175
  291. package/ci/test-optimization-validation/approval.js +0 -386
  292. package/ci/test-optimization-validation/artifact-id.js +0 -18
  293. package/ci/test-optimization-validation/blocker-category.js +0 -24
  294. package/ci/test-optimization-validation/bounded-json.js +0 -120
  295. package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
  296. package/ci/test-optimization-validation/ci-discovery.js +0 -192
  297. package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
  298. package/ci/test-optimization-validation/ci-remediation.js +0 -283
  299. package/ci/test-optimization-validation/cli.js +0 -954
  300. package/ci/test-optimization-validation/command-blocker.js +0 -377
  301. package/ci/test-optimization-validation/command-output-policy.js +0 -188
  302. package/ci/test-optimization-validation/command-runner.js +0 -649
  303. package/ci/test-optimization-validation/environment.js +0 -88
  304. package/ci/test-optimization-validation/executable-approval.js +0 -47
  305. package/ci/test-optimization-validation/executable.js +0 -244
  306. package/ci/test-optimization-validation/execution-lock.js +0 -70
  307. package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
  308. package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
  309. package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
  310. package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
  311. package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
  312. package/ci/test-optimization-validation/generated-file-policy.js +0 -63
  313. package/ci/test-optimization-validation/generated-files.js +0 -425
  314. package/ci/test-optimization-validation/generated-test-contract.js +0 -284
  315. package/ci/test-optimization-validation/generated-verifier.js +0 -235
  316. package/ci/test-optimization-validation/literal-environment.js +0 -56
  317. package/ci/test-optimization-validation/literal-glob.js +0 -52
  318. package/ci/test-optimization-validation/manifest-loader.js +0 -116
  319. package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
  320. package/ci/test-optimization-validation/manifest-schema.js +0 -695
  321. package/ci/test-optimization-validation/offline-fixtures.js +0 -335
  322. package/ci/test-optimization-validation/offline-output.js +0 -406
  323. package/ci/test-optimization-validation/package-check.js +0 -97
  324. package/ci/test-optimization-validation/payload-normalizer.js +0 -72
  325. package/ci/test-optimization-validation/plan-writer.js +0 -541
  326. package/ci/test-optimization-validation/preflight-runner.js +0 -186
  327. package/ci/test-optimization-validation/project-build-artifact.js +0 -31
  328. package/ci/test-optimization-validation/redaction.js +0 -319
  329. package/ci/test-optimization-validation/report-writer.js +0 -666
  330. package/ci/test-optimization-validation/result-semantics.js +0 -103
  331. package/ci/test-optimization-validation/runner-command.js +0 -264
  332. package/ci/test-optimization-validation/runner-contract.js +0 -695
  333. package/ci/test-optimization-validation/safe-files.js +0 -202
  334. package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
  335. package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
  336. package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
  337. package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
  338. package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
  339. package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
  340. package/ci/test-optimization-validation/source-text.js +0 -84
  341. package/ci/test-optimization-validation/static-diagnosis.js +0 -166
  342. package/ci/test-optimization-validation/test-output.js +0 -120
  343. package/ci/test-optimization-validation/validation-blocker.js +0 -21
  344. package/ci/validate-test-optimization.js +0 -3
  345. package/packages/datadog-esbuild/src/resolver.js +0 -284
  346. package/packages/datadog-esbuild/src/utils.js +0 -318
  347. package/packages/datadog-plugin-cypress/src/support.js +0 -1348
  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
@@ -1,156 +0,0 @@
1
- 'use strict'
2
-
3
- /* eslint-disable eslint-rules/eslint-process-env */
4
-
5
- const TestOptimizationHttpCache = require('../../test-optimization-http-cache').TestOptimizationHttpCache
6
- const CiVisibilityExporter = require('../ci-visibility-exporter')
7
- const { CiValidationSink } = require('./sink')
8
- const CiValidationWriter = require('./writer')
9
-
10
- const VALIDATION_MANIFEST_ENV = '_DD_TEST_OPTIMIZATION_VALIDATION_MANIFEST_FILE'
11
- const VALIDATION_OUTPUT_ENV = '_DD_TEST_OPTIMIZATION_VALIDATION_OUTPUT_DIR'
12
- const VALIDATION_CAPTURE_MODE_ENV = '_DD_TEST_OPTIMIZATION_VALIDATION_CAPTURE_MODE'
13
-
14
- class CiValidationExporter extends CiVisibilityExporter {
15
- /**
16
- * Creates an immediately available cache-only Test Optimization exporter.
17
- *
18
- * @param {object} config tracer configuration
19
- */
20
- constructor (config) {
21
- const validationManifestPath = process.env[VALIDATION_MANIFEST_ENV]
22
- const validationOutputRoot = process.env[VALIDATION_OUTPUT_ENV]
23
- if (!validationManifestPath) {
24
- throw new Error('Offline Test Optimization validation requires an explicit private manifest path.')
25
- }
26
- if (!validationOutputRoot) {
27
- throw new Error('Offline Test Optimization validation requires an explicit private output root.')
28
- }
29
- const cache = new TestOptimizationHttpCache({
30
- validationManifestPath,
31
- })
32
- super(config, { cacheOnly: true, testOptimizationHttpCache: cache })
33
-
34
- this._sink = new CiValidationSink(validationOutputRoot, {
35
- captureMode: process.env[VALIDATION_CAPTURE_MODE_ENV] || 'strict',
36
- })
37
- this._writer = new CiValidationWriter({ sink: this._sink, tags: config.tags })
38
- this._isInitialized = true
39
- this._isGzipCompatible = false
40
- this._resolveCanUseCiVisProtocol(true)
41
- this._resolveGit()
42
- this.exportUncodedTraces()
43
-
44
- this._finalizeValidation = () => this.flush(() => this._sink.writeSummary())
45
- globalThis[Symbol.for('dd-trace')].beforeExitHandlers.add(this._finalizeValidation)
46
- process.once('exit', this._finalizeValidation)
47
- }
48
-
49
- /**
50
- * Loads library settings from the validator-controlled cache.
51
- *
52
- * @param {object} testConfiguration test configuration identity
53
- * @param {Function} callback completion callback
54
- */
55
- getLibraryConfiguration (testConfiguration, callback) {
56
- super.getLibraryConfiguration(testConfiguration, (err, configuration) => {
57
- this._sink.writeInputResult('settings', err)
58
- if (err) process.exitCode = 1
59
- callback(err, configuration)
60
- })
61
- }
62
-
63
- /**
64
- * Loads known tests from the validator-controlled cache.
65
- *
66
- * @param {object} testConfiguration test configuration identity
67
- * @param {Function} callback completion callback
68
- */
69
- getKnownTests (testConfiguration, callback) {
70
- super.getKnownTests(testConfiguration, (err, tests) => {
71
- this._sink.writeInputResult('known_tests', err)
72
- if (err) process.exitCode = 1
73
- callback(err, tests)
74
- })
75
- }
76
-
77
- /**
78
- * Loads skippable suites from the validator-controlled cache.
79
- *
80
- * @param {object} testConfiguration test configuration identity
81
- * @param {Function} callback completion callback
82
- */
83
- getSkippableSuites (testConfiguration, callback) {
84
- super.getSkippableSuites(testConfiguration, (err, suites, correlationId, coverage) => {
85
- this._sink.writeInputResult('skippable_tests', err)
86
- if (err) process.exitCode = 1
87
- callback(err, suites, correlationId, coverage)
88
- })
89
- }
90
-
91
- /**
92
- * Loads managed tests from the validator-controlled cache.
93
- *
94
- * @param {object} testConfiguration test configuration identity
95
- * @param {Function} callback completion callback
96
- */
97
- getTestManagementTests (testConfiguration, callback) {
98
- super.getTestManagementTests(testConfiguration, (err, tests) => {
99
- this._sink.writeInputResult('test_management', err)
100
- if (err) process.exitCode = 1
101
- callback(err, tests)
102
- })
103
- }
104
-
105
- /**
106
- * Resolves the inherited git-upload gate without performing an upload.
107
- *
108
- */
109
- sendGitMetadata () {
110
- this._resolveGit()
111
- }
112
-
113
- /**
114
- * Drops debugger logs in offline validation mode.
115
- *
116
- */
117
- exportDiLogs () {}
118
-
119
- /**
120
- * Reports that code coverage is outside the offline validator's scope.
121
- *
122
- */
123
- canReportCodeCoverage () {
124
- return false
125
- }
126
-
127
- /**
128
- * Rejects coverage report upload in offline validation mode.
129
- *
130
- * @param {object} options ignored upload options
131
- * @param {Function} callback completion callback
132
- */
133
- uploadCoverageReport (options, callback) {
134
- callback(new Error('Coverage report upload is disabled during offline Test Optimization validation.'))
135
- }
136
-
137
- /**
138
- * Reports that screenshot upload is unavailable.
139
- *
140
- */
141
- canUploadTestScreenshots () {
142
- return false
143
- }
144
-
145
- /**
146
- * Rejects screenshot upload in offline validation mode.
147
- *
148
- * @param {object} options ignored upload options
149
- * @param {Function} callback completion callback
150
- */
151
- uploadTestScreenshot (options, callback) {
152
- callback(new Error('Screenshot upload is disabled during offline Test Optimization validation.'))
153
- }
154
- }
155
-
156
- module.exports = CiValidationExporter
@@ -1,287 +0,0 @@
1
- 'use strict'
2
-
3
- const MAX_COLLECTION_ENTRIES = 100_000
4
- const MAX_INPUT_BYTES = 16 * 1024 * 1024
5
- const MAX_NESTING_DEPTH = 128
6
- const MAX_OUTPUT_BYTES = 16 * 1024 * 1024
7
- const MAX_STRING_BYTES = 64 * 1024
8
-
9
- /**
10
- * Converts one bounded MessagePack value to JSON without losing 64-bit integer precision.
11
- *
12
- * @param {Buffer} input encoded MessagePack payload
13
- * @returns {Buffer} JSON payload
14
- */
15
- function msgpackToJson (input) {
16
- if (!Buffer.isBuffer(input) || input.length === 0) {
17
- throw new Error('MessagePack validation payload must be a non-empty Buffer.')
18
- }
19
- if (input.length > MAX_INPUT_BYTES) {
20
- throw new Error(`MessagePack validation payload exceeds ${MAX_INPUT_BYTES} bytes.`)
21
- }
22
-
23
- const writer = new BoundedJsonWriter()
24
- const converter = new MsgpackJsonConverter(input, writer)
25
- converter.convert()
26
- return writer.toBuffer()
27
- }
28
-
29
- class BoundedJsonWriter {
30
- #bytes = 0
31
- #chunks = []
32
-
33
- /**
34
- * Appends one JSON fragment while enforcing the aggregate output limit.
35
- *
36
- * @param {string} fragment JSON fragment
37
- */
38
- write (fragment) {
39
- const bytes = Buffer.byteLength(fragment)
40
- if (this.#bytes + bytes > MAX_OUTPUT_BYTES) {
41
- throw new Error(`JSON validation payload exceeds ${MAX_OUTPUT_BYTES} bytes.`)
42
- }
43
- this.#bytes += bytes
44
- this.#chunks.push(fragment)
45
- }
46
-
47
- /**
48
- * Materializes the completed bounded JSON payload.
49
- *
50
- * @returns {Buffer} JSON payload
51
- */
52
- toBuffer () {
53
- return Buffer.from(this.#chunks.join(''))
54
- }
55
- }
56
-
57
- class MsgpackJsonConverter {
58
- #collectionEntries = 0
59
- #input
60
- #offset = 0
61
- #writer
62
-
63
- /**
64
- * Creates a converter for one MessagePack payload.
65
- *
66
- * @param {Buffer} input encoded MessagePack payload
67
- * @param {BoundedJsonWriter} writer bounded JSON writer
68
- */
69
- constructor (input, writer) {
70
- this.#input = input
71
- this.#writer = writer
72
- }
73
-
74
- /**
75
- * Converts exactly one top-level value and rejects trailing data.
76
- */
77
- convert () {
78
- this.#writeValue(0)
79
- if (this.#offset !== this.#input.length) {
80
- throw new Error('MessagePack validation payload contains trailing data.')
81
- }
82
- }
83
-
84
- /**
85
- * Writes one MessagePack value as JSON.
86
- *
87
- * @param {number} depth current nesting depth
88
- */
89
- #writeValue (depth) {
90
- if (depth > MAX_NESTING_DEPTH) {
91
- throw new Error('MessagePack nesting exceeds validation payload limit.')
92
- }
93
-
94
- const prefix = this.#readUInt8()
95
- if (prefix <= 0x7F) return this.#writer.write(String(prefix))
96
- if (prefix >= 0xE0) return this.#writer.write(String(prefix - 0x01_00))
97
- if ((prefix & 0xE0) === 0xA0) return this.#writeString(prefix & 0x1F)
98
- if ((prefix & 0xF0) === 0x90) return this.#writeArray(prefix & 0x0F, depth)
99
- if ((prefix & 0xF0) === 0x80) return this.#writeMap(prefix & 0x0F, depth)
100
-
101
- switch (prefix) {
102
- case 0xC0: return this.#writer.write('null')
103
- case 0xC2: return this.#writer.write('false')
104
- case 0xC3: return this.#writer.write('true')
105
- case 0xC4: return this.#writeBinary(this.#readUInt8())
106
- case 0xC5: return this.#writeBinary(this.#read('readUInt16BE', 2))
107
- case 0xC6: return this.#writeBinary(this.#read('readUInt32BE', 4))
108
- case 0xCA: return this.#writeFloat(this.#read('readFloatBE', 4))
109
- case 0xCB: return this.#writeFloat(this.#read('readDoubleBE', 8))
110
- case 0xCC: return this.#writer.write(String(this.#readUInt8()))
111
- case 0xCD: return this.#writer.write(String(this.#read('readUInt16BE', 2)))
112
- case 0xCE: return this.#writer.write(String(this.#read('readUInt32BE', 4)))
113
- case 0xCF: return this.#writer.write(this.#read('readBigUInt64BE', 8).toString())
114
- case 0xD0: return this.#writer.write(String(this.#read('readInt8', 1)))
115
- case 0xD1: return this.#writer.write(String(this.#read('readInt16BE', 2)))
116
- case 0xD2: return this.#writer.write(String(this.#read('readInt32BE', 4)))
117
- case 0xD3: return this.#writer.write(this.#read('readBigInt64BE', 8).toString())
118
- case 0xD9: return this.#writeString(this.#readUInt8())
119
- case 0xDA: return this.#writeString(this.#read('readUInt16BE', 2))
120
- case 0xDB: return this.#writeString(this.#read('readUInt32BE', 4))
121
- case 0xDC: return this.#writeArray(this.#read('readUInt16BE', 2), depth)
122
- case 0xDD: return this.#writeArray(this.#read('readUInt32BE', 4), depth)
123
- case 0xDE: return this.#writeMap(this.#read('readUInt16BE', 2), depth)
124
- case 0xDF: return this.#writeMap(this.#read('readUInt32BE', 4), depth)
125
- default:
126
- throw new Error(`Unsupported MessagePack byte 0x${prefix.toString(16)} at offset ${this.#offset - 1}.`)
127
- }
128
- }
129
-
130
- /**
131
- * Writes one MessagePack array.
132
- *
133
- * @param {number} length array length
134
- * @param {number} depth current nesting depth
135
- */
136
- #writeArray (length, depth) {
137
- this.#assertCollectionLength(length)
138
- this.#writer.write('[')
139
- for (let index = 0; index < length; index++) {
140
- if (index > 0) this.#writer.write(',')
141
- this.#writeValue(depth + 1)
142
- }
143
- this.#writer.write(']')
144
- }
145
-
146
- /**
147
- * Writes one MessagePack map with JSON-compatible keys.
148
- *
149
- * @param {number} length map entry count
150
- * @param {number} depth current nesting depth
151
- */
152
- #writeMap (length, depth) {
153
- this.#assertCollectionLength(length)
154
- this.#writer.write('{')
155
- for (let index = 0; index < length; index++) {
156
- if (index > 0) this.#writer.write(',')
157
- this.#writeMapKey()
158
- this.#writer.write(':')
159
- this.#writeValue(depth + 1)
160
- }
161
- this.#writer.write('}')
162
- }
163
-
164
- /**
165
- * Writes a string or integer MessagePack map key as a JSON string.
166
- */
167
- #writeMapKey () {
168
- const prefix = this.#readUInt8()
169
- if (prefix <= 0x7F) return this.#writer.write(JSON.stringify(String(prefix)))
170
- if (prefix >= 0xE0) return this.#writer.write(JSON.stringify(String(prefix - 0x01_00)))
171
- if ((prefix & 0xE0) === 0xA0) return this.#writeString(prefix & 0x1F)
172
-
173
- let value
174
- switch (prefix) {
175
- case 0xCC: value = this.#readUInt8(); break
176
- case 0xCD: value = this.#read('readUInt16BE', 2); break
177
- case 0xCE: value = this.#read('readUInt32BE', 4); break
178
- case 0xCF: value = this.#read('readBigUInt64BE', 8); break
179
- case 0xD0: value = this.#read('readInt8', 1); break
180
- case 0xD1: value = this.#read('readInt16BE', 2); break
181
- case 0xD2: value = this.#read('readInt32BE', 4); break
182
- case 0xD3: value = this.#read('readBigInt64BE', 8); break
183
- case 0xD9: return this.#writeString(this.#readUInt8())
184
- case 0xDA: return this.#writeString(this.#read('readUInt16BE', 2))
185
- case 0xDB: return this.#writeString(this.#read('readUInt32BE', 4))
186
- default:
187
- throw new Error(`Unsupported MessagePack map key byte 0x${prefix.toString(16)}.`)
188
- }
189
- this.#writer.write(JSON.stringify(String(value)))
190
- }
191
-
192
- /**
193
- * Writes one UTF-8 MessagePack string.
194
- *
195
- * @param {number} length encoded byte length
196
- */
197
- #writeString (length) {
198
- if (length > MAX_STRING_BYTES) {
199
- throw new Error('MessagePack string exceeds validation payload limit.')
200
- }
201
- this.#assertAvailable(length)
202
- const end = this.#offset + length
203
- const value = this.#input.toString('utf8', this.#offset, end)
204
- this.#offset = end
205
- this.#writer.write(JSON.stringify(value))
206
- }
207
-
208
- /**
209
- * Writes one binary MessagePack value as a base64 JSON string.
210
- *
211
- * @param {number} length encoded byte length
212
- */
213
- #writeBinary (length) {
214
- this.#assertAvailable(length)
215
- const end = this.#offset + length
216
- const value = this.#input.subarray(this.#offset, end).toString('base64')
217
- this.#offset = end
218
- this.#writer.write(JSON.stringify(value))
219
- }
220
-
221
- /**
222
- * Writes one finite floating-point value.
223
- *
224
- * @param {number} value decoded floating-point value
225
- */
226
- #writeFloat (value) {
227
- if (!Number.isFinite(value)) throw new TypeError('MessagePack validation payload contains a non-finite number.')
228
- this.#writer.write(Object.is(value, -0) ? '-0' : String(value))
229
- }
230
-
231
- /**
232
- * Enforces per-collection and aggregate collection-entry limits.
233
- *
234
- * @param {number} length collection length
235
- */
236
- #assertCollectionLength (length) {
237
- if (length > MAX_COLLECTION_ENTRIES) {
238
- throw new Error(`MessagePack collection length ${length} exceeds validation entry limit.`)
239
- }
240
- this.#collectionEntries += length
241
- if (this.#collectionEntries > MAX_COLLECTION_ENTRIES) {
242
- throw new Error('MessagePack aggregate collection entries exceed validation limit.')
243
- }
244
- if (length > this.#input.length - this.#offset) {
245
- throw new Error(`MessagePack collection length ${length} exceeds remaining payload bytes.`)
246
- }
247
- }
248
-
249
- /**
250
- * Ensures the requested bytes remain in the input.
251
- *
252
- * @param {number} length byte count
253
- */
254
- #assertAvailable (length) {
255
- if (length < 0 || this.#offset + length > this.#input.length) {
256
- throw new Error('Unexpected end of MessagePack validation payload.')
257
- }
258
- }
259
-
260
- #readUInt8 () {
261
- this.#assertAvailable(1)
262
- return this.#input[this.#offset++]
263
- }
264
-
265
- /**
266
- * Reads one fixed-width numeric value.
267
- *
268
- * @param {keyof Buffer} method Buffer reader method
269
- * @param {number} bytes encoded width
270
- * @returns {number|bigint} decoded value
271
- */
272
- #read (method, bytes) {
273
- this.#assertAvailable(bytes)
274
- const value = this.#input[method](this.#offset)
275
- this.#offset += bytes
276
- return value
277
- }
278
- }
279
-
280
- module.exports = {
281
- MAX_COLLECTION_ENTRIES,
282
- MAX_INPUT_BYTES,
283
- MAX_NESTING_DEPTH,
284
- MAX_OUTPUT_BYTES,
285
- MAX_STRING_BYTES,
286
- msgpackToJson,
287
- }
@@ -1,84 +0,0 @@
1
- 'use strict'
2
-
3
- const EVENT_TYPES = new Set(['test', 'test_module_end', 'test_session_end', 'test_suite_end'])
4
- const META_FIELDS = new Set([
5
- 'test.command',
6
- 'test.early_flake.enabled',
7
- 'test.final_status',
8
- 'test.is_new',
9
- 'test.is_retry',
10
- 'test.module',
11
- 'test.name',
12
- 'test.retry_reason',
13
- 'test.source.file',
14
- 'test.status',
15
- 'test.suite',
16
- 'test.test_management.attempt_to_fix_passed',
17
- 'test.test_management.enabled',
18
- 'test.test_management.is_attempt_to_fix',
19
- 'test.test_management.is_quarantined',
20
- 'test.test_management.is_test_disabled',
21
- ])
22
- const METRIC_FIELDS = new Set(['test.is_new', 'test.is_retry'])
23
-
24
- /**
25
- * Projects a decoded Test Optimization payload into the fixed validation-only event schema.
26
- *
27
- * @param {unknown} payload decoded Test Optimization payload
28
- * @returns {{events: object[], version: 1}} allowlisted payload
29
- */
30
- function projectTestCyclePayload (payload) {
31
- if (!isObject(payload) || payload.version !== 1 || !Array.isArray(payload.events)) {
32
- throw new Error('Test Optimization validation payload has an unsupported envelope.')
33
- }
34
-
35
- const events = []
36
- for (const event of payload.events) {
37
- if (isNonTestSpan(event)) continue
38
- events.push(projectEvent(event))
39
- }
40
- return { version: 1, events }
41
- }
42
-
43
- function projectEvent (event) {
44
- if (!isObject(event) || !EVENT_TYPES.has(event.type) || !isObject(event.content)) {
45
- throw new Error('Test Optimization validation payload contains an unsupported event shape.')
46
- }
47
-
48
- return {
49
- type: event.type,
50
- content: {
51
- meta: projectFields(event.content.meta, META_FIELDS),
52
- metrics: projectFields(event.content.metrics, METRIC_FIELDS),
53
- },
54
- }
55
- }
56
-
57
- function isNonTestSpan (event) {
58
- if (!isObject(event) || event.type !== 'span') return false
59
- if (!isObject(event.content)) {
60
- throw new Error('Test Optimization validation payload contains an unsupported span shape.')
61
- }
62
- return true
63
- }
64
-
65
- function projectFields (source, allowed) {
66
- const projected = {}
67
- if (!isObject(source)) return projected
68
- for (const name of allowed) copyScalar(projected, source, name)
69
- return projected
70
- }
71
-
72
- function copyScalar (target, source, name) {
73
- const value = source[name]
74
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') target[name] = value
75
- }
76
-
77
- function isObject (value) {
78
- return Boolean(value && typeof value === 'object' && !Array.isArray(value))
79
- }
80
-
81
- module.exports = {
82
- EVENT_TYPES,
83
- projectTestCyclePayload,
84
- }