dd-trace 5.134.0 → 5.136.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.
- package/LICENSE-3rdparty.csv +0 -1
- package/ci/cypress/support.js +15 -1
- package/ci/init.js +2 -22
- package/ci/test-annotations.d.ts +5 -0
- package/ci/test-annotations.js +5 -0
- package/ci/vitest-no-worker-init-annotations.mjs +4 -0
- package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
- package/ci/vitest-no-worker-init-runner-setup.mjs +7 -32
- package/ci/vitest-no-worker-init-setup.mjs +34 -12
- package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
- package/ext/exporters.js +1 -1
- package/index.d.ts +124 -5
- package/initialize.mjs +5 -2
- package/lambda.d.ts +39 -0
- package/lambda.js +3 -0
- package/loader-hook.mjs +53 -0
- package/openfeature/exposure-hook.d.ts +66 -0
- package/openfeature/exposure-hook.js +5 -0
- package/package.json +19 -15
- package/packages/datadog-core/src/storage.js +1 -1
- package/packages/datadog-esbuild/index.js +78 -62
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +56 -19
- package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +29 -20
- package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
- package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -8
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +18 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +58 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +25 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/jest.js +265 -82
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
- package/packages/datadog-instrumentations/src/mariadb.js +13 -6
- package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
- package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
- package/packages/datadog-instrumentations/src/mocha/utils.js +58 -12
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +19 -6
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/oracledb.js +33 -0
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/playwright.js +81 -28
- package/packages/datadog-instrumentations/src/react-router.js +106 -0
- package/packages/datadog-instrumentations/src/typesafe.js +89 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -48
- package/packages/datadog-instrumentations/src/vitest-main.js +26 -0
- package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
- package/packages/datadog-instrumentations/src/vitest.js +10 -8
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-cucumber/src/index.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +296 -55
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
- package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
- package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
- package/packages/datadog-plugin-cypress/src/support.js +1217 -439
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/utils.js +5 -5
- package/packages/datadog-plugin-http/src/client.js +32 -9
- package/packages/datadog-plugin-http2/src/client.js +38 -13
- package/packages/datadog-plugin-jest/src/index.js +25 -3
- package/packages/datadog-plugin-mocha/src/index.js +47 -6
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
- package/packages/datadog-plugin-playwright/src/index.js +4 -0
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-react-router/src/index.js +118 -0
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-typesafe/src/index.js +17 -0
- package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +8 -0
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/dd-trace/src/agent/info.js +2 -1
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/sdk.js +8 -13
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
- package/packages/dd-trace/src/appsec/graphql.js +91 -6
- package/packages/dd-trace/src/appsec/recommended.json +1287 -90
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +24 -18
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +16 -36
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -18
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +10 -15
- package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
- package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
- package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +10 -17
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +9 -3
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -2
- package/packages/dd-trace/src/config/index.js +111 -43
- package/packages/dd-trace/src/config/parsers.js +18 -1
- package/packages/dd-trace/src/config/supported-configurations.json +174 -4
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
- package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
- package/packages/dd-trace/src/encode/0.4.js +2 -2
- package/packages/dd-trace/src/esm-module-load.js +58 -0
- package/packages/dd-trace/src/exporter.js +23 -15
- package/packages/dd-trace/src/exporters/agent/index.js +3 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
- package/packages/dd-trace/src/exporters/common/request.js +83 -50
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
- package/packages/dd-trace/src/exporters/log/index.js +4 -3
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/lambda/facade.js +74 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +3 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
- package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
- package/packages/dd-trace/src/llmobs/index.js +13 -2
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +27 -10
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
- package/packages/dd-trace/src/llmobs/sdk.js +21 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +219 -12
- package/packages/dd-trace/src/llmobs/tagger.js +25 -0
- package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +13 -2
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +68 -6
- package/packages/dd-trace/src/openfeature/configuration_source.js +41 -17
- package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
- package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +58 -14
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
- package/packages/dd-trace/src/openfeature/writers/base.js +63 -30
- package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
- package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +33 -13
- package/packages/dd-trace/src/otel-thread-ctx.js +72 -49
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +45 -14
- package/packages/dd-trace/src/plugins/index.js +9 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +18 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +273 -86
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +77 -50
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +90 -45
- package/packages/dd-trace/src/plugins/util/url.js +10 -2
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
- package/packages/dd-trace/src/plugins/util/web.js +81 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiling/config.js +6 -3
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/proxy.js +48 -57
- package/packages/dd-trace/src/serverless.js +3 -2
- package/packages/dd-trace/src/span_processor.js +41 -9
- package/packages/dd-trace/src/span_stats.js +28 -2
- package/packages/dd-trace/src/startup-log.js +8 -5
- package/packages/dd-trace/src/tagger.js +7 -5
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
- package/packages/dd-trace/src/telemetry/index.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -0
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/util.js +1 -1
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +4 -2
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/{@opentelemetry/resources → @datadog/flagging-core}/LICENSE +22 -2
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -19
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -650
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
- package/vendor/dist/@opentelemetry/resources/index.js +0 -1
|
@@ -7,7 +7,7 @@ const satisfies = require('../../../vendor/dist/semifies')
|
|
|
7
7
|
const { getDynamicAtrRetryCount } = require('../../dd-trace/src/ci-visibility/dynamic-atr-retries')
|
|
8
8
|
const { EMPTY_EFD_RETRY_POLICY, hasEfdRetries } = require('../../dd-trace/src/ci-visibility/efd-retry-policy')
|
|
9
9
|
const { RUM_TEST_EXECUTION_ID_COOKIE_NAME } = require('../../dd-trace/src/ci-visibility/rum')
|
|
10
|
-
const { getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
|
|
10
|
+
const { getEnvironmentVariable, getValueFromEnvSources } = require('../../dd-trace/src/config/helper')
|
|
11
11
|
const log = require('../../dd-trace/src/log')
|
|
12
12
|
const {
|
|
13
13
|
DYNAMIC_NAME_RE,
|
|
@@ -57,6 +57,14 @@ const VITEST_NO_WORKER_INIT_SETUP_FILE = path.join(
|
|
|
57
57
|
'ci',
|
|
58
58
|
'vitest-no-worker-init-setup.mjs'
|
|
59
59
|
)
|
|
60
|
+
const VITEST_NO_WORKER_INIT_NODE_SETUP_FILE = path.join(
|
|
61
|
+
__dirname,
|
|
62
|
+
'..',
|
|
63
|
+
'..',
|
|
64
|
+
'..',
|
|
65
|
+
'ci',
|
|
66
|
+
'vitest-no-worker-init-node-setup.mjs'
|
|
67
|
+
)
|
|
60
68
|
const VITEST_NO_WORKER_INIT_RUNNER_SETUP_FILE = path.join(
|
|
61
69
|
__dirname,
|
|
62
70
|
'..',
|
|
@@ -73,6 +81,11 @@ const VITEST_NO_WORKER_INIT_V5_SETUP_FILE = path.join(
|
|
|
73
81
|
'ci',
|
|
74
82
|
'vitest-no-worker-init-v5-setup.mjs'
|
|
75
83
|
)
|
|
84
|
+
const VITEST_NO_WORKER_INIT_ENTRYPOINTS = new Set([
|
|
85
|
+
VITEST_NO_WORKER_INIT_NODE_SETUP_FILE,
|
|
86
|
+
VITEST_NO_WORKER_INIT_RUNNER_SETUP_FILE,
|
|
87
|
+
VITEST_NO_WORKER_INIT_V5_SETUP_FILE,
|
|
88
|
+
])
|
|
76
89
|
const VITEST_BROWSER_SETUP_FILE_PLUGIN = {
|
|
77
90
|
name: 'datadog:vitest-browser-setup-file',
|
|
78
91
|
config: configureVitestBrowserSetupFile,
|
|
@@ -412,14 +425,12 @@ function configureWorkerEnv (workerEnv, shouldSkipWorkerInit = false) {
|
|
|
412
425
|
}
|
|
413
426
|
|
|
414
427
|
workerEnv[VITEST_NO_WORKER_INIT_ACTIVE_ENV] = '1'
|
|
415
|
-
|
|
428
|
+
// Pool env objects omit inherited variables; retain the parent's non-Datadog options.
|
|
429
|
+
const inheritedNodeOptions = workerEnv.NODE_OPTIONS ?? getEnvironmentVariable('NODE_OPTIONS')
|
|
430
|
+
rememberDatadogTestOptimizationNodeOptions(inheritedNodeOptions)
|
|
416
431
|
|
|
417
|
-
const nodeOptions = removeDatadogTestOptimizationNodeOptions(
|
|
418
|
-
if (nodeOptions)
|
|
419
|
-
workerEnv.NODE_OPTIONS = nodeOptions
|
|
420
|
-
} else {
|
|
421
|
-
delete workerEnv.NODE_OPTIONS
|
|
422
|
-
}
|
|
432
|
+
const nodeOptions = removeDatadogTestOptimizationNodeOptions(inheritedNodeOptions)
|
|
433
|
+
if (nodeOptions !== undefined) workerEnv.NODE_OPTIONS = nodeOptions
|
|
423
434
|
return workerEnv
|
|
424
435
|
}
|
|
425
436
|
|
|
@@ -438,12 +449,11 @@ function restoreDatadogTestOptimizationNodeOptions (workerEnv) {
|
|
|
438
449
|
}
|
|
439
450
|
}
|
|
440
451
|
|
|
441
|
-
function addSetupFileToVitestConfigs (ctx,
|
|
452
|
+
function addSetupFileToVitestConfigs (ctx, browserSetupFile, testSpecifications) {
|
|
442
453
|
const configs = getNoWorkerInitVitestConfigs(ctx, testSpecifications)
|
|
443
454
|
|
|
444
|
-
for (const config of configs) {
|
|
445
|
-
|
|
446
|
-
|
|
455
|
+
for (const [config, isBrowserMode] of configs) {
|
|
456
|
+
const setupFile = isBrowserMode ? browserSetupFile : VITEST_NO_WORKER_INIT_NODE_SETUP_FILE
|
|
447
457
|
config.includeTaskLocation = true
|
|
448
458
|
if (config.setupFiles === undefined) {
|
|
449
459
|
config.setupFiles = []
|
|
@@ -451,14 +461,28 @@ function addSetupFileToVitestConfigs (ctx, setupFile, testSpecifications) {
|
|
|
451
461
|
config.setupFiles = [config.setupFiles]
|
|
452
462
|
}
|
|
453
463
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if (setupFileIndex > 0) {
|
|
457
|
-
config.setupFiles.splice(setupFileIndex, 1)
|
|
458
|
-
}
|
|
459
|
-
config.setupFiles.unshift(setupFile)
|
|
464
|
+
for (let index = config.setupFiles.length - 1; index >= 0; index--) {
|
|
465
|
+
if (VITEST_NO_WORKER_INIT_ENTRYPOINTS.has(config.setupFiles[index])) config.setupFiles.splice(index, 1)
|
|
460
466
|
}
|
|
467
|
+
config.setupFiles.unshift(setupFile)
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Makes the annotation helper available to browser setup before Vitest creates its Vite server.
|
|
473
|
+
*
|
|
474
|
+
* @param {{ plugins?: object[] }|undefined} viteOverrides
|
|
475
|
+
*/
|
|
476
|
+
function addBrowserAnnotationPlugin (viteOverrides = {}) {
|
|
477
|
+
if (!viteOverrides.plugins || !Object.isExtensible(viteOverrides) ||
|
|
478
|
+
!Object.isExtensible(viteOverrides.plugins)) {
|
|
479
|
+
viteOverrides = { ...viteOverrides, plugins: [...(viteOverrides.plugins || [])] }
|
|
480
|
+
}
|
|
481
|
+
viteOverrides.plugins ||= []
|
|
482
|
+
if (!viteOverrides.plugins.includes(VITEST_BROWSER_SETUP_FILE_PLUGIN)) {
|
|
483
|
+
viteOverrides.plugins.push(VITEST_BROWSER_SETUP_FILE_PLUGIN)
|
|
461
484
|
}
|
|
485
|
+
return viteOverrides
|
|
462
486
|
}
|
|
463
487
|
|
|
464
488
|
/**
|
|
@@ -501,6 +525,8 @@ function allowVitestBrowserSetupFile (viteConfig) {
|
|
|
501
525
|
VITEST_NO_WORKER_INIT_SETUP_FILE,
|
|
502
526
|
VITEST_NO_WORKER_INIT_RUNNER_SETUP_FILE,
|
|
503
527
|
VITEST_NO_WORKER_INIT_V5_SETUP_FILE,
|
|
528
|
+
require.resolve('../../../ci/vitest-no-worker-init-annotations.mjs'),
|
|
529
|
+
require.resolve('../../dd-trace/src/ci-visibility/test-declaration-annotations'),
|
|
504
530
|
]
|
|
505
531
|
for (const setupFile of setupFiles) {
|
|
506
532
|
if (!allow.includes(setupFile)) {
|
|
@@ -562,31 +588,32 @@ function addVitestBrowserCommand (config) {
|
|
|
562
588
|
}
|
|
563
589
|
|
|
564
590
|
function getNoWorkerInitVitestConfigs (ctx, testSpecifications) {
|
|
565
|
-
const configs = new
|
|
591
|
+
const configs = new Map()
|
|
592
|
+
let fallbackIsBrowserMode
|
|
566
593
|
if (Array.isArray(testSpecifications)) {
|
|
567
|
-
let shouldAddRootConfig = false
|
|
568
594
|
for (const testSpecification of testSpecifications) {
|
|
569
595
|
const project = getTestSpecificationProject(testSpecification)
|
|
570
596
|
const config = safeConfig(project)
|
|
597
|
+
const isBrowserMode = isBrowserTestSpecification(testSpecification)
|
|
571
598
|
if (config) {
|
|
572
|
-
addNoWorkerInitConfig(configs, config)
|
|
599
|
+
addNoWorkerInitConfig(configs, config, isBrowserMode)
|
|
573
600
|
} else {
|
|
574
|
-
|
|
601
|
+
fallbackIsBrowserMode ||= isBrowserMode
|
|
575
602
|
}
|
|
576
603
|
}
|
|
577
604
|
|
|
578
|
-
if (
|
|
605
|
+
if (fallbackIsBrowserMode === undefined && configs.size > 0) {
|
|
579
606
|
return configs
|
|
580
607
|
}
|
|
581
608
|
}
|
|
582
609
|
|
|
583
|
-
addNoWorkerInitConfig(configs, safeConfig(ctx))
|
|
584
|
-
addNoWorkerInitConfig(configs, safeConfig(safeWorkspaceProject(ctx)))
|
|
610
|
+
addNoWorkerInitConfig(configs, safeConfig(ctx), fallbackIsBrowserMode)
|
|
611
|
+
addNoWorkerInitConfig(configs, safeConfig(safeWorkspaceProject(ctx)), fallbackIsBrowserMode)
|
|
585
612
|
return configs
|
|
586
613
|
}
|
|
587
614
|
|
|
588
|
-
function addNoWorkerInitConfig (configs, config) {
|
|
589
|
-
if (config) configs.
|
|
615
|
+
function addNoWorkerInitConfig (configs, config, isBrowserMode = config?.browser?.enabled === true) {
|
|
616
|
+
if (config && !configs.has(config)) configs.set(config, isBrowserMode)
|
|
590
617
|
}
|
|
591
618
|
|
|
592
619
|
function getSelectedTestManagementTests (testManagementTestsBySuite, propertyName) {
|
|
@@ -919,7 +946,8 @@ function createMainProcessReporter (reporterState) {
|
|
|
919
946
|
)
|
|
920
947
|
const knownTests = testProperties?.knownTests
|
|
921
948
|
const testManagementProperties = testProperties?.testManagementTests?.[testName] || {}
|
|
922
|
-
const
|
|
949
|
+
const annotations = task.meta?.__ddTestOptAnnotations || {}
|
|
950
|
+
const isAttemptToFix = testManagementProperties.isAttemptToFix && !annotations.noAutoRetry
|
|
923
951
|
const isNew = !!(
|
|
924
952
|
!isAttemptToFix &&
|
|
925
953
|
state.isKnownTestsEnabled &&
|
|
@@ -929,20 +957,23 @@ function createMainProcessReporter (reporterState) {
|
|
|
929
957
|
)
|
|
930
958
|
const isModified = testProperties?.isModified === true
|
|
931
959
|
const { flakyTestRetriesConfiguration } = testOptimizationData
|
|
932
|
-
const isFlakyTestRetries = !!flakyTestRetriesConfiguration &&
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
960
|
+
const isFlakyTestRetries = !annotations.noAutoRetry && !!flakyTestRetriesConfiguration &&
|
|
961
|
+
isFlakyTestRetriesEnabledForTask({
|
|
962
|
+
isFlakyTestRetriesEnabled: state.isFlakyTestRetriesEnabled,
|
|
963
|
+
isDynamicAtrEnabled: state.isDynamicAtrEnabled,
|
|
964
|
+
flakyTestRetriesIncludesUnnamedProject: flakyTestRetriesConfiguration.includesUnnamedProject,
|
|
965
|
+
flakyTestRetriesProjectNames: flakyTestRetriesConfiguration.projectNames,
|
|
966
|
+
flakyTestRetriesUseRetryMarker: flakyTestRetriesConfiguration.usesRetryMarker,
|
|
967
|
+
}, task)
|
|
939
968
|
|
|
940
969
|
return {
|
|
941
970
|
isAttemptToFix,
|
|
942
|
-
|
|
971
|
+
annotations,
|
|
972
|
+
assignedProperties: testManagementProperties,
|
|
973
|
+
isDisabled: testManagementProperties.isDisabled && !annotations.mustFail,
|
|
943
974
|
isEarlyFlakeDetection: task.meta?.__ddTestOptEfdRetries !== undefined,
|
|
944
975
|
isFlakyTestRetries,
|
|
945
|
-
isQuarantined: testManagementProperties.isQuarantined,
|
|
976
|
+
isQuarantined: testManagementProperties.isQuarantined && !annotations.mustFail,
|
|
946
977
|
isModified,
|
|
947
978
|
isNew,
|
|
948
979
|
testSuite,
|
|
@@ -1283,12 +1314,13 @@ function reportFinalTestAttempt (testReport) {
|
|
|
1283
1314
|
} = getRumCorrelation(task, attemptIndex)
|
|
1284
1315
|
testSkipCh.publish({
|
|
1285
1316
|
...browserEnvironment,
|
|
1317
|
+
annotations: testProperties.annotations,
|
|
1286
1318
|
testName,
|
|
1287
1319
|
testSuiteAbsolutePath,
|
|
1288
1320
|
isNew: testProperties.isNew,
|
|
1289
|
-
isAttemptToFix: testProperties.isAttemptToFix,
|
|
1290
|
-
isDisabled: testProperties.isDisabled,
|
|
1291
|
-
isQuarantined: testProperties.isQuarantined,
|
|
1321
|
+
isAttemptToFix: testProperties.assignedProperties.isAttemptToFix,
|
|
1322
|
+
isDisabled: testProperties.assignedProperties.isDisabled,
|
|
1323
|
+
isQuarantined: testProperties.assignedProperties.isQuarantined,
|
|
1292
1324
|
isRumActive,
|
|
1293
1325
|
isTestFrameworkWorker: true,
|
|
1294
1326
|
requestErrorTags: state.requestErrorTags,
|
|
@@ -1369,9 +1401,10 @@ function reportTestAttempt (testReport, attempt) {
|
|
|
1369
1401
|
isRetry: attempt.isRetry,
|
|
1370
1402
|
isNew: testProperties.isNew,
|
|
1371
1403
|
hasDynamicName: testProperties.hasDynamicName,
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1404
|
+
annotations: testProperties.annotations,
|
|
1405
|
+
isAttemptToFix: testProperties.assignedProperties.isAttemptToFix,
|
|
1406
|
+
isDisabled: testProperties.assignedProperties.isDisabled,
|
|
1407
|
+
isQuarantined: testProperties.assignedProperties.isQuarantined,
|
|
1375
1408
|
isModified: testProperties.isModified,
|
|
1376
1409
|
isRetryReasonEfd: attempt.isRetryReasonEfd,
|
|
1377
1410
|
isRetryReasonAttemptToFix: testProperties.isAttemptToFix && attempt.isRetry,
|
|
@@ -1607,9 +1640,9 @@ function splitNodeOptions (nodeOptions) {
|
|
|
1607
1640
|
const char = nodeOptions[index]
|
|
1608
1641
|
|
|
1609
1642
|
if (quote) {
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
index
|
|
1643
|
+
// Node treats a backslash inside double quotes as escaping the next character.
|
|
1644
|
+
if (char === '\\' && index + 1 < nodeOptions.length) {
|
|
1645
|
+
token += nodeOptions[++index]
|
|
1613
1646
|
continue
|
|
1614
1647
|
}
|
|
1615
1648
|
|
|
@@ -1621,7 +1654,8 @@ function splitNodeOptions (nodeOptions) {
|
|
|
1621
1654
|
continue
|
|
1622
1655
|
}
|
|
1623
1656
|
|
|
1624
|
-
|
|
1657
|
+
// NODE_OPTIONS uses double quotes for grouping; apostrophes belong to option values.
|
|
1658
|
+
if (char === '"') {
|
|
1625
1659
|
quote = char
|
|
1626
1660
|
continue
|
|
1627
1661
|
}
|
|
@@ -1649,7 +1683,8 @@ function serializeNodeOptions (tokens) {
|
|
|
1649
1683
|
for (const token of tokens) {
|
|
1650
1684
|
if (hasSerializedToken) serializedTokens += ' '
|
|
1651
1685
|
if (NODE_OPTIONS_QUOTE_RE.test(token)) {
|
|
1652
|
-
|
|
1686
|
+
// Escape only Node's grouping syntax; JSON would turn literal whitespace into escape letters.
|
|
1687
|
+
serializedTokens += `"${token.replaceAll('\\', '\\\\').replaceAll('"', String.raw`\"`)}"`
|
|
1653
1688
|
} else {
|
|
1654
1689
|
serializedTokens += token
|
|
1655
1690
|
}
|
|
@@ -1868,6 +1903,7 @@ function safeWorkspaceProject (ctx) {
|
|
|
1868
1903
|
}
|
|
1869
1904
|
|
|
1870
1905
|
module.exports = {
|
|
1906
|
+
addBrowserAnnotationPlugin,
|
|
1871
1907
|
configure,
|
|
1872
1908
|
deactivate,
|
|
1873
1909
|
configureWorkerEnv,
|
|
@@ -1055,6 +1055,15 @@ function configureFlakyTestRetries (ctx, testSpecifications, frameworkVersion) {
|
|
|
1055
1055
|
const projectNames = []
|
|
1056
1056
|
for (const { config, projectName } of getVitestProjectConfigs(ctx, testSpecifications)) {
|
|
1057
1057
|
if (!config.retry || config.retry.__ddTestOptAtr) {
|
|
1058
|
+
// Tag retries are resolved during declaration, after the callback's own options were captured.
|
|
1059
|
+
if (config.tags) {
|
|
1060
|
+
config.tags = config.tags.map(tag => tag.retry === undefined
|
|
1061
|
+
? tag
|
|
1062
|
+
: {
|
|
1063
|
+
...tag,
|
|
1064
|
+
meta: { ...tag.meta, __ddTestOptHasFrameworkRetry: true },
|
|
1065
|
+
})
|
|
1066
|
+
}
|
|
1058
1067
|
// The serializable marker survives task inheritance and setup refreshes, unlike numeric retry counts.
|
|
1059
1068
|
config.retry = usesRetryMarker ? { count: retryCount, __ddTestOptAtr: true } : retryCount
|
|
1060
1069
|
configured = true
|
|
@@ -1280,6 +1289,13 @@ function getFinishWrapper (exitOrClose) {
|
|
|
1280
1289
|
function getCliOrStartVitestWrapper (frameworkVersion) {
|
|
1281
1290
|
return function (oldCliOrStartVitest) {
|
|
1282
1291
|
return function (...args) {
|
|
1292
|
+
const entrypoint = oldCliOrStartVitest.name
|
|
1293
|
+
if (testSessionStartCh.hasSubscribers && (entrypoint === 'createVitest' || entrypoint === 'startVitest')) {
|
|
1294
|
+
const isCreate = entrypoint === 'createVitest'
|
|
1295
|
+
const isLegacySignature = typeof args[0] === 'string'
|
|
1296
|
+
const overridesIndex = isCreate ? (isLegacySignature ? 2 : 1) : (isLegacySignature ? 3 : 2)
|
|
1297
|
+
args[overridesIndex] = noWorkerInit.addBrowserAnnotationPlugin(args[overridesIndex])
|
|
1298
|
+
}
|
|
1283
1299
|
if (!testSessionStartCh.hasSubscribers || isSessionStarted) {
|
|
1284
1300
|
return oldCliOrStartVitest.apply(this, args)
|
|
1285
1301
|
}
|
|
@@ -2078,6 +2094,16 @@ function getStartVitestWrapper (cliApiPackage, frameworkVersion) {
|
|
|
2078
2094
|
if (createVitestExport) {
|
|
2079
2095
|
shimmer.wrap(cliApiPackage, createVitestExport.key, getCliOrStartVitestWrapper(frameworkVersion))
|
|
2080
2096
|
}
|
|
2097
|
+
// Newer CLI chunks call the bundled namespace instead of the direct function exports.
|
|
2098
|
+
for (const [key, value] of Object.entries(cliApiPackage)) {
|
|
2099
|
+
if (value && typeof value === 'object' && typeof value.startVitest === 'function') {
|
|
2100
|
+
cliApiPackage[key] = {
|
|
2101
|
+
...value,
|
|
2102
|
+
startVitest: cliApiPackage[startVitestExport.key],
|
|
2103
|
+
}
|
|
2104
|
+
if (createVitestExport) cliApiPackage[key].createVitest = cliApiPackage[createVitestExport.key]
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2081
2107
|
wrapMessagePortOn()
|
|
2082
2108
|
|
|
2083
2109
|
wrapVitestInternals(cliApiPackage, frameworkVersion)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { wrapDeclaration } = require('../../dd-trace/src/ci-visibility/test-declaration-annotations')
|
|
4
|
+
const { addHook } = require('./helpers/instrument')
|
|
5
|
+
const { findExportByName, testSessionStartCh } = require('./vitest-util')
|
|
6
|
+
|
|
7
|
+
/** @param {Record<string, unknown>} pkg */
|
|
8
|
+
function captureDeclarations (pkg) {
|
|
9
|
+
if (!testSessionStartCh.hasSubscribers) return pkg
|
|
10
|
+
const getCurrentSuite = findExportByName(pkg, 'getCurrentSuite')?.value
|
|
11
|
+
if (!getCurrentSuite) return pkg
|
|
12
|
+
for (const [name, value] of Object.entries(pkg)) {
|
|
13
|
+
if (typeof value !== 'function' || !('each' in value)) continue
|
|
14
|
+
pkg[name] = wrapDeclaration(value, getCurrentSuite)
|
|
15
|
+
}
|
|
16
|
+
return pkg
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
addHook({ name: '@vitest/runner', versions: ['>=1.6.0 <5.0.0'] }, captureDeclarations)
|
|
20
|
+
addHook({ name: 'vitest', versions: ['>=5.0.0'], filePattern: 'dist/chunks/run.*' }, captureDeclarations)
|
|
@@ -46,6 +46,26 @@ const {
|
|
|
46
46
|
getVitestTestProperties,
|
|
47
47
|
} = require('./vitest-util')
|
|
48
48
|
|
|
49
|
+
const emptyAnnotations = { mustFail: false, noAutoRetry: false }
|
|
50
|
+
|
|
51
|
+
/** @param {object} task */
|
|
52
|
+
function getAnnotations (task) {
|
|
53
|
+
return task.meta?.__ddTestOptAnnotations || emptyAnnotations
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** @param {object} task */
|
|
57
|
+
function getReportedProperties (task) {
|
|
58
|
+
const properties = taskToTestProperties.get(task) || getVitestTestProperties(
|
|
59
|
+
getProvidedContext(), task.file.filepath, getTestName(task)
|
|
60
|
+
)
|
|
61
|
+
return {
|
|
62
|
+
isAttemptToFix: properties.isAttemptToFix,
|
|
63
|
+
isDisabled: properties.isDisabled,
|
|
64
|
+
isQuarantined: properties.isQuarantined,
|
|
65
|
+
annotations: getAnnotations(task),
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
49
69
|
const EFD_SUITE_ADMISSION_TIMEOUT_MS = 5000
|
|
50
70
|
const logSubmissionFlushCh = channel('ci:log-submission:flush')
|
|
51
71
|
const wrappedTestRunners = new WeakSet()
|
|
@@ -382,10 +402,11 @@ function hasConcurrentTests (file) {
|
|
|
382
402
|
*/
|
|
383
403
|
function hasRunnableNewTest (file, providedContext) {
|
|
384
404
|
for (const task of getTypeTasks(file.tasks)) {
|
|
385
|
-
if (task.mode === 'skip' || task.mode === 'todo') continue
|
|
405
|
+
if (task.mode === 'skip' || task.mode === 'todo' || getAnnotations(task).noAutoRetry) continue
|
|
386
406
|
|
|
387
407
|
const testProperties = getVitestTestProperties(providedContext, file.filepath, getTestName(task))
|
|
388
|
-
if (testProperties.isNew && !testProperties.isAttemptToFix &&
|
|
408
|
+
if (testProperties.isNew && !testProperties.isAttemptToFix &&
|
|
409
|
+
(!testProperties.isDisabled || getAnnotations(task).mustFail)) {
|
|
389
410
|
return true
|
|
390
411
|
}
|
|
391
412
|
}
|
|
@@ -550,6 +571,11 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
550
571
|
} = providedContext
|
|
551
572
|
const testProperties = getVitestTestProperties(providedContext, task.file.filepath, testName)
|
|
552
573
|
taskToTestProperties.set(task, testProperties)
|
|
574
|
+
const annotations = getAnnotations(task)
|
|
575
|
+
if (annotations.noAutoRetry && !annotations.hasFrameworkRetry &&
|
|
576
|
+
isFlakyTestRetriesEnabledForTask(providedContext, task)) {
|
|
577
|
+
task.retry = 0
|
|
578
|
+
}
|
|
553
579
|
|
|
554
580
|
if (isTestManagementTestsEnabled) {
|
|
555
581
|
const {
|
|
@@ -557,7 +583,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
557
583
|
isDisabled,
|
|
558
584
|
isQuarantined,
|
|
559
585
|
} = testProperties
|
|
560
|
-
if (isAttemptToFix) {
|
|
586
|
+
if (isAttemptToFix && !annotations.noAutoRetry) {
|
|
561
587
|
if (task.repeats !== testManagementAttemptToFixRetries) {
|
|
562
588
|
attemptToFixRetryTasks.add(task)
|
|
563
589
|
}
|
|
@@ -566,10 +592,10 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
566
592
|
attemptToFixTasks.add(task)
|
|
567
593
|
attemptToFixTaskToStatuses.set(task, [])
|
|
568
594
|
}
|
|
569
|
-
if (isQuarantined) {
|
|
595
|
+
if (isQuarantined && !annotations.mustFail) {
|
|
570
596
|
quarantinedTasks.add(task)
|
|
571
597
|
}
|
|
572
|
-
if (isDisabled) {
|
|
598
|
+
if (isDisabled && !annotations.mustFail) {
|
|
573
599
|
disabledTasks.add(task)
|
|
574
600
|
if (!attemptToFixTasks.has(task)) {
|
|
575
601
|
// we only actually skip if the test is not being attempted to be fixed
|
|
@@ -589,7 +615,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
589
615
|
}
|
|
590
616
|
}
|
|
591
617
|
|
|
592
|
-
const isEfdCandidate = isEarlyFlakeDetectionEnabled &&
|
|
618
|
+
const isEfdCandidate = !annotations.noAutoRetry && isEarlyFlakeDetectionEnabled &&
|
|
593
619
|
!attemptToFixTasks.has(task) &&
|
|
594
620
|
!disabledTasks.has(task) &&
|
|
595
621
|
(modifiedTasks.has(task) || newTasks.has(task))
|
|
@@ -605,6 +631,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
605
631
|
}
|
|
606
632
|
|
|
607
633
|
if (
|
|
634
|
+
!annotations.noAutoRetry &&
|
|
608
635
|
providedContext.isDynamicAtrEnabled &&
|
|
609
636
|
isFlakyTestRetriesEnabledForTask(providedContext, task) &&
|
|
610
637
|
!attemptToFixTasks.has(task) &&
|
|
@@ -818,7 +845,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
818
845
|
}
|
|
819
846
|
}
|
|
820
847
|
|
|
821
|
-
const isRetryReasonAtr = numAttempt > 0 &&
|
|
848
|
+
const isRetryReasonAtr = !getAnnotations(task).noAutoRetry && numAttempt > 0 &&
|
|
822
849
|
isFlakyTestRetriesEnabledForTask(providedContext, task) &&
|
|
823
850
|
!attemptToFixRetryTasks.has(task) &&
|
|
824
851
|
!efdRetryTasks.has(task)
|
|
@@ -832,9 +859,7 @@ function wrapVitestTestRunner (VitestTestRunner) {
|
|
|
832
859
|
isNew,
|
|
833
860
|
hasDynamicName: dynamicNameTasks.has(task),
|
|
834
861
|
mightHitProbe: isDiEnabled && isFailedTestReplayAllowed && numAttempt > 0,
|
|
835
|
-
|
|
836
|
-
isDisabled: disabledTasks.has(task),
|
|
837
|
-
isQuarantined: quarantinedTasks.has(task),
|
|
862
|
+
...getReportedProperties(task),
|
|
838
863
|
isRetryReasonAtr,
|
|
839
864
|
isModified: modifiedTasks.has(task),
|
|
840
865
|
}
|
|
@@ -1123,9 +1148,7 @@ function getStartTestsWrapper (frameworkVersion) {
|
|
|
1123
1148
|
testName: getTestName(task),
|
|
1124
1149
|
testSuiteAbsolutePath: task.file.filepath,
|
|
1125
1150
|
isNew: newTasks.has(task),
|
|
1126
|
-
|
|
1127
|
-
isDisabled: disabledTasks.has(task),
|
|
1128
|
-
isQuarantined: quarantinedTasks.has(task),
|
|
1151
|
+
...getReportedProperties(task),
|
|
1129
1152
|
})
|
|
1130
1153
|
} else if ((state === 'pass' && !isSwitchedStatus) || switchedStatus === 'pass') {
|
|
1131
1154
|
// Attempt-to-fix can pass its last attempt while an earlier failure still fails the suite.
|
|
@@ -1174,7 +1197,8 @@ function getStartTestsWrapper (frameworkVersion) {
|
|
|
1174
1197
|
}
|
|
1175
1198
|
|
|
1176
1199
|
// ATR: set hasFailedAllRetries when all auto test retries were exhausted and every attempt failed
|
|
1177
|
-
const isAtrRetry =
|
|
1200
|
+
const isAtrRetry = !getAnnotations(task).noAutoRetry &&
|
|
1201
|
+
isFlakyTestRetriesEnabledForTask(providedContext, task) && !attemptToFixTasks.has(task) &&
|
|
1178
1202
|
!efdRetryTasks.has(task)
|
|
1179
1203
|
if (isAtrRetry) {
|
|
1180
1204
|
// Dynamic ATR: use the per-test duration-based count instead of the flat limit.
|
|
@@ -1230,9 +1254,7 @@ function getStartTestsWrapper (frameworkVersion) {
|
|
|
1230
1254
|
testName: getTestName(task),
|
|
1231
1255
|
testSuiteAbsolutePath: task.file.filepath,
|
|
1232
1256
|
isNew: newTasks.has(task),
|
|
1233
|
-
|
|
1234
|
-
isDisabled: disabledTasks.has(task),
|
|
1235
|
-
isQuarantined: quarantinedTasks.has(task),
|
|
1257
|
+
...getReportedProperties(task),
|
|
1236
1258
|
})
|
|
1237
1259
|
}
|
|
1238
1260
|
}
|
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
const { getEnvironmentVariable } = require('../../dd-trace/src/config/helper')
|
|
4
4
|
const { isTrue } = require('../../dd-trace/src/util')
|
|
5
|
+
|
|
6
|
+
const isWorker = getEnvironmentVariable('DD_VITEST_WORKER') === '1'
|
|
7
|
+
const VITEST_NO_WORKER_INIT_ACTIVE_ENV = 'DD_TEST_OPT_VITEST_NO_WORKER_INIT_ACTIVE'
|
|
8
|
+
|
|
9
|
+
// No-worker setup captures declarations directly, without registering instrumentation hooks.
|
|
10
|
+
// eslint-disable-next-line eslint-rules/eslint-process-env
|
|
11
|
+
if (isWorker && isTrue(process.env[VITEST_NO_WORKER_INIT_ACTIVE_ENV])) return
|
|
12
|
+
|
|
5
13
|
const { channel } = require('./helpers/instrument')
|
|
14
|
+
require('./vitest-test-annotations')
|
|
6
15
|
|
|
7
16
|
channel('tracing:orchestrion:@vitest/runner:createTestTask:end').subscribe(({ arguments: args, result: task }) => {
|
|
8
17
|
// Suite options have already been merged here, including overrides equal to ATR's count.
|
|
@@ -11,14 +20,7 @@ channel('tracing:orchestrion:@vitest/runner:createTestTask:end').subscribe(({ ar
|
|
|
11
20
|
}
|
|
12
21
|
})
|
|
13
22
|
|
|
14
|
-
if (
|
|
15
|
-
const VITEST_NO_WORKER_INIT_ACTIVE_ENV = 'DD_TEST_OPT_VITEST_NO_WORKER_INIT_ACTIVE'
|
|
16
|
-
|
|
17
|
-
// In no-worker-init mode the main process reports Vitest events from reporter hooks.
|
|
18
|
-
// Loading worker instrumentation here would reintroduce the worker tracer path.
|
|
19
|
-
// eslint-disable-next-line eslint-rules/eslint-process-env
|
|
20
|
-
if (isTrue(process.env[VITEST_NO_WORKER_INIT_ACTIVE_ENV])) return
|
|
21
|
-
|
|
23
|
+
if (isWorker) {
|
|
22
24
|
require('./vitest-worker')
|
|
23
25
|
} else {
|
|
24
26
|
require('./vitest-main')
|
|
@@ -23,7 +23,7 @@ const {
|
|
|
23
23
|
TEST_SUITE_EXECUTION_ID,
|
|
24
24
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
25
25
|
const { publishWithCompletion } = require('./helpers/channel')
|
|
26
|
-
const {
|
|
26
|
+
const { channel, tracingChannel } = require('./helpers/instrument')
|
|
27
27
|
const {
|
|
28
28
|
CONFIGURATION_REQUEST,
|
|
29
29
|
CONFIGURATION_RESPONSE,
|
|
@@ -97,7 +97,8 @@ if (loadCh.hasSubscribers) {
|
|
|
97
97
|
|
|
98
98
|
const coordinatorStates = new WeakMap()
|
|
99
99
|
const emptyShardConfigurations = new WeakSet()
|
|
100
|
-
|
|
100
|
+
// A WebdriverIO process runs a single @wdio/local-runner version.
|
|
101
|
+
let localRunnerVersion
|
|
101
102
|
const rumBrowsers = new Set()
|
|
102
103
|
const rumCorrelationBrowsers = new Set()
|
|
103
104
|
const rumRunnerBrowsers = new WeakSet()
|
|
@@ -115,15 +116,14 @@ function getCurrentRumContext () {
|
|
|
115
116
|
return globalThis.window
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
})
|
|
119
|
+
/**
|
|
120
|
+
* @param {import('./helpers/rewriter/instrumentation-registry').Activation} activation
|
|
121
|
+
*/
|
|
122
|
+
function recordLocalRunnerVersion ({ moduleName, version }) {
|
|
123
|
+
if (moduleName === '@wdio/local-runner') localRunnerVersion = version
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
exports.recordLocalRunnerVersion = recordLocalRunnerVersion
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* Returns whether this browser can preload and clean correlation across every browsing context.
|
|
@@ -1165,7 +1165,7 @@ function getCoordinatorState (localRunner) {
|
|
|
1165
1165
|
initializationCallbacks: [],
|
|
1166
1166
|
sessionStarted: false,
|
|
1167
1167
|
finished: false,
|
|
1168
|
-
frameworkVersion:
|
|
1168
|
+
frameworkVersion: localRunnerVersion,
|
|
1169
1169
|
testFrameworkAdapter: getRunnerConfiguration(localRunner)?.framework,
|
|
1170
1170
|
activeWorkers: 0,
|
|
1171
1171
|
attemptToFixExecutions: new Map(),
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
|
|
4
|
+
|
|
5
|
+
class AsyncMutexPlugin extends TracingPlugin {
|
|
6
|
+
static id = 'async-mutex'
|
|
7
|
+
static prefix = 'tracing:orchestrion:async-mutex:Semaphore_acquire'
|
|
8
|
+
|
|
9
|
+
bindStart (ctx) {
|
|
10
|
+
const weight = ctx.arguments?.[0] ?? 1
|
|
11
|
+
const priority = ctx.arguments?.[1] ?? 0
|
|
12
|
+
const semaphore = ctx.self
|
|
13
|
+
|
|
14
|
+
const metrics = {}
|
|
15
|
+
if (weight !== 1) metrics['async_mutex.weight'] = weight
|
|
16
|
+
if (priority !== 0) metrics['async_mutex.priority'] = priority
|
|
17
|
+
// `_couldLockImmediately` is the library's own predicate for "would this queue". Guarded so a
|
|
18
|
+
// version that drops it reports nothing rather than a wrong answer.
|
|
19
|
+
if (typeof semaphore?._couldLockImmediately === 'function') {
|
|
20
|
+
metrics['async_mutex.contended'] = semaphore._couldLockImmediately(weight, priority) ? 0 : 1
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
this.startSpan('async-mutex.acquire', {
|
|
24
|
+
service: this.config.service || this._tracerConfig.service,
|
|
25
|
+
resource: 'acquire',
|
|
26
|
+
meta: {
|
|
27
|
+
component: 'async-mutex',
|
|
28
|
+
},
|
|
29
|
+
metrics,
|
|
30
|
+
}, ctx)
|
|
31
|
+
|
|
32
|
+
return ctx.currentStore
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
end (ctx) {
|
|
36
|
+
if (ctx.error === undefined) return
|
|
37
|
+
|
|
38
|
+
this.finish(ctx)
|
|
39
|
+
|
|
40
|
+
return ctx.parentStore
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
asyncEnd (ctx) {
|
|
44
|
+
this.finish(ctx)
|
|
45
|
+
|
|
46
|
+
return ctx.parentStore
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = AsyncMutexPlugin
|