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
|
@@ -30,6 +30,8 @@ const {
|
|
|
30
30
|
GIT_BRANCH,
|
|
31
31
|
GIT_COMMIT_SHA,
|
|
32
32
|
GIT_REPOSITORY_URL,
|
|
33
|
+
GIT_CHECKOUT_ROOT,
|
|
34
|
+
GIT_CHECKOUT_IS_CUSTOM,
|
|
33
35
|
GIT_TAG,
|
|
34
36
|
GIT_COMMIT_AUTHOR_DATE,
|
|
35
37
|
GIT_COMMIT_AUTHOR_EMAIL,
|
|
@@ -46,6 +48,7 @@ const {
|
|
|
46
48
|
GIT_COMMIT_HEAD_COMMITTER_NAME,
|
|
47
49
|
GIT_COMMIT_HEAD_MESSAGE,
|
|
48
50
|
CI_WORKSPACE_PATH,
|
|
51
|
+
CI_GIT_MERGE_COMMIT_SHA,
|
|
49
52
|
CI_PIPELINE_ID,
|
|
50
53
|
CI_PIPELINE_NAME,
|
|
51
54
|
CI_PIPELINE_DISPLAY_NAME,
|
|
@@ -75,6 +78,7 @@ const {
|
|
|
75
78
|
getLocalBranches,
|
|
76
79
|
getMergeBase,
|
|
77
80
|
getCounts,
|
|
81
|
+
hasLocalGitObject,
|
|
78
82
|
} = require('./git')
|
|
79
83
|
|
|
80
84
|
/**
|
|
@@ -269,6 +273,9 @@ const TEST_LEVELS_METADATA_TAGS = [
|
|
|
269
273
|
CI_PROVIDER_NAME,
|
|
270
274
|
CI_STAGE_NAME,
|
|
271
275
|
CI_WORKSPACE_PATH,
|
|
276
|
+
CI_GIT_MERGE_COMMIT_SHA,
|
|
277
|
+
GIT_CHECKOUT_ROOT,
|
|
278
|
+
GIT_CHECKOUT_IS_CUSTOM,
|
|
272
279
|
GIT_BRANCH,
|
|
273
280
|
GIT_COMMIT_AUTHOR_DATE,
|
|
274
281
|
GIT_COMMIT_AUTHOR_EMAIL,
|
|
@@ -310,6 +317,8 @@ const DI_DEBUG_ERROR_LINE_SUFFIX = 'line'
|
|
|
310
317
|
|
|
311
318
|
// Test Management tags
|
|
312
319
|
const TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX = 'test.test_management.is_attempt_to_fix'
|
|
320
|
+
const TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION = 'test.test_management.prevent_failure_suppression'
|
|
321
|
+
const TEST_MANAGEMENT_NO_AUTO_RETRY = 'test.test_management.no_auto_retry'
|
|
313
322
|
const TEST_MANAGEMENT_IS_DISABLED = 'test.test_management.is_test_disabled'
|
|
314
323
|
const TEST_MANAGEMENT_IS_QUARANTINED = 'test.test_management.is_quarantined'
|
|
315
324
|
const TEST_MANAGEMENT_ENABLED = 'test.test_management.enabled'
|
|
@@ -591,6 +600,8 @@ module.exports = {
|
|
|
591
600
|
DD_TEST_IS_USER_PROVIDED_SERVICE,
|
|
592
601
|
TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX,
|
|
593
602
|
TEST_MANAGEMENT_IS_DISABLED,
|
|
603
|
+
TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION,
|
|
604
|
+
TEST_MANAGEMENT_NO_AUTO_RETRY,
|
|
594
605
|
TEST_MANAGEMENT_IS_QUARANTINED,
|
|
595
606
|
TEST_MANAGEMENT_ENABLED,
|
|
596
607
|
TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED,
|
|
@@ -652,8 +663,8 @@ function removeInvalidMetadata (metadata) {
|
|
|
652
663
|
log.error('Repository URL is not a valid repository URL: %s.', metadata[GIT_REPOSITORY_URL])
|
|
653
664
|
return filteredTags
|
|
654
665
|
}
|
|
655
|
-
if (tag === GIT_COMMIT_SHA && !validateGitCommitSha(metadata[
|
|
656
|
-
log.error('Git commit SHA must be a full-length git SHA: %s.', metadata[
|
|
666
|
+
if ((tag === GIT_COMMIT_SHA || tag === CI_GIT_MERGE_COMMIT_SHA) && !validateGitCommitSha(metadata[tag])) {
|
|
667
|
+
log.error('Git commit SHA must be a full-length git SHA: %s.', metadata[tag])
|
|
657
668
|
return filteredTags
|
|
658
669
|
}
|
|
659
670
|
if (tag === CI_PIPELINE_URL && !validateUrl(metadata[CI_PIPELINE_URL])) {
|
|
@@ -732,15 +743,15 @@ function checkShaDiscrepancies (ciMetadata, userProvidedGitMetadata) {
|
|
|
732
743
|
v1: ciRepositoryUrl,
|
|
733
744
|
v2: gitRepositoryUrl,
|
|
734
745
|
type: 'repository_discrepancy',
|
|
735
|
-
expected: '
|
|
736
|
-
discrepant: '
|
|
746
|
+
expected: 'git_client',
|
|
747
|
+
discrepant: 'ci_provider',
|
|
737
748
|
},
|
|
738
749
|
{
|
|
739
750
|
v1: ciCommitSHA,
|
|
740
751
|
v2: gitCommitSHA,
|
|
741
752
|
type: 'commit_discrepancy',
|
|
742
|
-
expected: '
|
|
743
|
-
discrepant: '
|
|
753
|
+
expected: 'git_client',
|
|
754
|
+
discrepant: 'ci_provider',
|
|
744
755
|
},
|
|
745
756
|
]
|
|
746
757
|
|
|
@@ -778,32 +789,36 @@ function getTestEnvironmentMetadata (testFramework, config, shouldSkipGitMetadat
|
|
|
778
789
|
if (!shouldSkipGitMetadataExtraction) {
|
|
779
790
|
checkShaDiscrepancies(ciMetadata, userProvidedGitMetadata)
|
|
780
791
|
|
|
781
|
-
const {
|
|
782
|
-
[GIT_COMMIT_SHA]: commitSHA,
|
|
783
|
-
[GIT_BRANCH]: branch,
|
|
784
|
-
[GIT_REPOSITORY_URL]: repositoryUrl,
|
|
785
|
-
[GIT_TAG]: tag,
|
|
786
|
-
[GIT_COMMIT_AUTHOR_NAME]: authorName,
|
|
787
|
-
[GIT_COMMIT_AUTHOR_EMAIL]: authorEmail,
|
|
788
|
-
[GIT_COMMIT_MESSAGE]: commitMessage,
|
|
789
|
-
[CI_WORKSPACE_PATH]: ciWorkspacePath,
|
|
790
|
-
[GIT_COMMIT_HEAD_SHA]: headCommitSha,
|
|
791
|
-
} = ciMetadata
|
|
792
792
|
gitMetadata = getGitMetadata({
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
repositoryUrl,
|
|
796
|
-
tag,
|
|
797
|
-
authorName,
|
|
798
|
-
authorEmail,
|
|
799
|
-
commitMessage,
|
|
800
|
-
ciWorkspacePath,
|
|
801
|
-
headCommitSha,
|
|
793
|
+
ciWorkspacePath: ciMetadata[CI_WORKSPACE_PATH],
|
|
794
|
+
headCommitSha: ciMetadata[GIT_COMMIT_HEAD_SHA],
|
|
802
795
|
pullRequestBaseBranchSha: userProvidedGitMetadata[GIT_PULL_REQUEST_BASE_BRANCH_SHA] ||
|
|
803
796
|
ciMetadata[GIT_PULL_REQUEST_BASE_BRANCH_SHA],
|
|
804
797
|
})
|
|
805
798
|
}
|
|
806
799
|
|
|
800
|
+
let providerMetadata = ciMetadata
|
|
801
|
+
if (gitMetadata[GIT_COMMIT_SHA]) {
|
|
802
|
+
providerMetadata = {}
|
|
803
|
+
// Preserve workflow and PR relationships separately from the selected checkout metadata.
|
|
804
|
+
for (const key of Object.keys(ciMetadata)) {
|
|
805
|
+
const isPullRequestMetadata = key.startsWith('git.commit.head.') || key.startsWith('git.pull_request.')
|
|
806
|
+
if (!key.startsWith('git.') || isPullRequestMetadata) {
|
|
807
|
+
providerMetadata[key] = ciMetadata[key]
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
const isMatchingDetachedCheckout = ciMetadata[CI_WORKSPACE_PATH] && gitMetadata[GIT_CHECKOUT_ROOT] &&
|
|
811
|
+
gitMetadata[GIT_CHECKOUT_IS_CUSTOM] !== 'true' && !gitMetadata[GIT_BRANCH] &&
|
|
812
|
+
(gitMetadata[GIT_COMMIT_SHA] === ciMetadata[GIT_COMMIT_SHA] ||
|
|
813
|
+
gitMetadata[GIT_COMMIT_SHA] === ciMetadata[CI_GIT_MERGE_COMMIT_SHA])
|
|
814
|
+
if (isMatchingDetachedCheckout) {
|
|
815
|
+
// A detached CI checkout can use a mirror remote; CI supplies its branch, tag and canonical repository identity.
|
|
816
|
+
for (const key of [GIT_BRANCH, GIT_TAG, GIT_REPOSITORY_URL]) {
|
|
817
|
+
if (ciMetadata[key]) providerMetadata[key] = ciMetadata[key]
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
807
822
|
/** @type {TestEnvironmentMetadata} */
|
|
808
823
|
const runtimeAndOSMetadata = getRuntimeAndOSMetadata()
|
|
809
824
|
|
|
@@ -811,10 +826,22 @@ function getTestEnvironmentMetadata (testFramework, config, shouldSkipGitMetadat
|
|
|
811
826
|
[TEST_FRAMEWORK]: testFramework,
|
|
812
827
|
[DD_TEST_IS_USER_PROVIDED_SERVICE]: (config && config.isServiceUserProvided) ? 'true' : 'false',
|
|
813
828
|
...gitMetadata,
|
|
814
|
-
...
|
|
829
|
+
...providerMetadata,
|
|
815
830
|
...userProvidedGitMetadata,
|
|
816
831
|
...runtimeAndOSMetadata,
|
|
817
832
|
}
|
|
833
|
+
const explicitSha = userProvidedGitMetadata[GIT_COMMIT_SHA]
|
|
834
|
+
if (explicitSha && explicitSha !== (gitMetadata[GIT_COMMIT_SHA] || ciMetadata[GIT_COMMIT_SHA])) {
|
|
835
|
+
// The checkout's author, message and tag must not describe a different user-selected commit.
|
|
836
|
+
for (const key of Object.keys(metadata)) {
|
|
837
|
+
if ((key === GIT_TAG || (key.startsWith('git.commit.') && key !== GIT_COMMIT_SHA &&
|
|
838
|
+
!key.startsWith('git.commit.head.'))) &&
|
|
839
|
+
// eslint-disable-next-line prefer-object-has-own -- Cypress 6's plugin process runs on Node 12.
|
|
840
|
+
!Object.prototype.hasOwnProperty.call(userProvidedGitMetadata, key)) {
|
|
841
|
+
delete metadata[key]
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
818
845
|
if (/^(true|1)$/i.test(getEnvironmentVariable('_DD_TEST_PARALLELIZATION_ENABLED'))) {
|
|
819
846
|
metadata[TEST_PARALLELIZATION_ENABLED] = 'true'
|
|
820
847
|
Object.assign(metadata, getTestParallelizationPlanMetadata())
|
|
@@ -1964,23 +1991,25 @@ function getLibraryCapabilitiesTags (testFramework, frameworkVersion, options =
|
|
|
1964
1991
|
}
|
|
1965
1992
|
}
|
|
1966
1993
|
|
|
1967
|
-
function getPullRequestBaseBranch (pullRequestBaseBranch) {
|
|
1968
|
-
const remoteName = getGitRemoteName()
|
|
1994
|
+
function getPullRequestBaseBranch (pullRequestBaseBranch, gitRoot) {
|
|
1995
|
+
const remoteName = getGitRemoteName(gitRoot)
|
|
1969
1996
|
|
|
1970
|
-
const sourceBranch = getSourceBranch()
|
|
1997
|
+
const sourceBranch = getSourceBranch(gitRoot)
|
|
1971
1998
|
// TODO: We will get the default branch name from the backend in the future.
|
|
1972
1999
|
const POSSIBLE_DEFAULT_BRANCHES = ['main', 'master']
|
|
1973
2000
|
|
|
1974
2001
|
const candidateBranches = []
|
|
1975
2002
|
if (pullRequestBaseBranch) {
|
|
1976
|
-
checkAndFetchBranch(pullRequestBaseBranch, remoteName)
|
|
1977
|
-
candidateBranches.push(pullRequestBaseBranch)
|
|
2003
|
+
checkAndFetchBranch(pullRequestBaseBranch, remoteName, gitRoot)
|
|
2004
|
+
candidateBranches.push(hasLocalGitObject(pullRequestBaseBranch, gitRoot)
|
|
2005
|
+
? pullRequestBaseBranch
|
|
2006
|
+
: `${remoteName}/${pullRequestBaseBranch}`)
|
|
1978
2007
|
} else {
|
|
1979
2008
|
for (const branch of POSSIBLE_BASE_BRANCHES) {
|
|
1980
|
-
checkAndFetchBranch(branch, remoteName)
|
|
2009
|
+
checkAndFetchBranch(branch, remoteName, gitRoot)
|
|
1981
2010
|
}
|
|
1982
2011
|
|
|
1983
|
-
const localBranches = getLocalBranches(remoteName)
|
|
2012
|
+
const localBranches = getLocalBranches(remoteName, gitRoot)
|
|
1984
2013
|
for (const branch of localBranches) {
|
|
1985
2014
|
const shortBranchName = branch.replace(new RegExp(`^${remoteName}/`), '')
|
|
1986
2015
|
if (branch !== sourceBranch && BASE_LIKE_BRANCH_FILTER.test(shortBranchName)) {
|
|
@@ -1990,19 +2019,19 @@ function getPullRequestBaseBranch (pullRequestBaseBranch) {
|
|
|
1990
2019
|
}
|
|
1991
2020
|
|
|
1992
2021
|
if (candidateBranches.length === 1) {
|
|
1993
|
-
return getMergeBase(candidateBranches[0], sourceBranch)
|
|
2022
|
+
return getMergeBase(candidateBranches[0], sourceBranch, gitRoot)
|
|
1994
2023
|
}
|
|
1995
2024
|
|
|
1996
2025
|
const metrics = {}
|
|
1997
2026
|
let hasMetrics = false
|
|
1998
2027
|
for (const candidate of candidateBranches) {
|
|
1999
2028
|
// Find common ancestor
|
|
2000
|
-
const baseSha = getMergeBase(candidate, sourceBranch)
|
|
2029
|
+
const baseSha = getMergeBase(candidate, sourceBranch, gitRoot)
|
|
2001
2030
|
if (!baseSha) {
|
|
2002
2031
|
continue
|
|
2003
2032
|
}
|
|
2004
2033
|
// Count commits ahead/behind
|
|
2005
|
-
const counts = getCounts(candidate, sourceBranch)
|
|
2034
|
+
const counts = getCounts(candidate, sourceBranch, gitRoot)
|
|
2006
2035
|
if (!counts) {
|
|
2007
2036
|
continue
|
|
2008
2037
|
}
|
|
@@ -2038,11 +2067,11 @@ function getPullRequestBaseBranch (pullRequestBaseBranch) {
|
|
|
2038
2067
|
return bestBranch ? metrics[bestBranch].baseSha : null
|
|
2039
2068
|
}
|
|
2040
2069
|
|
|
2041
|
-
function getPullRequestDiff (baseCommit, targetCommit) {
|
|
2070
|
+
function getPullRequestDiff (baseCommit, targetCommit, gitRoot) {
|
|
2042
2071
|
if (!baseCommit) {
|
|
2043
2072
|
return
|
|
2044
2073
|
}
|
|
2045
|
-
return getGitDiff(baseCommit, targetCommit)
|
|
2074
|
+
return getGitDiff(baseCommit, targetCommit, gitRoot)
|
|
2046
2075
|
}
|
|
2047
2076
|
|
|
2048
2077
|
function getModifiedFilesFromDiff (diff) {
|
|
@@ -2343,14 +2372,17 @@ function collectDynamicNameFromTraceSpan (span, newTestsWithDynamicNames) {
|
|
|
2343
2372
|
|
|
2344
2373
|
function collectAttemptToFixExecutionFromTraceSpan (span, attemptToFixExecutions) {
|
|
2345
2374
|
const meta = span.meta
|
|
2346
|
-
if (meta?.[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] !== 'true'
|
|
2375
|
+
if (meta?.[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] !== 'true' ||
|
|
2376
|
+
meta[TEST_MANAGEMENT_NO_AUTO_RETRY] === 'true') return
|
|
2347
2377
|
|
|
2348
2378
|
recordAttemptToFixExecution(attemptToFixExecutions, {
|
|
2349
2379
|
testSuite: meta[TEST_SUITE],
|
|
2350
2380
|
testName: meta[TEST_NAME],
|
|
2351
2381
|
status: meta[TEST_STATUS],
|
|
2352
|
-
isDisabled: meta[TEST_MANAGEMENT_IS_DISABLED] === 'true'
|
|
2353
|
-
|
|
2382
|
+
isDisabled: meta[TEST_MANAGEMENT_IS_DISABLED] === 'true' &&
|
|
2383
|
+
meta[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] !== 'true',
|
|
2384
|
+
isQuarantined: meta[TEST_MANAGEMENT_IS_QUARANTINED] === 'true' &&
|
|
2385
|
+
meta[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] !== 'true',
|
|
2354
2386
|
})
|
|
2355
2387
|
}
|
|
2356
2388
|
|
|
@@ -2368,9 +2400,12 @@ function collectTestManagementExecutionFromTraceSpan (span, executions) {
|
|
|
2368
2400
|
testSuite: meta[TEST_SUITE],
|
|
2369
2401
|
testName: meta[TEST_NAME],
|
|
2370
2402
|
status: meta[TEST_STATUS],
|
|
2371
|
-
isAttemptToFix: meta[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] === 'true'
|
|
2372
|
-
|
|
2373
|
-
|
|
2403
|
+
isAttemptToFix: meta[TEST_MANAGEMENT_IS_ATTEMPT_TO_FIX] === 'true' &&
|
|
2404
|
+
meta[TEST_MANAGEMENT_NO_AUTO_RETRY] !== 'true',
|
|
2405
|
+
isDisabled: meta[TEST_MANAGEMENT_IS_DISABLED] === 'true' &&
|
|
2406
|
+
meta[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] !== 'true',
|
|
2407
|
+
isQuarantined: meta[TEST_MANAGEMENT_IS_QUARANTINED] === 'true' &&
|
|
2408
|
+
meta[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] !== 'true',
|
|
2374
2409
|
}, executions)
|
|
2375
2410
|
}
|
|
2376
2411
|
|
|
@@ -2381,6 +2416,7 @@ function collectTestManagementExecutionFromTraceSpan (span, executions) {
|
|
|
2381
2416
|
* @param {string} data - JSON-serialized traces from a worker
|
|
2382
2417
|
* @param {{
|
|
2383
2418
|
* newTestsWithDynamicNames?: Set<string>,
|
|
2419
|
+
* testAnnotations?: Map<string, { mustFail: boolean, noAutoRetry: boolean }>,
|
|
2384
2420
|
* attemptToFixExecutions?: AttemptToFixExecutions,
|
|
2385
2421
|
* testManagementExecutions?: TestManagementExecutions
|
|
2386
2422
|
* }} summaries
|
|
@@ -2390,12 +2426,21 @@ function collectTestOptimizationSummariesFromTraces (data, summaries) {
|
|
|
2390
2426
|
newTestsWithDynamicNames,
|
|
2391
2427
|
attemptToFixExecutions,
|
|
2392
2428
|
testManagementExecutions: executions = testManagementExecutions,
|
|
2429
|
+
testAnnotations,
|
|
2393
2430
|
} = summaries
|
|
2394
2431
|
|
|
2395
2432
|
try {
|
|
2396
2433
|
const traces = JSON.parse(data)
|
|
2397
2434
|
for (const trace of traces) {
|
|
2398
2435
|
for (const span of trace) {
|
|
2436
|
+
if (testAnnotations && span.type === 'test' &&
|
|
2437
|
+
(span.meta?.[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] === 'true' ||
|
|
2438
|
+
span.meta?.[TEST_MANAGEMENT_NO_AUTO_RETRY] === 'true')) {
|
|
2439
|
+
testAnnotations.set(`${span.meta[TEST_SUITE]} › ${span.meta[TEST_NAME]}`, {
|
|
2440
|
+
mustFail: span.meta[TEST_MANAGEMENT_PREVENT_FAILURE_SUPPRESSION] === 'true',
|
|
2441
|
+
noAutoRetry: span.meta[TEST_MANAGEMENT_NO_AUTO_RETRY] === 'true',
|
|
2442
|
+
})
|
|
2443
|
+
}
|
|
2399
2444
|
if (newTestsWithDynamicNames) {
|
|
2400
2445
|
collectDynamicNameFromTraceSpan(span, newTestsWithDynamicNames)
|
|
2401
2446
|
}
|
|
@@ -16,6 +16,8 @@ const INT_ID_SEGMENT = /^(?=.*[0-9])[0-9._-]{3,}$/ // Mixed string with digits a
|
|
|
16
16
|
const HEX_SEGMENT = /^(?=.*[0-9])[A-Fa-f0-9]{6,}$/ // Hexadecimal digits of size at least 6 with at least one decimal digit
|
|
17
17
|
const HEX_ID_SEGMENT = /^(?=.*[0-9])[A-Fa-f0-9._-]{6,}$/ // Mixed string with hex digits and delimiters
|
|
18
18
|
const SPECIAL_CHARACTER_SEGMENT = /[%&'()*+,:=@]/
|
|
19
|
+
const SCP_STYLE_REPOSITORY_URL = /^(?:[^@/:\s\\]+@)?(?:\[[^@\]/\s\\]+\]|[^@/:\s\\]+):.+$/
|
|
20
|
+
const REPOSITORY_URI_OR_DRIVE = /^(?:[a-z][a-z\d+.-]*:\/\/|[a-z]:[\\/])/i
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Extract full URL from HTTP request
|
|
@@ -178,12 +180,17 @@ function calculateHttpEndpoint (url) {
|
|
|
178
180
|
: '/'
|
|
179
181
|
}
|
|
180
182
|
|
|
183
|
+
/** @param {string} repositoryUrl */
|
|
184
|
+
function isScpStyleRepositoryUrl (repositoryUrl) {
|
|
185
|
+
return !REPOSITORY_URI_OR_DRIVE.test(repositoryUrl) && SCP_STYLE_REPOSITORY_URL.test(repositoryUrl)
|
|
186
|
+
}
|
|
187
|
+
|
|
181
188
|
function filterSensitiveInfoFromRepository (repositoryUrl) {
|
|
182
189
|
if (!repositoryUrl) {
|
|
183
190
|
return ''
|
|
184
191
|
}
|
|
185
|
-
if (repositoryUrl
|
|
186
|
-
return repositoryUrl
|
|
192
|
+
if (isScpStyleRepositoryUrl(repositoryUrl)) {
|
|
193
|
+
return repositoryUrl.startsWith('git@') ? repositoryUrl : repositoryUrl.replace(/^[^@/:]+@/, '')
|
|
187
194
|
}
|
|
188
195
|
|
|
189
196
|
// Remove the username from ssh URLs
|
|
@@ -208,5 +215,6 @@ module.exports = {
|
|
|
208
215
|
buildClientHttpUrl,
|
|
209
216
|
calculateHttpEndpoint,
|
|
210
217
|
filterSensitiveInfoFromRepository,
|
|
218
|
+
isScpStyleRepositoryUrl,
|
|
211
219
|
extractPathFromUrl, // used by http-otel-semantics decomposeServerUrl fallback (and tests)
|
|
212
220
|
}
|
|
@@ -19,7 +19,7 @@ const {
|
|
|
19
19
|
} = require('./tags')
|
|
20
20
|
|
|
21
21
|
const { normalizeRef } = require('./ci')
|
|
22
|
-
const { filterSensitiveInfoFromRepository } = require('./url')
|
|
22
|
+
const { filterSensitiveInfoFromRepository, isScpStyleRepositoryUrl } = require('./url')
|
|
23
23
|
|
|
24
24
|
function removeEmptyValues (tagsAndValues) {
|
|
25
25
|
const filteredTags = {}
|
|
@@ -36,7 +36,7 @@ function removeEmptyValues (tagsAndValues) {
|
|
|
36
36
|
// https://github.com/jonschlinkert/is-git-url/blob/396965ffabf2f46656c8af4c47bef1d69f09292e/index.js#L9C15-L9C87
|
|
37
37
|
// The `.git` suffix is optional in this version
|
|
38
38
|
function validateGitRepositoryUrl (repoUrl) {
|
|
39
|
-
return /(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\/?|#[-\w.]+)$/.test(repoUrl)
|
|
39
|
+
return isScpStyleRepositoryUrl(repoUrl) || /(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\/?|#[-\w.]+)$/.test(repoUrl)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function validateGitCommitSha (gitCommitSha) {
|
|
@@ -15,7 +15,14 @@ const urlFilter = require('./urlfilter')
|
|
|
15
15
|
const { createInferredProxySpan, finishInferredProxySpan } = require('./inferred_proxy')
|
|
16
16
|
const { getServerStatusValidator } = require('./status-validator')
|
|
17
17
|
const { extractURL, obfuscateQs, getQsObfuscator, calculateHttpEndpoint } = require('./url')
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
HTTP_STATUS_ERROR,
|
|
20
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
21
|
+
isInstrumentationOwnedResource,
|
|
22
|
+
NETWORK_PEER_ADDRESS,
|
|
23
|
+
otelHttpResourceName,
|
|
24
|
+
setInstrumentationHttpResource,
|
|
25
|
+
} = require('./http-otel-semantics')
|
|
19
26
|
|
|
20
27
|
const WEB = types.WEB
|
|
21
28
|
const SERVER = kinds.SERVER
|
|
@@ -144,9 +151,27 @@ const web = {
|
|
|
144
151
|
setRoute (req, path) {
|
|
145
152
|
const context = contexts.get(req)
|
|
146
153
|
|
|
147
|
-
if (!context) return
|
|
154
|
+
if (!context?.span) return
|
|
155
|
+
|
|
156
|
+
if (!path || !context.config?.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
157
|
+
context.paths = [path]
|
|
158
|
+
return
|
|
159
|
+
}
|
|
148
160
|
|
|
161
|
+
const spanContext = context.span.context()
|
|
162
|
+
const currentRoute = spanContext.getTag(HTTP_ROUTE)
|
|
163
|
+
const publishedRoute = context.paths.length > 1 ? context.paths.join('') : context.paths[0]
|
|
149
164
|
context.paths = [path]
|
|
165
|
+
// Publish before finish because downstream requests can trigger sampling inside the handler.
|
|
166
|
+
// Replace only values this context owns, so an upstream route still wins.
|
|
167
|
+
let route = currentRoute
|
|
168
|
+
if (currentRoute === undefined || currentRoute === publishedRoute) {
|
|
169
|
+
route = path
|
|
170
|
+
context.span.setTag(HTTP_ROUTE, path)
|
|
171
|
+
}
|
|
172
|
+
if (ownsResource(spanContext)) {
|
|
173
|
+
setInstrumentationHttpResource(context.span, otelHttpResourceName(req.method, route))
|
|
174
|
+
}
|
|
150
175
|
},
|
|
151
176
|
|
|
152
177
|
// Remove the current route segment.
|
|
@@ -204,6 +229,22 @@ const web = {
|
|
|
204
229
|
return context ? context.span : null
|
|
205
230
|
},
|
|
206
231
|
|
|
232
|
+
/** @param {import('../../opentracing/span') | undefined} span */
|
|
233
|
+
rootFromSpan (span) {
|
|
234
|
+
if (!span) return
|
|
235
|
+
|
|
236
|
+
const started = span.context()._trace.started
|
|
237
|
+
while (span) {
|
|
238
|
+
const context = span.context()
|
|
239
|
+
if (context.getTag(SPAN_KIND) === SERVER && typeof context.getTag(HTTP_URL) === 'string') return span
|
|
240
|
+
|
|
241
|
+
const parentId = context._parentId
|
|
242
|
+
if (!parentId) return
|
|
243
|
+
span = started.find(parent => parent.context()._spanId === parentId)
|
|
244
|
+
}
|
|
245
|
+
return span
|
|
246
|
+
},
|
|
247
|
+
|
|
207
248
|
// Return the active span.
|
|
208
249
|
active (req) {
|
|
209
250
|
const context = contexts.get(req)
|
|
@@ -252,10 +293,16 @@ const web = {
|
|
|
252
293
|
|
|
253
294
|
if (!spanHasExistingError && !isValidStatusCode) {
|
|
254
295
|
span.setTag(ERROR, error || true)
|
|
296
|
+
if (context.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
297
|
+
span.setTag(HTTP_STATUS_ERROR, String(statusCode))
|
|
298
|
+
}
|
|
255
299
|
}
|
|
256
300
|
|
|
257
301
|
if (inferredProxySpan && !inferredSpanHasExistingError && !isValidStatusCode) {
|
|
258
302
|
inferredProxySpan.setTag(ERROR, error || true)
|
|
303
|
+
if (context.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
304
|
+
inferredProxySpan.setTag(HTTP_STATUS_ERROR, String(statusCode))
|
|
305
|
+
}
|
|
259
306
|
}
|
|
260
307
|
},
|
|
261
308
|
|
|
@@ -286,8 +333,7 @@ const web = {
|
|
|
286
333
|
if (context.finished && !req.stream) return
|
|
287
334
|
|
|
288
335
|
// `addRequestTags` is idempotent: in the normal HTTP path it ran during
|
|
289
|
-
// `web.startSpan
|
|
290
|
-
// `web.startSpan` and rely on this call to do the request-side work.
|
|
336
|
+
// `web.startSpan`, and this call applies any framework config installed afterwards.
|
|
291
337
|
addRequestTags(context, spanType)
|
|
292
338
|
// Configured-header tagging runs at finish time. Framework plugins
|
|
293
339
|
// (connect, express, ...) install their own config via `setFramework`
|
|
@@ -493,6 +539,10 @@ function addRequestTags (context, spanType) {
|
|
|
493
539
|
// other HTTP attributes, which are renamed centrally in span_format) it is set
|
|
494
540
|
// here directly when OTel semantics are enabled.
|
|
495
541
|
if (config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
542
|
+
// Claim the resource before propagation can sample it.
|
|
543
|
+
if (ownsResource(spanContext)) {
|
|
544
|
+
setInstrumentationHttpResource(span, otelHttpResourceName(req.method))
|
|
545
|
+
}
|
|
496
546
|
const peerAddress = req.socket?.remoteAddress
|
|
497
547
|
if (peerAddress) span.setTag(NETWORK_PEER_ADDRESS, peerAddress)
|
|
498
548
|
}
|
|
@@ -565,18 +615,39 @@ function applyRouteOrEndpointTag (context) {
|
|
|
565
615
|
span.setTag(HTTP_ENDPOINT, endpoint)
|
|
566
616
|
}
|
|
567
617
|
|
|
618
|
+
/**
|
|
619
|
+
* @param {import('../../opentracing/span_context')} spanContext
|
|
620
|
+
*/
|
|
621
|
+
function ownsResource (spanContext) {
|
|
622
|
+
return isInstrumentationOwnedResource(
|
|
623
|
+
spanContext.getTag(RESOURCE_NAME),
|
|
624
|
+
spanContext.getTag(INSTRUMENTATION_HTTP_RESOURCE)
|
|
625
|
+
)
|
|
626
|
+
}
|
|
627
|
+
|
|
568
628
|
function addResourceTag (context) {
|
|
569
|
-
const { req, span } = context
|
|
629
|
+
const { req, span, config } = context
|
|
570
630
|
const spanContext = span.context()
|
|
631
|
+
const currentResource = spanContext.getTag(RESOURCE_NAME)
|
|
632
|
+
|
|
633
|
+
if (!config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
634
|
+
if (currentResource) return
|
|
635
|
+
|
|
636
|
+
let resource = req.method
|
|
637
|
+
const route = spanContext.getTag(HTTP_ROUTE)
|
|
571
638
|
|
|
572
|
-
|
|
639
|
+
if (route) resource += ` ${route}`
|
|
640
|
+
span.setTag(RESOURCE_NAME, resource)
|
|
641
|
+
return
|
|
642
|
+
}
|
|
573
643
|
|
|
574
|
-
|
|
575
|
-
|
|
644
|
+
const instrumentationResource = spanContext.getTag(INSTRUMENTATION_HTTP_RESOURCE)
|
|
645
|
+
if (currentResource && !isInstrumentationOwnedResource(currentResource, instrumentationResource)) return
|
|
576
646
|
|
|
577
|
-
|
|
647
|
+
const resource = otelHttpResourceName(req.method, spanContext.getTag(HTTP_ROUTE))
|
|
648
|
+
if (currentResource === resource && instrumentationResource === resource) return
|
|
578
649
|
|
|
579
|
-
span
|
|
650
|
+
setInstrumentationHttpResource(span, resource)
|
|
580
651
|
}
|
|
581
652
|
|
|
582
653
|
function addRequestHeaders (context) {
|
|
@@ -78,7 +78,6 @@ function createProfilers (config, { asyncContextFrameEnabled, flushInterval, tag
|
|
|
78
78
|
const profilers = []
|
|
79
79
|
for (const name of selectProfilerTypes(config)) {
|
|
80
80
|
switch (name) {
|
|
81
|
-
case 'cpu':
|
|
82
81
|
case 'wall':
|
|
83
82
|
profilers.push(new WallProfiler(config, { asyncContextFrameEnabled, flushInterval }))
|
|
84
83
|
break
|
|
@@ -112,7 +111,12 @@ function selectProfilerTypes ({
|
|
|
112
111
|
// snapshots the space profile won't include memory taken by profiles created
|
|
113
112
|
// before it in the sequence. That memory is ultimately transient and will be
|
|
114
113
|
// released when all profiles are subsequently encoded.
|
|
115
|
-
|
|
114
|
+
// 'cpu' is an alias of 'wall'. Normalizing it here keeps the settings below from adding a second
|
|
115
|
+
// wall profiler next to the alias.
|
|
116
|
+
const profilers = new Set()
|
|
117
|
+
for (const name of DD_PROFILING_PROFILERS) {
|
|
118
|
+
profilers.add(name === 'cpu' ? 'wall' : name)
|
|
119
|
+
}
|
|
116
120
|
|
|
117
121
|
let spaceExplicitlyEnabled = false
|
|
118
122
|
// Add/remove space depending on the value of DD_PROFILING_HEAP_ENABLED
|
|
@@ -133,7 +137,6 @@ function selectProfilerTypes ({
|
|
|
133
137
|
profilers.add('wall')
|
|
134
138
|
} else {
|
|
135
139
|
profilers.delete('wall')
|
|
136
|
-
profilers.delete('cpu') // remove alias too
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
142
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { HTTP_METHOD, HTTP_ROUTE, RESOURCE_NAME, SPAN_TYPE } = require('../../../../ext/tags')
|
|
4
4
|
const { WEB } = require('../../../../ext/types')
|
|
5
|
+
const { INSTRUMENTATION_HTTP_RESOURCE, otelHttpResourceName } = require('../plugins/util/http-otel-semantics')
|
|
5
6
|
|
|
6
7
|
function isWebServerSpan (tags) {
|
|
7
8
|
return tags[SPAN_TYPE] === WEB
|
|
@@ -18,10 +19,9 @@ function endpointNameFromTags (tags) {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
// The endpoint name a web-server span's tag bag yields changes over the span's
|
|
21
|
-
// lifetime: plugins set `http.method` when the request arrives and
|
|
22
|
-
// `http.route`
|
|
23
|
-
//
|
|
24
|
-
// while it is still an interim placeholder.
|
|
22
|
+
// lifetime: plugins set `http.method` when the request arrives and refine
|
|
23
|
+
// `http.route` and `resource.name` as nested framework routes resolve.
|
|
24
|
+
// Returns the current endpoint, or undefined for a method-only placeholder.
|
|
25
25
|
//
|
|
26
26
|
// Consumers that read the tag bag lazily (the wall profiler resolves endpoint
|
|
27
27
|
// labels at serialization time) see the settled value for free and only need
|
|
@@ -44,7 +44,8 @@ function finalEndpoint (tags) {
|
|
|
44
44
|
// the string building inside endpointNameFromTags.
|
|
45
45
|
if (tags[RESOURCE_NAME] == null && tags[HTTP_ROUTE] == null) return
|
|
46
46
|
const endpoint = endpointNameFromTags(tags)
|
|
47
|
-
if (!endpoint || endpoint === tags[HTTP_METHOD]
|
|
47
|
+
if (!endpoint || endpoint === tags[HTTP_METHOD] ||
|
|
48
|
+
(endpoint === tags[INSTRUMENTATION_HTTP_RESOURCE] && endpoint === otelHttpResourceName(tags[HTTP_METHOD]))) return
|
|
48
49
|
return endpoint
|
|
49
50
|
}
|
|
50
51
|
|