dd-trace 6.23.0 → 6.25.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
|
@@ -24,6 +24,7 @@ const { recordDegraded, recordDropped, recordPayloadSplit } = require('./flag-ev
|
|
|
24
24
|
* @property {string} [targeting_key]
|
|
25
25
|
* @property {{ evaluation: ContextSnapshot }} [context]
|
|
26
26
|
* @property {{ key: string }} [variant]
|
|
27
|
+
* @property {Record<string, string | number | boolean>} [features]
|
|
27
28
|
* @property {{ key: string }} [allocation]
|
|
28
29
|
* @property {{ message: string }} [error]
|
|
29
30
|
*/
|
|
@@ -52,6 +53,7 @@ function makeRow (entry, timestamp, degraded) {
|
|
|
52
53
|
const allocation = normalizeTargetingKey(entry.allocation)
|
|
53
54
|
if (variant) row.variant = { key: variant }
|
|
54
55
|
if (allocation) row.allocation = { key: allocation }
|
|
56
|
+
if (entry.features !== undefined) row.features = entry.features
|
|
55
57
|
const error = protectedErrorCode(entry.error)
|
|
56
58
|
if (error !== undefined) row.error = { message: error }
|
|
57
59
|
if (!degraded) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { hashTargetingKey: digestTargetingKey } = require('../encoding')
|
|
4
|
+
const { snapshotFeatures } = require('./split-features')
|
|
4
5
|
|
|
5
6
|
// Keep this vocabulary explicit: an upstream enum addition needs a privacy review.
|
|
6
7
|
const ERROR_CODES = new Set([
|
|
@@ -90,6 +91,7 @@ function normalizeFlagEvaluationEvent (event, targetingKey) {
|
|
|
90
91
|
flagKey: normalizeTargetingKey(event.flagKey),
|
|
91
92
|
variant: optionalKey(event.variant),
|
|
92
93
|
allocationKey: optionalKey(event.allocationKey),
|
|
94
|
+
features: snapshotFeatures(event.features),
|
|
93
95
|
runtimeDefault: event.runtimeDefault === true,
|
|
94
96
|
errorCode: protectedErrorCode(event.errorCode),
|
|
95
97
|
targetingKey,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Snapshot scalar split features in canonical key order for stable aggregation.
|
|
5
|
+
* A prefix selects one provider destination; hook-only metadata must not reach intake.
|
|
6
|
+
* @param {unknown} source
|
|
7
|
+
* @param {string} [prefix]
|
|
8
|
+
* @returns {Record<string, string | number | boolean> | undefined}
|
|
9
|
+
*/
|
|
10
|
+
function snapshotFeatures (source, prefix = '') {
|
|
11
|
+
if (source === null || typeof source !== 'object' || Array.isArray(source)) return
|
|
12
|
+
let features
|
|
13
|
+
for (const key of Object.keys(source).sort()) {
|
|
14
|
+
if (!key.startsWith(prefix) || key.length === prefix.length) continue
|
|
15
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key)
|
|
16
|
+
const value = descriptor?.value
|
|
17
|
+
if (typeof value !== 'string' && typeof value !== 'boolean' &&
|
|
18
|
+
!(typeof value === 'number' && Number.isFinite(value))) continue
|
|
19
|
+
features ??= Object.create(null)
|
|
20
|
+
features[key.slice(prefix.length)] = value
|
|
21
|
+
}
|
|
22
|
+
return features
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = { snapshotFeatures }
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { logs } = require('@opentelemetry/api-logs')
|
|
4
|
+
|
|
3
5
|
const { buildResourceAttributes, registerResourceAttributeRefresh } = require('../resource-attributes')
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -35,6 +37,8 @@ const OtlpHttpLogExporter = require('./otlp_http_log_exporter')
|
|
|
35
37
|
/**
|
|
36
38
|
* Initializes OpenTelemetry Logs support
|
|
37
39
|
* @param {import('../../config/config-base')} config - Tracer configuration instance
|
|
40
|
+
* @returns {import('../startup-config').InitializedExporter | undefined} Startup reporting metadata
|
|
41
|
+
* with the effective protocol and resource, or undefined when another provider owns the global Logs API.
|
|
38
42
|
*/
|
|
39
43
|
function initializeOpenTelemetryLogs (config) {
|
|
40
44
|
// Create OTLP exporter using resolved config values
|
|
@@ -58,11 +62,18 @@ function initializeOpenTelemetryLogs (config) {
|
|
|
58
62
|
|
|
59
63
|
// Expose this provider to application calls through the OpenTelemetry Logs API.
|
|
60
64
|
loggerProvider.register()
|
|
65
|
+
// Registration can leave an existing global provider in place; only report ours when it is active.
|
|
66
|
+
const registered = logs.getLoggerProvider() === loggerProvider
|
|
61
67
|
|
|
62
68
|
// Include final log batches in lifecycle retention with trace delivery.
|
|
63
69
|
registerTelemetryFlusher(done => loggerProvider.forceFlush(done))
|
|
64
70
|
|
|
65
71
|
registerResourceAttributeRefresh(exporter, () => buildResourceAttributes(config))
|
|
72
|
+
if (!registered) return
|
|
73
|
+
return {
|
|
74
|
+
protocol: exporter.transformer.protocol,
|
|
75
|
+
resourceAttributes: exporter.getStartupResourceAttributes(),
|
|
76
|
+
}
|
|
66
77
|
}
|
|
67
78
|
|
|
68
79
|
module.exports = {
|
|
@@ -29,7 +29,7 @@ class OtlpHttpLogExporter extends OtlpHttpExporterBase {
|
|
|
29
29
|
* @param {Attributes} resourceAttributes - Resource attributes
|
|
30
30
|
*/
|
|
31
31
|
constructor (url, headers, timeout, protocol, resourceAttributes) {
|
|
32
|
-
super(url, headers, timeout, protocol, 'logs')
|
|
32
|
+
super(url, headers, timeout, protocol, 'logs', resourceAttributes)
|
|
33
33
|
this.transformer = new OtlpTransformer(resourceAttributes, protocol)
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -45,6 +45,7 @@ const RESERVED_TRACER_TAGS = new Set(['service', 'env', 'version', 'runtime_id',
|
|
|
45
45
|
/**
|
|
46
46
|
* Initializes OpenTelemetry Metrics support
|
|
47
47
|
* @param {import('../../config/config-base')} config - Tracer configuration instance
|
|
48
|
+
* @returns {import('../startup-config').InitializedExporter | undefined}
|
|
48
49
|
*/
|
|
49
50
|
function initializeOpenTelemetryMetrics (config) {
|
|
50
51
|
const exporter = new OtlpHttpMetricExporter(
|
|
@@ -63,12 +64,17 @@ function initializeOpenTelemetryMetrics (config) {
|
|
|
63
64
|
)
|
|
64
65
|
|
|
65
66
|
const meterProvider = new MeterProvider({ reader })
|
|
66
|
-
metrics.setGlobalMeterProvider(meterProvider)
|
|
67
|
+
const registered = metrics.setGlobalMeterProvider(meterProvider)
|
|
67
68
|
|
|
68
69
|
// Include the final metric collection and export in lifecycle retention.
|
|
69
70
|
registerTelemetryFlusher(done => reader.forceFlush(done))
|
|
70
71
|
|
|
71
72
|
registerResourceAttributeRefresh(exporter, () => buildGeneralResourceAttributes(config))
|
|
73
|
+
if (!registered) return
|
|
74
|
+
return {
|
|
75
|
+
protocol: exporter.transformer.protocol,
|
|
76
|
+
resourceAttributes: exporter.getStartupResourceAttributes(),
|
|
77
|
+
}
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
/**
|
|
@@ -25,7 +25,7 @@ class OtlpHttpMetricExporter extends OtlpHttpExporterBase {
|
|
|
25
25
|
* @param {Attributes} resourceAttributes - Resource attributes
|
|
26
26
|
*/
|
|
27
27
|
constructor (url, headers, timeout, protocol, resourceAttributes) {
|
|
28
|
-
super(url, headers, timeout, protocol, 'metrics')
|
|
28
|
+
super(url, headers, timeout, protocol, 'metrics', resourceAttributes)
|
|
29
29
|
this.transformer = new OtlpTransformer(resourceAttributes, protocol)
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -15,8 +15,11 @@ class OtlpStatsExporter extends OtlpHttpExporterBase {
|
|
|
15
15
|
* @param {number} [timeout]
|
|
16
16
|
*/
|
|
17
17
|
constructor (url, protocol, resourceAttributes, headers, timeout = 10_000) {
|
|
18
|
-
super(url, headers, timeout, protocol, 'span-stats')
|
|
18
|
+
super(url, headers, timeout, protocol, 'span-stats', resourceAttributes)
|
|
19
19
|
this.#transformer = new OtlpStatsTransformer(resourceAttributes, protocol)
|
|
20
|
+
// Expose the protocol actually used after transformer fallback (e.g. grpc -> http/protobuf)
|
|
21
|
+
// so startup reporting describes the exporter rather than the requested protocol.
|
|
22
|
+
this.protocol = this.#transformer.protocol
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
/**
|
|
@@ -12,10 +12,10 @@ const { nowUnixNano } = require('./time')
|
|
|
12
12
|
* @param {(error: Error | null) => void} [done]
|
|
13
13
|
* @param {Error | null} [error]
|
|
14
14
|
*/
|
|
15
|
-
function callDone (done, error) {
|
|
15
|
+
function callDone (done, error = null) {
|
|
16
16
|
if (!done) return
|
|
17
17
|
try {
|
|
18
|
-
done(error
|
|
18
|
+
done(error)
|
|
19
19
|
} catch (callbackError) {
|
|
20
20
|
log.error('Error completing OTLP metrics lifecycle callback:', callbackError)
|
|
21
21
|
}
|
|
@@ -22,6 +22,12 @@ const legacyStorage = storage('legacy')
|
|
|
22
22
|
* @class OtlpHttpExporterBase
|
|
23
23
|
*/
|
|
24
24
|
class OtlpHttpExporterBase {
|
|
25
|
+
/**
|
|
26
|
+
* @readonly
|
|
27
|
+
* @type {Readonly<Record<string, unknown>>}
|
|
28
|
+
*/
|
|
29
|
+
#startupResourceAttributes
|
|
30
|
+
|
|
25
31
|
#transport = https
|
|
26
32
|
#serverlessDeliveryTracker
|
|
27
33
|
|
|
@@ -34,8 +40,12 @@ class OtlpHttpExporterBase {
|
|
|
34
40
|
* @param {number} timeout - Request timeout in milliseconds
|
|
35
41
|
* @param {string} protocol - OTLP protocol (http/protobuf or http/json)
|
|
36
42
|
* @param {string} signalType - Signal type for error messages (e.g., 'logs', 'metrics')
|
|
43
|
+
* @param {import('@opentelemetry/api').Attributes} [resourceAttributes] - Resource passed to the transformer
|
|
37
44
|
*/
|
|
38
|
-
constructor (url, headers, timeout, protocol, signalType) {
|
|
45
|
+
constructor (url, headers, timeout, protocol, signalType, resourceAttributes = {}) {
|
|
46
|
+
this.#startupResourceAttributes = Object.fromEntries(Object.entries(resourceAttributes).map(([key, value]) => [
|
|
47
|
+
key, Array.isArray(value) ? [...value] : value,
|
|
48
|
+
]))
|
|
39
49
|
this.#serverlessDeliveryTracker = createServerlessDeliveryTracker()
|
|
40
50
|
this.protocol = protocol
|
|
41
51
|
this.signalType = signalType
|
|
@@ -59,6 +69,14 @@ class OtlpHttpExporterBase {
|
|
|
59
69
|
this.#applyUrl(url)
|
|
60
70
|
}
|
|
61
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Returns the resource captured at construction, before later identity refreshes.
|
|
74
|
+
* @returns {Readonly<Record<string, unknown>>}
|
|
75
|
+
*/
|
|
76
|
+
getStartupResourceAttributes () {
|
|
77
|
+
return this.#startupResourceAttributes
|
|
78
|
+
}
|
|
79
|
+
|
|
62
80
|
/**
|
|
63
81
|
* Records telemetry metrics for exported data.
|
|
64
82
|
* @param {string} metricName - Name of the metric to record
|
|
@@ -6,5 +6,9 @@
|
|
|
6
6
|
// the already-built payload. Its own dependency-free module so an instrumentation can register
|
|
7
7
|
// without loading the OTel bridge, and a plain holder so the caller gates on `hook` existing.
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @type {{
|
|
11
|
+
* hook: ((ddSpan: import('../opentracing/span'), otelSemanticsEnabled: boolean) => boolean | undefined) | undefined
|
|
12
|
+
* }}
|
|
13
|
+
*/
|
|
10
14
|
module.exports = { hook: undefined }
|
|
@@ -254,7 +254,7 @@ function recordException (ddSpan, exception, timeInput, otelTraceSemanticsEnable
|
|
|
254
254
|
|
|
255
255
|
/**
|
|
256
256
|
* Applies OTel `setStatus({ code, message })` per spec: UNSET / missing is a no-op, OK is
|
|
257
|
-
* final, ERROR is replaceable. Only ERROR writes
|
|
257
|
+
* final, ERROR is replaceable. Only ERROR writes error metadata; the returned code is the one the
|
|
258
258
|
* caller must store for the next call.
|
|
259
259
|
*
|
|
260
260
|
* @param {import('../opentracing/span')} ddSpan
|
|
@@ -266,6 +266,11 @@ function applyOtelStatus (ddSpan, currentCode, status, otelTraceSemanticsEnabled
|
|
|
266
266
|
if (!isWritable(ddSpan)) return currentCode
|
|
267
267
|
|
|
268
268
|
const code = status?.code
|
|
269
|
+
if (otelTraceSemanticsEnabled && (code === 1 || currentCode === 1)) {
|
|
270
|
+
ddSpan.context().deleteTag(ERROR_MESSAGE)
|
|
271
|
+
ddSpan.setTag(IGNORE_OTEL_ERROR, true)
|
|
272
|
+
return 1
|
|
273
|
+
}
|
|
269
274
|
if (!code || currentCode === 1) {
|
|
270
275
|
if (otelTraceSemanticsEnabled) {
|
|
271
276
|
ddSpan.context().deleteTag(ERROR_MESSAGE)
|
|
@@ -261,8 +261,8 @@ class Span extends BridgeSpanBase {
|
|
|
261
261
|
const endTime = hrTimeToMilliseconds(hrEndTime)
|
|
262
262
|
|
|
263
263
|
// Must run before `finish()`, while the DD span is still unfinished. See span-ending-hook.js.
|
|
264
|
-
if (spanEndingHook.hook
|
|
265
|
-
|
|
264
|
+
if (spanEndingHook.hook?.(this._ddSpan, this._otelTraceSemanticsEnabled)) {
|
|
265
|
+
this.setStatus({ code: api.SpanStatusCode.ERROR, message: this._ddSpan.context().getTag('error.message') })
|
|
266
266
|
}
|
|
267
267
|
this._ddSpan.finish(endTime)
|
|
268
268
|
this._spanProcessor.onEnd(this)
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { isDeepStrictEqual } = require('node:util')
|
|
4
|
+
|
|
5
|
+
const { DD_MAJOR } = require('../../../../version')
|
|
6
|
+
const { VALID_PROPAGATION_STYLES } = require('../config/parsers')
|
|
7
|
+
const { getLogLevel } = require('../log/writer')
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Readonly<{
|
|
11
|
+
* protocol: string,
|
|
12
|
+
* resourceAttributes: Readonly<Record<string, unknown>>,
|
|
13
|
+
* }>} InitializedExporter
|
|
14
|
+
* @typedef {Readonly<{
|
|
15
|
+
* tracing?: boolean,
|
|
16
|
+
* traces?: InitializedExporter,
|
|
17
|
+
* metrics?: InitializedExporter,
|
|
18
|
+
* logs?: InitializedExporter,
|
|
19
|
+
* spanMetrics?: InitializedExporter,
|
|
20
|
+
* }>} Pipelines
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {ReturnType<import('../config')>} config
|
|
25
|
+
* @param {import('../sampling_rule')[]} rules
|
|
26
|
+
* @param {Pipelines} [pipelines]
|
|
27
|
+
* @returns {Record<string, unknown>}
|
|
28
|
+
*/
|
|
29
|
+
function startupConfig (config, rules, pipelines = {}) {
|
|
30
|
+
const tracing = !!pipelines.tracing
|
|
31
|
+
const traces = !!pipelines.traces
|
|
32
|
+
const metrics = !!pipelines.metrics
|
|
33
|
+
const logs = !!pipelines.logs
|
|
34
|
+
const spanMetrics = !!pipelines.spanMetrics
|
|
35
|
+
const resources = [pipelines.traces, pipelines.metrics, pipelines.logs, pipelines.spanMetrics]
|
|
36
|
+
.filter(exporter => exporter !== undefined)
|
|
37
|
+
.map(exporter => exporter.resourceAttributes)
|
|
38
|
+
const attributes = commonResourceAttributes(resources)
|
|
39
|
+
|
|
40
|
+
/** @type {Record<string, unknown>} */
|
|
41
|
+
const out = {
|
|
42
|
+
DD_TRACE_OTEL_ENABLED: !!config.DD_TRACE_OTEL_ENABLED,
|
|
43
|
+
DD_TRACE_OTEL_SEMANTICS_ENABLED: !!config.DD_TRACE_OTEL_SEMANTICS_ENABLED,
|
|
44
|
+
DD_METRICS_OTEL_ENABLED: !!config.DD_METRICS_OTEL_ENABLED,
|
|
45
|
+
DD_LOGS_OTEL_ENABLED: !!config.DD_LOGS_OTEL_ENABLED,
|
|
46
|
+
OTEL_LOG_LEVEL: getLogLevel(),
|
|
47
|
+
OTEL_SERVICE_NAME: typeof attributes['service.name'] === 'string'
|
|
48
|
+
? attributes['service.name']
|
|
49
|
+
: undefined,
|
|
50
|
+
OTEL_RESOURCE_ATTRIBUTES: attributes,
|
|
51
|
+
OTEL_TRACES_EXPORTER: traces ? 'otlp' : 'none',
|
|
52
|
+
OTEL_METRICS_EXPORTER: metrics ? 'otlp' : 'none',
|
|
53
|
+
OTEL_LOGS_EXPORTER: logs ? 'otlp' : 'none',
|
|
54
|
+
OTEL_TRACES_SPAN_METRICS_ENABLED: spanMetrics,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (tracing) {
|
|
58
|
+
const { inject, extract } = config.tracePropagationStyle
|
|
59
|
+
if (DD_MAJOR >= 6 && config.DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT === 'continue' &&
|
|
60
|
+
inject.length === extract.length &&
|
|
61
|
+
inject.every((name, i) => name === extract[i] && VALID_PROPAGATION_STYLES.has(name))) {
|
|
62
|
+
const propagators = inject.filter(name => name !== 'none')
|
|
63
|
+
.map(name => name === 'b3 single header' ? 'b3' : name)
|
|
64
|
+
out.OTEL_PROPAGATORS = propagators.join(',') || 'none'
|
|
65
|
+
}
|
|
66
|
+
const firstRule = rules[0]
|
|
67
|
+
if (config.apmTracingEnabled !== false && firstRule) {
|
|
68
|
+
const globalRuleCount = config.sampler.sampleRate === undefined ? 0 : 1
|
|
69
|
+
if (rules.length > globalRuleCount) {
|
|
70
|
+
out.OTEL_TRACES_SAMPLER = 'datadog_custom_rules'
|
|
71
|
+
} else {
|
|
72
|
+
const rate = firstRule.sampleRate
|
|
73
|
+
out.OTEL_TRACES_SAMPLER = rate === 0
|
|
74
|
+
? 'parentbased_always_off'
|
|
75
|
+
: rate === 1 ? 'parentbased_always_on' : 'parentbased_traceidratio'
|
|
76
|
+
if (rate > 0 && rate < 1) out.OTEL_TRACES_SAMPLER_ARG = rate
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (pipelines.traces) {
|
|
82
|
+
Object.assign(out, buildSanitizedExporterConfig(config, 'TRACES', pipelines.traces.protocol))
|
|
83
|
+
}
|
|
84
|
+
const metricsExporter = pipelines.metrics || pipelines.spanMetrics
|
|
85
|
+
if (metricsExporter) {
|
|
86
|
+
Object.assign(out, buildSanitizedExporterConfig(config, 'METRICS', metricsExporter.protocol))
|
|
87
|
+
}
|
|
88
|
+
if (metrics) {
|
|
89
|
+
out.OTEL_METRIC_EXPORT_INTERVAL = config.OTEL_METRIC_EXPORT_INTERVAL
|
|
90
|
+
out.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE =
|
|
91
|
+
config.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE.toLowerCase()
|
|
92
|
+
}
|
|
93
|
+
if (pipelines.logs) {
|
|
94
|
+
Object.assign(out, buildSanitizedExporterConfig(config, 'LOGS', pipelines.logs.protocol))
|
|
95
|
+
out.OTEL_BLRP_SCHEDULE_DELAY = config.OTEL_BSP_SCHEDULE_DELAY
|
|
96
|
+
out.OTEL_BLRP_MAX_EXPORT_BATCH_SIZE = config.OTEL_BSP_MAX_EXPORT_BATCH_SIZE
|
|
97
|
+
}
|
|
98
|
+
return out
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {Readonly<Record<string, unknown>>[]} resources
|
|
103
|
+
* @returns {Record<string, unknown>}
|
|
104
|
+
*/
|
|
105
|
+
function commonResourceAttributes (resources) {
|
|
106
|
+
const [reference, ...others] = resources
|
|
107
|
+
/** @type {Record<string, unknown>} */
|
|
108
|
+
const shared = {}
|
|
109
|
+
|
|
110
|
+
if (!reference) return shared
|
|
111
|
+
|
|
112
|
+
for (const [key, value] of Object.entries(reference)) {
|
|
113
|
+
const supported = isAttributeValue(value) ||
|
|
114
|
+
(Array.isArray(value) && value.every(isAttributeValue))
|
|
115
|
+
if (!supported) continue
|
|
116
|
+
|
|
117
|
+
const matchesEveryResource = others.every(resource =>
|
|
118
|
+
Object.hasOwn(resource, key) && isDeepStrictEqual(resource[key], value))
|
|
119
|
+
if (!matchesEveryResource) continue
|
|
120
|
+
|
|
121
|
+
shared[key] = Array.isArray(value) ? [...value] : value
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return shared
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** @param {unknown} value */
|
|
128
|
+
function isAttributeValue (value) {
|
|
129
|
+
return typeof value === 'string' || typeof value === 'boolean' ||
|
|
130
|
+
(typeof value === 'number' && Number.isFinite(value))
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {ReturnType<import('../config')>} config
|
|
135
|
+
* @param {'TRACES' | 'METRICS' | 'LOGS'} signal
|
|
136
|
+
* @param {string} protocol
|
|
137
|
+
* @returns {Record<string, unknown>}
|
|
138
|
+
*/
|
|
139
|
+
function buildSanitizedExporterConfig (config, signal, protocol) {
|
|
140
|
+
const prefix = `OTEL_EXPORTER_OTLP_${signal}`
|
|
141
|
+
const endpoint = sanitizeEndpoint(config[`${prefix}_ENDPOINT`])
|
|
142
|
+
return {
|
|
143
|
+
...(endpoint && { [`${prefix}_ENDPOINT`]: endpoint }),
|
|
144
|
+
[`${prefix}_PROTOCOL`]: protocol,
|
|
145
|
+
[`${prefix}_HEADERS`]: redactHeaders(config[`${prefix}_HEADERS`]),
|
|
146
|
+
[`${prefix}_TIMEOUT`]: config[`${prefix}_TIMEOUT`],
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** @param {string} endpoint */
|
|
151
|
+
function sanitizeEndpoint (endpoint) {
|
|
152
|
+
let sanitized
|
|
153
|
+
try {
|
|
154
|
+
const url = new URL(endpoint)
|
|
155
|
+
url.username = ''
|
|
156
|
+
url.password = ''
|
|
157
|
+
url.search = ''
|
|
158
|
+
url.hash = ''
|
|
159
|
+
if (url.protocol === 'http:' || url.protocol === 'https:') sanitized = url.href
|
|
160
|
+
} catch {
|
|
161
|
+
// A malformed endpoint has no safe representation in diagnostics.
|
|
162
|
+
}
|
|
163
|
+
return sanitized
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @param {Record<string, string> | undefined} headers
|
|
168
|
+
* @returns {Record<string, string>}
|
|
169
|
+
*/
|
|
170
|
+
function redactHeaders (headers) {
|
|
171
|
+
return Object.fromEntries(Object.keys(headers ?? {}).map(name => [name, '<redacted>']))
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
module.exports = startupConfig
|
|
@@ -39,7 +39,7 @@ class OtlpHttpTraceExporter extends OtlpHttpExporterBase {
|
|
|
39
39
|
* @param {boolean} otelTraceSemanticsEnabled - When true, do not emit Datadog-only attributes as span attributes
|
|
40
40
|
*/
|
|
41
41
|
constructor (url, headers, timeout, resourceAttributes, otelTraceSemanticsEnabled) {
|
|
42
|
-
super(url, headers, timeout, 'http/json', 'traces')
|
|
42
|
+
super(url, headers, timeout, 'http/json', 'traces', resourceAttributes)
|
|
43
43
|
this.#transformer = new OtlpTraceTransformer(resourceAttributes, otelTraceSemanticsEnabled)
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -295,7 +295,13 @@ class OtlpTraceTransformer extends OtlpTransformerBase {
|
|
|
295
295
|
if (errorType && errorMessage) {
|
|
296
296
|
message = `${errorType}: ${errorMessage}`
|
|
297
297
|
} else if (errorType) {
|
|
298
|
-
|
|
298
|
+
const kind = span.meta?.['span.kind']
|
|
299
|
+
// The HTTP response status already explains a status-only error.
|
|
300
|
+
const isHttpStatusError = this.#otelTraceSemanticsEnabled &&
|
|
301
|
+
(kind === 'server' || kind === 'client') &&
|
|
302
|
+
!span.meta?.['error.stack'] &&
|
|
303
|
+
errorType === span.metrics?.['http.response.status_code']?.toString()
|
|
304
|
+
if (!isHttpStatusError) message = errorType
|
|
299
305
|
} else if (errorMessage) {
|
|
300
306
|
message = errorMessage
|
|
301
307
|
}
|
|
@@ -84,7 +84,11 @@ class TracerProvider {
|
|
|
84
84
|
return Promise.reject(new Error('Not started'))
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
exporter.
|
|
87
|
+
if (typeof exporter.flush === 'function') {
|
|
88
|
+
exporter.flush()
|
|
89
|
+
} else {
|
|
90
|
+
exporter._writer?.flush()
|
|
91
|
+
}
|
|
88
92
|
return this.#activeProcessor.forceFlush()
|
|
89
93
|
}
|
|
90
94
|
|
|
@@ -15,49 +15,102 @@ const WHITESPACE = /[ \t]/
|
|
|
15
15
|
* @param {boolean} rejectValueTabs Drop entries whose value contains an internal tab.
|
|
16
16
|
* @param {number} [maxEntries] Maximum number of entries to parse.
|
|
17
17
|
* @param {number} [maxValueLength] Maximum length of an entry value.
|
|
18
|
+
* @param {boolean} [prioritizeDd] Keep dd first even when it follows the member limit.
|
|
18
19
|
* @returns {[string, string][]} Entries in reverse of wire order.
|
|
19
20
|
*/
|
|
20
|
-
function parseEntries (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// Extract up 31 additional entries.
|
|
21
|
+
function parseEntries (
|
|
22
|
+
value, fieldSeparator, pairSeparator, rejectValueTabs, maxEntries = Infinity, maxValueLength = Infinity, prioritizeDd
|
|
23
|
+
) {
|
|
24
|
+
/** @type {[string, string][]} */
|
|
25
25
|
const entries = []
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
/** @type {[string, string] | undefined} */
|
|
27
|
+
let ddEntry
|
|
28
|
+
let start = 0
|
|
29
|
+
let memberCount = 0
|
|
30
|
+
let splitIndex = -1
|
|
31
|
+
|
|
32
|
+
while (start <= value.length && memberCount < maxEntries) {
|
|
33
|
+
const separatorIndex = value.indexOf(fieldSeparator, start)
|
|
34
|
+
const end = separatorIndex === -1 ? value.length : separatorIndex
|
|
35
|
+
// Reuse the next separator (or end) so malformed members do not rescan the suffix.
|
|
36
|
+
if (splitIndex < start && start < end) {
|
|
37
|
+
splitIndex = value.indexOf(pairSeparator, start)
|
|
38
|
+
if (splitIndex === -1) splitIndex = value.length
|
|
39
|
+
}
|
|
40
|
+
const key = splitIndex > start && splitIndex < end ? value.slice(start, splitIndex).trim() : undefined
|
|
41
|
+
if (key && !WHITESPACE.test(key)) {
|
|
42
|
+
// W3C §3.3.1.3.2: value = 0*255(chr) nblk-chr; chr = %x20 / nblk-chr (no tab).
|
|
43
|
+
// Leading 0x20 is part of value; trailing whitespace is OWS.
|
|
44
|
+
const entryValue = value.slice(splitIndex + 1, end).trimEnd()
|
|
45
|
+
if (entryValue &&
|
|
46
|
+
entryValue.length <= maxValueLength &&
|
|
47
|
+
(!rejectValueTabs || !entryValue.includes('\t'))) {
|
|
48
|
+
if (prioritizeDd && key === 'dd') {
|
|
49
|
+
ddEntry ??= [key, entryValue]
|
|
50
|
+
} else {
|
|
51
|
+
entries.push([key, entryValue])
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
memberCount++
|
|
57
|
+
if (separatorIndex === -1) {
|
|
58
|
+
start = value.length + 1
|
|
59
|
+
break
|
|
60
|
+
}
|
|
61
|
+
start = separatorIndex + fieldSeparator.length
|
|
39
62
|
}
|
|
63
|
+
|
|
64
|
+
if (prioritizeDd && ddEntry === undefined && start < value.length) {
|
|
65
|
+
let position = value.indexOf('dd', start)
|
|
66
|
+
while (position !== -1) {
|
|
67
|
+
const segmentStart = value.lastIndexOf(',', position) + 1
|
|
68
|
+
const separatorIndex = value.indexOf(',', position)
|
|
69
|
+
const end = separatorIndex === -1 ? value.length : separatorIndex
|
|
70
|
+
const segment = value.slice(segmentStart, end)
|
|
71
|
+
const splitIndex = segment.indexOf('=')
|
|
72
|
+
|
|
73
|
+
if (splitIndex > 0 && segment.slice(0, splitIndex).trim() === 'dd') {
|
|
74
|
+
const entryValue = segment.slice(splitIndex + 1).trimEnd()
|
|
75
|
+
if (entryValue && entryValue.length <= maxValueLength && !entryValue.includes('\t')) {
|
|
76
|
+
ddEntry = ['dd', entryValue]
|
|
77
|
+
break
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (separatorIndex === -1) break
|
|
82
|
+
position = value.indexOf('dd', separatorIndex + 1)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (ddEntry && entries.length === maxEntries) entries.pop()
|
|
40
87
|
// Reverse so the Map's insertion order is reverse of wire order. `toString`
|
|
41
88
|
// prepends as it iterates, which yields the original wire order back.
|
|
42
89
|
entries.reverse()
|
|
90
|
+
if (ddEntry) entries.push(ddEntry)
|
|
43
91
|
return entries
|
|
44
92
|
}
|
|
45
93
|
|
|
46
94
|
/**
|
|
47
|
-
* @
|
|
95
|
+
* @template T
|
|
96
|
+
* @param {new (entries?: [string, string][]) => T} Type
|
|
48
97
|
* @param {string | undefined} value
|
|
49
98
|
* @param {string} fieldSeparator
|
|
50
99
|
* @param {string} pairSeparator
|
|
51
100
|
* @param {boolean} rejectValueTabs
|
|
52
101
|
* @param {number} [maxEntries]
|
|
53
102
|
* @param {number} [maxValueLength]
|
|
54
|
-
* @
|
|
103
|
+
* @param {boolean} [prioritizeDd]
|
|
55
104
|
*/
|
|
56
|
-
function fromString (
|
|
105
|
+
function fromString (
|
|
106
|
+
Type, value, fieldSeparator, pairSeparator, rejectValueTabs, maxEntries, maxValueLength, prioritizeDd
|
|
107
|
+
) {
|
|
57
108
|
if (typeof value !== 'string' || !value.length) {
|
|
58
109
|
return new Type()
|
|
59
110
|
}
|
|
60
|
-
return new Type(parseEntries(
|
|
111
|
+
return new Type(parseEntries(
|
|
112
|
+
value, fieldSeparator, pairSeparator, rejectValueTabs, maxEntries, maxValueLength, prioritizeDd
|
|
113
|
+
))
|
|
61
114
|
}
|
|
62
115
|
|
|
63
116
|
function toString (map, pairSeparator, fieldSeparator) {
|
|
@@ -221,8 +274,9 @@ class TraceState {
|
|
|
221
274
|
return result
|
|
222
275
|
}
|
|
223
276
|
|
|
277
|
+
/** @param {string | undefined} value */
|
|
224
278
|
static fromString (value) {
|
|
225
|
-
return fromString(TraceState, value, ',', '=', true, MAX_LIST_MEMBERS, MAX_VALUE_LENGTH)
|
|
279
|
+
return fromString(TraceState, value, ',', '=', true, MAX_LIST_MEMBERS, MAX_VALUE_LENGTH, true)
|
|
226
280
|
}
|
|
227
281
|
|
|
228
282
|
toString () {
|