dd-trace 6.24.0 → 6.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/ci/cypress/support.js +2 -1
- package/ci/init.js +2 -22
- package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-setup.mjs +729 -724
- package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
- package/ext/exporters.js +0 -1
- package/index.d.ts +105 -5
- package/initialize.mjs +5 -2
- package/package.json +41 -36
- package/packages/datadog-esbuild/index.js +16 -70
- package/packages/datadog-esbuild/src/log.js +2 -29
- package/packages/datadog-instrumentations/src/ai.js +6 -1
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +20 -17
- package/packages/datadog-instrumentations/src/helpers/bundler-esm-exports.js +582 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +576 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-client.js +30 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +61 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +80 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +23 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/microgateway-core.js +1 -2
- package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -1
- package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +41 -0
- package/packages/datadog-instrumentations/src/next.js +203 -26
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/router.js +35 -12
- package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/arn.js +41 -0
- package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -13
- package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-express/src/code_origin.js +2 -2
- package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +20 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +21 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +11 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-http/src/client.js +34 -10
- package/packages/datadog-plugin-http2/src/client.js +40 -14
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
- package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-postgres/src/index.js +118 -41
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
- package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
- package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +3 -2
- package/packages/datadog-plugin-ws/src/close.js +3 -5
- package/packages/datadog-plugin-ws/src/producer.js +1 -4
- package/packages/datadog-plugin-ws/src/receiver.js +3 -5
- package/packages/datadog-plugin-ws/src/server.js +44 -13
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-vite/index.js +537 -0
- package/packages/datadog-vite/src/log.js +5 -0
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/datadog-webpack/src/log.js +2 -29
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/index.js +1 -1
- package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
- package/packages/dd-trace/src/aiguard/sdk.js +8 -2
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +21 -1
- package/packages/dd-trace/src/appsec/channels.js +7 -0
- package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
- package/packages/dd-trace/src/appsec/graphql.js +89 -7
- package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
- package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
- package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
- package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
- package/packages/dd-trace/src/appsec/index.js +6 -0
- package/packages/dd-trace/src/appsec/lambda.js +17 -17
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
- package/packages/dd-trace/src/appsec/rasp/index.js +8 -1
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
- package/packages/dd-trace/src/appsec/rasp/utils.js +33 -3
- package/packages/dd-trace/src/appsec/recommended.json +1358 -94
- package/packages/dd-trace/src/appsec/reporter.js +9 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
- package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
- package/packages/dd-trace/src/appsec/waf/index.js +65 -6
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +5 -0
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -4
- package/packages/dd-trace/src/config/index.js +63 -31
- package/packages/dd-trace/src/config/parsers.js +44 -0
- package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
- package/packages/dd-trace/src/config/remote_config.js +2 -1
- package/packages/dd-trace/src/config/supported-configurations.json +172 -10
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/datastreams/fnv.js +27 -0
- package/packages/dd-trace/src/datastreams/pathway.js +113 -28
- package/packages/dd-trace/src/datastreams/processor.js +5 -4
- package/packages/dd-trace/src/debugger/config.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +2 -2
- package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +6 -2
- package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
- package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
- package/packages/dd-trace/src/exporter.js +0 -11
- package/packages/dd-trace/src/exporters/common/request.js +81 -48
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/git_metadata.js +2 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/index.js +6 -3
- package/packages/dd-trace/src/lambda/facade.js +75 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +54 -3
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +81 -1
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/sdk.js +19 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
- package/packages/dd-trace/src/llmobs/tagger.js +22 -0
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +6 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +7 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +55 -27
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
- package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +24 -0
- package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +143 -17
- package/packages/dd-trace/src/plugins/index.js +8 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +52 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +263 -82
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +80 -56
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +92 -40
- package/packages/dd-trace/src/plugins/util/url.js +18 -7
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +6 -6
- package/packages/dd-trace/src/plugins/util/web.js +65 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiler.js +74 -12
- package/packages/dd-trace/src/profiling/profiler.js +30 -2
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/profiling/remote-config.js +354 -0
- package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/propagation-hash/index.js +7 -0
- package/packages/dd-trace/src/proxy.js +46 -54
- package/packages/dd-trace/src/span_processor.js +20 -0
- package/packages/dd-trace/src/startup-log.js +8 -6
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +220 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/vite.d.ts +7 -0
- package/vite.js +3 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -18
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -649
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/datadog-esbuild/src/utils.js +0 -318
- package/packages/datadog-plugin-cypress/src/support.js +0 -1348
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
|
@@ -16,6 +16,7 @@ const {
|
|
|
16
16
|
SPAN_KIND,
|
|
17
17
|
MODEL_NAME,
|
|
18
18
|
MODEL_PROVIDER,
|
|
19
|
+
EXPERIMENT_EXPECTED_OUTPUT,
|
|
19
20
|
METADATA,
|
|
20
21
|
COST_TAGS,
|
|
21
22
|
AGENT_MANIFEST,
|
|
@@ -267,6 +268,11 @@ class LLMObsSpanProcessor {
|
|
|
267
268
|
const isExperiment = spanKind === 'experiment'
|
|
268
269
|
const hasExperimentInput = isExperiment && Object.hasOwn(mlObsTags, EXPERIMENT_INPUT)
|
|
269
270
|
const hasExperimentOutput = isExperiment && Object.hasOwn(mlObsTags, EXPERIMENT_OUTPUT)
|
|
271
|
+
const hasExperimentExpectedOutput = isExperiment && Object.hasOwn(mlObsTags, EXPERIMENT_EXPECTED_OUTPUT)
|
|
272
|
+
|
|
273
|
+
if (hasExperimentExpectedOutput) {
|
|
274
|
+
llmObsSpan.expectedOutput = mlObsTags[EXPERIMENT_EXPECTED_OUTPUT]
|
|
275
|
+
}
|
|
270
276
|
|
|
271
277
|
if (hasExperimentInput) {
|
|
272
278
|
llmObsSpan.input = [{ role: '', content: mlObsTags[EXPERIMENT_INPUT] }]
|
|
@@ -318,6 +324,9 @@ class LLMObsSpanProcessor {
|
|
|
318
324
|
const [processedOutput] = processedSpan.output
|
|
319
325
|
if (hasExperimentInput && processedInput !== undefined) meta.input = processedInput.content
|
|
320
326
|
if (hasExperimentOutput && processedOutput !== undefined) meta.output = processedOutput.content
|
|
327
|
+
if (Object.hasOwn(processedSpan, 'expectedOutput') && processedSpan.expectedOutput !== undefined) {
|
|
328
|
+
meta.expected_output = processedSpan.expectedOutput
|
|
329
|
+
}
|
|
321
330
|
} else {
|
|
322
331
|
if (processedSpan.input) {
|
|
323
332
|
if (inputType === 'messages') {
|
|
@@ -8,9 +8,11 @@ const {
|
|
|
8
8
|
MODEL_NAME,
|
|
9
9
|
MODEL_PROVIDER,
|
|
10
10
|
SESSION_ID,
|
|
11
|
+
EXPERIMENT_TAGS,
|
|
11
12
|
SESSION_ID_TRACE_DEFAULT_KEY,
|
|
12
13
|
ML_APP,
|
|
13
14
|
SPAN_KIND,
|
|
15
|
+
EXPERIMENT_EXPECTED_OUTPUT,
|
|
14
16
|
EXPERIMENT_INPUT,
|
|
15
17
|
EXPERIMENT_OUTPUT,
|
|
16
18
|
INPUT_VALUE,
|
|
@@ -121,6 +123,7 @@ class LLMObsTagger {
|
|
|
121
123
|
integration,
|
|
122
124
|
agentVersion,
|
|
123
125
|
_decorator,
|
|
126
|
+
_experimentTags,
|
|
124
127
|
} = {}) {
|
|
125
128
|
// Do not register it in the map if it does not have an LLMObs span kind.
|
|
126
129
|
if (!this.#config.llmobs.DD_LLMOBS_ENABLED || !kind) return
|
|
@@ -188,6 +191,15 @@ class LLMObsTagger {
|
|
|
188
191
|
const tags = annotationContext?.tags
|
|
189
192
|
if (tags) this.tagSpanTags(span, tags)
|
|
190
193
|
|
|
194
|
+
// Experiment context flows down the span tree, matching Python, which carries it on the span context.
|
|
195
|
+
// It stays out of annotationContext and is applied after its tags, so a user's nested
|
|
196
|
+
// annotationContext({ tags }) can neither replace it nor reassign the span to another run.
|
|
197
|
+
const experimentTags = _experimentTags ?? registry.get(parent)?.[EXPERIMENT_TAGS]
|
|
198
|
+
if (experimentTags) {
|
|
199
|
+
this._setTag(span, EXPERIMENT_TAGS, experimentTags)
|
|
200
|
+
this.tagSpanTags(span, experimentTags)
|
|
201
|
+
}
|
|
202
|
+
|
|
191
203
|
// apply after tags so only keys present at span start are accepted.
|
|
192
204
|
if (annotationContext?.costTags != null) {
|
|
193
205
|
this.tagCostTags(span, annotationContext.costTags, 'annotation_context')
|
|
@@ -342,6 +354,16 @@ class LLMObsTagger {
|
|
|
342
354
|
this.#tagExperimentValue(span, outputData, EXPERIMENT_OUTPUT, 'output')
|
|
343
355
|
}
|
|
344
356
|
|
|
357
|
+
/**
|
|
358
|
+
* Stores the expected output for an experiment span.
|
|
359
|
+
*
|
|
360
|
+
* @param {import('../opentracing/span')} span
|
|
361
|
+
* @param {unknown} expectedOutput
|
|
362
|
+
*/
|
|
363
|
+
tagExperimentExpectedOutput (span, expectedOutput) {
|
|
364
|
+
this.#tagExperimentValue(span, expectedOutput, EXPERIMENT_EXPECTED_OUTPUT, 'expected output')
|
|
365
|
+
}
|
|
366
|
+
|
|
345
367
|
tagTextIO (span, inputData, outputData) {
|
|
346
368
|
this.#tagText(span, inputData, INPUT_VALUE)
|
|
347
369
|
this.#tagText(span, outputData, OUTPUT_VALUE)
|
|
@@ -25,6 +25,10 @@ class LogChannel {
|
|
|
25
25
|
this._level = getChannelLogLevel(level)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
getLevel () {
|
|
29
|
+
return Object.keys(Level).find(name => Level[name] === this._level) ?? 'none'
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
subscribe (logger) {
|
|
29
33
|
if (Level.trace >= this._level) {
|
|
30
34
|
traceChannel.subscribe(logger.trace)
|
|
@@ -65,4 +65,9 @@ function trace (log) {
|
|
|
65
65
|
withNoop(() => logger.debug(log))
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
function getLogLevel () {
|
|
69
|
+
if (!enabled) return 'none'
|
|
70
|
+
return logChannel.getLevel()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = { configure, error, warn, info, debug, trace, getLogLevel }
|
|
@@ -7,6 +7,7 @@ const { setTimeout: sleep } = require('node:timers/promises')
|
|
|
7
7
|
const request = require('../exporters/common/request')
|
|
8
8
|
const { getClientLibraryHeaders } = require('../exporters/common/client-library-headers')
|
|
9
9
|
const log = require('../log')
|
|
10
|
+
const { reportIgnoredFlagSelection } = require('./flag-selection')
|
|
10
11
|
|
|
11
12
|
const MAX_ATTEMPTS = 3
|
|
12
13
|
const FIRST_RETRY_MIN_MS = 2000
|
|
@@ -20,10 +21,12 @@ const POLL_FAILED_WITHOUT_CONFIGURATION = 'Feature Flags: agentless configuratio
|
|
|
20
21
|
/**
|
|
21
22
|
* @typedef {object} AgentlessSourceConfig
|
|
22
23
|
* @property {URL} endpoint
|
|
24
|
+
* @property {boolean} [flagSelectionSent]
|
|
23
25
|
* @property {number} pollIntervalMs
|
|
24
26
|
* @property {number} requestTimeoutMs
|
|
25
27
|
* @property {string | undefined} apiKey
|
|
26
28
|
* @property {string | undefined} env
|
|
29
|
+
* @property {string | undefined} service
|
|
27
30
|
*/
|
|
28
31
|
|
|
29
32
|
/**
|
|
@@ -161,6 +164,8 @@ class AgentlessConfigurationSource {
|
|
|
161
164
|
const headers = getClientLibraryHeaders()
|
|
162
165
|
headers['Accept-Encoding'] = 'gzip'
|
|
163
166
|
if (this.#config.apiKey) headers['DD-API-KEY'] = this.#config.apiKey
|
|
167
|
+
// The CDN uses this header to attribute the usage of this request to the service.
|
|
168
|
+
if (this.#config.service) headers['DD-Service'] = this.#config.service
|
|
164
169
|
if (this.#etag) headers['If-None-Match'] = this.#etag
|
|
165
170
|
|
|
166
171
|
/**
|
|
@@ -248,6 +253,8 @@ class AgentlessConfigurationSource {
|
|
|
248
253
|
return
|
|
249
254
|
}
|
|
250
255
|
|
|
256
|
+
if (this.#config.flagSelectionSent) reportIgnoredFlagSelection(response.headers)
|
|
257
|
+
|
|
251
258
|
const etag = response.headers?.etag
|
|
252
259
|
const value = Array.isArray(etag) ? etag[0] : etag
|
|
253
260
|
this.#etag = value?.trim() || undefined
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { normalizeService } = require('../config/normalize-service')
|
|
3
4
|
const { createSiteUrl } = require('../exporters/common/url')
|
|
4
5
|
const log = require('../log')
|
|
6
|
+
const { warnRemoteConfigFlagSelection, withFlagSelection } = require('./flag-selection')
|
|
5
7
|
|
|
6
8
|
const DEFAULT_AGENTLESS_PATH = '/api/v2/feature-flagging/config/rules-based/server'
|
|
7
9
|
const MAX_POLL_INTERVAL_SECONDS = 60 * 60
|
|
@@ -10,12 +12,21 @@ const AGENTLESS_START_MESSAGE = 'Feature Flags: starting agentless configuration
|
|
|
10
12
|
const REMOTE_CONFIG_DISABLED_WARNING = 'Feature Flags: configuration source is remote_config but Remote ' +
|
|
11
13
|
'Configuration is disabled; flag evaluations will return their default values. Set ' +
|
|
12
14
|
'DD_REMOTE_CONFIGURATION_ENABLED=true or DD_FEATURE_FLAGS_CONFIGURATION_SOURCE=agentless'
|
|
15
|
+
const USAGE_SERVICE_REJECTED_MESSAGE =
|
|
16
|
+
'Feature Flags: service %s has no normalized name; DD-Service header not sent'
|
|
17
|
+
const MISSING_API_KEY_MESSAGE = 'DD_API_KEY is required for the default Datadog Feature Flagging endpoint; ' +
|
|
18
|
+
'set DD_API_KEY, set DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL, or set ' +
|
|
19
|
+
'DD_FEATURE_FLAGS_CONFIGURATION_SOURCE=remote_config to load flags through the Datadog Agent'
|
|
13
20
|
|
|
14
21
|
/**
|
|
15
22
|
* @typedef {import('@datadog/openfeature-node-server').UniversalFlagConfigurationV1} UniversalFlagConfiguration
|
|
16
23
|
*/
|
|
17
24
|
|
|
18
25
|
/**
|
|
26
|
+
* Creates the agentless source when it is the selected configuration source.
|
|
27
|
+
*
|
|
28
|
+
* Throws when the agentless source is selected but cannot start, so the provider can fail initialization.
|
|
29
|
+
*
|
|
19
30
|
* @param {import('../config/config-base')} config
|
|
20
31
|
* @param {(configuration: UniversalFlagConfiguration) => void} applyConfiguration
|
|
21
32
|
*/
|
|
@@ -26,46 +37,47 @@ function create (config, applyConfiguration) {
|
|
|
26
37
|
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_POLL_INTERVAL_SECONDS: pollIntervalSeconds,
|
|
27
38
|
DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_REQUEST_TIMEOUT_SECONDS: requestTimeoutSeconds,
|
|
28
39
|
DD_FEATURE_FLAGS_ENABLED: enabled,
|
|
40
|
+
flagSelection,
|
|
29
41
|
} = config.featureFlags
|
|
30
42
|
|
|
31
43
|
if (!enabled) return
|
|
32
44
|
|
|
33
45
|
if (source !== 'agentless') {
|
|
34
46
|
log.debug('Feature Flags: configuration source is %s, not agentless; skipping agentless setup', source)
|
|
35
|
-
if (source === 'remote_config'
|
|
36
|
-
log.warn(REMOTE_CONFIG_DISABLED_WARNING)
|
|
47
|
+
if (source === 'remote_config') {
|
|
48
|
+
if (!config.remoteConfig?.DD_REMOTE_CONFIGURATION_ENABLED) log.warn(REMOTE_CONFIG_DISABLED_WARNING)
|
|
49
|
+
warnRemoteConfigFlagSelection(flagSelection)
|
|
37
50
|
}
|
|
38
51
|
return
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
const hasCustomEndpoint = Boolean(baseUrl?.trim())
|
|
42
55
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
throw new Error('DD_API_KEY is required for the default Datadog Feature Flagging endpoint')
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const AgentlessConfigurationSource = require('./agentless_configuration_source')
|
|
49
|
-
const resolvedEndpoint = endpoint(config, baseUrl)
|
|
50
|
-
const effectivePollIntervalSeconds = Math.min(pollIntervalSeconds, MAX_POLL_INTERVAL_SECONDS)
|
|
51
|
-
log.debug(
|
|
52
|
-
AGENTLESS_START_MESSAGE,
|
|
53
|
-
redactedUrl(resolvedEndpoint),
|
|
54
|
-
hasCustomEndpoint ? 'custom' : 'default',
|
|
55
|
-
effectivePollIntervalSeconds,
|
|
56
|
-
requestTimeoutSeconds,
|
|
57
|
-
hasCustomEndpoint ? 'not sent' : 'sent'
|
|
58
|
-
)
|
|
59
|
-
return new AgentlessConfigurationSource({
|
|
60
|
-
endpoint: resolvedEndpoint,
|
|
61
|
-
pollIntervalMs: effectivePollIntervalSeconds * 1000,
|
|
62
|
-
requestTimeoutMs: requestTimeoutSeconds * 1000,
|
|
63
|
-
apiKey: hasCustomEndpoint ? undefined : config.DD_API_KEY,
|
|
64
|
-
env: config.env,
|
|
65
|
-
}, applyConfiguration)
|
|
66
|
-
} catch (error) {
|
|
67
|
-
log.error('Unable to configure Feature Flagging configuration source', error)
|
|
56
|
+
if (!hasCustomEndpoint && !config.DD_API_KEY?.trim()) {
|
|
57
|
+
throw new Error(MISSING_API_KEY_MESSAGE)
|
|
68
58
|
}
|
|
59
|
+
|
|
60
|
+
const AgentlessConfigurationSource = require('./agentless_configuration_source')
|
|
61
|
+
const resolvedEndpoint = endpoint(config, baseUrl)
|
|
62
|
+
const selectedEndpoint = withFlagSelection(resolvedEndpoint, flagSelection)
|
|
63
|
+
const effectivePollIntervalSeconds = Math.min(pollIntervalSeconds, MAX_POLL_INTERVAL_SECONDS)
|
|
64
|
+
log.debug(
|
|
65
|
+
AGENTLESS_START_MESSAGE,
|
|
66
|
+
redactedUrl(resolvedEndpoint),
|
|
67
|
+
hasCustomEndpoint ? 'custom' : 'default',
|
|
68
|
+
effectivePollIntervalSeconds,
|
|
69
|
+
requestTimeoutSeconds,
|
|
70
|
+
hasCustomEndpoint ? 'not sent' : 'sent'
|
|
71
|
+
)
|
|
72
|
+
return new AgentlessConfigurationSource({
|
|
73
|
+
endpoint: selectedEndpoint ?? resolvedEndpoint,
|
|
74
|
+
flagSelectionSent: selectedEndpoint !== undefined,
|
|
75
|
+
pollIntervalMs: effectivePollIntervalSeconds * 1000,
|
|
76
|
+
requestTimeoutMs: requestTimeoutSeconds * 1000,
|
|
77
|
+
apiKey: hasCustomEndpoint ? undefined : config.DD_API_KEY,
|
|
78
|
+
env: config.env,
|
|
79
|
+
service: usageService(config.service),
|
|
80
|
+
}, applyConfiguration)
|
|
69
81
|
}
|
|
70
82
|
|
|
71
83
|
/**
|
|
@@ -107,6 +119,22 @@ function endpoint (config, configuredBaseUrl) {
|
|
|
107
119
|
return url
|
|
108
120
|
}
|
|
109
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Selects the DD-Service value: the tracer service, normalized with the same function as the inferred service. For
|
|
124
|
+
* example, `My Service` becomes `my_service`.
|
|
125
|
+
*
|
|
126
|
+
* If nothing is left of the normalized name, no value is sent. The normalized name has only ASCII characters, so
|
|
127
|
+
* Node.js cannot throw on the header. The tracer service itself does not change. The CDN alone decides which values it
|
|
128
|
+
* uses.
|
|
129
|
+
*
|
|
130
|
+
* @param {string | undefined} service - Tracer service name.
|
|
131
|
+
*/
|
|
132
|
+
function usageService (service) {
|
|
133
|
+
const name = normalizeService(service)
|
|
134
|
+
if (service && !name) log.debug(USAGE_SERVICE_REJECTED_MESSAGE, service)
|
|
135
|
+
return name || undefined
|
|
136
|
+
}
|
|
137
|
+
|
|
110
138
|
/**
|
|
111
139
|
* Drops everything but the origin; a custom base URL may embed a signed token in its path.
|
|
112
140
|
*
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const log = require('../log')
|
|
4
|
+
const telemetryMetrics = require('../telemetry/metrics')
|
|
5
|
+
|
|
6
|
+
// Fastly answers URLs over 8 KB with 414 URI Too Long: https://docs.fastly.com/products/network-services-resource-limits
|
|
7
|
+
const MAX_RULES_URL_BYTES = 8192
|
|
8
|
+
const NOT_SENT = 'featureFlags.flagSelection was not sent (%s: %s). Loading the full flag configuration.'
|
|
9
|
+
const IGNORED = 'featureFlags.flagSelection was ignored by the server (%s). Loaded the full flag configuration.'
|
|
10
|
+
const REMOTE_CONFIG_UNSUPPORTED = 'featureFlags.flagSelection is not supported when flags are delivered through ' +
|
|
11
|
+
'Remote Config. Loading the full flag configuration.'
|
|
12
|
+
const MALFORMED_LIMIT = 'featureFlags.flagSelection must be an object with optional tags and keyPatterns string arrays'
|
|
13
|
+
const URL_LIMIT = `the request URL is at most ${MAX_RULES_URL_BYTES} bytes`
|
|
14
|
+
const IGNORED_REASONS = new Set([
|
|
15
|
+
'malformed_selection',
|
|
16
|
+
'too_many_values',
|
|
17
|
+
'invalid_key_pattern',
|
|
18
|
+
'invalid_tag',
|
|
19
|
+
'tag_load_failed',
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
const tracerMetrics = telemetryMetrics.manager.namespace('tracers')
|
|
23
|
+
const countedDroppedReasons = new Set()
|
|
24
|
+
const reportedIgnoredReasons = new Set()
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {'malformed_selection' | 'too_many_values' | 'invalid_key_pattern' | 'invalid_tag'} DropReason
|
|
28
|
+
* @typedef {{ selection?: { tags: string[], keyPatterns: string[] }, error?: DropReason }} CanonicalizeResult
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
let flaggingCore
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {unknown} option - Raw `featureFlags.flagSelection` value; must not be null or undefined.
|
|
35
|
+
* @returns {CanonicalizeResult}
|
|
36
|
+
*/
|
|
37
|
+
function canonicalize (option) {
|
|
38
|
+
try {
|
|
39
|
+
flaggingCore ??= require('../../../../vendor/dist/@datadog/flagging-core')
|
|
40
|
+
return flaggingCore.canonicalizeFlagSelection(option)
|
|
41
|
+
} catch {
|
|
42
|
+
// Canonicalization failed or the vendored bundle could not load: nothing can be sent.
|
|
43
|
+
return { error: 'malformed_selection' }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {DropReason} reason
|
|
49
|
+
*/
|
|
50
|
+
function limitDescription (reason) {
|
|
51
|
+
switch (reason) {
|
|
52
|
+
case 'malformed_selection':
|
|
53
|
+
return MALFORMED_LIMIT
|
|
54
|
+
case 'too_many_values':
|
|
55
|
+
return `each list accepts at most ${flaggingCore.MAX_FLAG_SELECTION_VALUES} values`
|
|
56
|
+
case 'invalid_key_pattern':
|
|
57
|
+
return `each key pattern is at most ${flaggingCore.MAX_FLAG_SELECTION_KEY_PATTERN_BYTES} UTF-8 bytes`
|
|
58
|
+
case 'invalid_tag':
|
|
59
|
+
return `each tag is at most ${flaggingCore.MAX_FLAG_SELECTION_TAG_BYTES} UTF-8 bytes`
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {DropReason} reason
|
|
65
|
+
* @param {string} limit
|
|
66
|
+
*/
|
|
67
|
+
function reportDropped (reason, limit) {
|
|
68
|
+
log.error(NOT_SENT, reason, limit)
|
|
69
|
+
if (countedDroppedReasons.has(reason)) return
|
|
70
|
+
countedDroppedReasons.add(reason)
|
|
71
|
+
tracerMetrics.count('flag_selection.dropped', { reason }).inc()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Percent-encodes everything outside the RFC 3986 unreserved set; `encodeURIComponent` keeps `!'()*`.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} value
|
|
78
|
+
*/
|
|
79
|
+
function encodeQueryValue (value) {
|
|
80
|
+
return encodeURIComponent(value)
|
|
81
|
+
.replaceAll(/[!'()*]/g, char => `%${char.charCodeAt(0).toString(16).toUpperCase()}`)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Adds the canonical selection to the rules endpoint query, or reports why it is not sent.
|
|
86
|
+
*
|
|
87
|
+
* @param {URL} endpoint
|
|
88
|
+
* @param {unknown} option - Raw `featureFlags.flagSelection` value.
|
|
89
|
+
* @returns {URL | undefined} The endpoint with the selection, or undefined when no selection is sent.
|
|
90
|
+
*/
|
|
91
|
+
function withFlagSelection (endpoint, option) {
|
|
92
|
+
if (option === undefined || option === null) return
|
|
93
|
+
|
|
94
|
+
const { selection, error } = canonicalize(option)
|
|
95
|
+
if (error) {
|
|
96
|
+
reportDropped(error, limitDescription(error))
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
if (!selection) return
|
|
100
|
+
|
|
101
|
+
let parameters
|
|
102
|
+
try {
|
|
103
|
+
parameters = [
|
|
104
|
+
...selection.tags.map(tag => `selected_flag_tags=${encodeQueryValue(tag)}`),
|
|
105
|
+
...selection.keyPatterns.map(pattern => `selected_flag_key_patterns=${encodeQueryValue(pattern)}`),
|
|
106
|
+
].join('&')
|
|
107
|
+
} catch {
|
|
108
|
+
// flagging-core validates entries by index but canonicalizes through the iterator, which can yield bad text.
|
|
109
|
+
reportDropped('malformed_selection', MALFORMED_LIMIT)
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
const url = new URL(endpoint)
|
|
113
|
+
const query = url.search.slice(1)
|
|
114
|
+
url.search = query ? `${query}&${parameters}` : parameters
|
|
115
|
+
|
|
116
|
+
if (Buffer.byteLength(url.href) > MAX_RULES_URL_BYTES) {
|
|
117
|
+
reportDropped('too_many_values', URL_LIMIT)
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
return url
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param {import('node:http').IncomingHttpHeaders | undefined} headers - Headers of an applied 200 response.
|
|
125
|
+
*/
|
|
126
|
+
function reportIgnoredFlagSelection (headers) {
|
|
127
|
+
const value = headers?.['dd-flag-selection-ignored']
|
|
128
|
+
if (value === undefined || value === '') return
|
|
129
|
+
|
|
130
|
+
// Anything but an exact known reason is reported as unknown, so header content never reaches logs or telemetry.
|
|
131
|
+
const reason = typeof value === 'string' && IGNORED_REASONS.has(value) ? value : 'unknown'
|
|
132
|
+
if (reportedIgnoredReasons.has(reason)) return
|
|
133
|
+
reportedIgnoredReasons.add(reason)
|
|
134
|
+
log.error(IGNORED, reason)
|
|
135
|
+
tracerMetrics.count('flag_selection.ignored', { reason }).inc()
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @param {unknown} option - Raw `featureFlags.flagSelection` value.
|
|
140
|
+
*/
|
|
141
|
+
function warnRemoteConfigFlagSelection (option) {
|
|
142
|
+
if (option === undefined || option === null) return
|
|
143
|
+
|
|
144
|
+
const { selection, error } = canonicalize(option)
|
|
145
|
+
if (selection || error) log.warn(REMOTE_CONFIG_UNSUPPORTED)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
module.exports = {
|
|
149
|
+
reportIgnoredFlagSelection,
|
|
150
|
+
warnRemoteConfigFlagSelection,
|
|
151
|
+
withFlagSelection,
|
|
152
|
+
}
|
|
@@ -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')
|
|
@@ -16,6 +17,7 @@ const FlagEvalEVPHook = require('./writers/flag-eval-evp-hook')
|
|
|
16
17
|
const RAW_EVALUATION_DATA_WARNING = 'Feature Flags: debug logging is enabled, so feature flag logs include raw ' +
|
|
17
18
|
'evaluation data (targeting keys, evaluation context attributes, flag values, and default values) that may ' +
|
|
18
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.'
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* OpenFeature provider that integrates with Datadog's feature flagging system.
|
|
@@ -34,6 +36,9 @@ class FlaggingProvider extends DatadogNodeServerProvider {
|
|
|
34
36
|
/** @type {{ start: Function, stop: Function } | undefined} */
|
|
35
37
|
#configurationSource
|
|
36
38
|
|
|
39
|
+
/** @type {Error | undefined} */
|
|
40
|
+
#configurationSourceError
|
|
41
|
+
|
|
37
42
|
/** @type {number} */
|
|
38
43
|
#initializationTimeoutMs
|
|
39
44
|
|
|
@@ -82,7 +87,17 @@ class FlaggingProvider extends DatadogNodeServerProvider {
|
|
|
82
87
|
this.hooks.push(telemetryHook(this.#flagEvalEVPHook))
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
|
|
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
|
+
}
|
|
86
101
|
this.#configurationSource?.start()
|
|
87
102
|
}
|
|
88
103
|
|
|
@@ -98,6 +113,9 @@ class FlaggingProvider extends DatadogNodeServerProvider {
|
|
|
98
113
|
|
|
99
114
|
if (hasConfiguration) {
|
|
100
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)
|
|
101
119
|
} else {
|
|
102
120
|
log.debug('Feature Flags: waiting for provider initialization (timeout %dms)...', this.#initializationTimeoutMs)
|
|
103
121
|
}
|
|
@@ -329,9 +329,7 @@ class BaseFFEWriter {
|
|
|
329
329
|
* @param {(delivered: boolean) => void} [onComplete] - True only for a successful final response
|
|
330
330
|
*/
|
|
331
331
|
#sendRequest (payload, eventCount, route, fallbackRoute, onComplete) {
|
|
332
|
-
|
|
333
|
-
const requestOptions = { ...route.requestOptions, headers: { ...route.requestOptions.headers } }
|
|
334
|
-
request(payload, requestOptions, (error, response, statusCode) => {
|
|
332
|
+
request(payload, route.requestOptions, (error, response, statusCode) => {
|
|
335
333
|
const errorMessage = error && (this.#formatError
|
|
336
334
|
? this.#formatError(error, statusCode)
|
|
337
335
|
: error.message)
|
|
@@ -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
|
/**
|
|
@@ -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)
|