dd-trace 5.134.0 → 5.136.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +0 -1
- package/ci/cypress/support.js +15 -1
- package/ci/init.js +2 -22
- package/ci/test-annotations.d.ts +5 -0
- package/ci/test-annotations.js +5 -0
- package/ci/vitest-no-worker-init-annotations.mjs +4 -0
- package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
- package/ci/vitest-no-worker-init-runner-setup.mjs +7 -32
- package/ci/vitest-no-worker-init-setup.mjs +34 -12
- package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
- package/ext/exporters.js +1 -1
- package/index.d.ts +124 -5
- package/initialize.mjs +5 -2
- package/lambda.d.ts +39 -0
- package/lambda.js +3 -0
- package/loader-hook.mjs +53 -0
- package/openfeature/exposure-hook.d.ts +66 -0
- package/openfeature/exposure-hook.js +5 -0
- package/package.json +19 -15
- package/packages/datadog-core/src/storage.js +1 -1
- package/packages/datadog-esbuild/index.js +78 -62
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +56 -19
- package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +29 -20
- package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
- package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -8
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +18 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +58 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +25 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/jest.js +265 -82
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
- package/packages/datadog-instrumentations/src/mariadb.js +13 -6
- package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
- package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
- package/packages/datadog-instrumentations/src/mocha/utils.js +58 -12
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +19 -6
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/oracledb.js +33 -0
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/playwright.js +81 -28
- package/packages/datadog-instrumentations/src/react-router.js +106 -0
- package/packages/datadog-instrumentations/src/typesafe.js +89 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -48
- package/packages/datadog-instrumentations/src/vitest-main.js +26 -0
- package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
- package/packages/datadog-instrumentations/src/vitest.js +10 -8
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-cucumber/src/index.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +296 -55
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
- package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
- package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
- package/packages/datadog-plugin-cypress/src/support.js +1217 -439
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/utils.js +5 -5
- package/packages/datadog-plugin-http/src/client.js +32 -9
- package/packages/datadog-plugin-http2/src/client.js +38 -13
- package/packages/datadog-plugin-jest/src/index.js +25 -3
- package/packages/datadog-plugin-mocha/src/index.js +47 -6
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
- package/packages/datadog-plugin-playwright/src/index.js +4 -0
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-react-router/src/index.js +118 -0
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-typesafe/src/index.js +17 -0
- package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +8 -0
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/dd-trace/src/agent/info.js +2 -1
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/sdk.js +8 -13
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
- package/packages/dd-trace/src/appsec/graphql.js +91 -6
- package/packages/dd-trace/src/appsec/recommended.json +1287 -90
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +24 -18
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +16 -36
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -18
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +10 -15
- package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
- package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
- package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +10 -17
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +9 -3
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -2
- package/packages/dd-trace/src/config/index.js +111 -43
- package/packages/dd-trace/src/config/parsers.js +18 -1
- package/packages/dd-trace/src/config/supported-configurations.json +174 -4
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
- package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
- package/packages/dd-trace/src/encode/0.4.js +2 -2
- package/packages/dd-trace/src/esm-module-load.js +58 -0
- package/packages/dd-trace/src/exporter.js +23 -15
- package/packages/dd-trace/src/exporters/agent/index.js +3 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
- package/packages/dd-trace/src/exporters/common/request.js +83 -50
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
- package/packages/dd-trace/src/exporters/log/index.js +4 -3
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/lambda/facade.js +74 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +3 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
- package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
- package/packages/dd-trace/src/llmobs/index.js +13 -2
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +27 -10
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
- package/packages/dd-trace/src/llmobs/sdk.js +21 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +219 -12
- package/packages/dd-trace/src/llmobs/tagger.js +25 -0
- package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +13 -2
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +68 -6
- package/packages/dd-trace/src/openfeature/configuration_source.js +41 -17
- package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
- package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +58 -14
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
- package/packages/dd-trace/src/openfeature/writers/base.js +63 -30
- package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
- package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +33 -13
- package/packages/dd-trace/src/otel-thread-ctx.js +72 -49
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +45 -14
- package/packages/dd-trace/src/plugins/index.js +9 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +18 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +273 -86
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +77 -50
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +90 -45
- package/packages/dd-trace/src/plugins/util/url.js +10 -2
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
- package/packages/dd-trace/src/plugins/util/web.js +81 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiling/config.js +6 -3
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/proxy.js +48 -57
- package/packages/dd-trace/src/serverless.js +3 -2
- package/packages/dd-trace/src/span_processor.js +41 -9
- package/packages/dd-trace/src/span_stats.js +28 -2
- package/packages/dd-trace/src/startup-log.js +8 -5
- package/packages/dd-trace/src/tagger.js +7 -5
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
- package/packages/dd-trace/src/telemetry/index.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -0
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/util.js +1 -1
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +4 -2
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/{@opentelemetry/resources → @datadog/flagging-core}/LICENSE +22 -2
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -19
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -650
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
- package/vendor/dist/@opentelemetry/resources/index.js +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/** @type {WeakSet<() => void>} */
|
|
4
|
+
const finalizers = new WeakSet()
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Registers synchronous span finalization before ordinary exit handlers flush and stop writers.
|
|
8
|
+
* Handlers remain in the existing set, so its normal registration/removal lifecycle is preserved.
|
|
9
|
+
* @param {() => void} handler
|
|
10
|
+
*/
|
|
11
|
+
function addBeforeExitFinalizer (handler) {
|
|
12
|
+
finalizers.add(handler)
|
|
13
|
+
globalThis[Symbol.for('dd-trace')]?.beforeExitHandlers?.add(handler)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @param {Set<() => void>} handlers */
|
|
17
|
+
function runBeforeExitHandlers (handlers) {
|
|
18
|
+
for (const handler of handlers) {
|
|
19
|
+
if (!finalizers.has(handler)) continue
|
|
20
|
+
try {
|
|
21
|
+
handler()
|
|
22
|
+
} catch (error) {
|
|
23
|
+
// Lazy to avoid loading the logger while bootstrap creates the lifecycle registry.
|
|
24
|
+
require('./log').error('Error finalizing spans before process exit: %s', error?.message || error)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
for (const handler of handlers) {
|
|
28
|
+
if (!finalizers.has(handler)) handler()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { addBeforeExitFinalizer, runBeforeExitHandlers }
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { runBeforeExitHandlers } = require('./before-exit')
|
|
4
|
+
|
|
3
5
|
if (!global._ddtrace) {
|
|
4
6
|
const ddTraceSymbol = Symbol.for('dd-trace')
|
|
5
7
|
|
|
@@ -8,6 +10,8 @@ if (!global._ddtrace) {
|
|
|
8
10
|
Object.defineProperty(globalThis, ddTraceSymbol, {
|
|
9
11
|
value: {
|
|
10
12
|
beforeExitHandlers: new Set(),
|
|
13
|
+
// Handler hooks may have populated Lambda caches before the tracer was initialized.
|
|
14
|
+
lambda: globalThis[ddTraceSymbol]?.lambda,
|
|
11
15
|
},
|
|
12
16
|
enumerable: false,
|
|
13
17
|
configurable: true,
|
|
@@ -16,9 +20,7 @@ if (!global._ddtrace) {
|
|
|
16
20
|
|
|
17
21
|
process.once('beforeExit', function mainBeforeExit () {
|
|
18
22
|
if (globalThis[ddTraceSymbol]?.beforeExitHandlers) {
|
|
19
|
-
|
|
20
|
-
handler()
|
|
21
|
-
}
|
|
23
|
+
runBeforeExitHandlers(globalThis[ddTraceSymbol].beforeExitHandlers)
|
|
22
24
|
}
|
|
23
25
|
})
|
|
24
26
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { performance } = require('node:perf_hooks')
|
|
4
|
+
|
|
3
5
|
const getConfig = require('../../config')
|
|
4
|
-
const { EVP_SUBDOMAIN_HEADER_NAME } = require('../../evp_proxy/constants')
|
|
5
|
-
const { joinEVPProxyPath } = require('../../evp_proxy/path')
|
|
6
6
|
const id = require('../../id')
|
|
7
7
|
const log = require('../../log')
|
|
8
8
|
const {
|
|
@@ -13,9 +13,13 @@ const {
|
|
|
13
13
|
TELEMETRY_KNOWN_TESTS_ERRORS,
|
|
14
14
|
TELEMETRY_KNOWN_TESTS_RESPONSE_TESTS,
|
|
15
15
|
TELEMETRY_KNOWN_TESTS_RESPONSE_BYTES,
|
|
16
|
+
TELEMETRY_KNOWN_TESTS_PAGES_FETCHED,
|
|
17
|
+
TELEMETRY_KNOWN_TESTS_TOTAL_FETCH_MS,
|
|
18
|
+
TELEMETRY_KNOWN_TESTS_TOTAL_REQUEST_MS,
|
|
16
19
|
} = require('../../ci-visibility/telemetry')
|
|
17
20
|
const { getNumFromKnownTests } = require('../../plugins/util/test')
|
|
18
21
|
const request = require('../requests/request')
|
|
22
|
+
const { createApiRequestRoute } = require('../requests/route')
|
|
19
23
|
const { buildCacheKey, writeToCache, withCache } = require('../requests/fs-cache')
|
|
20
24
|
const { validateKnownTestsResponse } = require('../test-optimization-http-cache-schema')
|
|
21
25
|
|
|
@@ -60,7 +64,7 @@ function parseJsonResponse (rawJson) {
|
|
|
60
64
|
function parseKnownTestsResponse (rawJson, options = {}) {
|
|
61
65
|
const parsedResponse = parseJsonResponse(rawJson)
|
|
62
66
|
if (options.validateRequiredFields) {
|
|
63
|
-
validateKnownTestsResponse(parsedResponse
|
|
67
|
+
validateKnownTestsResponse(parsedResponse)
|
|
64
68
|
}
|
|
65
69
|
const { data: { attributes: { tests } } } = parsedResponse
|
|
66
70
|
return tests
|
|
@@ -147,32 +151,26 @@ function fetchFromApi ({
|
|
|
147
151
|
custom,
|
|
148
152
|
cacheKey,
|
|
149
153
|
}, done) {
|
|
154
|
+
const path = '/api/v2/ci/libraries/tests'
|
|
155
|
+
const route = createApiRequestRoute(getConfig(), { url, path, isEvpProxy, evpProxyPrefix })
|
|
156
|
+
if (!route) {
|
|
157
|
+
return done(new Error('Known tests were not fetched because Datadog API key is not defined.'))
|
|
158
|
+
}
|
|
159
|
+
|
|
150
160
|
const options = {
|
|
151
|
-
|
|
161
|
+
...route,
|
|
152
162
|
method: 'POST',
|
|
153
163
|
headers: {
|
|
164
|
+
...route.headers,
|
|
154
165
|
'Content-Type': 'application/json',
|
|
155
166
|
},
|
|
156
167
|
timeout: 20_000,
|
|
157
|
-
url,
|
|
158
168
|
}
|
|
159
169
|
|
|
160
170
|
if (isGzipCompatible) {
|
|
161
171
|
options.headers['accept-encoding'] = 'gzip'
|
|
162
172
|
}
|
|
163
173
|
|
|
164
|
-
if (isEvpProxy) {
|
|
165
|
-
options.path = joinEVPProxyPath(evpProxyPrefix, '/api/v2/ci/libraries/tests')
|
|
166
|
-
options.headers[EVP_SUBDOMAIN_HEADER_NAME] = 'api'
|
|
167
|
-
} else {
|
|
168
|
-
const { DD_API_KEY } = getConfig()
|
|
169
|
-
if (!DD_API_KEY) {
|
|
170
|
-
return done(new Error('Known tests were not fetched because Datadog API key is not defined.'))
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
options.headers['dd-api-key'] = DD_API_KEY
|
|
174
|
-
}
|
|
175
|
-
|
|
176
174
|
const configurations = {
|
|
177
175
|
'os.platform': osPlatform,
|
|
178
176
|
'os.version': osVersion,
|
|
@@ -185,9 +183,11 @@ function fetchFromApi ({
|
|
|
185
183
|
incrementCountMetric(TELEMETRY_KNOWN_TESTS)
|
|
186
184
|
|
|
187
185
|
const startTime = Date.now()
|
|
186
|
+
const totalFetchStartTime = performance.now()
|
|
188
187
|
let aggregateTests = null
|
|
189
188
|
let totalResponseBytes = 0
|
|
190
189
|
let pageNumber = 0
|
|
190
|
+
let totalRequestMs = 0
|
|
191
191
|
|
|
192
192
|
function fetchPage (pageState) {
|
|
193
193
|
pageNumber++
|
|
@@ -215,7 +215,9 @@ function fetchFromApi ({
|
|
|
215
215
|
},
|
|
216
216
|
})
|
|
217
217
|
|
|
218
|
+
const pageStartTime = performance.now()
|
|
218
219
|
request(data, options, (err, res, statusCode) => {
|
|
220
|
+
totalRequestMs += performance.now() - pageStartTime
|
|
219
221
|
if (err) {
|
|
220
222
|
distributionMetric(TELEMETRY_KNOWN_TESTS_MS, {}, Date.now() - startTime)
|
|
221
223
|
incrementCountMetric(TELEMETRY_KNOWN_TESTS_ERRORS, { statusCode })
|
|
@@ -245,9 +247,13 @@ function fetchFromApi ({
|
|
|
245
247
|
|
|
246
248
|
// Done — no more pages
|
|
247
249
|
distributionMetric(TELEMETRY_KNOWN_TESTS_MS, {}, Date.now() - startTime)
|
|
248
|
-
|
|
249
250
|
const numTests = getNumFromKnownTests(aggregateTests)
|
|
250
251
|
|
|
252
|
+
// Request time includes transport retries and backoff, but excludes parsing and merging pages.
|
|
253
|
+
distributionMetric(TELEMETRY_KNOWN_TESTS_PAGES_FETCHED, {}, pageNumber)
|
|
254
|
+
distributionMetric(TELEMETRY_KNOWN_TESTS_TOTAL_FETCH_MS, {}, performance.now() - totalFetchStartTime)
|
|
255
|
+
distributionMetric(TELEMETRY_KNOWN_TESTS_TOTAL_REQUEST_MS, {}, totalRequestMs)
|
|
256
|
+
|
|
251
257
|
distributionMetric(TELEMETRY_KNOWN_TESTS_RESPONSE_TESTS, {}, numTests)
|
|
252
258
|
distributionMetric(TELEMETRY_KNOWN_TESTS_RESPONSE_BYTES, {}, totalResponseBytes)
|
|
253
259
|
|
|
@@ -27,6 +27,7 @@ const {
|
|
|
27
27
|
} = require('../requests/upload-test-screenshot')
|
|
28
28
|
const { parsers } = require('../../config/parsers')
|
|
29
29
|
const log = require('../../log')
|
|
30
|
+
const telemetry = require('../../telemetry')
|
|
30
31
|
const { getSegment } = require('../../util')
|
|
31
32
|
const BufferingExporter = require('../../exporters/common/buffering-exporter')
|
|
32
33
|
const { GIT_REPOSITORY_URL, GIT_COMMIT_SHA } = require('../../plugins/util/tags')
|
|
@@ -61,7 +62,7 @@ const SETTINGS_BOOLEAN_FIELDS = Object.freeze([
|
|
|
61
62
|
* the git repository or the runtime may not expose them.
|
|
62
63
|
*
|
|
63
64
|
* @typedef {{
|
|
64
|
-
* repositoryUrl?: string, sha?: string, branch?: string, tag?: string, testLevel?: string,
|
|
65
|
+
* repositoryUrl?: string, sha?: string, gitRoot?: string, branch?: string, tag?: string, testLevel?: string,
|
|
65
66
|
* osVersion?: string, osPlatform?: string, osArchitecture?: string,
|
|
66
67
|
* runtimeName?: string, runtimeVersion?: string, commitMessage?: string,
|
|
67
68
|
* pullRequestBaseSha?: string, commitHeadSha?: string, commitHeadMessage?: string,
|
|
@@ -211,7 +212,7 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
211
212
|
#deferredTestSuiteSpans = new Map()
|
|
212
213
|
#gitUploadTimeoutId
|
|
213
214
|
|
|
214
|
-
constructor (config
|
|
215
|
+
constructor (config) {
|
|
215
216
|
super(config)
|
|
216
217
|
this._timer = undefined
|
|
217
218
|
this._coverageTimer = undefined
|
|
@@ -222,8 +223,7 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
222
223
|
this._dynamicAtrEnabled = isDynamicAtrEnabled(dynamicAtrEnabled)
|
|
223
224
|
this._dynamicAtrBuckets = this._dynamicAtrEnabled ? getDynamicAtrBuckets(dynamicAtrBuckets) ?? undefined : undefined
|
|
224
225
|
this._hasRecordedDynamicAtrTelemetry = false
|
|
225
|
-
this._testOptimizationHttpCache =
|
|
226
|
-
this._isTestOptimizationCacheOnly = options.cacheOnly === true
|
|
226
|
+
this._testOptimizationHttpCache = new TestOptimizationHttpCache()
|
|
227
227
|
const coverageReportFlags = parsers.ARRAY(config?.testOptimization?.DD_CODE_COVERAGE_FLAGS)
|
|
228
228
|
if (coverageReportFlags?.length > MAX_COVERAGE_REPORT_FLAGS) {
|
|
229
229
|
log.warn(
|
|
@@ -264,7 +264,8 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
264
264
|
}
|
|
265
265
|
})
|
|
266
266
|
|
|
267
|
-
|
|
267
|
+
// Final upload errors are recorded after telemetry's initial app-closing drain.
|
|
268
|
+
globalThis[Symbol.for('dd-trace')].beforeExitHandlers.add(() => this.flush(() => telemetry.flush()))
|
|
268
269
|
}
|
|
269
270
|
|
|
270
271
|
shouldRequestSkippableSuites () {
|
|
@@ -325,12 +326,10 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
325
326
|
const { skippableSuites, correlationId, coverage } = cachedSkippableSuites
|
|
326
327
|
return callback(null, skippableSuites, correlationId, coverage)
|
|
327
328
|
}
|
|
328
|
-
if (this._isTestOptimizationCacheOnly) {
|
|
329
|
-
return callback(this._getCacheOnlyError('skippable tests'), [])
|
|
330
|
-
}
|
|
331
|
-
|
|
332
329
|
this._gitUploadPromise.then(gitUploadError => {
|
|
333
|
-
|
|
330
|
+
const isKnownCommitUnavailable = gitUploadError?.code === 'ERR_GIT_COMMIT_UNAVAILABLE' &&
|
|
331
|
+
this._libraryConfig?.requireGit === false
|
|
332
|
+
if (gitUploadError && !isKnownCommitUnavailable) {
|
|
334
333
|
return callback(gitUploadError, [])
|
|
335
334
|
}
|
|
336
335
|
getSkippableSuitesRequest(requestConfiguration, callback)
|
|
@@ -345,9 +344,6 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
345
344
|
if (cachedKnownTests !== CACHE_MISS) {
|
|
346
345
|
return callback(null, cachedKnownTests)
|
|
347
346
|
}
|
|
348
|
-
if (this._isTestOptimizationCacheOnly) {
|
|
349
|
-
return callback(this._getCacheOnlyError('known tests'))
|
|
350
|
-
}
|
|
351
347
|
getKnownTestsRequest(this.getRequestConfiguration(testConfiguration), callback)
|
|
352
348
|
}
|
|
353
349
|
|
|
@@ -359,9 +355,6 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
359
355
|
if (cachedTestManagementTests !== CACHE_MISS) {
|
|
360
356
|
return callback(null, cachedTestManagementTests)
|
|
361
357
|
}
|
|
362
|
-
if (this._isTestOptimizationCacheOnly) {
|
|
363
|
-
return callback(this._getCacheOnlyError('test management tests'))
|
|
364
|
-
}
|
|
365
358
|
getTestManagementTestsRequest(this.getRequestConfiguration(testConfiguration), callback)
|
|
366
359
|
}
|
|
367
360
|
|
|
@@ -385,10 +378,6 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
385
378
|
return this._applyCachedSettings(cachedLibraryConfig, configuration, repositoryUrl, false, callback)
|
|
386
379
|
}
|
|
387
380
|
|
|
388
|
-
if (this._isTestOptimizationCacheOnly) {
|
|
389
|
-
return callback(this._getCacheOnlyError('settings'), {})
|
|
390
|
-
}
|
|
391
|
-
|
|
392
381
|
// The settings request has a two-phase shape: when the backend returns
|
|
393
382
|
// `require_git`, we upload git metadata and re-request settings. Only the
|
|
394
383
|
// final (post-git-upload) configuration is cached, so the cross-process
|
|
@@ -469,7 +458,7 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
469
458
|
isCoverageReportUploadEnabled: configuration.isCoverageReportUploadEnabled,
|
|
470
459
|
})
|
|
471
460
|
if (!canUseCachedSkippableSuites && (this._libraryConfig.requireGit || isFilesystemCache)) {
|
|
472
|
-
this.sendGitMetadata(repositoryUrl)
|
|
461
|
+
this.sendGitMetadata(repositoryUrl, configuration.sha, configuration.gitRoot)
|
|
473
462
|
} else {
|
|
474
463
|
this._resolveGit()
|
|
475
464
|
}
|
|
@@ -487,7 +476,7 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
487
476
|
* @param {Function} done - Completion callback.
|
|
488
477
|
*/
|
|
489
478
|
_fetchLibraryConfigurationFromBackend (configuration, repositoryUrl, cacheKey, done) {
|
|
490
|
-
this.sendGitMetadata(repositoryUrl)
|
|
479
|
+
this.sendGitMetadata(repositoryUrl, configuration.sha, configuration.gitRoot)
|
|
491
480
|
getLibraryConfigurationRequest(configuration, (err, libraryConfig) => {
|
|
492
481
|
// Mirror the original live path: keep the phase-1 config on `_libraryConfig` even
|
|
493
482
|
// before the git upload resolves, so `shouldRequestSkippableSuites()` and the
|
|
@@ -521,17 +510,6 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
521
510
|
})
|
|
522
511
|
}
|
|
523
512
|
|
|
524
|
-
/**
|
|
525
|
-
* Returns the deterministic cache error for offline exporters.
|
|
526
|
-
*
|
|
527
|
-
* @param {string} input required cache input
|
|
528
|
-
* @returns {Error} cache error
|
|
529
|
-
*/
|
|
530
|
-
_getCacheOnlyError (input) {
|
|
531
|
-
return this._testOptimizationHttpCache.getLastError?.() ||
|
|
532
|
-
new Error(`Offline Test Optimization validation requires a valid ${input} cache fixture.`)
|
|
533
|
-
}
|
|
534
|
-
|
|
535
513
|
// Takes into account potential kill switches
|
|
536
514
|
filterConfiguration (remoteConfiguration = EMPTY_SETTINGS) {
|
|
537
515
|
const { testOptimization } = this._config
|
|
@@ -602,7 +580,7 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
602
580
|
}
|
|
603
581
|
}
|
|
604
582
|
|
|
605
|
-
sendGitMetadata (repositoryUrl) {
|
|
583
|
+
sendGitMetadata (repositoryUrl, sha, gitRoot = process.cwd()) {
|
|
606
584
|
if (!this._config.testOptimization.DD_CIVISIBILITY_GIT_UPLOAD_ENABLED) {
|
|
607
585
|
this._resolveGit()
|
|
608
586
|
return
|
|
@@ -624,12 +602,14 @@ class CiVisibilityExporter extends BufferingExporter {
|
|
|
624
602
|
repositoryUrl,
|
|
625
603
|
(err) => {
|
|
626
604
|
if (err) {
|
|
627
|
-
log.error('Error uploading git metadata
|
|
605
|
+
log.error('Error uploading git metadata', err)
|
|
628
606
|
} else {
|
|
629
607
|
log.debug('Successfully uploaded git metadata')
|
|
630
608
|
}
|
|
631
609
|
this._resolveGit(err)
|
|
632
|
-
}
|
|
610
|
+
},
|
|
611
|
+
sha,
|
|
612
|
+
gitRoot
|
|
633
613
|
)
|
|
634
614
|
})
|
|
635
615
|
}
|
|
@@ -10,6 +10,8 @@ const FormData = require('../../../exporters/common/form-data')
|
|
|
10
10
|
const request = require('../../../exporters/common/request')
|
|
11
11
|
|
|
12
12
|
const log = require('../../../log')
|
|
13
|
+
const { validateGitRepositoryUrl, validateGitCommitSha } = require('../../../plugins/util/user-provided-git')
|
|
14
|
+
const { filterSensitiveInfoFromRepository } = require('../../../plugins/util/url')
|
|
13
15
|
const { getSegment } = require('../../../util')
|
|
14
16
|
const {
|
|
15
17
|
getLatestCommits,
|
|
@@ -18,6 +20,7 @@ const {
|
|
|
18
20
|
getCommitsRevList,
|
|
19
21
|
isShallowRepository,
|
|
20
22
|
unshallowRepository,
|
|
23
|
+
fetchHeadCommitSha,
|
|
21
24
|
isGitAvailable,
|
|
22
25
|
} = require('../../../plugins/util/git')
|
|
23
26
|
|
|
@@ -35,7 +38,7 @@ const {
|
|
|
35
38
|
} = require('../../../ci-visibility/telemetry')
|
|
36
39
|
|
|
37
40
|
/** @typedef {{ isEvpProxy: boolean, evpProxyPrefix: string }} EvpProxyConfiguration */
|
|
38
|
-
/** @typedef {EvpProxyConfiguration & { url: URL, repositoryUrl: string }} GitUploadTarget */
|
|
41
|
+
/** @typedef {EvpProxyConfiguration & { url: URL, repositoryUrl: string, gitRoot?: string }} GitUploadTarget */
|
|
39
42
|
|
|
40
43
|
const isValidSha1 = (sha) => /^[0-9a-f]{40}$/.test(sha)
|
|
41
44
|
const isValidSha256 = (sha) => /^[0-9a-f]{64}$/.test(sha)
|
|
@@ -71,7 +74,7 @@ function getCommonRequestOptions (url) {
|
|
|
71
74
|
* @param {GitUploadTarget & { latestCommits: string[] }} options
|
|
72
75
|
* @param {(error: Error | null, commitsToUpload?: string[]) => void} callback
|
|
73
76
|
*/
|
|
74
|
-
function getCommitsToUpload ({ url, repositoryUrl, latestCommits, isEvpProxy, evpProxyPrefix }, callback) {
|
|
77
|
+
function getCommitsToUpload ({ url, repositoryUrl, latestCommits, isEvpProxy, evpProxyPrefix, gitRoot }, callback) {
|
|
75
78
|
const commonOptions = getCommonRequestOptions(url)
|
|
76
79
|
|
|
77
80
|
const options = {
|
|
@@ -123,7 +126,11 @@ function getCommitsToUpload ({ url, repositoryUrl, latestCommits, isEvpProxy, ev
|
|
|
123
126
|
return callback(null, [])
|
|
124
127
|
}
|
|
125
128
|
|
|
126
|
-
|
|
129
|
+
let commitsToUpload = getCommitsRevList(alreadySeenCommits, commitsToInclude, false, gitRoot)
|
|
130
|
+
// Partial clones may need promised trees; only hydrate them when recovery is enabled, with a bounded retry.
|
|
131
|
+
if (commitsToUpload === null && getConfig().testOptimization.DD_CIVISIBILITY_GIT_UNSHALLOW_ENABLED) {
|
|
132
|
+
commitsToUpload = getCommitsRevList(alreadySeenCommits, commitsToInclude, true, gitRoot)
|
|
133
|
+
}
|
|
127
134
|
|
|
128
135
|
if (commitsToUpload === null) {
|
|
129
136
|
return callback(new Error('git rev-list failed'))
|
|
@@ -207,10 +214,11 @@ function generateAndUploadPackFiles ({
|
|
|
207
214
|
commitsToUpload,
|
|
208
215
|
repositoryUrl,
|
|
209
216
|
headCommit,
|
|
217
|
+
gitRoot,
|
|
210
218
|
}, callback) {
|
|
211
219
|
log.debug('There are %s commits to upload', commitsToUpload.length)
|
|
212
220
|
|
|
213
|
-
const packFilesToUpload = generatePackFilesForCommits(commitsToUpload)
|
|
221
|
+
const packFilesToUpload = generatePackFilesForCommits(commitsToUpload, gitRoot)
|
|
214
222
|
|
|
215
223
|
log.debug('Uploading %s packfiles.', packFilesToUpload.length)
|
|
216
224
|
|
|
@@ -261,23 +269,40 @@ function generateAndUploadPackFiles ({
|
|
|
261
269
|
* @param {EvpProxyConfiguration} evpProxyConfiguration
|
|
262
270
|
* @param {string | undefined} configRepositoryUrl repository URL from the configuration, if set
|
|
263
271
|
* @param {(error?: Error | null) => void} callback
|
|
272
|
+
* @param {string=} configCommitSha
|
|
273
|
+
* @param {string=} gitRoot
|
|
264
274
|
*/
|
|
265
|
-
function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryUrl, callback
|
|
275
|
+
function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryUrl, callback,
|
|
276
|
+
configCommitSha, gitRoot = process.cwd()) {
|
|
266
277
|
if (!isGitAvailable()) {
|
|
267
278
|
return callback(new Error('Git is not available'))
|
|
268
279
|
}
|
|
269
280
|
let repositoryUrl = configRepositoryUrl
|
|
270
281
|
if (!repositoryUrl) {
|
|
271
|
-
repositoryUrl = getRepositoryUrl()
|
|
282
|
+
repositoryUrl = getRepositoryUrl(gitRoot)
|
|
272
283
|
}
|
|
273
284
|
|
|
285
|
+
repositoryUrl = filterSensitiveInfoFromRepository(repositoryUrl)
|
|
274
286
|
log.debug('Uploading git history for repository', repositoryUrl)
|
|
275
287
|
|
|
276
|
-
if (!repositoryUrl) {
|
|
288
|
+
if (!repositoryUrl || !validateGitRepositoryUrl(repositoryUrl)) {
|
|
277
289
|
return callback(new Error('Repository URL is empty'))
|
|
278
290
|
}
|
|
279
291
|
|
|
280
|
-
let latestCommits = getLatestCommits()
|
|
292
|
+
let latestCommits = getLatestCommits(configCommitSha, gitRoot)
|
|
293
|
+
let recoveredSelectedCommit = false
|
|
294
|
+
if (!latestCommits.length && getConfig().testOptimization.DD_CIVISIBILITY_GIT_UNSHALLOW_ENABLED &&
|
|
295
|
+
validateGitCommitSha(configCommitSha)) {
|
|
296
|
+
if (isShallowRepository(true, gitRoot)) unshallowRepository(false, configCommitSha, gitRoot)
|
|
297
|
+
else fetchHeadCommitSha(configCommitSha, false, gitRoot)
|
|
298
|
+
latestCommits = getLatestCommits(configCommitSha, gitRoot)
|
|
299
|
+
recoveredSelectedCommit = true
|
|
300
|
+
}
|
|
301
|
+
if (!latestCommits.length) {
|
|
302
|
+
return callback(Object.assign(new Error('Selected Git commit is unavailable'), {
|
|
303
|
+
code: 'ERR_GIT_COMMIT_UNAVAILABLE',
|
|
304
|
+
}))
|
|
305
|
+
}
|
|
281
306
|
log.debug('There were %s commits since last month.', latestCommits.length)
|
|
282
307
|
|
|
283
308
|
const getOnFinishGetCommitsToUpload = (hasCheckedShallow) => (err, commitsToUpload) => {
|
|
@@ -291,8 +316,8 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
|
|
|
291
316
|
}
|
|
292
317
|
|
|
293
318
|
// If it has already unshallowed or the clone is not shallow, we move on
|
|
294
|
-
if (hasCheckedShallow || !isShallowRepository()) {
|
|
295
|
-
const
|
|
319
|
+
if (hasCheckedShallow || !isShallowRepository(false, gitRoot)) {
|
|
320
|
+
const headCommit = configCommitSha || latestCommits[0]
|
|
296
321
|
return generateAndUploadPackFiles({
|
|
297
322
|
url,
|
|
298
323
|
isEvpProxy,
|
|
@@ -300,22 +325,24 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
|
|
|
300
325
|
commitsToUpload,
|
|
301
326
|
repositoryUrl,
|
|
302
327
|
headCommit,
|
|
328
|
+
gitRoot,
|
|
303
329
|
}, callback)
|
|
304
330
|
}
|
|
305
331
|
// Otherwise we unshallow and get commits to upload again
|
|
306
332
|
log.debug('It is shallow clone, unshallowing...')
|
|
307
333
|
if (getConfig().testOptimization.DD_CIVISIBILITY_GIT_UNSHALLOW_ENABLED) {
|
|
308
|
-
unshallowRepository(false)
|
|
334
|
+
unshallowRepository(false, configCommitSha, gitRoot)
|
|
309
335
|
}
|
|
310
336
|
|
|
311
337
|
// The latest commits change after unshallowing
|
|
312
|
-
latestCommits = getLatestCommits()
|
|
338
|
+
latestCommits = getLatestCommits(configCommitSha, gitRoot)
|
|
313
339
|
getCommitsToUpload({
|
|
314
340
|
url,
|
|
315
341
|
repositoryUrl,
|
|
316
342
|
latestCommits,
|
|
317
343
|
isEvpProxy,
|
|
318
344
|
evpProxyPrefix,
|
|
345
|
+
gitRoot,
|
|
319
346
|
}, getOnFinishGetCommitsToUpload(true))
|
|
320
347
|
}
|
|
321
348
|
|
|
@@ -325,7 +352,8 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
|
|
|
325
352
|
latestCommits,
|
|
326
353
|
isEvpProxy,
|
|
327
354
|
evpProxyPrefix,
|
|
328
|
-
|
|
355
|
+
gitRoot,
|
|
356
|
+
}, getOnFinishGetCommitsToUpload(recoveredSelectedCommit))
|
|
329
357
|
}
|
|
330
358
|
|
|
331
359
|
module.exports = {
|
|
@@ -430,13 +430,12 @@ function requestBuffered (data, options, callback, reservedPayloadSize) {
|
|
|
430
430
|
(attemptTimedOut || isRetriableNetworkError(error) || isUnknownNetworkError ||
|
|
431
431
|
isRetriableHttpStatusCode(responseStatus))
|
|
432
432
|
const retryUntilDeadline = options.deadline !== undefined && options.retryUntilDeadline !== false
|
|
433
|
-
const reachedAttemptLimit = !retryUntilDeadline && attemptIndex >= getMaxAttempts(attemptOptions)
|
|
434
433
|
const reachedUnknownNetworkAttemptLimit = isUnknownNetworkError && attemptIndex >= 2
|
|
435
434
|
if (
|
|
436
435
|
options.retry === false ||
|
|
437
436
|
!isRetriableError ||
|
|
438
|
-
|
|
439
|
-
|
|
437
|
+
reachedUnknownNetworkAttemptLimit ||
|
|
438
|
+
(!retryUntilDeadline && attemptIndex >= getMaxAttempts(attemptOptions))
|
|
440
439
|
) {
|
|
441
440
|
complete(requestError, result, statusCode, headers)
|
|
442
441
|
return
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const getConfig = require('../../config')
|
|
4
|
-
const { EVP_SUBDOMAIN_HEADER_NAME } = require('../../evp_proxy/constants')
|
|
5
|
-
const { joinEVPProxyPath } = require('../../evp_proxy/path')
|
|
6
4
|
const log = require('../../log')
|
|
7
5
|
const {
|
|
8
6
|
incrementCountMetric,
|
|
@@ -15,6 +13,7 @@ const {
|
|
|
15
13
|
TELEMETRY_ITR_SKIPPABLE_TESTS_RESPONSE_BYTES,
|
|
16
14
|
} = require('../../ci-visibility/telemetry')
|
|
17
15
|
const request = require('../requests/request')
|
|
16
|
+
const { createApiRequestRoute } = require('../requests/route')
|
|
18
17
|
const { buildCacheKey, writeToCache, withCache } = require('../requests/fs-cache')
|
|
19
18
|
const { validateSkippableTestsResponse } = require('../test-optimization-http-cache-schema')
|
|
20
19
|
|
|
@@ -29,12 +28,11 @@ function parseSkippableSuitesResponse (
|
|
|
29
28
|
isCoverageReportUploadEnabled = false,
|
|
30
29
|
isLineCoverageSupported = true,
|
|
31
30
|
validateRequiredFields = false,
|
|
32
|
-
validationMode = false,
|
|
33
31
|
} = {}
|
|
34
32
|
) {
|
|
35
33
|
const parsedResponse = parseJsonResponse(rawJson)
|
|
36
34
|
if (validateRequiredFields) {
|
|
37
|
-
validateSkippableTestsResponse(parsedResponse
|
|
35
|
+
validateSkippableTestsResponse(parsedResponse)
|
|
38
36
|
}
|
|
39
37
|
let coverage
|
|
40
38
|
const coverageByFilename = parsedResponse.meta?.coverage
|
|
@@ -213,32 +211,26 @@ function fetchFromApi ({
|
|
|
213
211
|
isLineCoverageSupported,
|
|
214
212
|
cacheKey,
|
|
215
213
|
}, done) {
|
|
214
|
+
const path = '/api/v2/ci/tests/skippable'
|
|
215
|
+
const route = createApiRequestRoute(getConfig(), { url, path, isEvpProxy, evpProxyPrefix })
|
|
216
|
+
if (!route) {
|
|
217
|
+
return done(new Error('Skippable suites were not fetched because Datadog API key is not defined.'))
|
|
218
|
+
}
|
|
219
|
+
|
|
216
220
|
const options = {
|
|
217
|
-
|
|
221
|
+
...route,
|
|
218
222
|
method: 'POST',
|
|
219
223
|
headers: {
|
|
224
|
+
...route.headers,
|
|
220
225
|
'Content-Type': 'application/json',
|
|
221
226
|
},
|
|
222
227
|
timeout: 20_000,
|
|
223
|
-
url,
|
|
224
228
|
}
|
|
225
229
|
|
|
226
230
|
if (isGzipCompatible) {
|
|
227
231
|
options.headers['accept-encoding'] = 'gzip'
|
|
228
232
|
}
|
|
229
233
|
|
|
230
|
-
if (isEvpProxy) {
|
|
231
|
-
options.path = joinEVPProxyPath(evpProxyPrefix, '/api/v2/ci/tests/skippable')
|
|
232
|
-
options.headers[EVP_SUBDOMAIN_HEADER_NAME] = 'api'
|
|
233
|
-
} else {
|
|
234
|
-
const { DD_API_KEY } = getConfig()
|
|
235
|
-
if (!DD_API_KEY) {
|
|
236
|
-
return done(new Error('Skippable suites were not fetched because Datadog API key is not defined.'))
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
options.headers['dd-api-key'] = DD_API_KEY
|
|
240
|
-
}
|
|
241
|
-
|
|
242
234
|
const data = JSON.stringify({
|
|
243
235
|
data: {
|
|
244
236
|
type: 'test_params',
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const getConfig = require('../../config')
|
|
4
|
-
const { EVP_SUBDOMAIN_HEADER_NAME } = require('../../evp_proxy/constants')
|
|
5
|
-
const { joinEVPProxyPath } = require('../../evp_proxy/path')
|
|
6
4
|
const id = require('../../id')
|
|
7
5
|
const log = require('../../log')
|
|
8
6
|
const { EARLY_FLAKE_DETECTION_RETRY_BUCKETS, createEfdRetryPolicy } = require('../efd-retry-policy')
|
|
@@ -16,6 +14,7 @@ const {
|
|
|
16
14
|
} = require('../telemetry')
|
|
17
15
|
const { MAX_RETRIES, validateSettingsResponse } = require('../test-optimization-http-cache-schema')
|
|
18
16
|
const request = require('./request')
|
|
17
|
+
const { createApiRequestRoute } = require('./route')
|
|
19
18
|
|
|
20
19
|
const DEFAULT_EARLY_FLAKE_DETECTION_SLOW_TEST_RETRIES = Object.freeze({
|
|
21
20
|
'5s': 10,
|
|
@@ -156,7 +155,7 @@ function parseJsonResponse (rawJson) {
|
|
|
156
155
|
function parseLibraryConfigurationResponse (rawJson, config = getConfig(), options = {}) {
|
|
157
156
|
const parsedResponse = parseJsonResponse(rawJson)
|
|
158
157
|
if (options.validateRequiredFields) {
|
|
159
|
-
validateSettingsResponse(parsedResponse
|
|
158
|
+
validateSettingsResponse(parsedResponse)
|
|
160
159
|
}
|
|
161
160
|
const parsedAttributes = parsedResponse?.data?.attributes ?? parsedResponse
|
|
162
161
|
if (!isRecord(parsedAttributes)) {
|
|
@@ -228,26 +227,22 @@ function getLibraryConfiguration ({
|
|
|
228
227
|
tag,
|
|
229
228
|
}, done) {
|
|
230
229
|
const config = getConfig()
|
|
230
|
+
const path = '/api/v2/libraries/tests/services/setting'
|
|
231
|
+
const route = createApiRequestRoute(config, { url, path, isEvpProxy, evpProxyPrefix })
|
|
232
|
+
if (!route) {
|
|
233
|
+
return done(new Error('Request to settings endpoint was not done because Datadog API key is not defined.'))
|
|
234
|
+
}
|
|
235
|
+
|
|
231
236
|
const options = {
|
|
232
|
-
|
|
237
|
+
...route,
|
|
233
238
|
method: 'POST',
|
|
234
239
|
headers: {
|
|
240
|
+
...route.headers,
|
|
235
241
|
'Content-Type': 'application/json',
|
|
236
242
|
},
|
|
237
|
-
url,
|
|
238
243
|
timeout: 20_000,
|
|
239
244
|
}
|
|
240
245
|
|
|
241
|
-
if (isEvpProxy) {
|
|
242
|
-
options.path = joinEVPProxyPath(evpProxyPrefix, '/api/v2/libraries/tests/services/setting')
|
|
243
|
-
options.headers[EVP_SUBDOMAIN_HEADER_NAME] = 'api'
|
|
244
|
-
} else {
|
|
245
|
-
if (!config.DD_API_KEY) {
|
|
246
|
-
return done(new Error('Request to settings endpoint was not done because Datadog API key is not defined.'))
|
|
247
|
-
}
|
|
248
|
-
options.headers['dd-api-key'] = config.DD_API_KEY
|
|
249
|
-
}
|
|
250
|
-
|
|
251
246
|
const data = JSON.stringify({
|
|
252
247
|
data: {
|
|
253
248
|
id: id().toString(10),
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { EVP_SUBDOMAIN_HEADER_NAME } = require('../../evp_proxy/constants')
|
|
4
|
+
const { joinEVPProxyPath } = require('../../evp_proxy/path')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {object} ApiRequestRouteOptions
|
|
8
|
+
* @property {URL} url
|
|
9
|
+
* @property {string} path
|
|
10
|
+
* @property {boolean} isEvpProxy
|
|
11
|
+
* @property {string} evpProxyPrefix
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {object} ApiRequestRoute
|
|
16
|
+
* @property {URL} url
|
|
17
|
+
* @property {string} path
|
|
18
|
+
* @property {Record<string, string>} headers
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {import('../../config/config-base')} config
|
|
23
|
+
* @param {ApiRequestRouteOptions} options
|
|
24
|
+
* @returns {ApiRequestRoute|undefined}
|
|
25
|
+
*/
|
|
26
|
+
function createApiRequestRoute (config, { url, path, isEvpProxy, evpProxyPrefix }) {
|
|
27
|
+
if (isEvpProxy) {
|
|
28
|
+
return {
|
|
29
|
+
url,
|
|
30
|
+
path: joinEVPProxyPath(evpProxyPrefix, path),
|
|
31
|
+
headers: { [EVP_SUBDOMAIN_HEADER_NAME]: 'api' },
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (config.DD_API_KEY === undefined) return
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
url,
|
|
39
|
+
path,
|
|
40
|
+
headers: { 'dd-api-key': config.DD_API_KEY },
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = { createApiRequestRoute }
|