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
|
@@ -106,6 +106,49 @@ function normalizeSql (command) {
|
|
|
106
106
|
return command?.sql ?? command
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* @param {unknown} original
|
|
111
|
+
* @param {unknown} injected
|
|
112
|
+
* @param {unknown} originalSql
|
|
113
|
+
* @param {boolean} [mirrorOptions]
|
|
114
|
+
* @returns {unknown}
|
|
115
|
+
*/
|
|
116
|
+
function withInjectedSql (original, injected, originalSql, mirrorOptions) {
|
|
117
|
+
if (typeof originalSql !== 'string' || !originalSql || typeof injected !== 'string') {
|
|
118
|
+
return original
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (typeof original === 'string') return injected
|
|
122
|
+
|
|
123
|
+
const command = { ...original, sql: injected }
|
|
124
|
+
if (mirrorOptions) {
|
|
125
|
+
const enumerable = Object.getOwnPropertyDescriptor(original, 'metaAsArray')?.enumerable ?? true
|
|
126
|
+
Object.defineProperty(command, 'metaAsArray', {
|
|
127
|
+
configurable: true,
|
|
128
|
+
enumerable,
|
|
129
|
+
get () { return original.metaAsArray },
|
|
130
|
+
/** @param {boolean} value */
|
|
131
|
+
set (value) { original.metaAsArray = value },
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
return command
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @param {{ sql: unknown }} ctx
|
|
139
|
+
* @param {Function} command
|
|
140
|
+
* @param {ArgumentsLike} args
|
|
141
|
+
* @param {unknown} originalSql
|
|
142
|
+
* @param {unknown} [preparedSql]
|
|
143
|
+
* @param {boolean} [mirrorOptions]
|
|
144
|
+
*/
|
|
145
|
+
function runSqlCommand (ctx, command, args, originalSql, preparedSql, mirrorOptions) {
|
|
146
|
+
if (preparedSql === undefined && ctx.sql !== originalSql) {
|
|
147
|
+
args[0] = withInjectedSql(args[0], ctx.sql, originalSql, mirrorOptions)
|
|
148
|
+
}
|
|
149
|
+
return command.apply(this, args)
|
|
150
|
+
}
|
|
151
|
+
|
|
109
152
|
/**
|
|
110
153
|
* Parses connection options without allowing instrumentation to break the factory call.
|
|
111
154
|
*
|
|
@@ -584,7 +627,8 @@ function createWrapPromiseCommand (
|
|
|
584
627
|
if (!startCh.hasSubscribers) return command.apply(this, arguments)
|
|
585
628
|
|
|
586
629
|
const owner = trackActiveCommands ? (commandOwner ?? this) : undefined
|
|
587
|
-
const
|
|
630
|
+
const originalSql = preparedSql ?? normalizeSql(sql)
|
|
631
|
+
const ctx = { sql: originalSql, conf: options }
|
|
588
632
|
const acquisition = poolAcquisition === undefined
|
|
589
633
|
? undefined
|
|
590
634
|
: createPoolAcquisition(this, options, ctx, poolAcquisition)
|
|
@@ -594,7 +638,7 @@ function createWrapPromiseCommand (
|
|
|
594
638
|
let result
|
|
595
639
|
try {
|
|
596
640
|
result = acquisition === undefined
|
|
597
|
-
? startCh.runStores(ctx,
|
|
641
|
+
? startCh.runStores(ctx, runSqlCommand, this, ctx, command, arguments, originalSql, preparedSql)
|
|
598
642
|
: runPoolAcquisition(acquisition, command, this, arguments)
|
|
599
643
|
} catch (error) {
|
|
600
644
|
finishPoolCommandAcquisition(acquisition, error)
|
|
@@ -624,7 +668,7 @@ function createWrapPromiseCommand (
|
|
|
624
668
|
* @param {number} [commandArity] Original arity when command is wrapped by a variadic forwarding function.
|
|
625
669
|
* @param {boolean} [trackActiveCommands]
|
|
626
670
|
* @param {'measure' | 'observe'} [poolAcquisition]
|
|
627
|
-
* @returns {(command: Function) => Function}
|
|
671
|
+
* @returns {(command: Function, method?: string) => Function}
|
|
628
672
|
*/
|
|
629
673
|
function createWrapCallbackCommand (
|
|
630
674
|
options,
|
|
@@ -634,7 +678,11 @@ function createWrapCallbackCommand (
|
|
|
634
678
|
trackActiveCommands = true,
|
|
635
679
|
poolAcquisition
|
|
636
680
|
) {
|
|
637
|
-
|
|
681
|
+
/**
|
|
682
|
+
* @param {Function} command
|
|
683
|
+
* @param {string} [method]
|
|
684
|
+
*/
|
|
685
|
+
return function wrapCommand (command, method) {
|
|
638
686
|
const callbackIndex = (commandArity ?? command.length) - 1
|
|
639
687
|
|
|
640
688
|
return function (sql) {
|
|
@@ -642,7 +690,10 @@ function createWrapCallbackCommand (
|
|
|
642
690
|
|
|
643
691
|
const owner = trackActiveCommands ? (commandOwner ?? this) : undefined
|
|
644
692
|
const callback = arguments[arguments.length - 1]
|
|
645
|
-
const
|
|
693
|
+
const mirrorOptions = method === 'execute' ||
|
|
694
|
+
(method === 'query' && (typeof callback === 'function' || typeof arguments[1] === 'function'))
|
|
695
|
+
const originalSql = preparedSql ?? normalizeSql(sql)
|
|
696
|
+
const ctx = { sql: originalSql, conf: options }
|
|
646
697
|
const acquisition = poolAcquisition === undefined
|
|
647
698
|
? undefined
|
|
648
699
|
: createPoolAcquisition(this, options, ctx, poolAcquisition)
|
|
@@ -667,7 +718,9 @@ function createWrapCallbackCommand (
|
|
|
667
718
|
|
|
668
719
|
try {
|
|
669
720
|
return acquisition === undefined
|
|
670
|
-
? startCh.runStores(
|
|
721
|
+
? startCh.runStores(
|
|
722
|
+
ctx, runSqlCommand, this, ctx, command, arguments, originalSql, preparedSql, mirrorOptions
|
|
723
|
+
)
|
|
671
724
|
: runPoolAcquisition(acquisition, command, this, arguments)
|
|
672
725
|
} catch (error) {
|
|
673
726
|
finishPoolCommandAcquisition(acquisition, error)
|
|
@@ -692,12 +745,13 @@ function createWrapStream (options, preparedSql, commandOwner) {
|
|
|
692
745
|
if (!startCh.hasSubscribers) return streamMethod.apply(this, arguments)
|
|
693
746
|
|
|
694
747
|
const owner = commandOwner ?? this
|
|
695
|
-
const
|
|
748
|
+
const originalSql = preparedSql ?? normalizeSql(sql)
|
|
749
|
+
const ctx = { sql: originalSql, conf: options }
|
|
696
750
|
let stream
|
|
697
751
|
|
|
698
752
|
startCommand(owner)
|
|
699
753
|
try {
|
|
700
|
-
stream = startCh.runStores(ctx,
|
|
754
|
+
stream = startCh.runStores(ctx, runSqlCommand, this, ctx, streamMethod, arguments, originalSql, preparedSql)
|
|
701
755
|
} catch (error) {
|
|
702
756
|
finishCommand(ctx, owner, error)
|
|
703
757
|
throw error
|
|
@@ -732,14 +786,18 @@ function createWrapStream (options, preparedSql, commandOwner) {
|
|
|
732
786
|
* Wraps command methods exposed by a bundled client.
|
|
733
787
|
*
|
|
734
788
|
* @param {object} client
|
|
735
|
-
* @param {(command: Function) => Function} wrapper
|
|
789
|
+
* @param {(command: Function, method?: string) => Function} wrapper
|
|
736
790
|
*/
|
|
737
791
|
function wrapClientCommands (client, wrapper) {
|
|
738
792
|
if (wrappedClients.has(client)) return
|
|
739
793
|
|
|
740
794
|
wrappedClients.add(client)
|
|
741
795
|
for (const method of commandMethods) {
|
|
742
|
-
if (typeof client[method] === 'function')
|
|
796
|
+
if (typeof client[method] === 'function') {
|
|
797
|
+
/** @param {Function} command */
|
|
798
|
+
function wrapMethod (command) { return wrapper(command, method) }
|
|
799
|
+
shimmer.wrap(client, method, wrapMethod)
|
|
800
|
+
}
|
|
743
801
|
}
|
|
744
802
|
}
|
|
745
803
|
|
|
@@ -1570,4 +1628,4 @@ function wrapCallbackBundle (mariadb) {
|
|
|
1570
1628
|
])
|
|
1571
1629
|
}
|
|
1572
1630
|
|
|
1573
|
-
module.exports = { wrapCallbackBundle, wrapPromiseBundle }
|
|
1631
|
+
module.exports = { normalizeSql, runSqlCommand, wrapCallbackBundle, wrapPromiseBundle }
|
|
@@ -15,7 +15,7 @@ const {
|
|
|
15
15
|
takePoolWaitTime,
|
|
16
16
|
wrapPoolQueryMethod,
|
|
17
17
|
} = require('./helpers/pool-acquire')
|
|
18
|
-
const { wrapCallbackBundle, wrapPromiseBundle } = require('./mariadb-bundle')
|
|
18
|
+
const { normalizeSql, runSqlCommand, wrapCallbackBundle, wrapPromiseBundle } = require('./mariadb-bundle')
|
|
19
19
|
|
|
20
20
|
const commandAddCh = channel('apm:mariadb:command:add')
|
|
21
21
|
const connectionStartCh = channel('apm:mariadb:connection:start')
|
|
@@ -72,7 +72,12 @@ function wrapCommandStart (start, ctx) {
|
|
|
72
72
|
}
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
// Subscribers may rewrite `ctx.sql` (DBM propagation comment). The command encodes `this.sql` when it
|
|
76
|
+
// starts, so copy the rewritten text back first, as the mysql and mysql2 instrumentations do.
|
|
77
|
+
return startCh.runStores(ctx, function (...startArgs) {
|
|
78
|
+
if (typeof this.sql === 'string' && this.sql && typeof ctx.sql === 'string') this.sql = ctx.sql
|
|
79
|
+
return start.apply(this, startArgs)
|
|
80
|
+
}, this, ...args)
|
|
76
81
|
})
|
|
77
82
|
}
|
|
78
83
|
|
|
@@ -97,11 +102,12 @@ function createWrapQuery (options) {
|
|
|
97
102
|
return function (sql) {
|
|
98
103
|
if (!startCh.hasSubscribers) return query.apply(this, arguments)
|
|
99
104
|
|
|
100
|
-
const
|
|
105
|
+
const originalSql = normalizeSql(sql)
|
|
106
|
+
const ctx = { sql: originalSql, conf: options }
|
|
101
107
|
const poolWaitTime = takePoolWaitTime(this)
|
|
102
108
|
if (poolWaitTime !== undefined) ctx.poolWaitTime = poolWaitTime
|
|
103
109
|
|
|
104
|
-
return startCh.runStores(ctx,
|
|
110
|
+
return startCh.runStores(ctx, runSqlCommand, this, ctx, query, arguments, originalSql)
|
|
105
111
|
.then(result => {
|
|
106
112
|
ctx.result = result
|
|
107
113
|
finishCh.publish(ctx)
|
|
@@ -122,7 +128,8 @@ function createWrapQueryCallback (options) {
|
|
|
122
128
|
if (!startCh.hasSubscribers) return query.apply(this, arguments)
|
|
123
129
|
|
|
124
130
|
const cb = arguments[arguments.length - 1]
|
|
125
|
-
const
|
|
131
|
+
const originalSql = normalizeSql(sql)
|
|
132
|
+
const ctx = { sql: originalSql, conf: options }
|
|
126
133
|
const wrapper = (cb) => function (err) {
|
|
127
134
|
if (err) {
|
|
128
135
|
ctx.error = err
|
|
@@ -141,7 +148,7 @@ function createWrapQueryCallback (options) {
|
|
|
141
148
|
arguments[arguments.length - 1] = wrapper()
|
|
142
149
|
}
|
|
143
150
|
|
|
144
|
-
return startCh.runStores(ctx,
|
|
151
|
+
return startCh.runStores(ctx, runSqlCommand, this, ctx, query, arguments, originalSql)
|
|
145
152
|
}
|
|
146
153
|
}
|
|
147
154
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { addHook, channel } = require('../helpers/instrument')
|
|
4
4
|
const shimmer = require('../../../datadog-shimmer')
|
|
5
|
+
const { getTestAnnotations, copyTestAnnotations } = require('../../../dd-trace/src/ci-visibility/test-annotations')
|
|
5
6
|
const { getCallSites } = require('../../../dd-trace/src/plugins/util/stacktrace')
|
|
6
7
|
const { DD_MAJOR } = require('../../../../version')
|
|
7
8
|
const { testToStartLine } = require('./utils')
|
|
@@ -38,6 +39,13 @@ function addMochaRunHooks (versions, wrapMochaRun) {
|
|
|
38
39
|
}
|
|
39
40
|
metadata = { moduleBaseDir: hookMeta?.moduleBaseDir }
|
|
40
41
|
patchedMochaConstructors.set(Mocha, metadata)
|
|
42
|
+
// ui is exposed on the constructor already observed by the require hooks, so no source rewrite is needed.
|
|
43
|
+
// Attach our listener after the interface installs its declarations, before skipped callbacks are discarded.
|
|
44
|
+
shimmer.wrap(Mocha.prototype, 'ui', ui => function () {
|
|
45
|
+
const result = ui.apply(this, arguments)
|
|
46
|
+
this.suite.on('pre-require', context => preserveDeclarationAnnotations(context, Mocha))
|
|
47
|
+
return result
|
|
48
|
+
})
|
|
41
49
|
return wrapMochaRun(Mocha, frameworkVersion, metadata)
|
|
42
50
|
}
|
|
43
51
|
|
|
@@ -76,6 +84,61 @@ function addMochaRunHooks (versions, wrapMochaRun) {
|
|
|
76
84
|
}, wrapMochaPackage)
|
|
77
85
|
}
|
|
78
86
|
|
|
87
|
+
/**
|
|
88
|
+
* @param {object} context
|
|
89
|
+
* @param {Function} Mocha
|
|
90
|
+
*/
|
|
91
|
+
function preserveDeclarationAnnotations (context, Mocha) {
|
|
92
|
+
let declarationAnnotations
|
|
93
|
+
/** @param {Function} original */
|
|
94
|
+
function wrapDeclaration (original) {
|
|
95
|
+
return function (title, fn) {
|
|
96
|
+
const previousAnnotations = declarationAnnotations
|
|
97
|
+
// TDD test.skip delegates to test(title), dropping its callback and the returned Test.
|
|
98
|
+
declarationAnnotations ??= getTestAnnotations(fn)
|
|
99
|
+
try {
|
|
100
|
+
const test = original.apply(this, arguments)
|
|
101
|
+
if (test && !test.fn) test._ddDeclaredAnnotations = declarationAnnotations
|
|
102
|
+
return test
|
|
103
|
+
} finally {
|
|
104
|
+
declarationAnnotations = previousAnnotations
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
for (const key of ['it', 'specify', 'test', 'xit', 'xspecify']) {
|
|
110
|
+
const declare = context[key]
|
|
111
|
+
if (typeof declare !== 'function') continue
|
|
112
|
+
context[key] = shimmer.wrapFunction(declare, wrapDeclaration)
|
|
113
|
+
// Older Mocha interfaces copy declarations to exports before this listener runs.
|
|
114
|
+
for (const exported of ['it', 'specify', 'test', 'xit', 'xspecify']) {
|
|
115
|
+
if (Mocha[exported] === declare) Mocha[exported] = context[key]
|
|
116
|
+
}
|
|
117
|
+
for (const modifier of ['skip', 'only']) {
|
|
118
|
+
if (typeof declare[modifier] === 'function') {
|
|
119
|
+
context[key][modifier] = shimmer.wrapFunction(declare[modifier], wrapDeclaration)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Carry declaration policy alongside each serialized execution, including duplicate full titles.
|
|
126
|
+
addHook({
|
|
127
|
+
name: 'mocha',
|
|
128
|
+
versions: ['>=8.0.0'],
|
|
129
|
+
filePattern: String.raw`lib/test\.(?:c?js)$`,
|
|
130
|
+
}, TestPackage => {
|
|
131
|
+
const Test = TestPackage.Test ?? TestPackage
|
|
132
|
+
shimmer.wrap(Test.prototype, 'serialize', serialize => function () {
|
|
133
|
+
const serialized = serialize.apply(this, arguments)
|
|
134
|
+
const { mustFail, noAutoRetry } = this._ddTestAnnotations || this._ddDeclaredAnnotations ||
|
|
135
|
+
getTestAnnotations(this.fn)
|
|
136
|
+
serialized._ddTestAnnotations = { mustFail, noAutoRetry }
|
|
137
|
+
return serialized
|
|
138
|
+
})
|
|
139
|
+
return TestPackage
|
|
140
|
+
})
|
|
141
|
+
|
|
79
142
|
// mocha-each support
|
|
80
143
|
addHook({
|
|
81
144
|
name: 'mocha-each',
|
|
@@ -86,15 +149,33 @@ addHook({
|
|
|
86
149
|
patched.add(mochaEach)
|
|
87
150
|
|
|
88
151
|
return shimmer.wrapFunction(mochaEach, mochaEach => function (...args) {
|
|
89
|
-
const [params] = args
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
152
|
+
const [params, declare = global.it] = args
|
|
153
|
+
let sourceTestFn
|
|
154
|
+
/** @param {Function} original */
|
|
155
|
+
const wrapRow = original => function (title, fn) {
|
|
156
|
+
copyTestAnnotations(sourceTestFn, fn)
|
|
157
|
+
return original.apply(this, arguments)
|
|
158
|
+
}
|
|
159
|
+
const rowDeclaration = shimmer.wrapFunction(declare, wrapRow)
|
|
160
|
+
for (const modifier of ['skip', 'only']) {
|
|
161
|
+
if (typeof declare?.[modifier] === 'function') {
|
|
162
|
+
rowDeclaration[modifier] = shimmer.wrapFunction(declare[modifier], wrapRow)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const declarations = mochaEach.call(this, params, rowDeclaration, ...args.slice(2))
|
|
166
|
+
/** @param {Function} original */
|
|
167
|
+
const wrapEachDeclaration = original => function (title, fn) {
|
|
168
|
+
sourceTestFn = fn
|
|
169
|
+
parameterizedTestCh.publish({ title, params })
|
|
170
|
+
return original.apply(this, arguments)
|
|
171
|
+
}
|
|
172
|
+
declarations.it = shimmer.wrapFunction(declarations.it, wrapEachDeclaration)
|
|
173
|
+
for (const modifier of ['skip', 'only']) {
|
|
174
|
+
if (typeof declarations.it[modifier] === 'function') {
|
|
175
|
+
declarations.it[modifier] = shimmer.wrapFunction(declarations.it[modifier], wrapEachDeclaration)
|
|
176
|
+
}
|
|
97
177
|
}
|
|
178
|
+
return declarations
|
|
98
179
|
})
|
|
99
180
|
})
|
|
100
181
|
|
|
@@ -1319,11 +1319,13 @@ addHook({
|
|
|
1319
1319
|
shimmer.wrap(Runner.prototype, 'run', run => function (...args) {
|
|
1320
1320
|
if (!testFinishCh.hasSubscribers) {
|
|
1321
1321
|
resetRunState(this.suite)
|
|
1322
|
+
workerTestAnnotations.clear()
|
|
1322
1323
|
return runMochaRunner(run, this, args)
|
|
1323
1324
|
}
|
|
1324
1325
|
|
|
1325
1326
|
const { onRunDone, onFlushDone } = getRunCompletionCallbacks(args[0])
|
|
1326
1327
|
resetRunState(this.suite)
|
|
1328
|
+
workerTestAnnotations.clear()
|
|
1327
1329
|
runnerFailuresAdjusted.delete(this)
|
|
1328
1330
|
runnerFrameworkErrors.delete(this)
|
|
1329
1331
|
runnerStarted.delete(this)
|
|
@@ -1451,7 +1453,7 @@ addHook({
|
|
|
1451
1453
|
// instead of suiteA -> suiteB -> testA -> ... -> testB)
|
|
1452
1454
|
// when the suite has tests that are in the top level
|
|
1453
1455
|
// (no describe(...))
|
|
1454
|
-
this.prependListener('test', getOnTestHandler(true))
|
|
1456
|
+
this.prependListener('test', getOnTestHandler(true, config))
|
|
1455
1457
|
// Reporters are registered before Runner#run, so prepend this after the test handler
|
|
1456
1458
|
// to start the suite first and preserve the test event if a reporter throws.
|
|
1457
1459
|
this.prependListener('test', startRootSuite)
|
|
@@ -1658,12 +1660,15 @@ addHook({
|
|
|
1658
1660
|
file: 'lib/runnable.js',
|
|
1659
1661
|
}, (runnablePackage) => runnableWrapper(runnablePackage, config))
|
|
1660
1662
|
|
|
1663
|
+
const workerTestAnnotations = new Map()
|
|
1664
|
+
|
|
1661
1665
|
function onMessage (message) {
|
|
1662
1666
|
if (Array.isArray(message)) {
|
|
1663
1667
|
const [messageCode, payload] = message
|
|
1664
1668
|
if (messageCode === MOCHA_WORKER_TRACE_PAYLOAD_CODE) {
|
|
1665
1669
|
collectTestOptimizationSummariesFromTraces(payload, {
|
|
1666
1670
|
newTestsWithDynamicNames,
|
|
1671
|
+
testAnnotations: workerTestAnnotations,
|
|
1667
1672
|
attemptToFixExecutions,
|
|
1668
1673
|
})
|
|
1669
1674
|
workerReportTraceCh.publish(payload)
|
|
@@ -1731,6 +1736,7 @@ addHook({
|
|
|
1731
1736
|
filePattern: String.raw`lib/nodejs/parallel-buffered-runner\.(?:c?js)$`,
|
|
1732
1737
|
}, (ParallelBufferedRunner, frameworkVersion) => {
|
|
1733
1738
|
shimmer.wrap(ParallelBufferedRunner.prototype, 'run', run => function (cb, { files, options = {} }) {
|
|
1739
|
+
workerTestAnnotations.clear()
|
|
1734
1740
|
if (!testFinishCh.hasSubscribers) {
|
|
1735
1741
|
return run.apply(this, arguments)
|
|
1736
1742
|
}
|
|
@@ -1914,6 +1920,9 @@ addHook({
|
|
|
1914
1920
|
const isModified = config.isImpactedTestsEnabled && isModifiedTestSuite(testSuiteAbsolutePath)
|
|
1915
1921
|
|
|
1916
1922
|
for (const test of tests) {
|
|
1923
|
+
test._ddTestAnnotations ||= workerTestAnnotations.get(
|
|
1924
|
+
`${getTestSuitePath(test.file, process.cwd())} › ${test.fullTitle()}`
|
|
1925
|
+
)
|
|
1917
1926
|
const testProperties = getTestProperties(test, config.testManagementTests)
|
|
1918
1927
|
const isAttemptToFix = config.isTestManagementTestsEnabled && testProperties.isAttemptToFix
|
|
1919
1928
|
|
|
@@ -1930,7 +1939,7 @@ addHook({
|
|
|
1930
1939
|
}
|
|
1931
1940
|
}
|
|
1932
1941
|
// `efdTests` is filled in the worker process, so we need to use the test results to fill it here too.
|
|
1933
|
-
if (!isAttemptToFix && (isNew || isModified)) {
|
|
1942
|
+
if (!test._ddTestAnnotations?.noAutoRetry && !isAttemptToFix && (isNew || isModified)) {
|
|
1934
1943
|
const testFullName = getTestFullName(test)
|
|
1935
1944
|
const tests = efdTests[testFullName]
|
|
1936
1945
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const { performance } = require('node:perf_hooks')
|
|
4
4
|
|
|
5
|
+
const { getTestAnnotations } = require('../../../dd-trace/src/ci-visibility/test-annotations')
|
|
6
|
+
|
|
5
7
|
const { getEnvironmentVariable } = require('../../../dd-trace/src/config/helper')
|
|
6
8
|
const {
|
|
7
9
|
getEfdRetryCountForDuration,
|
|
@@ -133,6 +135,21 @@ function getAfterEachHooks (testOrHook) {
|
|
|
133
135
|
return hooks
|
|
134
136
|
}
|
|
135
137
|
|
|
138
|
+
/**
|
|
139
|
+
* @param {{ file: string, fullTitle: () => string }} test
|
|
140
|
+
* @param {object} config
|
|
141
|
+
* @param {boolean} [config.isTestManagementTestsEnabled]
|
|
142
|
+
* @param {{ mocha?: { suites?: Record<string, {
|
|
143
|
+
* tests?: Record<string, { properties?: Record<string, boolean> }>
|
|
144
|
+
* }> } }} [config.testManagementTests]
|
|
145
|
+
*/
|
|
146
|
+
function getAssignedProperties (test, config) {
|
|
147
|
+
return config.isTestManagementTestsEnabled
|
|
148
|
+
? config.testManagementTests?.mocha?.suites
|
|
149
|
+
?.[getTestSuitePath(test.file, process.cwd())]?.tests?.[test.fullTitle()]?.properties
|
|
150
|
+
: undefined
|
|
151
|
+
}
|
|
152
|
+
|
|
136
153
|
function getTestProperties (test, testManagementTests) {
|
|
137
154
|
const testSuite = getTestSuitePath(test.file, process.cwd())
|
|
138
155
|
const testName = test.fullTitle()
|
|
@@ -140,7 +157,13 @@ function getTestProperties (test, testManagementTests) {
|
|
|
140
157
|
const { attempt_to_fix: isAttemptToFix, disabled: isDisabled, quarantined: isQuarantined } =
|
|
141
158
|
testManagementTests?.mocha?.suites?.[testSuite]?.tests?.[testName]?.properties || {}
|
|
142
159
|
|
|
143
|
-
|
|
160
|
+
const { mustFail, noAutoRetry } =
|
|
161
|
+
test._ddTestAnnotations || test._ddDeclaredAnnotations || getTestAnnotations(test.fn)
|
|
162
|
+
return {
|
|
163
|
+
isAttemptToFix: isAttemptToFix && !noAutoRetry,
|
|
164
|
+
isDisabled: isDisabled && !mustFail,
|
|
165
|
+
isQuarantined: isQuarantined && !mustFail,
|
|
166
|
+
}
|
|
144
167
|
}
|
|
145
168
|
|
|
146
169
|
function isNewTest (test, knownTests) {
|
|
@@ -258,7 +281,8 @@ function isDatadogManagedRetryTest (test, config) {
|
|
|
258
281
|
* }} config
|
|
259
282
|
*/
|
|
260
283
|
function isEarlyFlakeDetectionTest (test, config) {
|
|
261
|
-
return !test.
|
|
284
|
+
return !getTestAnnotations(test.fn).noAutoRetry && !test._ddTestAnnotations?.noAutoRetry &&
|
|
285
|
+
!test._ddIsAttemptToFix &&
|
|
262
286
|
!test._ddIsDisabled &&
|
|
263
287
|
config.isEarlyFlakeDetectionEnabled &&
|
|
264
288
|
hasEfdRetries(config.earlyFlakeDetectionRetryPolicy) &&
|
|
@@ -281,6 +305,8 @@ function retryTest (test, numRetries, tags, retryPolicy) {
|
|
|
281
305
|
}
|
|
282
306
|
for (let retryIndex = 0; retryIndex < numRetries; retryIndex++) {
|
|
283
307
|
const clonedTest = test.clone()
|
|
308
|
+
clonedTest._ddTestAnnotations = test._ddTestAnnotations
|
|
309
|
+
clonedTest._ddAssignedProperties = test._ddAssignedProperties
|
|
284
310
|
disableMochaRetries(clonedTest)
|
|
285
311
|
datadogRetryOriginals.set(clonedTest, test)
|
|
286
312
|
suite.addTest(clonedTest)
|
|
@@ -378,6 +404,8 @@ function resetRunState (rootSuite) {
|
|
|
378
404
|
if (test._retriedTest) originalRetriesByTest.delete(test._retriedTest)
|
|
379
405
|
}
|
|
380
406
|
|
|
407
|
+
delete test._ddAssignedProperties
|
|
408
|
+
delete test._ddTestAnnotations
|
|
381
409
|
delete test._ddIsAttemptToFix
|
|
382
410
|
delete test._ddIsDisabled
|
|
383
411
|
delete test._ddIsQuarantined
|
|
@@ -460,7 +488,7 @@ function recordRetryTrackedAttempt (test) {
|
|
|
460
488
|
if (isNew) {
|
|
461
489
|
recordTestAttempt(newTests, test)
|
|
462
490
|
}
|
|
463
|
-
if (!isAttemptToFix && (isNew || isModified)) {
|
|
491
|
+
if (!test._ddTestAnnotations?.noAutoRetry && !isAttemptToFix && (isNew || isModified)) {
|
|
464
492
|
recordTestAttempt(efdTests, test)
|
|
465
493
|
}
|
|
466
494
|
}
|
|
@@ -525,6 +553,8 @@ function suppressSyntheticTestLifecycle (test) {
|
|
|
525
553
|
function inheritDatadogPropertiesFromRetriedTest (test) {
|
|
526
554
|
const retriedTest = test._retriedTest
|
|
527
555
|
if (!retriedTest) return
|
|
556
|
+
test._ddTestAnnotations = retriedTest._ddTestAnnotations
|
|
557
|
+
test._ddAssignedProperties = retriedTest._ddAssignedProperties
|
|
528
558
|
|
|
529
559
|
if (retriedTest._ddIsDisabled) {
|
|
530
560
|
test._ddIsDisabled = true
|
|
@@ -577,7 +607,8 @@ function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
|
577
607
|
return onRunnableFinished.apply(this, arguments)
|
|
578
608
|
}
|
|
579
609
|
}
|
|
580
|
-
} else if (libraryConfig?.isFlakyTestRetriesEnabled && !
|
|
610
|
+
} else if (libraryConfig?.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
611
|
+
!nativeRetryTests.has(test._retriedTest || test)) {
|
|
581
612
|
if (!originalRetriesByTest.has(test)) {
|
|
582
613
|
const originalRetries = originalRetriesByTest.get(test._retriedTest) ?? test.retries()
|
|
583
614
|
originalRetriesByTest.set(test, originalRetries)
|
|
@@ -633,7 +664,7 @@ function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
|
633
664
|
return RunnablePackage
|
|
634
665
|
}
|
|
635
666
|
|
|
636
|
-
function getOnTestHandler (isMain) {
|
|
667
|
+
function getOnTestHandler (isMain, config = {}) {
|
|
637
668
|
return function (test) {
|
|
638
669
|
if (test._ddSuppressSyntheticTestLifecycle || hasHandledHookFailure(test)) return
|
|
639
670
|
|
|
@@ -644,6 +675,9 @@ function getOnTestHandler (isMain) {
|
|
|
644
675
|
restoreRunnableFunction(test)
|
|
645
676
|
|
|
646
677
|
inheritDatadogPropertiesFromRetriedTest(test)
|
|
678
|
+
// Mocha 5/6 clones lack _retriedTest, but retain the annotated callback.
|
|
679
|
+
test._ddTestAnnotations ||= test._ddDeclaredAnnotations || getTestAnnotations(test.fn)
|
|
680
|
+
test._ddAssignedProperties ||= getAssignedProperties(test, config)
|
|
647
681
|
|
|
648
682
|
if (isInFailedSuite(test.parent)) {
|
|
649
683
|
recordRetryTrackedAttempt(test)
|
|
@@ -674,6 +708,8 @@ function getOnTestHandler (isMain) {
|
|
|
674
708
|
}
|
|
675
709
|
|
|
676
710
|
const testInfo = {
|
|
711
|
+
assignedProperties: test._ddAssignedProperties,
|
|
712
|
+
testAnnotations: test._ddTestAnnotations || test._ddDeclaredAnnotations || getTestAnnotations(test.fn),
|
|
677
713
|
testName: test.fullTitle(),
|
|
678
714
|
testSuiteAbsolutePath,
|
|
679
715
|
title,
|
|
@@ -686,6 +722,7 @@ function getOnTestHandler (isMain) {
|
|
|
686
722
|
|
|
687
723
|
testInfo.isNew = isNew
|
|
688
724
|
testInfo.isEfdRetry = isEfdRetry
|
|
725
|
+
testInfo.assignedProperties = test._ddAssignedProperties
|
|
689
726
|
testInfo.isAttemptToFix = isAttemptToFix
|
|
690
727
|
testInfo.isDisabled = isDisabled
|
|
691
728
|
testInfo.isQuarantined = isQuarantined
|
|
@@ -794,7 +831,7 @@ function getTestFinishInfo (test, status, config, error) {
|
|
|
794
831
|
const originalTest = test._retriedTest || test
|
|
795
832
|
if (
|
|
796
833
|
config.isDynamicAtrEnabled &&
|
|
797
|
-
config.isFlakyTestRetriesEnabled &&
|
|
834
|
+
config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
798
835
|
!test._ddIsAttemptToFix &&
|
|
799
836
|
!test._ddIsEfdRetry &&
|
|
800
837
|
!dynamicAtrRetryCountByTest.has(originalTest) &&
|
|
@@ -823,7 +860,7 @@ function getTestFinishInfo (test, status, config, error) {
|
|
|
823
860
|
// Mocha aborts native retries on hook failure, even when the retry budget is not exhausted.
|
|
824
861
|
const isTerminalHookFailure = test._ddHookFailed && !isDatadogManagedRetryTest(test, config)
|
|
825
862
|
const isLastAtrAttempt = isTerminalHookFailure || getIsLastRetry(test) ||
|
|
826
|
-
(config.isFlakyTestRetriesEnabled && status === 'pass')
|
|
863
|
+
(config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry && status === 'pass')
|
|
827
864
|
|
|
828
865
|
// Needed for the getFinalStatus call. This is because EFD does NOT tag as
|
|
829
866
|
// EFD retry the first run of the test. It only tags as retries the clones
|
|
@@ -846,19 +883,20 @@ function getTestFinishInfo (test, status, config, error) {
|
|
|
846
883
|
}
|
|
847
884
|
|
|
848
885
|
// ATR: mark terminal attempts when every executed attempt failed.
|
|
849
|
-
if (config.isFlakyTestRetriesEnabled && !test.
|
|
886
|
+
if (config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
887
|
+
!test._ddIsAttemptToFix && !test._ddIsEfdRetry &&
|
|
850
888
|
isLastAtrAttempt && testStatuses.every(status => status === 'fail')) {
|
|
851
889
|
hasFailedAllRetries = true
|
|
852
890
|
}
|
|
853
891
|
|
|
854
892
|
const isAttemptToFixRetry = test._ddIsAttemptToFix && testStatuses.length > 1
|
|
855
|
-
const isAtrRetry = config.isFlakyTestRetriesEnabled &&
|
|
893
|
+
const isAtrRetry = config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
856
894
|
automaticRetryAttempts.get(test._retriedTest || test)?.has(test._currentRetry) &&
|
|
857
895
|
!test._ddIsAttemptToFix &&
|
|
858
896
|
!test._ddIsEfdRetry
|
|
859
897
|
const isFinalAttempt = isTerminalHookFailure || status !== 'fail' || test._currentRetry >= test._retries
|
|
860
898
|
|
|
861
|
-
const
|
|
899
|
+
const isFlakyTestRetriesEnabled = config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry
|
|
862
900
|
const { _ddIsAttemptToFix, _ddIsQuarantined, _ddIsDisabled } = test
|
|
863
901
|
|
|
864
902
|
const finalStatus = getFinalStatus({
|
|
@@ -1211,7 +1249,7 @@ function getOnTestRetryHandler (config) {
|
|
|
1211
1249
|
}
|
|
1212
1250
|
const isFirstAttempt = test._currentRetry === 0
|
|
1213
1251
|
const isDynamicAtrTest = config.isDynamicAtrEnabled &&
|
|
1214
|
-
config.isFlakyTestRetriesEnabled &&
|
|
1252
|
+
config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
1215
1253
|
automaticRetryTests.has(test) &&
|
|
1216
1254
|
!test._ddIsAttemptToFix &&
|
|
1217
1255
|
!isEarlyFlakeDetectionTest(test, config)
|
|
@@ -1248,7 +1286,7 @@ function publishTestRetry (test, err, config) {
|
|
|
1248
1286
|
if (ctx) {
|
|
1249
1287
|
const willBeRetried = test._currentRetry < test._retries
|
|
1250
1288
|
const isAtrRetry = !isFirstAttempt &&
|
|
1251
|
-
config.isFlakyTestRetriesEnabled &&
|
|
1289
|
+
config.isFlakyTestRetriesEnabled && !test._ddTestAnnotations?.noAutoRetry &&
|
|
1252
1290
|
automaticRetryAttempts.get(test._retriedTest || test)?.has(test._currentRetry) &&
|
|
1253
1291
|
!test._ddIsAttemptToFix &&
|
|
1254
1292
|
!test._ddIsEfdRetry
|
|
@@ -1281,6 +1319,8 @@ function getOnPendingHandler () {
|
|
|
1281
1319
|
} = test
|
|
1282
1320
|
|
|
1283
1321
|
const testInfo = {
|
|
1322
|
+
assignedProperties: test._ddAssignedProperties,
|
|
1323
|
+
testAnnotations: test._ddTestAnnotations || test._ddDeclaredAnnotations || getTestAnnotations(test.fn),
|
|
1284
1324
|
testName: test.fullTitle(),
|
|
1285
1325
|
testSuiteAbsolutePath,
|
|
1286
1326
|
title,
|
|
@@ -1307,6 +1347,12 @@ function getOnPendingHandler () {
|
|
|
1307
1347
|
// Hook to add retries to tests if Test Management or EFD is enabled
|
|
1308
1348
|
function getRunTestsWrapper (runTests, config) {
|
|
1309
1349
|
return function (suite) {
|
|
1350
|
+
for (const test of suite.tests) {
|
|
1351
|
+
test._ddTestAnnotations = test.fn
|
|
1352
|
+
? getTestAnnotations(originalFns.get(test.fn) || test.fn)
|
|
1353
|
+
: test._ddDeclaredAnnotations || getTestAnnotations()
|
|
1354
|
+
test._ddAssignedProperties = getAssignedProperties(test, config)
|
|
1355
|
+
}
|
|
1310
1356
|
if (config.isTestManagementTestsEnabled) {
|
|
1311
1357
|
suite.tests.forEach((test) => {
|
|
1312
1358
|
const { isAttemptToFix, isDisabled, isQuarantined } = getTestProperties(test, config.testManagementTests)
|
|
@@ -5,6 +5,11 @@ const { isNativeError } = require('node:util').types
|
|
|
5
5
|
const shimmer = require('../../datadog-shimmer')
|
|
6
6
|
const nomenclature = require('../../dd-trace/src/service-naming')
|
|
7
7
|
const spanEndingHook = require('../../dd-trace/src/opentelemetry/span-ending-hook')
|
|
8
|
+
const {
|
|
9
|
+
HTTP_STATUS_ERROR,
|
|
10
|
+
otelHttpResourceName,
|
|
11
|
+
setInstrumentationHttpResource,
|
|
12
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
8
13
|
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
9
14
|
const { channel, addHook } = require('./helpers/instrument')
|
|
10
15
|
|
|
@@ -67,18 +72,26 @@ const NEXT_BASE_SERVER_HANDLE_REQUEST = 'BaseServer.handleRequest'
|
|
|
67
72
|
// own OTel spans and renames the root request span to `${method} ${route}` at finish, which the
|
|
68
73
|
// bridge routes into the DD operation name and leaves the resource as the bare method — the reverse
|
|
69
74
|
// of Datadog's contract. Correct it via the bridge's pre-finish hook. See span-ending-hook.js.
|
|
70
|
-
spanEndingHook.hook = (ddSpan) => {
|
|
75
|
+
spanEndingHook.hook = (ddSpan, otelSemanticsEnabled) => {
|
|
71
76
|
const tags = ddSpan.context().getTags()
|
|
72
77
|
if (tags['next.span_type'] !== NEXT_BASE_SERVER_HANDLE_REQUEST) return
|
|
73
78
|
|
|
74
79
|
const method = tags['http.method']
|
|
75
80
|
const route = tags['next.route'] ?? tags['http.route']
|
|
76
|
-
// Next already wrote the RSC-aware `${method} ${route}` into `next.span_name`; prefer it so we
|
|
77
|
-
// mirror Next's own naming, and only construct the resource when it is absent.
|
|
78
|
-
const resource = tags['next.span_name'] ?? (route ? `${method} ${route}` : method)
|
|
79
|
-
|
|
80
81
|
ddSpan.setOperationName(nomenclature.opName('web', 'server', 'next'))
|
|
81
|
-
|
|
82
|
+
if (otelSemanticsEnabled) {
|
|
83
|
+
setInstrumentationHttpResource(ddSpan, otelHttpResourceName(method, route))
|
|
84
|
+
const status = tags['http.status_code']
|
|
85
|
+
if (status >= 500) {
|
|
86
|
+
ddSpan.setTag(HTTP_STATUS_ERROR, String(status))
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
// Next already wrote the RSC-aware `${method} ${route}` into `next.span_name`; prefer it so we
|
|
91
|
+
// mirror Next's own naming, and only construct the resource when it is absent.
|
|
92
|
+
const resource = tags['next.span_name'] ?? (route ? `${method} ${route}` : method)
|
|
93
|
+
ddSpan.setTag(RESOURCE_NAME, resource)
|
|
94
|
+
}
|
|
82
95
|
}
|
|
83
96
|
|
|
84
97
|
function wrapHandleRequest (handleRequest) {
|