dd-trace 6.16.0 → 6.18.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/ci/diagnose.js +0 -23
- package/ci/test-optimization-validation/approval-artifacts.js +0 -3
- package/ci/test-optimization-validation/approval.js +0 -6
- package/ci/test-optimization-validation/artifact-id.js +0 -1
- package/ci/test-optimization-validation/bounded-json.js +0 -1
- package/ci/test-optimization-validation/cli.js +0 -12
- package/ci/test-optimization-validation/command-output-policy.js +0 -1
- package/ci/test-optimization-validation/command-runner.js +0 -3
- package/ci/test-optimization-validation/environment.js +0 -4
- package/ci/test-optimization-validation/executable-approval.js +0 -1
- package/ci/test-optimization-validation/executable.js +0 -5
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -6
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -3
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -6
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -4
- package/ci/test-optimization-validation/generated-test-contract.js +0 -5
- package/ci/test-optimization-validation/generated-verifier.js +0 -1
- package/ci/test-optimization-validation/literal-environment.js +0 -1
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -17
- package/ci/test-optimization-validation/manifest-schema.js +0 -21
- package/ci/test-optimization-validation/offline-fixtures.js +0 -4
- package/ci/test-optimization-validation/plan-writer.js +0 -11
- package/ci/test-optimization-validation/preflight-runner.js +0 -1
- package/ci/test-optimization-validation/redaction.js +0 -4
- package/ci/test-optimization-validation/report-writer.js +0 -16
- package/ci/test-optimization-validation/runner-command.js +0 -3
- package/ci/test-optimization-validation/runner-contract.js +0 -4
- package/ci/test-optimization-validation/safe-files.js +0 -1
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -1
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -1
- package/ci/test-optimization-validation/source-text.js +0 -3
- package/ci/vitest-no-worker-init-setup.mjs +41 -16
- package/index.d.ts +208 -0
- package/package.json +17 -16
- package/packages/datadog-esbuild/src/utils.js +0 -2
- package/packages/datadog-instrumentations/src/aerospike.js +28 -6
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +0 -2
- package/packages/datadog-instrumentations/src/aws-sdk.js +0 -2
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +0 -2
- package/packages/datadog-instrumentations/src/console.js +97 -0
- package/packages/datadog-instrumentations/src/cucumber.js +77 -12
- package/packages/datadog-instrumentations/src/cypress-config.js +27 -38
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +6 -0
- package/packages/datadog-instrumentations/src/helpers/channel.js +0 -2
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +0 -5
- package/packages/datadog-instrumentations/src/helpers/hooks.js +8 -6
- package/packages/datadog-instrumentations/src/helpers/instrumentation-utils.js +0 -3
- package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +0 -6
- package/packages/datadog-instrumentations/src/helpers/register.js +24 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +111 -26
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +3 -17
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +55 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +36 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/supabase.js +128 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +13 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +28 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +20 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +388 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +0 -5
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +0 -1
- package/packages/datadog-instrumentations/src/jest.js +165 -51
- package/packages/datadog-instrumentations/src/knex.js +0 -1
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +0 -24
- package/packages/datadog-instrumentations/src/mariadb.js +0 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +0 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +25 -26
- package/packages/datadog-instrumentations/src/mocha/utils.js +119 -49
- package/packages/datadog-instrumentations/src/mocha/webdriverio-protocol.js +0 -6
- package/packages/datadog-instrumentations/src/mocha/worker.js +14 -17
- package/packages/datadog-instrumentations/src/mysql2.js +0 -2
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +241 -0
- package/packages/datadog-instrumentations/src/openai-realtime/events.js +76 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +301 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +998 -0
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +211 -0
- package/packages/datadog-instrumentations/src/openai.js +51 -12
- package/packages/datadog-instrumentations/src/oracledb.js +9 -3
- package/packages/datadog-instrumentations/src/playwright-reporter.js +6 -20
- package/packages/datadog-instrumentations/src/playwright.js +280 -56
- package/packages/datadog-instrumentations/src/{azure-cosmos.js → postgres.js} +1 -1
- package/packages/datadog-instrumentations/src/router.js +0 -2
- package/packages/datadog-instrumentations/src/rum-browser-scripts.js +0 -2
- package/packages/datadog-instrumentations/src/sequelize.js +0 -1
- package/packages/datadog-instrumentations/src/supabase.js +15 -0
- package/packages/datadog-instrumentations/src/undici.js +7 -3
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +18 -18
- package/packages/datadog-instrumentations/src/vitest-main.js +121 -30
- package/packages/datadog-instrumentations/src/vitest-util.js +7 -1
- package/packages/datadog-instrumentations/src/vitest-worker.js +49 -13
- package/packages/datadog-instrumentations/src/webdriverio.js +44 -47
- package/packages/datadog-instrumentations/src/ws.js +41 -2
- package/packages/datadog-plugin-ai/src/utils.js +0 -2
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +0 -1
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +0 -2
- package/packages/datadog-plugin-aws-sdk/src/base.js +0 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +0 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +0 -1
- package/packages/datadog-plugin-aws-sdk/src/util.js +0 -1
- package/packages/datadog-plugin-azure-durable-functions/src/index.js +0 -1
- package/packages/datadog-plugin-cucumber/src/index.js +9 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +211 -85
- package/packages/datadog-plugin-cypress/src/finalization.js +0 -3
- package/packages/datadog-plugin-cypress/src/index.js +3 -1
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +0 -4
- package/packages/datadog-plugin-cypress/src/support.js +52 -7
- package/packages/datadog-plugin-graphql/src/resolve-error.js +1 -2
- package/packages/datadog-plugin-graphql/src/utils.js +0 -5
- package/packages/datadog-plugin-jest/src/index.js +12 -0
- package/packages/datadog-plugin-kafkajs/src/producer.js +0 -1
- package/packages/datadog-plugin-mocha/src/index.js +38 -11
- package/packages/datadog-plugin-mongodb-core/src/query.js +0 -1
- package/packages/datadog-plugin-openai/src/index.js +16 -1
- package/packages/datadog-plugin-openai/src/realtime.js +144 -0
- package/packages/datadog-plugin-openai-agents/src/integration.js +0 -4
- package/packages/datadog-plugin-openai-agents/src/util.js +0 -1
- package/packages/datadog-plugin-playwright/src/index.js +81 -9
- package/packages/datadog-plugin-postgres/src/index.js +167 -0
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +0 -1
- package/packages/datadog-plugin-redis/src/index.js +15 -1
- package/packages/datadog-plugin-supabase/src/error.js +18 -0
- package/packages/datadog-plugin-supabase/src/index.js +21 -0
- package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +69 -0
- package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +70 -0
- package/packages/datadog-plugin-supabase/src/supabase-postgrest-js-postgrestbuilder-then.js +122 -0
- package/packages/datadog-plugin-supabase/src/supabase-realtime-js-realtimechannel-send.js +66 -0
- package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +93 -0
- package/packages/datadog-plugin-supabase/src/url.js +17 -0
- package/packages/datadog-plugin-vitest/src/index.js +9 -0
- package/packages/datadog-plugin-ws/src/producer.js +1 -1
- package/packages/datadog-plugin-ws/src/util.js +0 -4
- package/packages/datadog-shimmer/src/shimmer.js +14 -10
- package/packages/datadog-turbopack/index.js +4 -7
- package/packages/datadog-turbopack/src/loader.js +6 -18
- package/packages/datadog-webpack/src/loader.js +0 -1
- package/packages/dd-trace/src/agent/info.js +5 -4
- package/packages/dd-trace/src/aiguard/client.js +2 -3
- package/packages/dd-trace/src/aiguard/evaluation.js +6 -12
- package/packages/dd-trace/src/aiguard/index.js +2 -2
- package/packages/dd-trace/src/aiguard/integrations/index.js +1 -1
- package/packages/dd-trace/src/aiguard/integrations/openai.js +81 -7
- package/packages/dd-trace/src/aiguard/messages/anthropic.js +0 -2
- package/packages/dd-trace/src/aiguard/messages/openai.js +64 -1
- package/packages/dd-trace/src/aiguard/messages/utils.js +0 -1
- package/packages/dd-trace/src/aiguard/redaction.js +0 -1
- package/packages/dd-trace/src/aiguard/sdk.js +1 -1
- package/packages/dd-trace/src/appsec/activation.js +1 -1
- package/packages/dd-trace/src/appsec/api_security/normalized-route.js +0 -5
- package/packages/dd-trace/src/appsec/api_security/sampler.js +0 -4
- package/packages/dd-trace/src/appsec/blocking/index.js +3 -3
- package/packages/dd-trace/src/appsec/downstream_requests.js +1 -4
- package/packages/dd-trace/src/appsec/iast/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +5 -5
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +3 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +8 -10
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +2 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +4 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +7 -7
- package/packages/dd-trace/src/appsec/index.js +2 -2
- package/packages/dd-trace/src/appsec/lambda.js +71 -2
- package/packages/dd-trace/src/appsec/rasp/utils.js +5 -1
- package/packages/dd-trace/src/appsec/remote_config.js +8 -6
- package/packages/dd-trace/src/appsec/reporter.js +10 -6
- package/packages/dd-trace/src/appsec/rule_manager.js +3 -3
- package/packages/dd-trace/src/appsec/sdk/track_event.js +0 -2
- package/packages/dd-trace/src/appsec/waf/index.js +2 -2
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +8 -5
- package/packages/dd-trace/src/carrier.js +0 -5
- package/packages/dd-trace/src/ci-visibility/dynamic-atr-retries.js +104 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +0 -2
- package/packages/dd-trace/src/ci-visibility/efd-retry-policy.js +34 -3
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -4
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +37 -15
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +0 -3
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +0 -11
- package/packages/dd-trace/src/ci-visibility/exporters/settings-cache-key.js +0 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +0 -1
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +0 -6
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -2
- package/packages/dd-trace/src/ci-visibility/requests/rate-limit.js +0 -1
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +0 -5
- package/packages/dd-trace/src/ci-visibility/requests/video-request.js +0 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +13 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +0 -1
- package/packages/dd-trace/src/ci-visibility/test-screenshot.js +0 -2
- package/packages/dd-trace/src/ci-visibility/test-video.js +0 -1
- package/packages/dd-trace/src/config/defaults.js +3 -2
- package/packages/dd-trace/src/config/generated-config-types.d.ts +88 -82
- package/packages/dd-trace/src/config/helper.js +0 -1
- package/packages/dd-trace/src/config/index.js +31 -30
- package/packages/dd-trace/src/config/parsers.js +34 -6
- package/packages/dd-trace/src/config/remote_config.js +25 -109
- package/packages/dd-trace/src/config/supported-configurations.json +150 -10
- package/packages/dd-trace/src/datastreams/encoding.js +0 -1
- package/packages/dd-trace/src/datastreams/pathway.js +0 -1
- package/packages/dd-trace/src/debugger/constants.js +10 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +62 -10
- package/packages/dd-trace/src/debugger/devtools_client/config.js +4 -1
- package/packages/dd-trace/src/debugger/devtools_client/guardrail-metrics.js +15 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +103 -27
- package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +50 -7
- package/packages/dd-trace/src/debugger/devtools_client/log.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +21 -8
- package/packages/dd-trace/src/debugger/devtools_client/send.js +41 -15
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +53 -13
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +118 -71
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +5 -3
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +0 -3
- package/packages/dd-trace/src/debugger/devtools_client/status.js +21 -7
- package/packages/dd-trace/src/debugger/guardrail-metrics.js +167 -0
- package/packages/dd-trace/src/debugger/index.js +51 -3
- package/packages/dd-trace/src/debugger/inspect-segment.js +0 -3
- package/packages/dd-trace/src/debugger/probe_sampler.js +133 -9
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +31 -1
- package/packages/dd-trace/src/dogstatsd.js +0 -23
- package/packages/dd-trace/src/encode/0.4-cross-payload.js +0 -3
- package/packages/dd-trace/src/encode/0.4.js +0 -7
- package/packages/dd-trace/src/encode/0.5.js +0 -2
- package/packages/dd-trace/src/encode/tags-processors.js +0 -1
- package/packages/dd-trace/src/evp_proxy/constants.js +2 -0
- package/packages/dd-trace/src/evp_proxy/direct.js +17 -13
- package/packages/dd-trace/src/evp_proxy/discovery.js +14 -11
- package/packages/dd-trace/src/evp_proxy/path.js +21 -9
- package/packages/dd-trace/src/exporters/agent/writer.js +0 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +0 -1
- package/packages/dd-trace/src/exporters/agentless/intake.js +0 -1
- package/packages/dd-trace/src/exporters/agentless/writer.js +0 -3
- package/packages/dd-trace/src/exporters/common/final-flush-request-tracker.js +0 -6
- package/packages/dd-trace/src/exporters/common/request.js +1 -0
- package/packages/dd-trace/src/exporters/common/url.js +33 -4
- package/packages/dd-trace/src/exporters/common/writer.js +0 -2
- package/packages/dd-trace/src/id.js +0 -11
- package/packages/dd-trace/src/llmobs/audio-codec.js +192 -0
- package/packages/dd-trace/src/llmobs/audio-utils.js +121 -0
- package/packages/dd-trace/src/llmobs/constants/audio.js +35 -0
- package/packages/dd-trace/src/llmobs/constants/prompts.js +14 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +17 -0
- package/packages/dd-trace/src/llmobs/eval-metric.js +0 -6
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +0 -4
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +0 -3
- package/packages/dd-trace/src/llmobs/experiments/index.js +7 -6
- package/packages/dd-trace/src/llmobs/experiments/util.js +1 -11
- package/packages/dd-trace/src/llmobs/index.js +1 -3
- package/packages/dd-trace/src/llmobs/noop.js +10 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +0 -4
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +0 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +0 -4
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +0 -2
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +0 -2
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +4 -6
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +285 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +16 -3
- package/packages/dd-trace/src/llmobs/prompts/cache.js +272 -0
- package/packages/dd-trace/src/llmobs/prompts/manager.js +647 -0
- package/packages/dd-trace/src/llmobs/prompts/noop.js +29 -0
- package/packages/dd-trace/src/llmobs/prompts/prompt.js +158 -0
- package/packages/dd-trace/src/llmobs/sdk.js +21 -6
- package/packages/dd-trace/src/llmobs/span_processor.js +81 -2
- package/packages/dd-trace/src/llmobs/tagger.js +39 -11
- package/packages/dd-trace/src/llmobs/telemetry.js +36 -4
- package/packages/dd-trace/src/llmobs/util.js +0 -34
- package/packages/dd-trace/src/llmobs/writers/base.js +0 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
- package/packages/dd-trace/src/log/channels.js +3 -0
- package/packages/dd-trace/src/log/index.js +23 -5
- package/packages/dd-trace/src/log-submission/log-submission-plugin.js +74 -6
- package/packages/dd-trace/src/msgpack/chunk.js +0 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +0 -12
- package/packages/dd-trace/src/openfeature/configuration_source.js +4 -1
- package/packages/dd-trace/src/openfeature/encoding.js +0 -2
- package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +0 -1
- package/packages/dd-trace/src/openfeature/flagging_provider.js +3 -3
- package/packages/dd-trace/src/openfeature/index.js +6 -6
- package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +0 -1
- package/packages/dd-trace/src/openfeature/span-enrichment.js +0 -4
- package/packages/dd-trace/src/openfeature/writers/base.js +90 -23
- package/packages/dd-trace/src/openfeature/writers/exposures.js +4 -5
- package/packages/dd-trace/src/openfeature/writers/util.js +104 -37
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +0 -1
- package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +0 -1
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +0 -1
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +0 -2
- package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +0 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +0 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +0 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +1 -14
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +0 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +30 -13
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +0 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +0 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +0 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +0 -3
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +0 -6
- package/packages/dd-trace/src/opentracing/span_context.js +0 -1
- package/packages/dd-trace/src/opentracing/tracer.js +3 -3
- package/packages/dd-trace/src/otel-thread-ctx.js +38 -11
- package/packages/dd-trace/src/payload-tagging/tagging.js +15 -3
- package/packages/dd-trace/src/plugin_manager.js +27 -8
- package/packages/dd-trace/src/plugins/ci_plugin.js +1 -2
- package/packages/dd-trace/src/plugins/database.js +2 -6
- package/packages/dd-trace/src/plugins/index.js +7 -0
- package/packages/dd-trace/src/plugins/plugin.js +0 -4
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/git.js +1 -3
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +0 -1
- package/packages/dd-trace/src/plugins/util/llm.js +0 -2
- package/packages/dd-trace/src/plugins/util/status-validator.js +0 -1
- package/packages/dd-trace/src/plugins/util/test.js +26 -20
- package/packages/dd-trace/src/plugins/util/url.js +0 -5
- package/packages/dd-trace/src/priority_sampler.js +0 -6
- package/packages/dd-trace/src/process-tags/index.js +0 -1
- package/packages/dd-trace/src/profiler.js +132 -35
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +0 -1
- package/packages/dd-trace/src/profiling/profiler.js +101 -41
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +29 -15
- package/packages/dd-trace/src/propagation-hash/index.js +0 -1
- package/packages/dd-trace/src/proxy.js +23 -47
- package/packages/dd-trace/src/random_sampler.js +0 -4
- package/packages/dd-trace/src/rate_limiter.js +0 -4
- package/packages/dd-trace/src/remote_config/capabilities.js +1 -9
- package/packages/dd-trace/src/remote_config/index.js +0 -1
- package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +0 -3
- package/packages/dd-trace/src/sampler.js +0 -4
- package/packages/dd-trace/src/sampling_rule.js +0 -7
- package/packages/dd-trace/src/serverless/vercel.js +0 -1
- package/packages/dd-trace/src/serverless.js +0 -1
- package/packages/dd-trace/src/service-naming/index.js +0 -1
- package/packages/dd-trace/src/service-naming/schemas/util.js +0 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +7 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +5 -0
- package/packages/dd-trace/src/span_processor.js +2 -2
- package/packages/dd-trace/src/span_sampler.js +0 -1
- package/packages/dd-trace/src/standalone/product.js +2 -2
- package/packages/dd-trace/src/standalone/tracesource.js +0 -1
- package/packages/dd-trace/src/startup-log.js +1 -1
- package/packages/dd-trace/src/telemetry/endpoints.js +0 -8
- package/packages/dd-trace/src/telemetry/logs/index.js +16 -5
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +16 -6
- package/packages/dd-trace/src/telemetry/metrics.js +0 -2
- package/packages/dd-trace/src/telemetry/send-data.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +4 -1
- package/packages/dd-trace/src/tracer.js +5 -4
- package/packages/dd-trace/src/util.js +13 -1
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/packages/datadog-instrumentations/src/bullmq.js +0 -11
- package/packages/datadog-instrumentations/src/langchain.js +0 -7
- package/packages/datadog-instrumentations/src/langgraph.js +0 -7
- package/packages/datadog-instrumentations/src/mercurius.js +0 -11
|
@@ -8,6 +8,9 @@ const {
|
|
|
8
8
|
hasEfdRetries,
|
|
9
9
|
shouldSkipEfdRetry,
|
|
10
10
|
} = require('../../../dd-trace/src/ci-visibility/efd-retry-policy')
|
|
11
|
+
const {
|
|
12
|
+
getDynamicAtrRetryCount,
|
|
13
|
+
} = require('../../../dd-trace/src/ci-visibility/dynamic-atr-retries')
|
|
11
14
|
const {
|
|
12
15
|
getTestSuitePath,
|
|
13
16
|
DYNAMIC_NAME_RE,
|
|
@@ -51,6 +54,7 @@ const testsQuarantined = new Set()
|
|
|
51
54
|
const testsStatuses = new Map()
|
|
52
55
|
const efdRetryCountByTestFullName = new Map()
|
|
53
56
|
const efdSlowAbortedTests = new Set()
|
|
57
|
+
let dynamicAtrRetryCountByTest = new WeakMap()
|
|
54
58
|
const attemptToFixExecutions = new Map()
|
|
55
59
|
const isMochaWorker = !!getEnvironmentVariable('MOCHA_WORKER_ID')
|
|
56
60
|
|
|
@@ -65,7 +69,6 @@ const loggedAttemptToFixTests = new Set()
|
|
|
65
69
|
* Checks whether a Mocha test failed, including serialized tests from parallel workers.
|
|
66
70
|
*
|
|
67
71
|
* @param {object} test
|
|
68
|
-
* @returns {boolean}
|
|
69
72
|
*/
|
|
70
73
|
function isTestFailed (test) {
|
|
71
74
|
if (test.isFailed) {
|
|
@@ -82,7 +85,6 @@ function isTestFailed (test) {
|
|
|
82
85
|
*
|
|
83
86
|
* @param {object} runner
|
|
84
87
|
* @param {object} config
|
|
85
|
-
* @returns {void}
|
|
86
88
|
*/
|
|
87
89
|
function adjustRunnerFailuresForTestOptimization (runner, config) {
|
|
88
90
|
if (config.isEarlyFlakeDetectionEnabled) {
|
|
@@ -212,7 +214,6 @@ function wrapOriginalEfdTest (test, retryPolicy) {
|
|
|
212
214
|
/**
|
|
213
215
|
* Disables Mocha's native retry mechanism for Datadog-managed clone retries.
|
|
214
216
|
* @param {{ retries?: (count: number) => void }} test
|
|
215
|
-
* @returns {void}
|
|
216
217
|
*/
|
|
217
218
|
function disableMochaRetries (test) {
|
|
218
219
|
if (typeof test.retries === 'function') {
|
|
@@ -232,7 +233,6 @@ function disableMochaRetries (test) {
|
|
|
232
233
|
* isEarlyFlakeDetectionEnabled?: boolean,
|
|
233
234
|
* earlyFlakeDetectionRetryPolicy?: import('../../../dd-trace/src/ci-visibility/efd-retry-policy').EfdRetryPolicy
|
|
234
235
|
* }} config
|
|
235
|
-
* @returns {boolean}
|
|
236
236
|
*/
|
|
237
237
|
function isDatadogManagedRetryTest (test, config) {
|
|
238
238
|
return test._ddIsAttemptToFix || isEarlyFlakeDetectionTest(test, config)
|
|
@@ -251,7 +251,6 @@ function isDatadogManagedRetryTest (test, config) {
|
|
|
251
251
|
* isEarlyFlakeDetectionEnabled?: boolean,
|
|
252
252
|
* earlyFlakeDetectionRetryPolicy?: import('../../../dd-trace/src/ci-visibility/efd-retry-policy').EfdRetryPolicy
|
|
253
253
|
* }} config
|
|
254
|
-
* @returns {boolean}
|
|
255
254
|
*/
|
|
256
255
|
function isEarlyFlakeDetectionTest (test, config) {
|
|
257
256
|
return !test._ddIsAttemptToFix &&
|
|
@@ -309,7 +308,6 @@ function retryTest (test, numRetries, tags, retryPolicy) {
|
|
|
309
308
|
* Restores a runnable function wrapped with its Test Optimization context.
|
|
310
309
|
*
|
|
311
310
|
* @param {import('mocha').Runnable} runnable
|
|
312
|
-
* @returns {void}
|
|
313
311
|
*/
|
|
314
312
|
function restoreRunnableFunction (runnable) {
|
|
315
313
|
const wrappedFunction = runnable.fn
|
|
@@ -322,7 +320,6 @@ function restoreRunnableFunction (runnable) {
|
|
|
322
320
|
* Restores a test function wrapped to measure its EFD duration.
|
|
323
321
|
*
|
|
324
322
|
* @param {import('mocha').Test} test
|
|
325
|
-
* @returns {void}
|
|
326
323
|
*/
|
|
327
324
|
function restoreEfdTestFunction (test) {
|
|
328
325
|
if (!originalEfdFns.has(test)) return
|
|
@@ -336,7 +333,6 @@ function restoreEfdTestFunction (test) {
|
|
|
336
333
|
* Clears state that belongs to one Mocha runner execution and removes retry clones from prior executions.
|
|
337
334
|
*
|
|
338
335
|
* @param {import('mocha').Suite} rootSuite
|
|
339
|
-
* @returns {void}
|
|
340
336
|
*/
|
|
341
337
|
function resetRunState (rootSuite) {
|
|
342
338
|
for (const key of Object.keys(newTests)) delete newTests[key]
|
|
@@ -347,6 +343,7 @@ function resetRunState (rootSuite) {
|
|
|
347
343
|
testsStatuses.clear()
|
|
348
344
|
efdRetryCountByTestFullName.clear()
|
|
349
345
|
efdSlowAbortedTests.clear()
|
|
346
|
+
dynamicAtrRetryCountByTest = new WeakMap()
|
|
350
347
|
attemptToFixExecutions.clear()
|
|
351
348
|
loggedAttemptToFixTests.clear()
|
|
352
349
|
|
|
@@ -369,6 +366,7 @@ function resetRunState (rootSuite) {
|
|
|
369
366
|
if (originalRetriesByTest.has(test)) {
|
|
370
367
|
test.retries(originalRetriesByTest.get(test))
|
|
371
368
|
originalRetriesByTest.delete(test)
|
|
369
|
+
if (test._retriedTest) originalRetriesByTest.delete(test._retriedTest)
|
|
372
370
|
}
|
|
373
371
|
|
|
374
372
|
delete test._ddIsAttemptToFix
|
|
@@ -381,6 +379,7 @@ function resetRunState (rootSuite) {
|
|
|
381
379
|
delete test._ddTestFinishPublished
|
|
382
380
|
delete test._ddIsFinalAttempt
|
|
383
381
|
delete test._ddHookFailed
|
|
382
|
+
delete test._ddPendingRetry
|
|
384
383
|
delete test._ddReporterStartFailed
|
|
385
384
|
delete test._ddReporterTerminalFailed
|
|
386
385
|
originalTests.push(test)
|
|
@@ -430,7 +429,6 @@ function getTestFullName (test) {
|
|
|
430
429
|
* Records every attempt for a test grouped by its full test name.
|
|
431
430
|
* @param {Record<string, Array<{ file: string, fullTitle: () => string }>>} testsByFullName
|
|
432
431
|
* @param {{ file: string, fullTitle: () => string }} test
|
|
433
|
-
* @returns {void}
|
|
434
432
|
*/
|
|
435
433
|
function recordTestAttempt (testsByFullName, test) {
|
|
436
434
|
const testFullName = getTestFullName(test)
|
|
@@ -470,7 +468,6 @@ function getTestContext (test) {
|
|
|
470
468
|
* Claims publication of a test finish event across Mocha's terminal event paths.
|
|
471
469
|
*
|
|
472
470
|
* @param {object} test
|
|
473
|
-
* @returns {boolean}
|
|
474
471
|
*/
|
|
475
472
|
function startTestFinish (test) {
|
|
476
473
|
if (test._ddTestFinishStarted || test._ddTestFinishPublished) return false
|
|
@@ -534,7 +531,27 @@ function runnableWrapper (RunnablePackage, libraryConfig) {
|
|
|
534
531
|
}
|
|
535
532
|
}
|
|
536
533
|
} else if (libraryConfig?.isFlakyTestRetriesEnabled) {
|
|
537
|
-
|
|
534
|
+
if (!originalRetriesByTest.has(test)) {
|
|
535
|
+
const originalRetries = originalRetriesByTest.get(test._retriedTest) ?? test.retries()
|
|
536
|
+
originalRetriesByTest.set(test, originalRetries)
|
|
537
|
+
}
|
|
538
|
+
if (libraryConfig.isDynamicAtrEnabled) {
|
|
539
|
+
// Dynamic ATR: set the max possible retries initially.
|
|
540
|
+
// The actual duration-based count is computed after the first attempt.
|
|
541
|
+
const dynamicCount = dynamicAtrRetryCountByTest.get(test._retriedTest || test)
|
|
542
|
+
if (dynamicCount === undefined) {
|
|
543
|
+
const maxRetries = libraryConfig.dynamicAtrBuckets
|
|
544
|
+
? Math.max(...libraryConfig.dynamicAtrBuckets)
|
|
545
|
+
: libraryConfig.earlyFlakeDetectionRetryPolicy?.schedulingRetryCount ?? 0
|
|
546
|
+
// Dynamic ATR guarantees one retry, including the >5m EFD fallback bucket.
|
|
547
|
+
test.retries(Math.max(1, maxRetries))
|
|
548
|
+
} else {
|
|
549
|
+
// A beforeEach hook runs before the retry body; update the clone, not the hook.
|
|
550
|
+
test.retries(dynamicCount)
|
|
551
|
+
}
|
|
552
|
+
} else {
|
|
553
|
+
test.retries(libraryConfig.flakyTestRetriesCount)
|
|
554
|
+
}
|
|
538
555
|
}
|
|
539
556
|
|
|
540
557
|
if (isTestHook || this.type === 'test') {
|
|
@@ -704,6 +721,26 @@ function getTestFinishInfo (test, status, config, error) {
|
|
|
704
721
|
setEfdRetryCountForTest(test, duration, config.earlyFlakeDetectionRetryPolicy)
|
|
705
722
|
}
|
|
706
723
|
|
|
724
|
+
// Dynamic ATR: after the first attempt, compute the duration-based retry budget.
|
|
725
|
+
// Mocha's native retry clones point to the original test, independently of duplicate titles.
|
|
726
|
+
const originalTest = test._retriedTest || test
|
|
727
|
+
if (
|
|
728
|
+
config.isDynamicAtrEnabled &&
|
|
729
|
+
config.isFlakyTestRetriesEnabled &&
|
|
730
|
+
!test._ddIsAttemptToFix &&
|
|
731
|
+
!test._ddIsEfdRetry &&
|
|
732
|
+
!dynamicAtrRetryCountByTest.has(originalTest) &&
|
|
733
|
+
test._currentRetry === 0
|
|
734
|
+
) {
|
|
735
|
+
const duration = test.duration > 0 ? test.duration : performance.now() - test._ddStartTime
|
|
736
|
+
const dynamicCount = getDynamicAtrRetryCount(
|
|
737
|
+
duration,
|
|
738
|
+
config.earlyFlakeDetectionRetryPolicy,
|
|
739
|
+
config.dynamicAtrBuckets
|
|
740
|
+
)
|
|
741
|
+
dynamicAtrRetryCountByTest.set(originalTest, dynamicCount)
|
|
742
|
+
}
|
|
743
|
+
|
|
707
744
|
if (testsStatuses.get(testName)) {
|
|
708
745
|
testsStatuses.get(testName).push(status)
|
|
709
746
|
} else {
|
|
@@ -715,7 +752,10 @@ function getTestFinishInfo (test, status, config, error) {
|
|
|
715
752
|
const efdRetryCount = efdRetryCountByTestFullName.get(testName) ??
|
|
716
753
|
config.earlyFlakeDetectionRetryPolicy.schedulingRetryCount
|
|
717
754
|
const isLastEfdRetry = testStatuses.length === efdRetryCount + 1
|
|
718
|
-
|
|
755
|
+
// Mocha aborts native retries on hook failure, even when the retry budget is not exhausted.
|
|
756
|
+
const isTerminalHookFailure = test._ddHookFailed && !isDatadogManagedRetryTest(test, config)
|
|
757
|
+
const isLastAtrAttempt = isTerminalHookFailure || getIsLastRetry(test) ||
|
|
758
|
+
(config.isFlakyTestRetriesEnabled && status === 'pass')
|
|
719
759
|
|
|
720
760
|
// Needed for the getFinalStatus call. This is because EFD does NOT tag as
|
|
721
761
|
// EFD retry the first run of the test. It only tags as retries the clones
|
|
@@ -737,9 +777,9 @@ function getTestFinishInfo (test, status, config, error) {
|
|
|
737
777
|
hasFailedAllRetries = true
|
|
738
778
|
}
|
|
739
779
|
|
|
740
|
-
// ATR:
|
|
780
|
+
// ATR: mark terminal attempts when every executed attempt failed.
|
|
741
781
|
if (config.isFlakyTestRetriesEnabled && !test._ddIsAttemptToFix && !test._ddIsEfdRetry &&
|
|
742
|
-
|
|
782
|
+
isLastAtrAttempt && testStatuses.every(status => status === 'fail')) {
|
|
743
783
|
hasFailedAllRetries = true
|
|
744
784
|
}
|
|
745
785
|
|
|
@@ -747,7 +787,7 @@ function getTestFinishInfo (test, status, config, error) {
|
|
|
747
787
|
const isAtrRetry = config.isFlakyTestRetriesEnabled &&
|
|
748
788
|
!test._ddIsAttemptToFix &&
|
|
749
789
|
!test._ddIsEfdRetry
|
|
750
|
-
const isFinalAttempt = status !== 'fail' || test._currentRetry >= test._retries
|
|
790
|
+
const isFinalAttempt = isTerminalHookFailure || status !== 'fail' || test._currentRetry >= test._retries
|
|
751
791
|
|
|
752
792
|
const { isFlakyTestRetriesEnabled } = config
|
|
753
793
|
const { _ddIsAttemptToFix, _ddIsQuarantined, _ddIsDisabled } = test
|
|
@@ -872,7 +912,7 @@ function getOnHookEndHandler (config, finalAttemptHandlers) {
|
|
|
872
912
|
const ctx = getTestContext(test)
|
|
873
913
|
// Disabled tests are already finished in getOnTestEndHandler,
|
|
874
914
|
// skip to avoid double-publishing
|
|
875
|
-
if (ctx && (!test._ddIsDisabled || test._ddIsAttemptToFix) && startTestFinish(test)) {
|
|
915
|
+
if (ctx && !test._ddPendingRetry && (!test._ddIsDisabled || test._ddIsAttemptToFix) && startTestFinish(test)) {
|
|
876
916
|
const testFinishInfo = getTestFinishInfo(test, status, config, ctx.err || test.err)
|
|
877
917
|
const isFinalAttempt = testFinishInfo.finalStatus !== undefined
|
|
878
918
|
const publishTestFinish = () => {
|
|
@@ -938,6 +978,11 @@ function finishDeferredHookEnd (test) {
|
|
|
938
978
|
* @returns {unknown}
|
|
939
979
|
*/
|
|
940
980
|
function runFailedTestReplayHookUpCallback (fn, test, failedTestReplayPromise, hookThis, args) {
|
|
981
|
+
const pendingRetry = test._ddPendingRetry
|
|
982
|
+
if (pendingRetry) {
|
|
983
|
+
delete test._ddPendingRetry
|
|
984
|
+
failedTestReplayPromise = pendingRetry()
|
|
985
|
+
}
|
|
941
986
|
const continueAfterProbe = () => {
|
|
942
987
|
const deferredHookEndPromise = finishDeferredHookEnd(test)
|
|
943
988
|
if (deferredHookEndPromise) {
|
|
@@ -1001,26 +1046,18 @@ function getOnFailHandler (isMain, config) {
|
|
|
1001
1046
|
}
|
|
1002
1047
|
if (testContext) {
|
|
1003
1048
|
if (isHook && startTestFinish(test)) {
|
|
1049
|
+
delete test._ddPendingRetry
|
|
1004
1050
|
const hookError = new Error(`${testOrHook.fullTitle()}: ${err.message}`, { cause: err })
|
|
1005
1051
|
hookError.name = err.name
|
|
1006
1052
|
hookError.stack = err.stack
|
|
1007
1053
|
testContext.err = hookError
|
|
1008
1054
|
errorCh.runStores(testContext, () => {})
|
|
1055
|
+
// Mocha marks the hook failed, so record the test failure before computing final metadata.
|
|
1056
|
+
test._ddHookFailed = true
|
|
1009
1057
|
const testFinishInfo = getTestFinishInfo(test, 'fail', config, hookError)
|
|
1010
|
-
|
|
1011
|
-
// which only runs when the test function executes — hooks bypass that path,
|
|
1012
|
-
// so _retries stays at -1 and getIsLastRetry returns false, leaving finalStatus
|
|
1013
|
-
// undefined. We must also mark the attempt final when no clone-based retry
|
|
1014
|
-
// mechanism (EFD original, EFD clone, ATF) has queued further attempts.
|
|
1015
|
-
const noCloneRetries = !test._ddIsEfdRetry &&
|
|
1016
|
-
!((test._ddIsNew || test._ddIsModified) && config.isEarlyFlakeDetectionEnabled) &&
|
|
1017
|
-
!test._ddIsAttemptToFix
|
|
1018
|
-
if (testFinishInfo.finalStatus !== undefined || noCloneRetries) {
|
|
1058
|
+
if (testFinishInfo.finalStatus !== undefined) {
|
|
1019
1059
|
test._ddIsFinalAttempt = true
|
|
1020
1060
|
}
|
|
1021
|
-
// test.state is never set to 'failed' for hook failures (Mocha marks the hook,
|
|
1022
|
-
// not the test). Flag it so finishRootSuiteForFile can compute the correct status.
|
|
1023
|
-
test._ddHookFailed = true
|
|
1024
1061
|
test._ddTestFinishPublished = true
|
|
1025
1062
|
testFinishCh.publish({
|
|
1026
1063
|
status: 'fail',
|
|
@@ -1052,31 +1089,64 @@ function getOnFailHandler (isMain, config) {
|
|
|
1052
1089
|
|
|
1053
1090
|
function getOnTestRetryHandler (config) {
|
|
1054
1091
|
return function (test, err) {
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
test.
|
|
1092
|
+
const isFirstAttempt = test._currentRetry === 0
|
|
1093
|
+
const isDynamicAtrTest = config.isDynamicAtrEnabled &&
|
|
1094
|
+
config.isFlakyTestRetriesEnabled &&
|
|
1095
|
+
!test._ddIsAttemptToFix &&
|
|
1096
|
+
!isEarlyFlakeDetectionTest(test, config)
|
|
1097
|
+
if (isDynamicAtrTest && isFirstAttempt) {
|
|
1098
|
+
const dynamicCount = getDynamicAtrRetryCount(
|
|
1099
|
+
test.duration > 0 ? test.duration : performance.now() - test._ddStartTime,
|
|
1100
|
+
config.earlyFlakeDetectionRetryPolicy,
|
|
1101
|
+
config.dynamicAtrBuckets
|
|
1102
|
+
)
|
|
1103
|
+
dynamicAtrRetryCountByTest.set(test._retriedTest || test, dynamicCount)
|
|
1104
|
+
// Mocha emits retry before its next attempt starts; narrow its ceiling here.
|
|
1105
|
+
test._retries = dynamicCount
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
if (config.isFlakyTestRetriesEnabled && getAfterEachHooks(test).length) {
|
|
1109
|
+
// Mocha queues retries before afterEach; a hook failure can still cancel the retry.
|
|
1110
|
+
test._ddPendingRetry = () => publishTestRetry(test, err, config)
|
|
1111
|
+
return
|
|
1074
1112
|
}
|
|
1075
|
-
|
|
1076
|
-
testToContext.delete(key)
|
|
1113
|
+
test._ddFailedTestReplayPromise = publishTestRetry(test, err, config)
|
|
1077
1114
|
}
|
|
1078
1115
|
}
|
|
1079
1116
|
|
|
1117
|
+
/**
|
|
1118
|
+
* Finishes a failed attempt once its afterEach hooks have allowed the retry to proceed.
|
|
1119
|
+
* @param {import('mocha').Test} test
|
|
1120
|
+
* @param {Error} err
|
|
1121
|
+
* @param {{ isFlakyTestRetriesEnabled?: boolean }} config
|
|
1122
|
+
*/
|
|
1123
|
+
function publishTestRetry (test, err, config) {
|
|
1124
|
+
const isFirstAttempt = test._currentRetry === 0
|
|
1125
|
+
let failedTestReplayPromise
|
|
1126
|
+
const ctx = getTestContext(test)
|
|
1127
|
+
if (ctx) {
|
|
1128
|
+
const willBeRetried = test._currentRetry < test._retries
|
|
1129
|
+
const isAtrRetry = !isFirstAttempt &&
|
|
1130
|
+
config.isFlakyTestRetriesEnabled &&
|
|
1131
|
+
!test._ddIsAttemptToFix &&
|
|
1132
|
+
!test._ddIsEfdRetry
|
|
1133
|
+
const promises = {}
|
|
1134
|
+
testRetryCh.publish({
|
|
1135
|
+
isFirstAttempt,
|
|
1136
|
+
err,
|
|
1137
|
+
willBeRetried,
|
|
1138
|
+
test,
|
|
1139
|
+
isAtrRetry,
|
|
1140
|
+
promises,
|
|
1141
|
+
...ctx.currentStore,
|
|
1142
|
+
})
|
|
1143
|
+
failedTestReplayPromise = getFailedTestReplayPromise(promises)
|
|
1144
|
+
}
|
|
1145
|
+
const key = getTestToContextKey(test)
|
|
1146
|
+
testToContext.delete(key)
|
|
1147
|
+
return failedTestReplayPromise
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1080
1150
|
function getOnPendingHandler () {
|
|
1081
1151
|
return function (test) {
|
|
1082
1152
|
if (test._ddShouldSkipEfdRetry) {
|
|
@@ -18,7 +18,6 @@ const SCREENSHOT_UPLOAD_TIMEOUT_MS = FINAL_FLUSH_TIMEOUT + 5000
|
|
|
18
18
|
* @param {object} message
|
|
19
19
|
* @param {(error?: Error) => void} [onError]
|
|
20
20
|
* @param {() => void} [onDone]
|
|
21
|
-
* @returns {void}
|
|
22
21
|
*/
|
|
23
22
|
function sendWebdriverioWorkerMessage (message, onError, onDone) {
|
|
24
23
|
if (!process.send || !process.connected) {
|
|
@@ -41,7 +40,6 @@ const screenshotUploadRequests = new Map()
|
|
|
41
40
|
/**
|
|
42
41
|
* Removes shared screenshot response listeners when there are no pending requests.
|
|
43
42
|
*
|
|
44
|
-
* @returns {void}
|
|
45
43
|
*/
|
|
46
44
|
function removeScreenshotUploadListeners () {
|
|
47
45
|
if (screenshotUploadRequests.size !== 0) return
|
|
@@ -55,7 +53,6 @@ function removeScreenshotUploadListeners () {
|
|
|
55
53
|
*
|
|
56
54
|
* @param {string} requestId
|
|
57
55
|
* @param {Error} [error]
|
|
58
|
-
* @returns {void}
|
|
59
56
|
*/
|
|
60
57
|
function finishScreenshotUploadRequest (requestId, error) {
|
|
61
58
|
const request = screenshotUploadRequests.get(requestId)
|
|
@@ -71,7 +68,6 @@ function finishScreenshotUploadRequest (requestId, error) {
|
|
|
71
68
|
* Dispatches one coordinator screenshot response to its pending request.
|
|
72
69
|
*
|
|
73
70
|
* @param {object} message
|
|
74
|
-
* @returns {void}
|
|
75
71
|
*/
|
|
76
72
|
function onScreenshotUploadResponse (message) {
|
|
77
73
|
if (message?.name !== SCREENSHOT_UPLOAD_RESPONSE) return
|
|
@@ -85,7 +81,6 @@ function onScreenshotUploadResponse (message) {
|
|
|
85
81
|
/**
|
|
86
82
|
* Fails every pending screenshot upload after coordinator disconnect.
|
|
87
83
|
*
|
|
88
|
-
* @returns {void}
|
|
89
84
|
*/
|
|
90
85
|
function onScreenshotUploadDisconnect () {
|
|
91
86
|
for (const requestId of screenshotUploadRequests.keys()) {
|
|
@@ -101,7 +96,6 @@ function onScreenshotUploadDisconnect () {
|
|
|
101
96
|
*
|
|
102
97
|
* @param {object} content - Screenshot upload metadata
|
|
103
98
|
* @param {(error?: Error) => void} onDone - Upload completion callback
|
|
104
|
-
* @returns {void}
|
|
105
99
|
*/
|
|
106
100
|
function requestWebdriverioScreenshotUpload (content, onDone) {
|
|
107
101
|
const requestId = `${process.pid}-${++screenshotUploadRequestId}`
|
|
@@ -39,6 +39,7 @@ const workerConfigurationCh = channel('ci:mocha:worker:configuration')
|
|
|
39
39
|
const config = {
|
|
40
40
|
earlyFlakeDetectionRetryPolicy: EMPTY_EFD_RETRY_POLICY,
|
|
41
41
|
}
|
|
42
|
+
const patchedRunners = new WeakSet()
|
|
42
43
|
const runnerToFiles = new WeakMap()
|
|
43
44
|
const runnerToFailedHooks = new WeakMap()
|
|
44
45
|
const isWebdriverioWorker = !!getEnvironmentVariable(WEBDRIVERIO_WORKER_ENV)
|
|
@@ -50,7 +51,6 @@ let configurationRequestId = 0
|
|
|
50
51
|
* @param {object} message
|
|
51
52
|
* @param {() => void} [onError]
|
|
52
53
|
* @param {() => void} [onDone]
|
|
53
|
-
* @returns {void}
|
|
54
54
|
*/
|
|
55
55
|
function sendWebdriverioMessage (message, onError, onDone) {
|
|
56
56
|
sendWebdriverioWorkerMessage(message, error => {
|
|
@@ -65,7 +65,6 @@ function sendWebdriverioMessage (message, onError, onDone) {
|
|
|
65
65
|
* Applies configuration encoded as private Mocha options by its parallel runner.
|
|
66
66
|
*
|
|
67
67
|
* @param {object} options
|
|
68
|
-
* @returns {void}
|
|
69
68
|
*/
|
|
70
69
|
function applyMochaOptions (options) {
|
|
71
70
|
if (options._ddIsKnownTestsEnabled) {
|
|
@@ -95,8 +94,12 @@ function applyMochaOptions (options) {
|
|
|
95
94
|
if (options._ddIsFlakyTestRetriesEnabled) {
|
|
96
95
|
config.isFlakyTestRetriesEnabled = true
|
|
97
96
|
config.flakyTestRetriesCount = options._ddFlakyTestRetriesCount
|
|
97
|
+
config.isDynamicAtrEnabled = options._ddIsDynamicAtrEnabled
|
|
98
|
+
config.dynamicAtrBuckets = options._ddDynamicAtrBuckets
|
|
98
99
|
delete options._ddIsFlakyTestRetriesEnabled
|
|
99
100
|
delete options._ddFlakyTestRetriesCount
|
|
101
|
+
delete options._ddIsDynamicAtrEnabled
|
|
102
|
+
delete options._ddDynamicAtrBuckets
|
|
100
103
|
}
|
|
101
104
|
if (options._ddIsFailedTestReplayEnabled) {
|
|
102
105
|
config.isTestDynamicInstrumentationEnabled = true
|
|
@@ -110,7 +113,6 @@ function applyMochaOptions (options) {
|
|
|
110
113
|
*
|
|
111
114
|
* @param {object} runner
|
|
112
115
|
* @param {string[]} skippedFiles
|
|
113
|
-
* @returns {void}
|
|
114
116
|
*/
|
|
115
117
|
function filterSkippedFiles (runner, skippedFiles) {
|
|
116
118
|
if (!skippedFiles.length) {
|
|
@@ -128,7 +130,6 @@ function filterSkippedFiles (runner, skippedFiles) {
|
|
|
128
130
|
* @param {string} frameworkVersion
|
|
129
131
|
* @param {string[]} files
|
|
130
132
|
* @param {(response: object) => void} onDone
|
|
131
|
-
* @returns {void}
|
|
132
133
|
*/
|
|
133
134
|
function requestWebdriverioConfiguration (frameworkVersion, files, onDone) {
|
|
134
135
|
const requestId = `${process.pid}-${++configurationRequestId}`
|
|
@@ -138,7 +139,6 @@ function requestWebdriverioConfiguration (frameworkVersion, files, onDone) {
|
|
|
138
139
|
* Finishes the configuration request exactly once.
|
|
139
140
|
*
|
|
140
141
|
* @param {object} response
|
|
141
|
-
* @returns {void}
|
|
142
142
|
*/
|
|
143
143
|
function finish (response) {
|
|
144
144
|
if (finished) {
|
|
@@ -155,7 +155,6 @@ function requestWebdriverioConfiguration (frameworkVersion, files, onDone) {
|
|
|
155
155
|
* Receives the matching coordinator response.
|
|
156
156
|
*
|
|
157
157
|
* @param {object} message
|
|
158
|
-
* @returns {void}
|
|
159
158
|
*/
|
|
160
159
|
function onMessage (message) {
|
|
161
160
|
if (message?.name === CONFIGURATION_RESPONSE && message.content?.requestId === requestId) {
|
|
@@ -166,7 +165,6 @@ function requestWebdriverioConfiguration (frameworkVersion, files, onDone) {
|
|
|
166
165
|
/**
|
|
167
166
|
* Releases the runner if its parent disconnects.
|
|
168
167
|
*
|
|
169
|
-
* @returns {void}
|
|
170
168
|
*/
|
|
171
169
|
function onDisconnect () {
|
|
172
170
|
finish({})
|
|
@@ -190,7 +188,6 @@ function requestWebdriverioConfiguration (frameworkVersion, files, onDone) {
|
|
|
190
188
|
* Reports the Mocha version as soon as WebdriverIO loads its framework adapter.
|
|
191
189
|
*
|
|
192
190
|
* @param {string} frameworkVersion
|
|
193
|
-
* @returns {void}
|
|
194
191
|
*/
|
|
195
192
|
function reportWebdriverioWorkerReady (frameworkVersion) {
|
|
196
193
|
if (!isWebdriverioWorker) {
|
|
@@ -208,7 +205,6 @@ function reportWebdriverioWorkerReady (frameworkVersion) {
|
|
|
208
205
|
* Checks whether Test Optimization converts a failed WebdriverIO test attempt to a passing result.
|
|
209
206
|
*
|
|
210
207
|
* @param {object|undefined} test
|
|
211
|
-
* @returns {boolean}
|
|
212
208
|
*/
|
|
213
209
|
function isWebdriverioFailureSuppressed (test) {
|
|
214
210
|
if (!test) {
|
|
@@ -235,7 +231,6 @@ function getWebdriverioHookTest (hook) {
|
|
|
235
231
|
* Removes managed hook failures from WebdriverIO's Mocha runner totals.
|
|
236
232
|
*
|
|
237
233
|
* @param {object} runner
|
|
238
|
-
* @returns {void}
|
|
239
234
|
*/
|
|
240
235
|
function adjustWebdriverioHookFailures (runner) {
|
|
241
236
|
let suppressedFailures = 0
|
|
@@ -314,7 +309,6 @@ function getWebdriverioSuiteResults (runner) {
|
|
|
314
309
|
*
|
|
315
310
|
* @param {object} runner
|
|
316
311
|
* @param {() => void} [onDone]
|
|
317
|
-
* @returns {void}
|
|
318
312
|
*/
|
|
319
313
|
function reportWebdriverioSuiteResults (runner, onDone) {
|
|
320
314
|
if (!isWebdriverioWorker) {
|
|
@@ -336,7 +330,6 @@ function reportWebdriverioSuiteResults (runner, onDone) {
|
|
|
336
330
|
*
|
|
337
331
|
* @param {object} runner
|
|
338
332
|
* @param {() => void} onDone
|
|
339
|
-
* @returns {void}
|
|
340
333
|
*/
|
|
341
334
|
function finishWebdriverioWorker (runner, onDone) {
|
|
342
335
|
try {
|
|
@@ -385,7 +378,6 @@ function wrapMochaRun (Mocha, frameworkVersion) {
|
|
|
385
378
|
/**
|
|
386
379
|
* Restores the root suite method after both delayed-mode gates are open.
|
|
387
380
|
*
|
|
388
|
-
* @returns {void}
|
|
389
381
|
*/
|
|
390
382
|
function restoreRootSuiteRun () {
|
|
391
383
|
if (hasOwnRootSuiteRun) {
|
|
@@ -424,7 +416,7 @@ function wrapMochaRun (Mocha, frameworkVersion) {
|
|
|
424
416
|
})
|
|
425
417
|
}
|
|
426
418
|
filterSkippedFiles(runner, skippedFiles)
|
|
427
|
-
if (isFailedTestReplayEnabled()) {
|
|
419
|
+
if (isFailedTestReplayEnabled() || config.isFlakyTestRetriesEnabled) {
|
|
428
420
|
patchFailedTestReplayHookUp(runner.constructor)
|
|
429
421
|
}
|
|
430
422
|
configurationReady = true
|
|
@@ -449,14 +441,19 @@ addHook({
|
|
|
449
441
|
name: 'mocha',
|
|
450
442
|
versions: [MINIMUM_MOCHA_VERSION],
|
|
451
443
|
filePattern: String.raw`lib/runner\.(?:c?js)$`,
|
|
452
|
-
}, function (
|
|
444
|
+
}, function (runnerPackage) {
|
|
445
|
+
const Runner = runnerPackage.Runner ?? runnerPackage.default ?? runnerPackage
|
|
446
|
+
if (typeof Runner !== 'function') return
|
|
447
|
+
if (patchedRunners.has(Runner)) return
|
|
448
|
+
|
|
449
|
+
patchedRunners.add(Runner)
|
|
453
450
|
shimmer.wrap(Runner.prototype, 'runTests', runTests => getRunTestsWrapper(runTests, config))
|
|
454
451
|
|
|
455
452
|
shimmer.wrap(Runner.prototype, 'run', run => function (...args) {
|
|
456
453
|
if (!workerFinishCh.hasSubscribers) {
|
|
457
454
|
return run.apply(this, args)
|
|
458
455
|
}
|
|
459
|
-
if (isFailedTestReplayEnabled()) {
|
|
456
|
+
if (isFailedTestReplayEnabled() || config.isFlakyTestRetriesEnabled) {
|
|
460
457
|
patchFailedTestReplayHookUp(Runner)
|
|
461
458
|
}
|
|
462
459
|
if (isWebdriverioWorker) {
|
|
@@ -512,7 +509,7 @@ addHook({
|
|
|
512
509
|
|
|
513
510
|
return run.apply(this, args)
|
|
514
511
|
})
|
|
515
|
-
return
|
|
512
|
+
return runnerPackage
|
|
516
513
|
})
|
|
517
514
|
|
|
518
515
|
// Used both in serial and parallel mode, and by both the main process and the workers
|
|
@@ -185,7 +185,6 @@ function wrapConnection (Connection, version) {
|
|
|
185
185
|
/**
|
|
186
186
|
* @param {object} cmd
|
|
187
187
|
* @param {object} ctx
|
|
188
|
-
* @returns {void}
|
|
189
188
|
*/
|
|
190
189
|
function wrapCommandOnResult (cmd, ctx) {
|
|
191
190
|
const onResult = cmd?.onResult
|
|
@@ -383,7 +382,6 @@ function wrapPool (Pool, version) {
|
|
|
383
382
|
/**
|
|
384
383
|
* @param {Function} Pool
|
|
385
384
|
* @param {'query'|'execute'} method
|
|
386
|
-
* @returns {boolean}
|
|
387
385
|
*/
|
|
388
386
|
function defersPoolAcquire (Pool, method) {
|
|
389
387
|
return !dispatchesAcquireSynchronously(
|