dd-trace 5.135.0 → 5.137.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/README.md +3 -0
- package/ci/cypress/support.js +2 -1
- package/ci/init.js +2 -22
- package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-setup.mjs +729 -724
- package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
- package/ext/exporters.js +0 -1
- package/index.d.ts +105 -5
- package/initialize.mjs +5 -2
- package/package.json +41 -36
- package/packages/datadog-esbuild/index.js +16 -70
- package/packages/datadog-esbuild/src/log.js +2 -29
- package/packages/datadog-instrumentations/src/ai.js +6 -1
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
- 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 +20 -17
- package/packages/datadog-instrumentations/src/helpers/bundler-esm-exports.js +582 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +576 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +8 -0
- 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.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-client.js +30 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +61 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +80 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +23 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
- 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/microgateway-core.js +1 -2
- package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -1
- package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +41 -0
- package/packages/datadog-instrumentations/src/next.js +203 -26
- 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/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/router.js +35 -12
- package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
- 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/arn.js +41 -0
- package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -13
- package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-express/src/code_origin.js +2 -2
- package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +20 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +21 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +11 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-http/src/client.js +34 -10
- package/packages/datadog-plugin-http2/src/client.js +40 -14
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
- package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-postgres/src/index.js +118 -41
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
- package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
- package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
- 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-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +3 -2
- package/packages/datadog-plugin-ws/src/close.js +3 -5
- package/packages/datadog-plugin-ws/src/producer.js +1 -4
- package/packages/datadog-plugin-ws/src/receiver.js +3 -5
- package/packages/datadog-plugin-ws/src/server.js +44 -13
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-vite/index.js +537 -0
- package/packages/datadog-vite/src/log.js +5 -0
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/datadog-webpack/src/log.js +2 -29
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/index.js +1 -1
- package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
- package/packages/dd-trace/src/aiguard/sdk.js +8 -2
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +21 -1
- package/packages/dd-trace/src/appsec/channels.js +7 -0
- package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
- package/packages/dd-trace/src/appsec/graphql.js +89 -7
- package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
- package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
- package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
- package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
- package/packages/dd-trace/src/appsec/index.js +6 -0
- package/packages/dd-trace/src/appsec/lambda.js +17 -17
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
- package/packages/dd-trace/src/appsec/rasp/index.js +8 -1
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
- package/packages/dd-trace/src/appsec/rasp/utils.js +33 -3
- package/packages/dd-trace/src/appsec/recommended.json +1358 -94
- package/packages/dd-trace/src/appsec/reporter.js +9 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
- package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
- package/packages/dd-trace/src/appsec/waf/index.js +65 -6
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
- 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 +15 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
- 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 +1 -2
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- 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 +5 -0
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -4
- package/packages/dd-trace/src/config/index.js +63 -31
- package/packages/dd-trace/src/config/parsers.js +44 -0
- package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
- package/packages/dd-trace/src/config/remote_config.js +2 -1
- package/packages/dd-trace/src/config/supported-configurations.json +172 -10
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/datastreams/fnv.js +27 -0
- package/packages/dd-trace/src/datastreams/pathway.js +113 -28
- package/packages/dd-trace/src/datastreams/processor.js +5 -4
- package/packages/dd-trace/src/debugger/config.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +2 -2
- package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +6 -2
- package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
- package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
- package/packages/dd-trace/src/exporter.js +0 -11
- package/packages/dd-trace/src/exporters/common/request.js +81 -48
- 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/git_metadata.js +2 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/index.js +6 -3
- package/packages/dd-trace/src/lambda/facade.js +75 -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 +2 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +54 -3
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +81 -1
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/sdk.js +19 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
- package/packages/dd-trace/src/llmobs/tagger.js +22 -0
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +6 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +7 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +55 -27
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
- package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
- 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/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/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +24 -0
- package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +143 -17
- package/packages/dd-trace/src/plugins/index.js +8 -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 +52 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +263 -82
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +80 -56
- 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 +92 -40
- package/packages/dd-trace/src/plugins/util/url.js +18 -7
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +6 -6
- package/packages/dd-trace/src/plugins/util/web.js +65 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiler.js +74 -12
- package/packages/dd-trace/src/profiling/profiler.js +30 -2
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/profiling/remote-config.js +354 -0
- package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/propagation-hash/index.js +7 -0
- package/packages/dd-trace/src/proxy.js +46 -54
- package/packages/dd-trace/src/span_processor.js +20 -0
- package/packages/dd-trace/src/startup-log.js +8 -6
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
- 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/rules-based/LICENSE +3 -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 +220 -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/vite.d.ts +7 -0
- package/vite.js +3 -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 -18
- 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 -649
- 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/datadog-esbuild/src/utils.js +0 -318
- package/packages/datadog-plugin-cypress/src/support.js +0 -1348
- 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
|
@@ -1,621 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const fs = require('node:fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
|
|
6
|
-
const { getArtifactId } = require('../artifact-id')
|
|
7
|
-
const { BLOCKER_CATEGORIES } = require('../blocker-category')
|
|
8
|
-
const { buildDatadogEnv, buildOfflineCaptureEnv, runCommand } = require('../command-runner')
|
|
9
|
-
const {
|
|
10
|
-
cleanupGeneratedRuntimeFiles,
|
|
11
|
-
findGeneratedScenario,
|
|
12
|
-
writeGeneratedFiles,
|
|
13
|
-
} = require('../generated-files')
|
|
14
|
-
const {
|
|
15
|
-
eventsOfType,
|
|
16
|
-
findTestsByIdentity,
|
|
17
|
-
} = require('../payload-normalizer')
|
|
18
|
-
const { cleanupOfflineFixture, createOfflineFixture } = require('../offline-fixtures')
|
|
19
|
-
const { readOfflineOutput } = require('../offline-output')
|
|
20
|
-
const { sanitizeForReport, sanitizeString } = require('../redaction')
|
|
21
|
-
const { getGeneratedCommand } = require('../runner-command')
|
|
22
|
-
const { ensureSafeDirectory, writeFileSafely } = require('../safe-files')
|
|
23
|
-
const { getValidationBlockerEvidence } = require('../validation-blocker')
|
|
24
|
-
|
|
25
|
-
const ANSI_PATTERN =
|
|
26
|
-
new RegExp(`${String.fromCharCode(27)}${String.raw`\[[\u0030-\u003F]*[\u0020-\u002F]*[\u0040-\u007E]`}`, 'g')
|
|
27
|
-
|
|
28
|
-
function frameworkOutDir (out, framework, scenario) {
|
|
29
|
-
return path.join(out, 'runs', getArtifactId(framework.id), scenario)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function runInstrumentedCommand ({
|
|
33
|
-
framework,
|
|
34
|
-
out,
|
|
35
|
-
scenarioName,
|
|
36
|
-
command,
|
|
37
|
-
options,
|
|
38
|
-
extraEnv,
|
|
39
|
-
fixtureConfig,
|
|
40
|
-
injectInitialization = true,
|
|
41
|
-
allowMissingInitialization = false,
|
|
42
|
-
}) {
|
|
43
|
-
const outDir = frameworkOutDir(out, framework, scenarioName)
|
|
44
|
-
const rawOutputRoot = path.join(outDir, '.offline-payloads')
|
|
45
|
-
ensureSafeDirectory(out, rawOutputRoot, 'offline validation payload output')
|
|
46
|
-
let fixture
|
|
47
|
-
let result
|
|
48
|
-
let offline
|
|
49
|
-
try {
|
|
50
|
-
fixture = createOfflineFixture({
|
|
51
|
-
approvedPlanSha256: options.approvedPlanSha256,
|
|
52
|
-
offlineFixtureNonce: options.offlineFixtureNonce,
|
|
53
|
-
framework,
|
|
54
|
-
repositoryRoot: options.repositoryRoot,
|
|
55
|
-
scenarioName,
|
|
56
|
-
...fixtureConfig,
|
|
57
|
-
})
|
|
58
|
-
const validationEnv = injectInitialization
|
|
59
|
-
? buildDatadogEnv({ fixture, outputRoot: rawOutputRoot, scenario: scenarioName, framework })
|
|
60
|
-
: buildOfflineCaptureEnv({ fixture, outputRoot: rawOutputRoot })
|
|
61
|
-
result = await runCommand(command, {
|
|
62
|
-
env: {
|
|
63
|
-
...validationEnv,
|
|
64
|
-
...extraEnv,
|
|
65
|
-
},
|
|
66
|
-
artifactRoot: out,
|
|
67
|
-
envMode: 'clean',
|
|
68
|
-
outDir,
|
|
69
|
-
label: `${framework.id}:${scenarioName}`,
|
|
70
|
-
repositoryRoot: options.repositoryRoot,
|
|
71
|
-
requireExecutableApproval: options.requireExecutableApproval,
|
|
72
|
-
verbose: options.verbose,
|
|
73
|
-
})
|
|
74
|
-
offline = readOfflineOutput(rawOutputRoot)
|
|
75
|
-
const sanitizedEvents = sanitizeForReport(offline.events)
|
|
76
|
-
writeFileSafely(
|
|
77
|
-
out,
|
|
78
|
-
path.join(outDir, 'events.ndjson'),
|
|
79
|
-
sanitizedEvents.map(event => JSON.stringify(event)).join('\n') + '\n',
|
|
80
|
-
'scenario events artifact'
|
|
81
|
-
)
|
|
82
|
-
writeFileSafely(
|
|
83
|
-
out,
|
|
84
|
-
path.join(outDir, 'result.json'),
|
|
85
|
-
`${JSON.stringify(sanitizeForReport(result), null, 2)}\n`,
|
|
86
|
-
'scenario result artifact'
|
|
87
|
-
)
|
|
88
|
-
if (!offline.initialized && injectInitialization && !allowMissingInitialization) {
|
|
89
|
-
const stderr = sanitizeString(result.stderr).trim().slice(-2000)
|
|
90
|
-
throw new Error(
|
|
91
|
-
'Offline Test Optimization exporter did not initialize or write completion evidence. ' +
|
|
92
|
-
`The test command exited ${result.exitCode}${result.signal ? ` with signal ${result.signal}` : ''}` +
|
|
93
|
-
`${result.timedOut ? ' after timing out' : ''}.${stderr ? ` Sanitized stderr tail: ${stderr}` : ''}`
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
if (offline.summary?.errors.length > 0) {
|
|
97
|
-
throw new Error(`Offline Test Optimization exporter failed: ${offline.summary.errors.join(', ')}`)
|
|
98
|
-
}
|
|
99
|
-
} catch (err) {
|
|
100
|
-
err.artifactDirectory = outDir
|
|
101
|
-
throw err
|
|
102
|
-
} finally {
|
|
103
|
-
if (fixture) cleanupOfflineFixture(fixture.root)
|
|
104
|
-
fs.rmSync(rawOutputRoot, { force: true, recursive: true })
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return { result, events: offline.events, offline, outDir }
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async function failWithDebugRerun ({
|
|
111
|
-
command,
|
|
112
|
-
fixtureConfig,
|
|
113
|
-
diagnosis,
|
|
114
|
-
evidence,
|
|
115
|
-
framework,
|
|
116
|
-
options,
|
|
117
|
-
out,
|
|
118
|
-
outDir,
|
|
119
|
-
scenarioName,
|
|
120
|
-
skipDebug,
|
|
121
|
-
}) {
|
|
122
|
-
if (!skipDebug && command) {
|
|
123
|
-
const debugRerun = await runDebugInstrumentedCommand({
|
|
124
|
-
command,
|
|
125
|
-
fixtureConfig,
|
|
126
|
-
framework,
|
|
127
|
-
options,
|
|
128
|
-
out,
|
|
129
|
-
scenarioName,
|
|
130
|
-
})
|
|
131
|
-
evidence.debugRerun = debugRerun.summary
|
|
132
|
-
|
|
133
|
-
const failure = fail(framework, scenarioName, diagnosis, evidence, outDir)
|
|
134
|
-
if (debugRerun.artifacts) {
|
|
135
|
-
failure.artifacts.push(...debugRerun.artifacts)
|
|
136
|
-
}
|
|
137
|
-
return failure
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return fail(framework, scenarioName, diagnosis, evidence, outDir)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async function runDebugInstrumentedCommand ({
|
|
144
|
-
command,
|
|
145
|
-
fixtureConfig,
|
|
146
|
-
framework,
|
|
147
|
-
options,
|
|
148
|
-
out,
|
|
149
|
-
scenarioName,
|
|
150
|
-
}) {
|
|
151
|
-
try {
|
|
152
|
-
cleanupGeneratedRuntimeFiles(framework)
|
|
153
|
-
|
|
154
|
-
const debug = await runInstrumentedCommand({
|
|
155
|
-
framework,
|
|
156
|
-
out,
|
|
157
|
-
scenarioName: `${scenarioName}-debug`,
|
|
158
|
-
command,
|
|
159
|
-
options,
|
|
160
|
-
fixtureConfig,
|
|
161
|
-
extraEnv: {
|
|
162
|
-
DD_TRACE_DEBUG: '1',
|
|
163
|
-
DD_TRACE_LOG_LEVEL: 'debug',
|
|
164
|
-
},
|
|
165
|
-
allowMissingInitialization: true,
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
summary: summarizeDebugRerun(debug),
|
|
170
|
-
artifacts: getDebugArtifacts(debug.outDir),
|
|
171
|
-
}
|
|
172
|
-
} catch (err) {
|
|
173
|
-
return {
|
|
174
|
-
summary: {
|
|
175
|
-
ran: false,
|
|
176
|
-
error: err && err.message ? err.message : String(err),
|
|
177
|
-
},
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
async function prepareGeneratedScenario (framework, scenarioId) {
|
|
183
|
-
const scenario = findGeneratedScenario(framework, scenarioId)
|
|
184
|
-
if (!scenario) return { scenario: null, written: [] }
|
|
185
|
-
cleanupGeneratedRuntimeFiles(framework)
|
|
186
|
-
const written = await writeGeneratedFiles(framework, scenario)
|
|
187
|
-
return {
|
|
188
|
-
scenario: {
|
|
189
|
-
...scenario,
|
|
190
|
-
runCommand: getGeneratedCommand(framework, scenario),
|
|
191
|
-
},
|
|
192
|
-
written,
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function requireGeneratedScenario (framework, scenarioId, scenarioName) {
|
|
197
|
-
const strategy = framework.generatedTestStrategy
|
|
198
|
-
if (strategy?.status === 'not_possible') {
|
|
199
|
-
return incomplete(
|
|
200
|
-
framework,
|
|
201
|
-
scenarioName,
|
|
202
|
-
`The validator cannot create a collectible test for this advanced feature: ${strategy.reason} ` +
|
|
203
|
-
'No conclusion was reached for this advanced feature.',
|
|
204
|
-
getGeneratedStrategySkipEvidence(framework, scenarioName, scenarioId)
|
|
205
|
-
)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (!strategy || strategy.status !== 'verified') {
|
|
209
|
-
return incomplete(
|
|
210
|
-
framework,
|
|
211
|
-
scenarioName,
|
|
212
|
-
'The validation manifest is incomplete because no verified generated test strategy is available. ' +
|
|
213
|
-
'No conclusion was reached for this advanced feature.',
|
|
214
|
-
getGeneratedStrategySkipEvidence(framework, scenarioName, scenarioId)
|
|
215
|
-
)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const scenario = findGeneratedScenario(framework, scenarioId)
|
|
219
|
-
if (!scenario) {
|
|
220
|
-
return incomplete(
|
|
221
|
-
framework,
|
|
222
|
-
scenarioName,
|
|
223
|
-
`The validation manifest is incomplete because generated scenario "${scenarioId}" is missing. ` +
|
|
224
|
-
'No conclusion was reached for this advanced feature.',
|
|
225
|
-
{
|
|
226
|
-
featureEligibility: {
|
|
227
|
-
eligible: false,
|
|
228
|
-
blockedBy: 'generated-scenario',
|
|
229
|
-
reasonCode: 'generated-scenario-missing',
|
|
230
|
-
scenario: scenarioName,
|
|
231
|
-
requiredGeneratedScenario: scenarioId,
|
|
232
|
-
},
|
|
233
|
-
}
|
|
234
|
-
)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return null
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Builds stable evidence for advanced feature checks that cannot run without generated tests.
|
|
242
|
-
*
|
|
243
|
-
* @param {object} framework manifest framework entry
|
|
244
|
-
* @param {string} scenarioName advanced scenario name
|
|
245
|
-
* @param {string} scenarioId required generated scenario id
|
|
246
|
-
* @returns {object} skip evidence for reports and UI payloads
|
|
247
|
-
*/
|
|
248
|
-
function getGeneratedStrategySkipEvidence (framework, scenarioName, scenarioId) {
|
|
249
|
-
const strategy = framework.generatedTestStrategy
|
|
250
|
-
const status = strategy?.status || 'missing'
|
|
251
|
-
let reasonCode = 'generated-test-strategy-missing'
|
|
252
|
-
|
|
253
|
-
if (status === 'proposed') {
|
|
254
|
-
reasonCode = 'generated-test-strategy-proposed-only'
|
|
255
|
-
} else if (status === 'not_possible') {
|
|
256
|
-
reasonCode = 'generated-test-strategy-not-possible'
|
|
257
|
-
} else if (status !== 'missing') {
|
|
258
|
-
reasonCode = 'generated-test-strategy-not-verified'
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const evidence = {
|
|
262
|
-
featureEligibility: {
|
|
263
|
-
...(reasonCode === 'generated-test-strategy-not-possible' ? {} : { eligible: false }),
|
|
264
|
-
blockedBy: 'generated-test-strategy',
|
|
265
|
-
reason: strategy?.reason,
|
|
266
|
-
reasonCode,
|
|
267
|
-
scenario: scenarioName,
|
|
268
|
-
strategyStatus: status,
|
|
269
|
-
requiredGeneratedScenario: scenarioId,
|
|
270
|
-
},
|
|
271
|
-
}
|
|
272
|
-
if (reasonCode === 'generated-test-strategy-not-possible') {
|
|
273
|
-
evidence.blockerCategory = BLOCKER_CATEGORIES.VALIDATOR_LIMITATION
|
|
274
|
-
evidence.recommendation = 'Report that the selected runner configuration cannot collect validator-generated ' +
|
|
275
|
-
'tests to validator engineering. Basic Reporting remains valid; project setup changes are not required.'
|
|
276
|
-
}
|
|
277
|
-
return evidence
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function basicEventEvidence (events) {
|
|
281
|
-
return {
|
|
282
|
-
testSessionEvents: eventsOfType(events, 'test_session_end').length,
|
|
283
|
-
testModuleEvents: eventsOfType(events, 'test_module_end').length,
|
|
284
|
-
testSuiteEvents: eventsOfType(events, 'test_suite_end').length,
|
|
285
|
-
testEvents: eventsOfType(events, 'test').length,
|
|
286
|
-
samples: basicEventSamples(events),
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function hasAllBasicEventTypes (events) {
|
|
291
|
-
const evidence = basicEventEvidence(events)
|
|
292
|
-
return evidence.testSessionEvents > 0 &&
|
|
293
|
-
evidence.testModuleEvents > 0 &&
|
|
294
|
-
evidence.testSuiteEvents > 0 &&
|
|
295
|
-
evidence.testEvents > 0
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function testsForScenario (events, scenario) {
|
|
299
|
-
return findTestsByIdentity(events, scenario.testIdentities || [])
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
async function discoverScenarioTests ({ framework, out, scenarioName, scenario, options }) {
|
|
303
|
-
const baseline = await runInstrumentedCommand({
|
|
304
|
-
framework,
|
|
305
|
-
out,
|
|
306
|
-
scenarioName: `${scenarioName}-baseline`,
|
|
307
|
-
command: scenario.runCommand,
|
|
308
|
-
options,
|
|
309
|
-
})
|
|
310
|
-
let tests = testsForScenario(baseline.events, scenario)
|
|
311
|
-
let identityMatch = 'manifest'
|
|
312
|
-
if (tests.length === 0) {
|
|
313
|
-
const nameAndFileIdentities = (scenario.testIdentities || [])
|
|
314
|
-
.filter(identity => identity.name && identity.file)
|
|
315
|
-
tests = findTestsByIdentity(baseline.events, nameAndFileIdentities, { ignoreSuite: true })
|
|
316
|
-
if (tests.length > 0) identityMatch = 'name-and-file-fallback'
|
|
317
|
-
}
|
|
318
|
-
cleanupGeneratedRuntimeFiles(framework)
|
|
319
|
-
return {
|
|
320
|
-
...baseline,
|
|
321
|
-
identityMatch,
|
|
322
|
-
tests,
|
|
323
|
-
testIdentities: tests.map(testToIdentity),
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Reports a missing generated test without blaming dd-trace when clean execution was unproven.
|
|
329
|
-
*
|
|
330
|
-
* @param {object} input missing-test evidence
|
|
331
|
-
* @param {object} input.command generated scenario command
|
|
332
|
-
* @param {string} input.diagnosis diagnosis used when clean execution was proven
|
|
333
|
-
* @param {object} input.discovery instrumented baseline result
|
|
334
|
-
* @param {object} input.framework framework manifest entry
|
|
335
|
-
* @param {object} input.options execution options
|
|
336
|
-
* @param {string} input.out validation output root
|
|
337
|
-
* @param {object} input.scenario generated scenario
|
|
338
|
-
* @param {string} input.scenarioName advanced scenario name
|
|
339
|
-
* @returns {object|Promise<object>} incomplete or confirmed failure result
|
|
340
|
-
*/
|
|
341
|
-
function reportMissingGeneratedTest ({
|
|
342
|
-
command,
|
|
343
|
-
diagnosis,
|
|
344
|
-
discovery,
|
|
345
|
-
framework,
|
|
346
|
-
options,
|
|
347
|
-
out,
|
|
348
|
-
scenario,
|
|
349
|
-
scenarioName,
|
|
350
|
-
}) {
|
|
351
|
-
const verification = framework.generatedTestStrategy?.verification?.observedScenarios
|
|
352
|
-
?.find(observed => observed.id === scenario.id)
|
|
353
|
-
const evidence = {
|
|
354
|
-
...discoveryEvidence(discovery),
|
|
355
|
-
generatedVerificationObservedTestCount: verification?.observedTestCount,
|
|
356
|
-
}
|
|
357
|
-
if (verification?.observedTestCount === null) {
|
|
358
|
-
return inconclusive(
|
|
359
|
-
framework,
|
|
360
|
-
scenarioName,
|
|
361
|
-
'The clean temporary validation command exited as expected without a parseable test count, and the ' +
|
|
362
|
-
'instrumented baseline emitted no matching test event. The validator cannot prove that the generated test ' +
|
|
363
|
-
'executed, so no advanced-feature conclusion was reached.',
|
|
364
|
-
{
|
|
365
|
-
...evidence,
|
|
366
|
-
reasonCode: 'generated-test-execution-unproven',
|
|
367
|
-
},
|
|
368
|
-
discovery.outDir
|
|
369
|
-
)
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return failWithDebugRerun({
|
|
373
|
-
command,
|
|
374
|
-
diagnosis,
|
|
375
|
-
evidence,
|
|
376
|
-
framework,
|
|
377
|
-
options,
|
|
378
|
-
out,
|
|
379
|
-
outDir: discovery.outDir,
|
|
380
|
-
scenarioName,
|
|
381
|
-
})
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function testsForDiscoveredScenario (events, scenario, discovery) {
|
|
385
|
-
if (discovery?.testIdentities?.length > 0) {
|
|
386
|
-
return findTestsByIdentity(events, discovery.testIdentities)
|
|
387
|
-
}
|
|
388
|
-
return testsForScenario(events, scenario)
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function discoveryEvidence (discovery) {
|
|
392
|
-
return {
|
|
393
|
-
baselineCommandExitCode: discovery.result.exitCode,
|
|
394
|
-
baselineIdentityMatch: discovery.identityMatch,
|
|
395
|
-
baselineMatchingTestEvents: discovery.tests.length,
|
|
396
|
-
baselineSamples: testEventSamples(discovery.tests),
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function testToIdentity (test) {
|
|
401
|
-
return {
|
|
402
|
-
discovered: true,
|
|
403
|
-
suite: test.testSuite,
|
|
404
|
-
name: test.testName,
|
|
405
|
-
file: test.testSourceFile,
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
function basicEventSamples (events) {
|
|
410
|
-
return [
|
|
411
|
-
sampleLevel(events, 'test_session_end', 'test session'),
|
|
412
|
-
sampleLevel(events, 'test_module_end', 'test module'),
|
|
413
|
-
sampleLevel(events, 'test_suite_end', 'test suite'),
|
|
414
|
-
sampleLevel(events, 'test', 'test'),
|
|
415
|
-
].filter(Boolean)
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
function sampleLevel (events, type, level) {
|
|
419
|
-
const event = eventsOfType(events, type)[0]
|
|
420
|
-
if (!event) return null
|
|
421
|
-
|
|
422
|
-
const sample = { level }
|
|
423
|
-
copy(sample, event.meta, 'test.command')
|
|
424
|
-
copy(sample, event.meta, 'test.module')
|
|
425
|
-
copy(sample, event.meta, 'test.suite')
|
|
426
|
-
copy(sample, event.meta, 'test.name')
|
|
427
|
-
copy(sample, event.meta, 'test.status')
|
|
428
|
-
return sample
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
function testEventSamples (tests) {
|
|
432
|
-
return tests.slice(0, 3).map(test => {
|
|
433
|
-
const sample = {}
|
|
434
|
-
copy(sample, test.meta, 'test.name')
|
|
435
|
-
copy(sample, test.meta, 'test.status')
|
|
436
|
-
copy(sample, test.meta, 'test.is_new')
|
|
437
|
-
copy(sample, test.meta, 'test.is_retry')
|
|
438
|
-
copy(sample, test.meta, 'test.retry_reason')
|
|
439
|
-
copy(sample, test.meta, 'test.final_status')
|
|
440
|
-
copy(sample, test.meta, 'test.test_management.enabled')
|
|
441
|
-
copy(sample, test.meta, 'test.test_management.is_test_disabled')
|
|
442
|
-
copy(sample, test.meta, 'test.test_management.is_quarantined')
|
|
443
|
-
copy(sample, test.meta, 'test.test_management.is_attempt_to_fix')
|
|
444
|
-
copy(sample, test.meta, 'test.test_management.attempt_to_fix_passed')
|
|
445
|
-
return sample
|
|
446
|
-
})
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
function copy (target, source, key) {
|
|
450
|
-
if (source && source[key] !== undefined) target[key] = source[key]
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
function summarizeDebugRerun ({ result, events, offline, outDir }) {
|
|
454
|
-
const output = `${result.stdout}\n${result.stderr}`
|
|
455
|
-
const testEvents = eventsOfType(events, 'test')
|
|
456
|
-
const sourceFiles = new Set(testEvents.map(test => test.testSourceFile).filter(Boolean))
|
|
457
|
-
|
|
458
|
-
return {
|
|
459
|
-
ran: true,
|
|
460
|
-
commandExitCode: result.exitCode,
|
|
461
|
-
commandTimedOut: result.timedOut,
|
|
462
|
-
debugCommandFailed: result.exitCode !== 0 || result.timedOut === true,
|
|
463
|
-
offlineExporterInitialized: offline.initialized,
|
|
464
|
-
settingsLoadedFromCache: offline.inputs.settings?.status === 'loaded',
|
|
465
|
-
artifactDirectory: outDir,
|
|
466
|
-
...basicEventEvidence(events),
|
|
467
|
-
testEventsWithoutSourceFile: testEvents.length - testEvents.filter(test => test.testSourceFile).length,
|
|
468
|
-
testSourceFileCount: sourceFiles.size,
|
|
469
|
-
testSourceFiles: [...sourceFiles].slice(0, 5),
|
|
470
|
-
debugLines: findInterestingLines(output, [
|
|
471
|
-
/dd-trace/i,
|
|
472
|
-
/test optimization/i,
|
|
473
|
-
/ci visibility/i,
|
|
474
|
-
/citestcycle/i,
|
|
475
|
-
/auto.?test.?retr/i,
|
|
476
|
-
/flaky.?retr/i,
|
|
477
|
-
/\b(?:error|warn)\b/i,
|
|
478
|
-
], 20),
|
|
479
|
-
stderrExcerpt: tailInterestingLines(result.stderr),
|
|
480
|
-
stdoutExcerpt: tailInterestingLines(result.stdout),
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
function getDebugArtifacts (outDir) {
|
|
485
|
-
return [
|
|
486
|
-
'command.json',
|
|
487
|
-
'stdout.txt',
|
|
488
|
-
'stderr.txt',
|
|
489
|
-
'events.ndjson',
|
|
490
|
-
'result.json',
|
|
491
|
-
].map(filename => path.join(outDir, filename))
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function findInterestingLines (output, patterns, limit = 8) {
|
|
495
|
-
return uniqueLines(output.split(/\r?\n/).map(stripAnsi).filter(line => {
|
|
496
|
-
if (/^\s*Encoding payload:/.test(line)) return false
|
|
497
|
-
return patterns.some(pattern => pattern.test(line))
|
|
498
|
-
}).map(truncateLine)).slice(0, limit)
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
function truncateLine (line) {
|
|
502
|
-
const maxLength = 500
|
|
503
|
-
return line.length > maxLength ? `${line.slice(0, maxLength)}...` : line
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function tailInterestingLines (output) {
|
|
507
|
-
return uniqueLines(output
|
|
508
|
-
.split(/\r?\n/)
|
|
509
|
-
.map(stripAnsi)
|
|
510
|
-
.map(line => line.trimEnd())
|
|
511
|
-
.filter(line => line.trim() !== '')
|
|
512
|
-
.filter(line => !/^\s*Encoding payload:/.test(line))
|
|
513
|
-
.map(truncateLine))
|
|
514
|
-
.slice(-12)
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
function stripAnsi (line) {
|
|
518
|
-
return line.replaceAll(ANSI_PATTERN, '')
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
function uniqueLines (lines) {
|
|
522
|
-
const seen = new Set()
|
|
523
|
-
const unique = []
|
|
524
|
-
for (const line of lines) {
|
|
525
|
-
const normalized = line.trim()
|
|
526
|
-
if (!normalized || seen.has(normalized)) continue
|
|
527
|
-
seen.add(normalized)
|
|
528
|
-
unique.push(line)
|
|
529
|
-
}
|
|
530
|
-
return unique
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
function pass (framework, scenario, diagnosis, evidence, outDir, extraArtifacts) {
|
|
534
|
-
return result(framework, scenario, 'pass', diagnosis, evidence, outDir, extraArtifacts)
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
function fail (framework, scenario, diagnosis, evidence, outDir, extraArtifacts) {
|
|
538
|
-
return result(framework, scenario, 'fail', diagnosis, evidence, outDir, extraArtifacts)
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
function skip (framework, scenario, diagnosis, evidence = {}) {
|
|
542
|
-
return result(framework, scenario, 'skip', diagnosis, evidence, null)
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
function incomplete (framework, scenario, diagnosis, evidence = {}) {
|
|
546
|
-
return result(framework, scenario, 'error', diagnosis, {
|
|
547
|
-
...evidence,
|
|
548
|
-
manifestIncomplete: true,
|
|
549
|
-
}, null)
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
function inconclusive (framework, scenario, diagnosis, evidence = {}, outDir, extraArtifacts) {
|
|
553
|
-
return result(framework, scenario, 'error', diagnosis, {
|
|
554
|
-
...evidence,
|
|
555
|
-
validationIncomplete: true,
|
|
556
|
-
}, outDir, extraArtifacts)
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
function error (framework, scenario, err, outDir = err?.artifactDirectory) {
|
|
560
|
-
const blockerEvidence = getValidationBlockerEvidence(err)
|
|
561
|
-
return result(
|
|
562
|
-
framework,
|
|
563
|
-
scenario,
|
|
564
|
-
blockerEvidence ? 'blocked' : 'error',
|
|
565
|
-
blockerEvidence ? err.message : (err && err.stack ? err.stack : String(err)),
|
|
566
|
-
blockerEvidence || {},
|
|
567
|
-
outDir
|
|
568
|
-
)
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
function result (framework, scenario, status, diagnosis, evidence, outDir, extraArtifacts) {
|
|
572
|
-
const artifacts = outDir
|
|
573
|
-
? [
|
|
574
|
-
path.join(outDir, 'command.json'),
|
|
575
|
-
path.join(outDir, 'stdout.txt'),
|
|
576
|
-
path.join(outDir, 'stderr.txt'),
|
|
577
|
-
path.join(outDir, 'events.ndjson'),
|
|
578
|
-
path.join(outDir, 'result.json'),
|
|
579
|
-
]
|
|
580
|
-
: []
|
|
581
|
-
|
|
582
|
-
if (Array.isArray(extraArtifacts)) {
|
|
583
|
-
artifacts.push(...extraArtifacts)
|
|
584
|
-
} else if (extraArtifacts && typeof extraArtifacts === 'object') {
|
|
585
|
-
artifacts.push(...Object.values(extraArtifacts).filter(Boolean))
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
return {
|
|
589
|
-
frameworkId: framework.id,
|
|
590
|
-
scenario,
|
|
591
|
-
status,
|
|
592
|
-
diagnosis,
|
|
593
|
-
evidence,
|
|
594
|
-
artifacts,
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
module.exports = {
|
|
599
|
-
basicEventEvidence,
|
|
600
|
-
discoverScenarioTests,
|
|
601
|
-
discoveryEvidence,
|
|
602
|
-
error,
|
|
603
|
-
fail,
|
|
604
|
-
failWithDebugRerun,
|
|
605
|
-
findInterestingLines,
|
|
606
|
-
frameworkOutDir,
|
|
607
|
-
hasAllBasicEventTypes,
|
|
608
|
-
incomplete,
|
|
609
|
-
inconclusive,
|
|
610
|
-
pass,
|
|
611
|
-
prepareGeneratedScenario,
|
|
612
|
-
reportMissingGeneratedTest,
|
|
613
|
-
requireGeneratedScenario,
|
|
614
|
-
runDebugInstrumentedCommand,
|
|
615
|
-
runInstrumentedCommand,
|
|
616
|
-
skip,
|
|
617
|
-
testEventSamples,
|
|
618
|
-
tailInterestingLines,
|
|
619
|
-
testsForDiscoveredScenario,
|
|
620
|
-
testsForScenario,
|
|
621
|
-
}
|