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
|
@@ -5,6 +5,7 @@ const { channel } = require('dc-polyfill')
|
|
|
5
5
|
const { DatadogNodeServerProvider } = require('../../../../vendor/dist/@datadog/openfeature-node-server')
|
|
6
6
|
const log = require('../log')
|
|
7
7
|
const { debugChannel } = require('../log/channels')
|
|
8
|
+
const { warn } = require('../log/writer')
|
|
8
9
|
const configurationSource = require('./configuration_source')
|
|
9
10
|
const { EXPOSURE_CHANNEL } = require('./constants/constants')
|
|
10
11
|
const DebugLoggingHook = require('./debug-logging-hook')
|
|
@@ -13,6 +14,11 @@ const EvaluationTelemetryOptOutHook = require('./evaluation-telemetry-opt-out-ho
|
|
|
13
14
|
const SpanEnrichmentHook = require('./span-enrichment-hook')
|
|
14
15
|
const FlagEvalEVPHook = require('./writers/flag-eval-evp-hook')
|
|
15
16
|
|
|
17
|
+
const RAW_EVALUATION_DATA_WARNING = 'Feature Flags: debug logging is enabled, so feature flag logs include raw ' +
|
|
18
|
+
'evaluation data (targeting keys, evaluation context attributes, flag values, and default values) that may ' +
|
|
19
|
+
'contain personal or sensitive information. Unset DD_TRACE_DEBUG when you no longer need it.'
|
|
20
|
+
const SOURCE_UNAVAILABLE_CONSEQUENCE = 'Provider initialization fails and flag evaluations return their default values.'
|
|
21
|
+
|
|
16
22
|
/**
|
|
17
23
|
* OpenFeature provider that integrates with Datadog's feature flagging system.
|
|
18
24
|
* Extends DatadogNodeServerProvider to add tracer integration and configuration management.
|
|
@@ -30,6 +36,12 @@ class FlaggingProvider extends DatadogNodeServerProvider {
|
|
|
30
36
|
/** @type {{ start: Function, stop: Function } | undefined} */
|
|
31
37
|
#configurationSource
|
|
32
38
|
|
|
39
|
+
/** @type {Error | undefined} */
|
|
40
|
+
#configurationSourceError
|
|
41
|
+
|
|
42
|
+
/** @type {number} */
|
|
43
|
+
#initializationTimeoutMs
|
|
44
|
+
|
|
33
45
|
/**
|
|
34
46
|
* @param {import('../tracer')} tracer - Datadog tracer instance
|
|
35
47
|
* @param {import('../config/config-base')} config - Tracer configuration object
|
|
@@ -52,7 +64,8 @@ class FlaggingProvider extends DatadogNodeServerProvider {
|
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
if (config.debug && debugChannel.hasSubscribers) {
|
|
55
|
-
this.hooks.push(new DebugLoggingHook())
|
|
67
|
+
this.hooks.push(new DebugLoggingHook(() => this.getConfiguration()))
|
|
68
|
+
log.warn(RAW_EVALUATION_DATA_WARNING)
|
|
56
69
|
}
|
|
57
70
|
|
|
58
71
|
if (config.featureFlags.DD_EXPERIMENTAL_FLAGGING_PROVIDER_SPAN_ENRICHMENT_ENABLED) {
|
|
@@ -64,15 +77,27 @@ class FlaggingProvider extends DatadogNodeServerProvider {
|
|
|
64
77
|
log.info('%s span enrichment disabled', this.constructor.name)
|
|
65
78
|
}
|
|
66
79
|
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
this.#initializationTimeoutMs = config.featureFlags.DD_EXPERIMENTAL_FLAGGING_PROVIDER_INITIALIZATION_TIMEOUT_MS
|
|
81
|
+
log.debug('Feature Flags: %s created (configuration source %s, sdk env=%s, initialization timeout %dms)',
|
|
82
|
+
this.constructor.name, config.featureFlags.DD_FEATURE_FLAGS_CONFIGURATION_SOURCE, config.env ?? 'unset',
|
|
83
|
+
this.#initializationTimeoutMs)
|
|
69
84
|
|
|
70
85
|
if (config.featureFlags?.DD_FLAGGING_EVALUATION_COUNTS_ENABLED !== false) {
|
|
71
86
|
this.#flagEvalEVPHook = new FlagEvalEVPHook(config)
|
|
72
87
|
this.hooks.push(telemetryHook(this.#flagEvalEVPHook))
|
|
73
88
|
}
|
|
74
89
|
|
|
75
|
-
|
|
90
|
+
try {
|
|
91
|
+
this.#configurationSource = configurationSource.create(config, this.setConfiguration.bind(this))
|
|
92
|
+
} catch (error) {
|
|
93
|
+
this.#configurationSourceError = error
|
|
94
|
+
log.error('Unable to configure Feature Flagging configuration source', error)
|
|
95
|
+
// log.error prints only with debug logging enabled, so write the diagnostic like the startup logs do.
|
|
96
|
+
// Only an explicit startupLogs=false (option or DD_TRACE_STARTUP_LOGS) hides it: v5 defaults it to false.
|
|
97
|
+
if (config.startupLogs || config.getOrigin('startupLogs') === 'default') {
|
|
98
|
+
warn(`DATADOG TRACER DIAGNOSTIC - Feature Flags: ${error.message}. ${SOURCE_UNAVAILABLE_CONSEQUENCE}`)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
76
101
|
this.#configurationSource?.start()
|
|
77
102
|
}
|
|
78
103
|
|
|
@@ -81,18 +106,19 @@ class FlaggingProvider extends DatadogNodeServerProvider {
|
|
|
81
106
|
* @returns {Promise<void>}
|
|
82
107
|
*/
|
|
83
108
|
initialize (context) {
|
|
84
|
-
|
|
109
|
+
const hasConfiguration = this.getConfiguration() !== undefined
|
|
85
110
|
|
|
86
|
-
this.#waitingForConfiguration = !
|
|
111
|
+
this.#waitingForConfiguration = !hasConfiguration
|
|
87
112
|
const promise = super.initialize(context)
|
|
88
113
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
114
|
+
if (hasConfiguration) {
|
|
115
|
+
this.#logInitialConfiguration()
|
|
116
|
+
} else if (this.#configurationSourceError) {
|
|
117
|
+
// No configuration can arrive, so fail now instead of waiting for the timeout.
|
|
118
|
+
this.setError(this.#configurationSourceError)
|
|
119
|
+
} else {
|
|
120
|
+
log.debug('Feature Flags: waiting for provider initialization (timeout %dms)...', this.#initializationTimeoutMs)
|
|
121
|
+
}
|
|
96
122
|
|
|
97
123
|
return promise
|
|
98
124
|
}
|
|
@@ -102,9 +128,20 @@ class FlaggingProvider extends DatadogNodeServerProvider {
|
|
|
102
128
|
*/
|
|
103
129
|
setConfiguration (configuration) {
|
|
104
130
|
const wasWaiting = this.#waitingForConfiguration
|
|
131
|
+
// The upstream provider emits PROVIDER_READY for this transition without logging it.
|
|
132
|
+
const recovering = !wasWaiting && configuration != null && this.getConfiguration() == null &&
|
|
133
|
+
this.initController !== undefined && !this.initController.isInitializing()
|
|
134
|
+
|
|
105
135
|
super.setConfiguration(configuration)
|
|
136
|
+
// An empty update leaves upstream initialization pending until configuration arrives or it times out.
|
|
137
|
+
if (configuration == null) return
|
|
106
138
|
this.#waitingForConfiguration = false
|
|
107
|
-
|
|
139
|
+
|
|
140
|
+
if (wasWaiting) {
|
|
141
|
+
this.#logInitialConfiguration()
|
|
142
|
+
} else if (recovering) {
|
|
143
|
+
this.#logRecovery()
|
|
144
|
+
}
|
|
108
145
|
}
|
|
109
146
|
|
|
110
147
|
/**
|
|
@@ -131,6 +168,12 @@ class FlaggingProvider extends DatadogNodeServerProvider {
|
|
|
131
168
|
} catch { /* logging failure must not affect initialization */ }
|
|
132
169
|
}
|
|
133
170
|
|
|
171
|
+
#logRecovery () {
|
|
172
|
+
try {
|
|
173
|
+
log.debug('Feature Flags: configuration applied after the provider was not ready; provider is ready again')
|
|
174
|
+
} catch { /* logging failure must not affect applying the configuration */ }
|
|
175
|
+
}
|
|
176
|
+
|
|
134
177
|
/**
|
|
135
178
|
* Called when the provider is shut down.
|
|
136
179
|
* Cleans up resources including channel subscriptions.
|
|
@@ -142,6 +185,7 @@ class FlaggingProvider extends DatadogNodeServerProvider {
|
|
|
142
185
|
this.#spanEnrichmentHook = undefined
|
|
143
186
|
this.#flagEvalEVPHook?.destroy()
|
|
144
187
|
this.#flagEvalEVPHook = undefined
|
|
188
|
+
log.debug('Feature Flags: provider closed')
|
|
145
189
|
}
|
|
146
190
|
}
|
|
147
191
|
|
|
@@ -20,18 +20,31 @@ function enable (rc, getOpenfeatureProxy, subscribe) {
|
|
|
20
20
|
/**
|
|
21
21
|
* @param {string} action
|
|
22
22
|
* @param {import('@datadog/openfeature-node-server').UniversalFlagConfigurationV1} conf
|
|
23
|
+
* @param {string} [id] - Remote Config configuration ID
|
|
23
24
|
*/
|
|
24
|
-
const updateConfiguration = (action, conf) => {
|
|
25
|
+
const updateConfiguration = (action, conf, id) => {
|
|
25
26
|
if (action === 'apply' || action === 'modify') {
|
|
26
27
|
getOpenfeatureProxy().setConfiguration(conf)
|
|
28
|
+
// Counting flags allocates a key array, so it stays behind the debug callback.
|
|
27
29
|
// eslint-disable-next-line eslint-rules/eslint-log-printf-style
|
|
28
30
|
log.debug(() => {
|
|
31
|
+
// The payload is not schema-validated and this runs after setConfiguration, so a throw here would
|
|
32
|
+
// report an already applied configuration as failed only when debug logging is on. Template literals
|
|
33
|
+
// throw on values such as `{ toString: null }`, so the callback returns printf arguments instead.
|
|
29
34
|
const flagCount = Object.keys(conf?.flags ?? {}).length
|
|
30
|
-
return
|
|
35
|
+
return [
|
|
36
|
+
'Feature Flags: remote_config configuration %s applied successfully ' +
|
|
37
|
+
'(%d flag(s) received; per-flag validity is checked at evaluation, ' +
|
|
38
|
+
'configuration environment=%s, createdAt=%s, id=%s)',
|
|
39
|
+
action, flagCount, conf?.environment?.name, conf?.createdAt, id,
|
|
40
|
+
]
|
|
31
41
|
})
|
|
32
42
|
} else if (action === 'unapply') {
|
|
33
|
-
log.debug('Feature Flags: remote_config configuration removed')
|
|
34
43
|
getOpenfeatureProxy().setConfiguration(undefined)
|
|
44
|
+
log.debug(
|
|
45
|
+
'Feature Flags: remote_config configuration %s removed; flag evaluations will return their default values',
|
|
46
|
+
id
|
|
47
|
+
)
|
|
35
48
|
}
|
|
36
49
|
}
|
|
37
50
|
rc.setProductHandler('FFE_FLAGS', updateConfiguration)
|
|
@@ -143,7 +143,14 @@ class BaseFFEWriter {
|
|
|
143
143
|
continue
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
let eventSizeBytes
|
|
147
|
+
try {
|
|
148
|
+
eventSizeBytes = Buffer.byteLength(JSON.stringify(event))
|
|
149
|
+
} catch {
|
|
150
|
+
log.warn('%s could not serialize an event, dropping event', this.constructor.name)
|
|
151
|
+
this._droppedEvents++
|
|
152
|
+
continue
|
|
153
|
+
}
|
|
147
154
|
|
|
148
155
|
// Check individual event size limit if configured
|
|
149
156
|
if (this._eventSizeLimit && eventSizeBytes > this._eventSizeLimit) {
|
|
@@ -175,7 +182,14 @@ class BaseFFEWriter {
|
|
|
175
182
|
this._buffer = []
|
|
176
183
|
this._bufferSize = 0
|
|
177
184
|
|
|
178
|
-
|
|
185
|
+
let payload
|
|
186
|
+
try {
|
|
187
|
+
payload = this._encode(this.makePayload(events))
|
|
188
|
+
} catch {
|
|
189
|
+
log.warn('%s could not encode %d events, dropping batch', this.constructor.name, events.length)
|
|
190
|
+
this._droppedEvents += events.length
|
|
191
|
+
return
|
|
192
|
+
}
|
|
179
193
|
|
|
180
194
|
// Keep byte counting behind the debug callback because payloads can be several megabytes.
|
|
181
195
|
// eslint-disable-next-line eslint-rules/eslint-log-printf-style
|
|
@@ -198,14 +212,19 @@ class BaseFFEWriter {
|
|
|
198
212
|
*/
|
|
199
213
|
destroy () {
|
|
200
214
|
if (this.#destroyer) {
|
|
201
|
-
log.debug('
|
|
215
|
+
log.debug('%s stopping with %d buffered events; final flush requested without awaiting delivery',
|
|
216
|
+
this.constructor.name, this._buffer.length)
|
|
202
217
|
clearInterval(this._periodic)
|
|
203
218
|
this.flush()
|
|
204
219
|
globalThis[Symbol.for('dd-trace')].beforeExitHandlers.delete(this.#destroyer)
|
|
205
220
|
this.#destroyer = undefined
|
|
206
221
|
|
|
207
222
|
if (this._droppedEvents > 0) {
|
|
208
|
-
log.warn(
|
|
223
|
+
log.warn(
|
|
224
|
+
'%s dropped %d events (buffer capacity, size limits, serialization or delivery failures)',
|
|
225
|
+
this.constructor.name,
|
|
226
|
+
this._droppedEvents
|
|
227
|
+
)
|
|
209
228
|
}
|
|
210
229
|
}
|
|
211
230
|
}
|
|
@@ -310,16 +329,15 @@ class BaseFFEWriter {
|
|
|
310
329
|
* @param {(delivered: boolean) => void} [onComplete] - True only for a successful final response
|
|
311
330
|
*/
|
|
312
331
|
#sendRequest (payload, eventCount, route, fallbackRoute, onComplete) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
332
|
+
request(payload, route.requestOptions, (error, response, statusCode) => {
|
|
333
|
+
const errorMessage = error && (this.#formatError
|
|
334
|
+
? this.#formatError(error, statusCode)
|
|
335
|
+
: error.message)
|
|
317
336
|
if (fallbackRoute && isSafeToReplay(error, statusCode)) {
|
|
318
337
|
log.debug(
|
|
319
|
-
'%s switching from %s
|
|
338
|
+
'%s switching from %s to direct intake after definitive rejection',
|
|
320
339
|
this.constructor.name,
|
|
321
|
-
route.url.
|
|
322
|
-
route.endpoint
|
|
340
|
+
route.url.origin
|
|
323
341
|
)
|
|
324
342
|
if (this._requestOptions === route.requestOptions) {
|
|
325
343
|
this.#activateRoute(fallbackRoute)
|
|
@@ -332,27 +350,25 @@ class BaseFFEWriter {
|
|
|
332
350
|
|
|
333
351
|
if (fallbackRoute && isTransportFailure(error, statusCode)) {
|
|
334
352
|
log.debug(
|
|
335
|
-
'%s switching future batches from %s
|
|
353
|
+
'%s switching future batches from %s to direct intake after an ambiguous failure without replay',
|
|
336
354
|
this.constructor.name,
|
|
337
|
-
route.url.
|
|
338
|
-
route.endpoint
|
|
355
|
+
route.url.origin
|
|
339
356
|
)
|
|
340
357
|
if (this._requestOptions === route.requestOptions) {
|
|
341
358
|
this.#activateRoute(fallbackRoute)
|
|
342
359
|
this._fallbackRoute = undefined
|
|
343
360
|
route.onFallback?.()
|
|
344
361
|
}
|
|
345
|
-
|
|
362
|
+
this.#logDropped(route, eventCount, error, errorMessage, statusCode)
|
|
346
363
|
onComplete?.(false)
|
|
347
364
|
return
|
|
348
365
|
}
|
|
349
366
|
|
|
350
367
|
if (fallbackRoute && shouldSwitchFutureRoute(statusCode)) {
|
|
351
368
|
log.debug(
|
|
352
|
-
'%s switching future batches from %s
|
|
369
|
+
'%s switching future batches from %s to direct intake after status %d without replay',
|
|
353
370
|
this.constructor.name,
|
|
354
|
-
route.url.
|
|
355
|
-
route.endpoint,
|
|
371
|
+
route.url.origin,
|
|
356
372
|
statusCode
|
|
357
373
|
)
|
|
358
374
|
if (this._requestOptions === route.requestOptions) {
|
|
@@ -360,7 +376,7 @@ class BaseFFEWriter {
|
|
|
360
376
|
this._fallbackRoute = undefined
|
|
361
377
|
route.onFallback?.()
|
|
362
378
|
}
|
|
363
|
-
|
|
379
|
+
this.#logDropped(route, eventCount, error, errorMessage, statusCode)
|
|
364
380
|
onComplete?.(false)
|
|
365
381
|
return
|
|
366
382
|
}
|
|
@@ -374,25 +390,42 @@ class BaseFFEWriter {
|
|
|
374
390
|
shouldSwitchFutureRoute(statusCode))
|
|
375
391
|
) {
|
|
376
392
|
route.onUnavailable()
|
|
377
|
-
|
|
378
|
-
log.error('Failed to send events to %s%s: %s', route.url.href, route.endpoint, errorMessage)
|
|
379
|
-
} else {
|
|
380
|
-
log.warn('Events request returned status %d', statusCode)
|
|
381
|
-
}
|
|
393
|
+
this.#logDropped(route, eventCount, error, errorMessage, statusCode)
|
|
382
394
|
onComplete?.(false)
|
|
383
395
|
return
|
|
384
396
|
}
|
|
385
397
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
398
|
+
const delivered = !error && statusCode >= 200 && statusCode < 300
|
|
399
|
+
if (delivered) {
|
|
400
|
+
log.debug('%s accepted %d events at %s (%s, status %d); downstream delivery is not observed',
|
|
401
|
+
this.constructor.name, eventCount, route.url.origin,
|
|
402
|
+
// An Agent URL path prefix precedes the EVP path, so the route type cannot be read from its start.
|
|
403
|
+
route.endpoint.includes('/evp_proxy/') ? 'Agent/local EVP handoff' : 'HTTP receiver', statusCode)
|
|
390
404
|
} else {
|
|
391
|
-
|
|
405
|
+
this.#logDropped(route, eventCount, error, errorMessage, statusCode)
|
|
392
406
|
}
|
|
393
|
-
onComplete?.(
|
|
407
|
+
onComplete?.(delivered)
|
|
394
408
|
})
|
|
395
409
|
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Batches are not retried after a failed final attempt, so the failure log states the loss.
|
|
413
|
+
*
|
|
414
|
+
* @param {ActiveWriterRoute} route - Route that failed
|
|
415
|
+
* @param {number} eventCount - Event count in the dropped batch
|
|
416
|
+
* @param {Error | null} error - Request error
|
|
417
|
+
* @param {string | null | undefined} errorMessage - Redacted request error
|
|
418
|
+
* @param {number | undefined} statusCode - HTTP response status
|
|
419
|
+
*/
|
|
420
|
+
#logDropped (route, eventCount, error, errorMessage, statusCode) {
|
|
421
|
+
if (error) {
|
|
422
|
+
log.error('%s failed to send %d events to %s (status=%s, cause=%s); events dropped',
|
|
423
|
+
this.constructor.name, eventCount, route.url.origin, statusCode ?? 'none', errorMessage)
|
|
424
|
+
} else {
|
|
425
|
+
log.warn('%s events request to %s returned status %d; %d events were dropped',
|
|
426
|
+
this.constructor.name, route.url.origin, statusCode, eventCount)
|
|
427
|
+
}
|
|
428
|
+
}
|
|
396
429
|
}
|
|
397
430
|
|
|
398
431
|
module.exports = BaseFFEWriter
|
|
@@ -12,12 +12,16 @@ const {
|
|
|
12
12
|
} = require('../../evp_proxy/constants')
|
|
13
13
|
const { joinEVPProxyPath } = require('../../evp_proxy/path')
|
|
14
14
|
const log = require('../../log')
|
|
15
|
+
const { snapshotFeatures } = require('./split-features')
|
|
15
16
|
const BaseFFEWriter = require('./base')
|
|
16
17
|
|
|
17
18
|
// Disabled-state cap. Drops invalidate experiment results because the provider's
|
|
18
19
|
// exposure dedupe cache keeps masking dropped events after recovery. The first
|
|
19
20
|
// drop emits a warning and `droppedEventCount` accumulates the cumulative loss.
|
|
20
21
|
const PENDING_MAX_EVENTS = 1000
|
|
22
|
+
// Include the in-flight batch in both budgets. Leave headroom in the shared 64 MiB request buffer.
|
|
23
|
+
const DELIVERY_MAX_BYTES = 16 * 1024 * 1024
|
|
24
|
+
const DELIVERY_MAX_BATCHES = 1000
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
27
|
* @typedef {object} ExposureRoute
|
|
@@ -39,6 +43,7 @@ const PENDING_MAX_EVENTS = 1000
|
|
|
39
43
|
* @property {string} flag.key - Flag key
|
|
40
44
|
* @property {object} variant - Variant information
|
|
41
45
|
* @property {string} variant.key - Variant key
|
|
46
|
+
* @property {Record<string, string | number | boolean>} [features]
|
|
42
47
|
* @property {number} [serial_id] - Serial id of the split the subject landed in
|
|
43
48
|
* @property {object} subject - Subject (user/entity) information
|
|
44
49
|
* @property {string} subject.id - Subject identifier
|
|
@@ -73,6 +78,19 @@ class ExposuresWriter extends BaseFFEWriter {
|
|
|
73
78
|
#context
|
|
74
79
|
|
|
75
80
|
#dropWarned = false
|
|
81
|
+
#deliveryWarned = false
|
|
82
|
+
#closed = false
|
|
83
|
+
#appendDepth = 0
|
|
84
|
+
#inFlight = false
|
|
85
|
+
#deliveryBytes = 0
|
|
86
|
+
#deliveryCount = 0
|
|
87
|
+
/** @type {{ payload: string, eventCount: number, bytes: number }[]} */
|
|
88
|
+
#deliveryQueue = []
|
|
89
|
+
/** @type {ReturnType<typeof setTimeout> | undefined} */
|
|
90
|
+
#deliveryTimer
|
|
91
|
+
#shutdownDeadline = Infinity
|
|
92
|
+
/** @type {ReturnType<typeof setTimeout> | undefined} */
|
|
93
|
+
#shutdownTimer
|
|
76
94
|
|
|
77
95
|
/**
|
|
78
96
|
* @param {import('../../config/config-base')} config - Tracer configuration object
|
|
@@ -91,6 +109,10 @@ class ExposuresWriter extends BaseFFEWriter {
|
|
|
91
109
|
payloadSizeLimit: EVP_PAYLOAD_SIZE_LIMIT,
|
|
92
110
|
eventSizeLimit: EVP_EVENT_SIZE_LIMIT,
|
|
93
111
|
headers,
|
|
112
|
+
// Request errors can echo credentials in the URL or response body.
|
|
113
|
+
formatError: (error, statusCode) => statusCode === undefined
|
|
114
|
+
? /** @type {{ code?: string }} */ (error).code ?? 'UNKNOWN'
|
|
115
|
+
: 'none',
|
|
94
116
|
})
|
|
95
117
|
|
|
96
118
|
if (route.agent || route.fallback) {
|
|
@@ -118,6 +140,14 @@ class ExposuresWriter extends BaseFFEWriter {
|
|
|
118
140
|
* @param {ExposureRoute} [route] - Selected EVP route
|
|
119
141
|
*/
|
|
120
142
|
setEnabled (enabled, route) {
|
|
143
|
+
if (this.#closed) {
|
|
144
|
+
// An outstanding request may discover unavailability during shutdown.
|
|
145
|
+
if (!enabled) {
|
|
146
|
+
this.#enabled = false
|
|
147
|
+
this.#discardDelivery()
|
|
148
|
+
}
|
|
149
|
+
return
|
|
150
|
+
}
|
|
121
151
|
if (route) {
|
|
122
152
|
this.#setRoute(route)
|
|
123
153
|
}
|
|
@@ -125,10 +155,14 @@ class ExposuresWriter extends BaseFFEWriter {
|
|
|
125
155
|
this.#enabled = enabled
|
|
126
156
|
|
|
127
157
|
if (enabled && this.#pendingEvents.length > 0) {
|
|
158
|
+
log.debug('%s exposure delivery enabled; queueing %d pending exposure event(s)',
|
|
159
|
+
this.constructor.name, this.#pendingEvents.length)
|
|
128
160
|
// Flush all pending events as a batch
|
|
129
161
|
super.append(this.#pendingEvents)
|
|
130
162
|
this.#pendingEvents = []
|
|
131
163
|
}
|
|
164
|
+
if (enabled) this.#scheduleDelivery()
|
|
165
|
+
else this.#cancelDelivery()
|
|
132
166
|
}
|
|
133
167
|
|
|
134
168
|
/**
|
|
@@ -162,8 +196,14 @@ class ExposuresWriter extends BaseFFEWriter {
|
|
|
162
196
|
* @param {ExposureEvent|ExposureEvent[]} events - Exposure event(s) to append
|
|
163
197
|
*/
|
|
164
198
|
append (events) {
|
|
199
|
+
if (this.#closed) return
|
|
165
200
|
if (this.#enabled) {
|
|
166
|
-
|
|
201
|
+
this.#appendDepth++
|
|
202
|
+
try {
|
|
203
|
+
super.append(events)
|
|
204
|
+
} finally {
|
|
205
|
+
this.#appendDepth--
|
|
206
|
+
}
|
|
167
207
|
return
|
|
168
208
|
}
|
|
169
209
|
|
|
@@ -194,6 +234,123 @@ class ExposuresWriter extends BaseFFEWriter {
|
|
|
194
234
|
return
|
|
195
235
|
}
|
|
196
236
|
super.flush()
|
|
237
|
+
// Explicit, periodic and shutdown flushes may start delivery immediately.
|
|
238
|
+
// A byte-triggered flush during append must never initiate transport inline.
|
|
239
|
+
if (this.#appendDepth === 0) this.#drainDelivery()
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
destroy () {
|
|
243
|
+
if (this.#closed) return
|
|
244
|
+
this.#closed = true
|
|
245
|
+
this.#shutdownDeadline = Date.now() + this._timeout
|
|
246
|
+
this.#shutdownTimer = setTimeout(() => {
|
|
247
|
+
this.#shutdownTimer = undefined
|
|
248
|
+
this.#expireShutdown()
|
|
249
|
+
}, this._timeout)
|
|
250
|
+
this.#shutdownTimer.unref?.()
|
|
251
|
+
if (!this.#enabled) {
|
|
252
|
+
const undelivered = this.#pendingEvents.length + this._buffer.length
|
|
253
|
+
if (undelivered > 0) {
|
|
254
|
+
log.warn('%s dropped %d exposure event(s) at shutdown because exposure delivery was not enabled',
|
|
255
|
+
this.constructor.name, undelivered)
|
|
256
|
+
}
|
|
257
|
+
this._droppedEvents += undelivered
|
|
258
|
+
this.#pendingEvents = []
|
|
259
|
+
this._buffer = []
|
|
260
|
+
this._bufferSize = 0
|
|
261
|
+
this.#discardDelivery()
|
|
262
|
+
}
|
|
263
|
+
super.destroy()
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Queues an encoded exposure batch, keeping accepted batches when capacity is exhausted.
|
|
268
|
+
* @param {string} payload - Encoded payload
|
|
269
|
+
* @param {number} eventCount - Number of exposures
|
|
270
|
+
*/
|
|
271
|
+
_sendPayload (payload, eventCount) {
|
|
272
|
+
const bytes = Buffer.byteLength(payload)
|
|
273
|
+
if (this.#deliveryBytes + bytes > DELIVERY_MAX_BYTES || this.#deliveryCount >= DELIVERY_MAX_BATCHES) {
|
|
274
|
+
this._droppedEvents += eventCount
|
|
275
|
+
if (!this.#deliveryWarned) {
|
|
276
|
+
this.#deliveryWarned = true
|
|
277
|
+
log.warn('%s delivery queue full, dropping newest batch', this.constructor.name)
|
|
278
|
+
}
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
this.#deliveryQueue.push({ payload, eventCount, bytes })
|
|
282
|
+
this.#deliveryBytes += bytes
|
|
283
|
+
this.#deliveryCount++
|
|
284
|
+
this.#scheduleDelivery()
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
#scheduleDelivery () {
|
|
288
|
+
if (this.#deliveryQueue.length === 0) {
|
|
289
|
+
if (!this.#inFlight) this.#cancelShutdownTimer()
|
|
290
|
+
return
|
|
291
|
+
}
|
|
292
|
+
if (!this.#enabled || this.#inFlight || this.#deliveryTimer) return
|
|
293
|
+
// A timer yields past socket completion so Node can reach beforeExit between requests.
|
|
294
|
+
// Only the bounded shutdown drain should keep an otherwise idle process alive.
|
|
295
|
+
this.#deliveryTimer = setTimeout(() => {
|
|
296
|
+
this.#deliveryTimer = undefined
|
|
297
|
+
this.#drainDelivery()
|
|
298
|
+
})
|
|
299
|
+
if (!this.#closed) this.#deliveryTimer.unref?.()
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
#expireShutdown () {
|
|
303
|
+
const before = this._droppedEvents
|
|
304
|
+
this.#discardDelivery()
|
|
305
|
+
const dropped = this._droppedEvents - before
|
|
306
|
+
if (dropped > 0) {
|
|
307
|
+
log.warn('%s shutdown deadline reached, dropping %d queued events', this.constructor.name, dropped)
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
#cancelShutdownTimer () {
|
|
312
|
+
clearTimeout(this.#shutdownTimer)
|
|
313
|
+
this.#shutdownTimer = undefined
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
#cancelDelivery () {
|
|
317
|
+
if (!this.#deliveryTimer) return
|
|
318
|
+
clearTimeout(this.#deliveryTimer)
|
|
319
|
+
this.#deliveryTimer = undefined
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
#discardDelivery () {
|
|
323
|
+
this.#cancelDelivery()
|
|
324
|
+
this.#cancelShutdownTimer()
|
|
325
|
+
for (const batch of this.#deliveryQueue) {
|
|
326
|
+
this._droppedEvents += batch.eventCount
|
|
327
|
+
this.#deliveryBytes -= batch.bytes
|
|
328
|
+
this.#deliveryCount--
|
|
329
|
+
}
|
|
330
|
+
this.#deliveryQueue = []
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
#drainDelivery () {
|
|
334
|
+
this.#cancelDelivery()
|
|
335
|
+
if (Date.now() >= this.#shutdownDeadline) {
|
|
336
|
+
this.#expireShutdown()
|
|
337
|
+
return
|
|
338
|
+
}
|
|
339
|
+
if (!this.#enabled || this.#inFlight) return
|
|
340
|
+
const batch = this.#deliveryQueue.shift()
|
|
341
|
+
if (!batch) {
|
|
342
|
+
this.#cancelShutdownTimer()
|
|
343
|
+
return
|
|
344
|
+
}
|
|
345
|
+
this.#inFlight = true
|
|
346
|
+
super._sendPayload(batch.payload, batch.eventCount, delivered => {
|
|
347
|
+
this.#inFlight = false
|
|
348
|
+
this.#deliveryBytes -= batch.bytes
|
|
349
|
+
this.#deliveryCount--
|
|
350
|
+
if (!delivered) this._droppedEvents += batch.eventCount
|
|
351
|
+
// Yield even when a transport implementation invokes its callback synchronously.
|
|
352
|
+
this.#scheduleDelivery()
|
|
353
|
+
})
|
|
197
354
|
}
|
|
198
355
|
|
|
199
356
|
/**
|
|
@@ -222,6 +379,9 @@ class ExposuresWriter extends BaseFFEWriter {
|
|
|
222
379
|
},
|
|
223
380
|
}
|
|
224
381
|
|
|
382
|
+
const features = snapshotFeatures(event.features)
|
|
383
|
+
if (features !== undefined) formatted.features = features
|
|
384
|
+
|
|
225
385
|
if (typeof event.serial_id === 'number') {
|
|
226
386
|
formatted.serial_id = event.serial_id
|
|
227
387
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { MAX_EVALUATION_TIMESTAMP_MS } = require('../constants/constants')
|
|
4
|
+
const { snapshotFeatures } = require('./split-features')
|
|
5
|
+
|
|
4
6
|
const { snapshotEvaluationContext } = require('./flag-evaluation-context')
|
|
5
7
|
const {
|
|
6
8
|
recordContextTruncated, recordDropped, recordHookError, recordTargetingKeyOmitted,
|
|
@@ -82,6 +84,9 @@ class FlagEvalEVPHook {
|
|
|
82
84
|
flagKey: hookContext.flagKey,
|
|
83
85
|
variant: evaluationDetails.variant,
|
|
84
86
|
allocationKey: typeof metadata?.__dd_allocation_key === 'string' ? metadata.__dd_allocation_key : undefined,
|
|
87
|
+
features: metadata?.__dd_has_evaluation_features === true
|
|
88
|
+
? snapshotFeatures(metadata, '__dd_evaluation_feature.')
|
|
89
|
+
: undefined,
|
|
85
90
|
runtimeDefault: evaluationDetails.variant === undefined,
|
|
86
91
|
errorCode: evaluationDetails.errorCode,
|
|
87
92
|
targetingKey,
|
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
FLAG_EVALUATION_GLOBAL_CAP,
|
|
8
8
|
FLAG_EVALUATION_PER_FLAG_CAP,
|
|
9
9
|
} = require('../constants/constants')
|
|
10
|
+
const { snapshotFeatures } = require('./split-features')
|
|
10
11
|
const { validatedContextEntries, snapshotFromEntries } = require('./flag-evaluation-context')
|
|
11
12
|
const { normalizeTargetingKey, optionalKey, protectedErrorCode } =
|
|
12
13
|
require('./flag-evaluation-pii')
|
|
@@ -20,6 +21,7 @@ const MAX_DIRECT_IDENTITY_LENGTH = 16_383
|
|
|
20
21
|
* @typedef {object} FlagEvaluationEvent
|
|
21
22
|
* @property {string} flagKey
|
|
22
23
|
* @property {string} [variant]
|
|
24
|
+
* @property {Record<string, string | number | boolean>} [features]
|
|
23
25
|
* @property {string} [allocationKey]
|
|
24
26
|
* @property {boolean} runtimeDefault
|
|
25
27
|
* @property {unknown} [errorCode]
|
|
@@ -32,6 +34,7 @@ const MAX_DIRECT_IDENTITY_LENGTH = 16_383
|
|
|
32
34
|
* @typedef {object} AggregationDimensions
|
|
33
35
|
* @property {string} flagKey
|
|
34
36
|
* @property {string} [variant]
|
|
37
|
+
* @property {Record<string, string | number | boolean>} [features]
|
|
35
38
|
* @property {string} [allocation]
|
|
36
39
|
* @property {string} [error]
|
|
37
40
|
*/
|
|
@@ -94,10 +97,11 @@ class FlagEvaluationAggregator {
|
|
|
94
97
|
const error = protectedErrorCode(event.errorCode)
|
|
95
98
|
const variant = optionalKey(event.variant)
|
|
96
99
|
const allocation = optionalKey(event.allocationKey)
|
|
100
|
+
const features = snapshotFeatures(event.features)
|
|
97
101
|
// Group by the raw key; the serializer independently hashes protected rows once per output bucket.
|
|
98
102
|
const identity = JSON.stringify([
|
|
99
103
|
flagKey, variant, allocation, event.runtimeDefault === true, error,
|
|
100
|
-
targetingKey, contextEntries, consent,
|
|
104
|
+
targetingKey, contextEntries, consent, features,
|
|
101
105
|
])
|
|
102
106
|
// Keep digest keys separate from short JSON identities, which always start with '['.
|
|
103
107
|
const fullKey = identity.length > MAX_DIRECT_IDENTITY_LENGTH
|
|
@@ -111,11 +115,11 @@ class FlagEvaluationAggregator {
|
|
|
111
115
|
|
|
112
116
|
const perFlag = this.#perFlag.get(flagKey) ?? 0
|
|
113
117
|
if (perFlag >= FLAG_EVALUATION_PER_FLAG_CAP) {
|
|
114
|
-
this.#addDegraded(event, { flagKey, variant, allocation, error })
|
|
118
|
+
this.#addDegraded(event, { flagKey, variant, allocation, error, features })
|
|
115
119
|
return
|
|
116
120
|
}
|
|
117
121
|
if (this.#full.size >= FLAG_EVALUATION_GLOBAL_CAP) {
|
|
118
|
-
this.#addDegraded(event, { flagKey, variant, allocation, error })
|
|
122
|
+
this.#addDegraded(event, { flagKey, variant, allocation, error, features })
|
|
119
123
|
return
|
|
120
124
|
}
|
|
121
125
|
|
|
@@ -124,6 +128,7 @@ class FlagEvaluationAggregator {
|
|
|
124
128
|
flagKey,
|
|
125
129
|
variant,
|
|
126
130
|
allocation,
|
|
131
|
+
features,
|
|
127
132
|
runtimeDefault: event.runtimeDefault === true,
|
|
128
133
|
error,
|
|
129
134
|
rawTargetingKey: targetingKey,
|
|
@@ -165,7 +170,7 @@ class FlagEvaluationAggregator {
|
|
|
165
170
|
recordDegraded('cardinality_cap')
|
|
166
171
|
const key = JSON.stringify([
|
|
167
172
|
dimensions.flagKey, dimensions.variant, dimensions.allocation,
|
|
168
|
-
event.runtimeDefault === true, dimensions.error,
|
|
173
|
+
event.runtimeDefault === true, dimensions.error, dimensions.features,
|
|
169
174
|
])
|
|
170
175
|
const existing = this.#degraded.get(key)
|
|
171
176
|
if (existing) {
|