dd-trace 6.24.0 → 6.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/ci/cypress/support.js +2 -1
- package/ci/init.js +2 -22
- package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-setup.mjs +729 -724
- package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
- package/ext/exporters.js +0 -1
- package/index.d.ts +105 -5
- package/initialize.mjs +5 -2
- package/package.json +41 -36
- package/packages/datadog-esbuild/index.js +16 -70
- package/packages/datadog-esbuild/src/log.js +2 -29
- package/packages/datadog-instrumentations/src/ai.js +6 -1
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +20 -17
- package/packages/datadog-instrumentations/src/helpers/bundler-esm-exports.js +582 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +576 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-client.js +30 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +61 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +80 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +23 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/microgateway-core.js +1 -2
- package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -1
- package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +41 -0
- package/packages/datadog-instrumentations/src/next.js +203 -26
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/router.js +35 -12
- package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/arn.js +41 -0
- package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -13
- package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-express/src/code_origin.js +2 -2
- package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +20 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +21 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +11 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-http/src/client.js +34 -10
- package/packages/datadog-plugin-http2/src/client.js +40 -14
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
- package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-postgres/src/index.js +118 -41
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
- package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
- package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +3 -2
- package/packages/datadog-plugin-ws/src/close.js +3 -5
- package/packages/datadog-plugin-ws/src/producer.js +1 -4
- package/packages/datadog-plugin-ws/src/receiver.js +3 -5
- package/packages/datadog-plugin-ws/src/server.js +44 -13
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-vite/index.js +537 -0
- package/packages/datadog-vite/src/log.js +5 -0
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/datadog-webpack/src/log.js +2 -29
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/index.js +1 -1
- package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
- package/packages/dd-trace/src/aiguard/sdk.js +8 -2
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +21 -1
- package/packages/dd-trace/src/appsec/channels.js +7 -0
- package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
- package/packages/dd-trace/src/appsec/graphql.js +89 -7
- package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
- package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
- package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
- package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
- package/packages/dd-trace/src/appsec/index.js +6 -0
- package/packages/dd-trace/src/appsec/lambda.js +17 -17
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
- package/packages/dd-trace/src/appsec/rasp/index.js +8 -1
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
- package/packages/dd-trace/src/appsec/rasp/utils.js +33 -3
- package/packages/dd-trace/src/appsec/recommended.json +1358 -94
- package/packages/dd-trace/src/appsec/reporter.js +9 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
- package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
- package/packages/dd-trace/src/appsec/waf/index.js +65 -6
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +5 -0
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -4
- package/packages/dd-trace/src/config/index.js +63 -31
- package/packages/dd-trace/src/config/parsers.js +44 -0
- package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
- package/packages/dd-trace/src/config/remote_config.js +2 -1
- package/packages/dd-trace/src/config/supported-configurations.json +172 -10
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/datastreams/fnv.js +27 -0
- package/packages/dd-trace/src/datastreams/pathway.js +113 -28
- package/packages/dd-trace/src/datastreams/processor.js +5 -4
- package/packages/dd-trace/src/debugger/config.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +2 -2
- package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +6 -2
- package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
- package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
- package/packages/dd-trace/src/exporter.js +0 -11
- package/packages/dd-trace/src/exporters/common/request.js +81 -48
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/git_metadata.js +2 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/index.js +6 -3
- package/packages/dd-trace/src/lambda/facade.js +75 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +54 -3
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +81 -1
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/sdk.js +19 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
- package/packages/dd-trace/src/llmobs/tagger.js +22 -0
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +6 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +7 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +55 -27
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
- package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +24 -0
- package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +143 -17
- package/packages/dd-trace/src/plugins/index.js +8 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +52 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +263 -82
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +80 -56
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +92 -40
- package/packages/dd-trace/src/plugins/util/url.js +18 -7
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +6 -6
- package/packages/dd-trace/src/plugins/util/web.js +65 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiler.js +74 -12
- package/packages/dd-trace/src/profiling/profiler.js +30 -2
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/profiling/remote-config.js +354 -0
- package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/propagation-hash/index.js +7 -0
- package/packages/dd-trace/src/proxy.js +46 -54
- package/packages/dd-trace/src/span_processor.js +20 -0
- package/packages/dd-trace/src/startup-log.js +8 -6
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +220 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/vite.d.ts +7 -0
- package/vite.js +3 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -18
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -649
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/datadog-esbuild/src/utils.js +0 -318
- package/packages/datadog-plugin-cypress/src/support.js +0 -1348
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
|
@@ -17,6 +17,8 @@ const USER_AGENT_ORIGINAL = 'user_agent.original'
|
|
|
17
17
|
const CLIENT_ADDRESS = 'client.address'
|
|
18
18
|
const NETWORK_PEER_ADDRESS = 'network.peer.address'
|
|
19
19
|
const HTTP_REQUEST_METHOD_ORIGINAL = 'http.request.method_original'
|
|
20
|
+
const INSTRUMENTATION_HTTP_RESOURCE = '_dd.otel.instrumentation_http_resource'
|
|
21
|
+
const HTTP_STATUS_ERROR = '_dd.otel.status_error'
|
|
20
22
|
|
|
21
23
|
// Known HTTP methods (RFC 9110 + PATCH RFC 5789 + QUERY httpbis draft). A verb
|
|
22
24
|
// outside this set is reported as `_OTHER` with the raw value preserved on
|
|
@@ -25,12 +27,48 @@ const KNOWN_METHODS = new Set([
|
|
|
25
27
|
'CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'QUERY', 'TRACE',
|
|
26
28
|
])
|
|
27
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The OTel HTTP span name: `{method} {target}`, or the bare method with no target. An unknown
|
|
32
|
+
* verb uses the literal `HTTP`, never the URL path.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} method
|
|
35
|
+
* @param {string} [route]
|
|
36
|
+
*/
|
|
37
|
+
function otelHttpResourceName (method, route) {
|
|
38
|
+
const normalizedMethod = KNOWN_METHODS.has(method) ? method : 'HTTP'
|
|
39
|
+
if (typeof route === 'string' && route.length > 0) return `${normalizedMethod} ${route}`
|
|
40
|
+
return normalizedMethod
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Record the generated resource so later passes do not overwrite an application change.
|
|
45
|
+
*
|
|
46
|
+
* @param {import('../../opentracing/span')} span
|
|
47
|
+
* @param {string} resource
|
|
48
|
+
*/
|
|
49
|
+
function setInstrumentationHttpResource (span, resource) {
|
|
50
|
+
span.context().setTag(INSTRUMENTATION_HTTP_RESOURCE, resource)
|
|
51
|
+
span.setTag('resource.name', resource)
|
|
52
|
+
}
|
|
53
|
+
|
|
28
54
|
// Datadog HTTP meta keys replaced by OTel names — omitted when rebuilding meta.
|
|
55
|
+
// `http.endpoint` stays: it has no OTel equivalent and ASM plus endpoint aggregation read it.
|
|
29
56
|
const DD_HTTP_META_KEYS = new Set([
|
|
30
57
|
'http.method', 'http.status_code', 'http.useragent', 'http.client_ip', 'http.url', 'out.host',
|
|
58
|
+
INSTRUMENTATION_HTTP_RESOURCE, HTTP_STATUS_ERROR,
|
|
31
59
|
])
|
|
32
60
|
const NETWORK_DESTINATION_PORT = 'network.destination.port'
|
|
33
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Treat a resource that differs from the recorded instrumentation value as application-owned.
|
|
64
|
+
*
|
|
65
|
+
* @param {string | undefined} currentResource
|
|
66
|
+
* @param {string | undefined} instrumentationResource
|
|
67
|
+
*/
|
|
68
|
+
function isInstrumentationOwnedResource (currentResource, instrumentationResource) {
|
|
69
|
+
return !currentResource || currentResource === instrumentationResource
|
|
70
|
+
}
|
|
71
|
+
|
|
34
72
|
// IPv6 literals arrive bracketed (URL.hostname / out.host = `[::1]`); OTel
|
|
35
73
|
// `server.address` is the bare address.
|
|
36
74
|
function stripIpv6Brackets (host) {
|
|
@@ -47,43 +85,37 @@ function stripIpv6Brackets (host) {
|
|
|
47
85
|
*/
|
|
48
86
|
|
|
49
87
|
/**
|
|
50
|
-
* Decompose
|
|
51
|
-
* parts. Structural fields (scheme, address, port, path) are read from the raw
|
|
52
|
-
* URL; the query is taken from the already-obfuscated URL so the configured
|
|
53
|
-
* query-string obfuscation is preserved.
|
|
88
|
+
* Decompose an already-obfuscated server request URL into OpenTelemetry `url.*` / `server.*` parts.
|
|
54
89
|
*
|
|
55
|
-
* @param {string}
|
|
56
|
-
* @param {string} obfuscatedUrl same URL with its query string obfuscated
|
|
90
|
+
* @param {string} url full request URL (`scheme://host[:port]/path?query`)
|
|
57
91
|
* @returns {ServerUrlParts}
|
|
58
92
|
*/
|
|
59
|
-
function decomposeServerUrl (
|
|
93
|
+
function decomposeServerUrl (url) {
|
|
60
94
|
let scheme
|
|
61
95
|
let address
|
|
62
96
|
let port
|
|
63
97
|
let path
|
|
64
98
|
|
|
65
99
|
try {
|
|
66
|
-
const parsed = new URL(
|
|
100
|
+
const parsed = new URL(url)
|
|
67
101
|
scheme = parsed.protocol.length > 1 ? parsed.protocol.slice(0, -1) : undefined
|
|
68
102
|
// `extractURL` builds `http://undefined/...` when the Host header is absent; skip that.
|
|
69
103
|
const hostname = parsed.hostname
|
|
70
104
|
if (hostname && hostname !== 'undefined') {
|
|
71
105
|
address = stripIpv6Brackets(hostname)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const parsedPort = Number.parseInt(parsed.port, 10)
|
|
75
|
-
if (parsedPort > 0) port = parsedPort
|
|
106
|
+
port = parsed.port ? Number.parseInt(parsed.port, 10) : defaultPortForUrl(url)
|
|
107
|
+
if (port === 0) port = undefined
|
|
76
108
|
}
|
|
77
109
|
path = parsed.pathname || '/'
|
|
78
110
|
} catch {
|
|
79
111
|
// Malformed or relative URL: fall back to a best-effort path only.
|
|
80
|
-
path = extractPathFromUrl(
|
|
112
|
+
path = extractPathFromUrl(url)
|
|
81
113
|
}
|
|
82
114
|
|
|
83
115
|
let query
|
|
84
|
-
const queryIndex =
|
|
116
|
+
const queryIndex = url.indexOf('?')
|
|
85
117
|
if (queryIndex !== -1) {
|
|
86
|
-
const rawQuery =
|
|
118
|
+
const rawQuery = url.slice(queryIndex + 1)
|
|
87
119
|
if (rawQuery) query = rawQuery
|
|
88
120
|
}
|
|
89
121
|
|
|
@@ -100,8 +132,8 @@ function toHttpScheme (scheme) {
|
|
|
100
132
|
|
|
101
133
|
/**
|
|
102
134
|
* Redact any userinfo embedded in a URL's authority, since `url.full` must not
|
|
103
|
-
* leak credentials
|
|
104
|
-
*
|
|
135
|
+
* leak credentials. Any userinfo becomes `REDACTED:REDACTED@host`, matching OpenTelemetry HTTP
|
|
136
|
+
* instrumentation. Returns the URL unchanged when no userinfo is present.
|
|
105
137
|
*
|
|
106
138
|
* @param {string} url
|
|
107
139
|
*/
|
|
@@ -124,17 +156,13 @@ function redactUrlCredentials (url) {
|
|
|
124
156
|
const at = url.lastIndexOf('@', authorityEnd - 1)
|
|
125
157
|
if (at < authorityStart) return url
|
|
126
158
|
|
|
127
|
-
|
|
128
|
-
return url.slice(0, authorityStart) + redacted + url.slice(at)
|
|
159
|
+
return url.slice(0, authorityStart) + 'REDACTED:REDACTED' + url.slice(at)
|
|
129
160
|
}
|
|
130
161
|
|
|
131
162
|
/**
|
|
132
|
-
*
|
|
133
|
-
* (the attribute is required for clients but the explicit port is absent for
|
|
134
|
-
* default-port requests).
|
|
163
|
+
* Return the required client `server.port` when the URL omits its default port.
|
|
135
164
|
*
|
|
136
165
|
* @param {string} [url]
|
|
137
|
-
* @returns {number | undefined}
|
|
138
166
|
*/
|
|
139
167
|
function defaultPortForUrl (url) {
|
|
140
168
|
if (url === undefined) return
|
|
@@ -165,7 +193,19 @@ function applyHttpOtelSemantics (formattedSpan) {
|
|
|
165
193
|
const metrics = formattedSpan.metrics
|
|
166
194
|
const method = meta['http.method']
|
|
167
195
|
const url = meta['http.url']
|
|
168
|
-
|
|
196
|
+
// Hooks can remove the method and URL; the resource marker still identifies HTTP spans whose
|
|
197
|
+
// remaining tags need renaming.
|
|
198
|
+
if (method === undefined && url === undefined && meta[INSTRUMENTATION_HTTP_RESOURCE] === undefined) {
|
|
199
|
+
// Rebuild to remove an orphaned internal marker without demoting `meta` to V8 dictionary mode.
|
|
200
|
+
if (Object.hasOwn(meta, HTTP_STATUS_ERROR)) {
|
|
201
|
+
const cleanMeta = {}
|
|
202
|
+
for (const key of Object.keys(meta)) {
|
|
203
|
+
if (key !== HTTP_STATUS_ERROR) cleanMeta[key] = meta[key]
|
|
204
|
+
}
|
|
205
|
+
formattedSpan.meta = cleanMeta
|
|
206
|
+
}
|
|
207
|
+
return
|
|
208
|
+
}
|
|
169
209
|
|
|
170
210
|
// Rebuild meta/metrics as fresh objects that omit the renamed Datadog HTTP
|
|
171
211
|
// keys. Deleting them in place demotes the formatted span to V8 dictionary
|
|
@@ -175,6 +215,7 @@ function applyHttpOtelSemantics (formattedSpan) {
|
|
|
175
215
|
for (const key of Object.keys(meta)) {
|
|
176
216
|
if (!DD_HTTP_META_KEYS.has(key)) newMeta[key] = meta[key]
|
|
177
217
|
}
|
|
218
|
+
|
|
178
219
|
const newMetrics = {}
|
|
179
220
|
for (const key of Object.keys(metrics)) {
|
|
180
221
|
if (key !== NETWORK_DESTINATION_PORT) newMetrics[key] = metrics[key]
|
|
@@ -186,29 +227,18 @@ function applyHttpOtelSemantics (formattedSpan) {
|
|
|
186
227
|
if (KNOWN_METHODS.has(method)) {
|
|
187
228
|
newMeta[HTTP_REQUEST_METHOD] = method
|
|
188
229
|
} else {
|
|
189
|
-
// Unknown verb: bucket to `_OTHER`, preserve the raw value, and use the
|
|
190
|
-
// literal "HTTP" in the span name (the spec forbids the URL path there).
|
|
191
|
-
// Known-method names are already `{method} {route}`.
|
|
192
230
|
newMeta[HTTP_REQUEST_METHOD] = '_OTHER'
|
|
193
231
|
newMeta[HTTP_REQUEST_METHOD_ORIGINAL] = method
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
} else if (resource.startsWith(`${method} `)) {
|
|
199
|
-
formattedSpan.resource = `HTTP${resource.slice(method.length)}`
|
|
200
|
-
}
|
|
201
|
-
}
|
|
232
|
+
}
|
|
233
|
+
// Comparing against the recorded value keeps a manual resource shaped like "GET /custom".
|
|
234
|
+
if (isInstrumentationOwnedResource(formattedSpan.resource, meta[INSTRUMENTATION_HTTP_RESOURCE])) {
|
|
235
|
+
formattedSpan.resource = otelHttpResourceName(method, kind === 'server' ? meta['http.route'] : undefined)
|
|
202
236
|
}
|
|
203
237
|
}
|
|
204
238
|
|
|
205
239
|
const status = meta['http.status_code']
|
|
206
240
|
let statusCode
|
|
207
241
|
if (status !== undefined) {
|
|
208
|
-
// OTel types http.response.status_code as an int, so emit it as a numeric
|
|
209
|
-
// metric (the OTLP exporter serializes meta as stringValue but metrics as
|
|
210
|
-
// intValue) — mirroring how server.port is handled below. Guard against a
|
|
211
|
-
// non-numeric status, which would otherwise write a NaN metric.
|
|
212
242
|
statusCode = Number.parseInt(status, 10)
|
|
213
243
|
if (Number.isFinite(statusCode)) newMetrics[HTTP_RESPONSE_STATUS_CODE] = statusCode
|
|
214
244
|
}
|
|
@@ -220,14 +250,9 @@ function applyHttpOtelSemantics (formattedSpan) {
|
|
|
220
250
|
if (clientIp !== undefined) newMeta[CLIENT_ADDRESS] = clientIp
|
|
221
251
|
|
|
222
252
|
if (kind === 'server') {
|
|
223
|
-
// FIXME: some server frameworks (e.g. Next.js — `packages/datadog-plugin-next`)
|
|
224
|
-
// never populate `http.url`, so the OTel `url.*` / `server.*` attributes below
|
|
225
|
-
// can't be derived and are omitted for those spans. This needs a fix; the
|
|
226
|
-
// short-term option is to set `http.url` in those integrations so they emit
|
|
227
|
-
// the full server attribute set.
|
|
228
253
|
if (url !== undefined) {
|
|
229
254
|
// The query in `http.url` is already obfuscated per config, so it is preserved.
|
|
230
|
-
const { scheme, address, port, path, query } = decomposeServerUrl(url
|
|
255
|
+
const { scheme, address, port, path, query } = decomposeServerUrl(url)
|
|
231
256
|
if (path !== undefined) newMeta[URL_PATH] = path
|
|
232
257
|
if (scheme !== undefined) newMeta[URL_SCHEME] = toHttpScheme(scheme)
|
|
233
258
|
if (query !== undefined) newMeta[URL_QUERY] = query
|
|
@@ -236,7 +261,6 @@ function applyHttpOtelSemantics (formattedSpan) {
|
|
|
236
261
|
}
|
|
237
262
|
} else {
|
|
238
263
|
if (url !== undefined) {
|
|
239
|
-
// url.full must not carry embedded credentials.
|
|
240
264
|
newMeta[URL_FULL] = redactUrlCredentials(url)
|
|
241
265
|
}
|
|
242
266
|
const outHost = meta['out.host']
|
|
@@ -251,15 +275,11 @@ function applyHttpOtelSemantics (formattedSpan) {
|
|
|
251
275
|
}
|
|
252
276
|
}
|
|
253
277
|
|
|
254
|
-
//
|
|
255
|
-
//
|
|
256
|
-
|
|
257
|
-
if (
|
|
258
|
-
|
|
259
|
-
if (isError) {
|
|
260
|
-
newMeta[ERROR_TYPE] = status
|
|
261
|
-
formattedSpan.error = 1
|
|
262
|
-
}
|
|
278
|
+
// Configured validators, not a fixed status range, decide whether status caused the error.
|
|
279
|
+
// Match the recorded status so a hook replacement is not blamed, and keep exception-derived types.
|
|
280
|
+
const statusCausedError = status !== undefined && meta[HTTP_STATUS_ERROR] === status
|
|
281
|
+
if (formattedSpan.error && newMeta[ERROR_TYPE] === undefined && statusCausedError && Number.isFinite(statusCode)) {
|
|
282
|
+
newMeta[ERROR_TYPE] = status
|
|
263
283
|
}
|
|
264
284
|
|
|
265
285
|
formattedSpan.meta = newMeta
|
|
@@ -267,7 +287,11 @@ function applyHttpOtelSemantics (formattedSpan) {
|
|
|
267
287
|
}
|
|
268
288
|
|
|
269
289
|
module.exports = {
|
|
290
|
+
HTTP_STATUS_ERROR,
|
|
291
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
270
292
|
NETWORK_PEER_ADDRESS, // imported by web.js (set from req.socket, not at serialization)
|
|
271
|
-
|
|
293
|
+
isInstrumentationOwnedResource,
|
|
294
|
+
otelHttpResourceName,
|
|
295
|
+
setInstrumentationHttpResource,
|
|
272
296
|
applyHttpOtelSemantics,
|
|
273
297
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const log = require('../../log')
|
|
4
4
|
const tags = require('../../../../../ext/tags')
|
|
5
|
+
const { INSTRUMENTATION_HTTP_RESOURCE, otelHttpResourceName } = require('./http-otel-semantics')
|
|
5
6
|
|
|
6
7
|
const RESOURCE_NAME = tags.RESOURCE_NAME
|
|
7
8
|
const SPAN_TYPE = tags.SPAN_TYPE
|
|
@@ -62,6 +63,9 @@ function createInferredProxySpan (headers, childOf, tracer, reqCtx, traceCtx, co
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
const proxySpanInfo = supportedProxies[proxyContext.proxySystemName]
|
|
66
|
+
const resourcePath = proxyContext.resourcePath || proxyContext.path
|
|
67
|
+
const otelSemantics = config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
68
|
+
let resourceName = `${proxyContext.method} ${resourcePath}`
|
|
65
69
|
|
|
66
70
|
log.debug('Successfully extracted inferred span info %s for proxy:', proxyContext, proxyContext.proxySystemName)
|
|
67
71
|
|
|
@@ -79,6 +83,11 @@ function createInferredProxySpan (headers, childOf, tracer, reqCtx, traceCtx, co
|
|
|
79
83
|
if (proxyContext.accountId) meta.account_id = proxyContext.accountId
|
|
80
84
|
if (proxyContext.apiId) meta.apiid = proxyContext.apiId
|
|
81
85
|
if (proxyContext.awsUser) meta.aws_user = proxyContext.awsUser
|
|
86
|
+
if (otelSemantics) {
|
|
87
|
+
resourceName = otelHttpResourceName(proxyContext.method, proxyContext.resourcePath)
|
|
88
|
+
meta[RESOURCE_NAME] = resourceName
|
|
89
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resourceName
|
|
90
|
+
}
|
|
82
91
|
|
|
83
92
|
const span = startSpanHelper(tracer, proxySpanInfo.spanName, {
|
|
84
93
|
childOf,
|
|
@@ -93,14 +102,13 @@ function createInferredProxySpan (headers, childOf, tracer, reqCtx, traceCtx, co
|
|
|
93
102
|
|
|
94
103
|
log.debug('Successfully created inferred proxy span.')
|
|
95
104
|
|
|
96
|
-
setInferredProxySpanTags(span, proxyContext)
|
|
105
|
+
setInferredProxySpanTags(span, proxyContext, resourceName)
|
|
97
106
|
|
|
98
107
|
return childOf
|
|
99
108
|
}
|
|
100
109
|
|
|
101
|
-
function setInferredProxySpanTags (span, proxyContext) {
|
|
102
|
-
|
|
103
|
-
span.setTag(RESOURCE_NAME, `${proxyContext.method} ${resourcePath}`)
|
|
110
|
+
function setInferredProxySpanTags (span, proxyContext, resourceName) {
|
|
111
|
+
span.setTag(RESOURCE_NAME, resourceName)
|
|
104
112
|
span.setTag('_dd.inferred_span', 1)
|
|
105
113
|
|
|
106
114
|
// Set dd_resource_key as API Gateway ARN if we have the required components
|
|
@@ -8,7 +8,6 @@ const MAX_HTTP_STATUS_CODE = 599
|
|
|
8
8
|
|
|
9
9
|
const SERVER_ERROR_STATUSES = 'DD_TRACE_HTTP_SERVER_ERROR_STATUSES'
|
|
10
10
|
const CLIENT_ERROR_STATUSES = 'DD_TRACE_HTTP_CLIENT_ERROR_STATUSES'
|
|
11
|
-
|
|
12
11
|
/** @typedef {(code: number) => boolean} StatusValidator */
|
|
13
12
|
|
|
14
13
|
/** @type {StatusValidator} */
|
|
@@ -21,30 +20,47 @@ function isNotClientErrorCode (code) {
|
|
|
21
20
|
return code < 400 || code >= 500
|
|
22
21
|
}
|
|
23
22
|
|
|
23
|
+
// OTel treats client 5xx responses and unrecognized codes above 599 as errors.
|
|
24
|
+
/** @type {StatusValidator} */
|
|
25
|
+
function isNotOtelClientErrorCode (code) {
|
|
26
|
+
return code < 400
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
/**
|
|
25
|
-
* @param {{
|
|
30
|
+
* @param {{
|
|
31
|
+
* validateStatus?: unknown,
|
|
32
|
+
* DD_TRACE_HTTP_SERVER_ERROR_STATUSES?: unknown,
|
|
33
|
+
* DD_TRACE_HTTP_CLIENT_ERROR_STATUSES?: unknown,
|
|
34
|
+
* }} config
|
|
26
35
|
* @returns {StatusValidator}
|
|
27
36
|
*/
|
|
28
37
|
function getServerStatusValidator (config) {
|
|
29
|
-
return getStatusValidator(config, SERVER_ERROR_STATUSES,
|
|
38
|
+
return getStatusValidator(config, SERVER_ERROR_STATUSES, isNotServerErrorCode)
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
/**
|
|
33
|
-
* @param {{
|
|
42
|
+
* @param {{
|
|
43
|
+
* validateStatus?: unknown,
|
|
44
|
+
* DD_TRACE_HTTP_CLIENT_ERROR_STATUSES?: unknown,
|
|
45
|
+
* DD_TRACE_OTEL_SEMANTICS_ENABLED?: unknown
|
|
46
|
+
* }} config
|
|
34
47
|
* @returns {StatusValidator}
|
|
35
48
|
*/
|
|
36
49
|
function getClientStatusValidator (config) {
|
|
37
|
-
|
|
50
|
+
if (config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
51
|
+
return getStatusValidator(config, CLIENT_ERROR_STATUSES, isNotOtelClientErrorCode)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return getStatusValidator(config, CLIENT_ERROR_STATUSES, isNotClientErrorCode)
|
|
38
55
|
}
|
|
39
56
|
|
|
40
57
|
/**
|
|
41
58
|
* @param {Record<string, unknown>} config
|
|
42
59
|
* @param {string} optionName - Name of the configuration holding the error status ranges.
|
|
43
|
-
* @param {string} defaultRanges - Ranges covered by `defaultValidator`
|
|
44
60
|
* @param {StatusValidator} defaultValidator
|
|
45
61
|
* @returns {StatusValidator}
|
|
46
62
|
*/
|
|
47
|
-
function getStatusValidator (config, optionName,
|
|
63
|
+
function getStatusValidator (config, optionName, defaultValidator) {
|
|
48
64
|
if (typeof config.validateStatus === 'function') {
|
|
49
65
|
return /** @type {StatusValidator} */ (config.validateStatus)
|
|
50
66
|
} else if (Object.hasOwn(config, 'validateStatus')) {
|
|
@@ -57,10 +73,7 @@ function getStatusValidator (config, optionName, defaultRanges, defaultValidator
|
|
|
57
73
|
log.error('Expected `%s` to be a string.', optionName)
|
|
58
74
|
return defaultValidator
|
|
59
75
|
}
|
|
60
|
-
if (ranges === defaultRanges) return defaultValidator
|
|
61
|
-
|
|
62
76
|
const normalized = ranges.replaceAll(whitespacePattern, '')
|
|
63
|
-
if (normalized === defaultRanges) return defaultValidator
|
|
64
77
|
if (!statusCodeRangesPattern.test(normalized)) {
|
|
65
78
|
log.error('`%s` must contain comma-separated status codes or ranges from 100 to 599.', optionName)
|
|
66
79
|
return defaultValidator
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const GIT_COMMIT_SHA = 'git.commit.sha'
|
|
4
4
|
const GIT_BRANCH = 'git.branch'
|
|
5
5
|
const GIT_REPOSITORY_URL = 'git.repository_url'
|
|
6
|
+
const GIT_CHECKOUT_ROOT = 'git.checkout.root'
|
|
7
|
+
const GIT_CHECKOUT_IS_CUSTOM = 'git.checkout.is_custom'
|
|
6
8
|
const GIT_TAG = 'git.tag'
|
|
7
9
|
const GIT_COMMIT_MESSAGE = 'git.commit.message'
|
|
8
10
|
const GIT_COMMIT_COMMITTER_DATE = 'git.commit.committer.date'
|
|
@@ -31,6 +33,7 @@ const CI_PIPELINE_NUMBER = 'ci.pipeline.number'
|
|
|
31
33
|
const CI_PIPELINE_URL = 'ci.pipeline.url'
|
|
32
34
|
const CI_PROVIDER_NAME = 'ci.provider.name'
|
|
33
35
|
const CI_WORKSPACE_PATH = 'ci.workspace_path'
|
|
36
|
+
const CI_GIT_MERGE_COMMIT_SHA = 'ci.git.merge_commit_sha'
|
|
34
37
|
const CI_JOB_URL = 'ci.job.url'
|
|
35
38
|
const CI_JOB_NAME = 'ci.job.name'
|
|
36
39
|
const CI_JOB_ID = 'ci.job.id'
|
|
@@ -46,6 +49,8 @@ module.exports = {
|
|
|
46
49
|
GIT_COMMIT_SHA,
|
|
47
50
|
GIT_BRANCH,
|
|
48
51
|
GIT_REPOSITORY_URL,
|
|
52
|
+
GIT_CHECKOUT_ROOT,
|
|
53
|
+
GIT_CHECKOUT_IS_CUSTOM,
|
|
49
54
|
GIT_TAG,
|
|
50
55
|
GIT_COMMIT_MESSAGE,
|
|
51
56
|
GIT_COMMIT_COMMITTER_DATE,
|
|
@@ -72,6 +77,7 @@ module.exports = {
|
|
|
72
77
|
CI_PIPELINE_URL,
|
|
73
78
|
CI_PROVIDER_NAME,
|
|
74
79
|
CI_WORKSPACE_PATH,
|
|
80
|
+
CI_GIT_MERGE_COMMIT_SHA,
|
|
75
81
|
CI_JOB_URL,
|
|
76
82
|
CI_JOB_NAME,
|
|
77
83
|
CI_JOB_ID,
|
|
@@ -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,
|
|
@@ -584,6 +591,7 @@ module.exports = {
|
|
|
584
591
|
TEST_RETRY_REASON_TYPES,
|
|
585
592
|
getNumFromKnownTests,
|
|
586
593
|
getFileAndLineNumberFromError,
|
|
594
|
+
getNonDependencyStackFramesFromError,
|
|
587
595
|
DI_ERROR_DEBUG_INFO_CAPTURED,
|
|
588
596
|
DI_DEBUG_ERROR_PREFIX,
|
|
589
597
|
DI_DEBUG_ERROR_SNAPSHOT_ID_SUFFIX,
|
|
@@ -656,9 +664,12 @@ function removeInvalidMetadata (metadata) {
|
|
|
656
664
|
log.error('Repository URL is not a valid repository URL: %s.', metadata[GIT_REPOSITORY_URL])
|
|
657
665
|
return filteredTags
|
|
658
666
|
}
|
|
659
|
-
if (tag === GIT_COMMIT_SHA && !validateGitCommitSha(metadata[
|
|
660
|
-
log.error('Git commit SHA must be a full-length git SHA: %s.', metadata[
|
|
661
|
-
|
|
667
|
+
if ((tag === GIT_COMMIT_SHA || tag === CI_GIT_MERGE_COMMIT_SHA) && !validateGitCommitSha(metadata[tag])) {
|
|
668
|
+
log.error('Git commit SHA must be a full-length git SHA: %s.', metadata[tag])
|
|
669
|
+
// A malformed commit SHA is reported as provided; consumers validate it before using it for Git or requests.
|
|
670
|
+
if (tag === CI_GIT_MERGE_COMMIT_SHA || !metadata[tag]) {
|
|
671
|
+
return filteredTags
|
|
672
|
+
}
|
|
662
673
|
}
|
|
663
674
|
if (tag === CI_PIPELINE_URL && !validateUrl(metadata[CI_PIPELINE_URL])) {
|
|
664
675
|
return filteredTags
|
|
@@ -736,15 +747,15 @@ function checkShaDiscrepancies (ciMetadata, userProvidedGitMetadata) {
|
|
|
736
747
|
v1: ciRepositoryUrl,
|
|
737
748
|
v2: gitRepositoryUrl,
|
|
738
749
|
type: 'repository_discrepancy',
|
|
739
|
-
expected: '
|
|
740
|
-
discrepant: '
|
|
750
|
+
expected: 'git_client',
|
|
751
|
+
discrepant: 'ci_provider',
|
|
741
752
|
},
|
|
742
753
|
{
|
|
743
754
|
v1: ciCommitSHA,
|
|
744
755
|
v2: gitCommitSHA,
|
|
745
756
|
type: 'commit_discrepancy',
|
|
746
|
-
expected: '
|
|
747
|
-
discrepant: '
|
|
757
|
+
expected: 'git_client',
|
|
758
|
+
discrepant: 'ci_provider',
|
|
748
759
|
},
|
|
749
760
|
]
|
|
750
761
|
|
|
@@ -782,32 +793,36 @@ function getTestEnvironmentMetadata (testFramework, config, shouldSkipGitMetadat
|
|
|
782
793
|
if (!shouldSkipGitMetadataExtraction) {
|
|
783
794
|
checkShaDiscrepancies(ciMetadata, userProvidedGitMetadata)
|
|
784
795
|
|
|
785
|
-
const {
|
|
786
|
-
[GIT_COMMIT_SHA]: commitSHA,
|
|
787
|
-
[GIT_BRANCH]: branch,
|
|
788
|
-
[GIT_REPOSITORY_URL]: repositoryUrl,
|
|
789
|
-
[GIT_TAG]: tag,
|
|
790
|
-
[GIT_COMMIT_AUTHOR_NAME]: authorName,
|
|
791
|
-
[GIT_COMMIT_AUTHOR_EMAIL]: authorEmail,
|
|
792
|
-
[GIT_COMMIT_MESSAGE]: commitMessage,
|
|
793
|
-
[CI_WORKSPACE_PATH]: ciWorkspacePath,
|
|
794
|
-
[GIT_COMMIT_HEAD_SHA]: headCommitSha,
|
|
795
|
-
} = ciMetadata
|
|
796
796
|
gitMetadata = getGitMetadata({
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
repositoryUrl,
|
|
800
|
-
tag,
|
|
801
|
-
authorName,
|
|
802
|
-
authorEmail,
|
|
803
|
-
commitMessage,
|
|
804
|
-
ciWorkspacePath,
|
|
805
|
-
headCommitSha,
|
|
797
|
+
ciWorkspacePath: ciMetadata[CI_WORKSPACE_PATH],
|
|
798
|
+
headCommitSha: ciMetadata[GIT_COMMIT_HEAD_SHA],
|
|
806
799
|
pullRequestBaseBranchSha: userProvidedGitMetadata[GIT_PULL_REQUEST_BASE_BRANCH_SHA] ||
|
|
807
800
|
ciMetadata[GIT_PULL_REQUEST_BASE_BRANCH_SHA],
|
|
808
801
|
})
|
|
809
802
|
}
|
|
810
803
|
|
|
804
|
+
let providerMetadata = ciMetadata
|
|
805
|
+
if (gitMetadata[GIT_COMMIT_SHA]) {
|
|
806
|
+
providerMetadata = {}
|
|
807
|
+
// Preserve workflow and PR relationships separately from the selected checkout metadata.
|
|
808
|
+
for (const key of Object.keys(ciMetadata)) {
|
|
809
|
+
const isPullRequestMetadata = key.startsWith('git.commit.head.') || key.startsWith('git.pull_request.')
|
|
810
|
+
if (!key.startsWith('git.') || isPullRequestMetadata) {
|
|
811
|
+
providerMetadata[key] = ciMetadata[key]
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
const isMatchingDetachedCheckout = ciMetadata[CI_WORKSPACE_PATH] && gitMetadata[GIT_CHECKOUT_ROOT] &&
|
|
815
|
+
gitMetadata[GIT_CHECKOUT_IS_CUSTOM] !== 'true' && !gitMetadata[GIT_BRANCH] &&
|
|
816
|
+
(gitMetadata[GIT_COMMIT_SHA] === ciMetadata[GIT_COMMIT_SHA] ||
|
|
817
|
+
gitMetadata[GIT_COMMIT_SHA] === ciMetadata[CI_GIT_MERGE_COMMIT_SHA])
|
|
818
|
+
if (isMatchingDetachedCheckout) {
|
|
819
|
+
// A detached CI checkout can use a mirror remote; CI supplies its branch, tag and canonical repository identity.
|
|
820
|
+
for (const key of [GIT_BRANCH, GIT_TAG, GIT_REPOSITORY_URL]) {
|
|
821
|
+
if (ciMetadata[key]) providerMetadata[key] = ciMetadata[key]
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
811
826
|
/** @type {TestEnvironmentMetadata} */
|
|
812
827
|
const runtimeAndOSMetadata = getRuntimeAndOSMetadata()
|
|
813
828
|
|
|
@@ -815,10 +830,22 @@ function getTestEnvironmentMetadata (testFramework, config, shouldSkipGitMetadat
|
|
|
815
830
|
[TEST_FRAMEWORK]: testFramework,
|
|
816
831
|
[DD_TEST_IS_USER_PROVIDED_SERVICE]: (config && config.isServiceUserProvided) ? 'true' : 'false',
|
|
817
832
|
...gitMetadata,
|
|
818
|
-
...
|
|
833
|
+
...providerMetadata,
|
|
819
834
|
...userProvidedGitMetadata,
|
|
820
835
|
...runtimeAndOSMetadata,
|
|
821
836
|
}
|
|
837
|
+
const explicitSha = userProvidedGitMetadata[GIT_COMMIT_SHA]
|
|
838
|
+
if (explicitSha && explicitSha !== (gitMetadata[GIT_COMMIT_SHA] || ciMetadata[GIT_COMMIT_SHA])) {
|
|
839
|
+
// The checkout's author, message and tag must not describe a different user-selected commit.
|
|
840
|
+
for (const key of Object.keys(metadata)) {
|
|
841
|
+
if ((key === GIT_TAG || (key.startsWith('git.commit.') && key !== GIT_COMMIT_SHA &&
|
|
842
|
+
!key.startsWith('git.commit.head.'))) &&
|
|
843
|
+
// eslint-disable-next-line prefer-object-has-own -- Cypress 6's plugin process runs on Node 12.
|
|
844
|
+
!Object.prototype.hasOwnProperty.call(userProvidedGitMetadata, key)) {
|
|
845
|
+
delete metadata[key]
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
822
849
|
if (/^(true|1)$/i.test(getEnvironmentVariable('_DD_TEST_PARALLELIZATION_ENABLED'))) {
|
|
823
850
|
metadata[TEST_PARALLELIZATION_ENABLED] = 'true'
|
|
824
851
|
Object.assign(metadata, getTestParallelizationPlanMetadata())
|
|
@@ -1886,6 +1913,29 @@ function getFileAndLineNumberFromError (error, repositoryRoot) {
|
|
|
1886
1913
|
return []
|
|
1887
1914
|
}
|
|
1888
1915
|
|
|
1916
|
+
function getNonDependencyStackFramesFromError (error, repositoryRoot) {
|
|
1917
|
+
if (!error?.stack) {
|
|
1918
|
+
return []
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
const stackLines = error.stack.split('\n')
|
|
1922
|
+
const frames = stackLines.filter(line => line.includes('at ') && line.includes(repositoryRoot))
|
|
1923
|
+
const locations = []
|
|
1924
|
+
|
|
1925
|
+
for (const frame of frames) {
|
|
1926
|
+
if (DEPENDENCY_FOLDERS.some(pattern => frame.includes(pattern))) {
|
|
1927
|
+
continue
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
const location = parseStackFrameLocation(frame, repositoryRoot)
|
|
1931
|
+
if (location) {
|
|
1932
|
+
locations.push(location)
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
return locations
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1889
1939
|
function getFormattedError (error, repositoryRoot) {
|
|
1890
1940
|
const newError = new Error(error.message)
|
|
1891
1941
|
if (error.stack) {
|
|
@@ -1968,23 +2018,25 @@ function getLibraryCapabilitiesTags (testFramework, frameworkVersion, options =
|
|
|
1968
2018
|
}
|
|
1969
2019
|
}
|
|
1970
2020
|
|
|
1971
|
-
function getPullRequestBaseBranch (pullRequestBaseBranch) {
|
|
1972
|
-
const remoteName = getGitRemoteName()
|
|
2021
|
+
function getPullRequestBaseBranch (pullRequestBaseBranch, gitRoot) {
|
|
2022
|
+
const remoteName = getGitRemoteName(gitRoot)
|
|
1973
2023
|
|
|
1974
|
-
const sourceBranch = getSourceBranch()
|
|
2024
|
+
const sourceBranch = getSourceBranch(gitRoot)
|
|
1975
2025
|
// TODO: We will get the default branch name from the backend in the future.
|
|
1976
2026
|
const POSSIBLE_DEFAULT_BRANCHES = ['main', 'master']
|
|
1977
2027
|
|
|
1978
2028
|
const candidateBranches = []
|
|
1979
2029
|
if (pullRequestBaseBranch) {
|
|
1980
|
-
checkAndFetchBranch(pullRequestBaseBranch, remoteName)
|
|
1981
|
-
candidateBranches.push(pullRequestBaseBranch)
|
|
2030
|
+
checkAndFetchBranch(pullRequestBaseBranch, remoteName, gitRoot)
|
|
2031
|
+
candidateBranches.push(hasLocalGitObject(pullRequestBaseBranch, gitRoot)
|
|
2032
|
+
? pullRequestBaseBranch
|
|
2033
|
+
: `${remoteName}/${pullRequestBaseBranch}`)
|
|
1982
2034
|
} else {
|
|
1983
2035
|
for (const branch of POSSIBLE_BASE_BRANCHES) {
|
|
1984
|
-
checkAndFetchBranch(branch, remoteName)
|
|
2036
|
+
checkAndFetchBranch(branch, remoteName, gitRoot)
|
|
1985
2037
|
}
|
|
1986
2038
|
|
|
1987
|
-
const localBranches = getLocalBranches(remoteName)
|
|
2039
|
+
const localBranches = getLocalBranches(remoteName, gitRoot)
|
|
1988
2040
|
for (const branch of localBranches) {
|
|
1989
2041
|
const shortBranchName = branch.replace(new RegExp(`^${remoteName}/`), '')
|
|
1990
2042
|
if (branch !== sourceBranch && BASE_LIKE_BRANCH_FILTER.test(shortBranchName)) {
|
|
@@ -1994,19 +2046,19 @@ function getPullRequestBaseBranch (pullRequestBaseBranch) {
|
|
|
1994
2046
|
}
|
|
1995
2047
|
|
|
1996
2048
|
if (candidateBranches.length === 1) {
|
|
1997
|
-
return getMergeBase(candidateBranches[0], sourceBranch)
|
|
2049
|
+
return getMergeBase(candidateBranches[0], sourceBranch, gitRoot)
|
|
1998
2050
|
}
|
|
1999
2051
|
|
|
2000
2052
|
const metrics = {}
|
|
2001
2053
|
let hasMetrics = false
|
|
2002
2054
|
for (const candidate of candidateBranches) {
|
|
2003
2055
|
// Find common ancestor
|
|
2004
|
-
const baseSha = getMergeBase(candidate, sourceBranch)
|
|
2056
|
+
const baseSha = getMergeBase(candidate, sourceBranch, gitRoot)
|
|
2005
2057
|
if (!baseSha) {
|
|
2006
2058
|
continue
|
|
2007
2059
|
}
|
|
2008
2060
|
// Count commits ahead/behind
|
|
2009
|
-
const counts = getCounts(candidate, sourceBranch)
|
|
2061
|
+
const counts = getCounts(candidate, sourceBranch, gitRoot)
|
|
2010
2062
|
if (!counts) {
|
|
2011
2063
|
continue
|
|
2012
2064
|
}
|
|
@@ -2042,11 +2094,11 @@ function getPullRequestBaseBranch (pullRequestBaseBranch) {
|
|
|
2042
2094
|
return bestBranch ? metrics[bestBranch].baseSha : null
|
|
2043
2095
|
}
|
|
2044
2096
|
|
|
2045
|
-
function getPullRequestDiff (baseCommit, targetCommit) {
|
|
2097
|
+
function getPullRequestDiff (baseCommit, targetCommit, gitRoot) {
|
|
2046
2098
|
if (!baseCommit) {
|
|
2047
2099
|
return
|
|
2048
2100
|
}
|
|
2049
|
-
return getGitDiff(baseCommit, targetCommit)
|
|
2101
|
+
return getGitDiff(baseCommit, targetCommit, gitRoot)
|
|
2050
2102
|
}
|
|
2051
2103
|
|
|
2052
2104
|
function getModifiedFilesFromDiff (diff) {
|