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
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { normalizeService } = require('../config/normalize-service')
|
|
4
|
+
const applyRemoteConfig = require('../config/remote-config-layers')
|
|
5
|
+
const log = require('../log')
|
|
6
|
+
const { allocationProfilingAvailable, cpuProfilingAvailable } = require('./runtime-capabilities')
|
|
7
|
+
|
|
8
|
+
const PRODUCT = 'APM_PROFILING'
|
|
9
|
+
|
|
10
|
+
/** @typedef {'cpuTime' | 'wallTime' | 'heapSize' | 'heapObjects' | 'allocations'} ProfileType */
|
|
11
|
+
|
|
12
|
+
// Keep every mapped profile type here; parsing is derived from this list. Profile types Node.js
|
|
13
|
+
// can't collect, like locks and exceptions, are ignored. So are CPU time and allocations where this
|
|
14
|
+
// runtime can't collect them, as the tracer configuration would turn them off again.
|
|
15
|
+
const PROFILE_TYPES = /** @type {ProfileType[]} */ (['wallTime', 'heapSize', 'heapObjects'])
|
|
16
|
+
if (cpuProfilingAvailable) PROFILE_TYPES.unshift('cpuTime')
|
|
17
|
+
if (allocationProfilingAvailable) PROFILE_TYPES.push('allocations')
|
|
18
|
+
|
|
19
|
+
// Profile types collected by the heap profiler.
|
|
20
|
+
const HEAP_PROFILE_TYPES = /** @type {ProfileType[]} */ (['heapSize', 'heapObjects', 'allocations'])
|
|
21
|
+
|
|
22
|
+
// Running profiler types (see the profiling layer's getRunningTypes()) by the profile types they serve.
|
|
23
|
+
const PROFILE_TYPES_BY_RUNNING_TYPE = /** @type {Record<string, ProfileType[]>} */ ({
|
|
24
|
+
cpu: ['cpuTime'],
|
|
25
|
+
wall: ['wallTime'],
|
|
26
|
+
space: ['heapSize', 'heapObjects'],
|
|
27
|
+
allocations: ['allocations'],
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// Specificity levels of a target, from least to most specific, following the profiling Remote
|
|
31
|
+
// Config payload merging ADR: other tags < env < service < workload < container name < pod <
|
|
32
|
+
// container ID. Infrastructure levels are recognized by the tag names the Datadog agent assigns.
|
|
33
|
+
const LEVEL_OTHER_TAGS = 1
|
|
34
|
+
const LEVEL_ENV = 2
|
|
35
|
+
const LEVEL_SERVICE = 3
|
|
36
|
+
/** @type {Map<string, number>} */
|
|
37
|
+
const LEVEL_BY_TAG_NAME = new Map()
|
|
38
|
+
for (const [level, names] of /** @type {[number, string[]][]} */ ([
|
|
39
|
+
[4, ['kube_deployment', 'kube_replica_set', 'kube_stateful_set', 'kube_daemon_set', 'kube_job', 'kube_cronjob',
|
|
40
|
+
'kube_argo_rollout', 'oshift_deployment', 'task_family']],
|
|
41
|
+
[5, ['kube_container_name', 'container_name', 'ecs_container_name']],
|
|
42
|
+
[6, ['pod_name', 'task_arn']],
|
|
43
|
+
[7, ['container_id']],
|
|
44
|
+
])) {
|
|
45
|
+
for (const name of names) LEVEL_BY_TAG_NAME.set(name, level)
|
|
46
|
+
}
|
|
47
|
+
// A target's level outranks any number of conditions, which only break ties within a level.
|
|
48
|
+
const CONDITIONS_PER_LEVEL = 1000
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {ReturnType<import('../config')>} Config
|
|
52
|
+
* @typedef {Partial<Record<ProfileType, boolean>>} RequestedProfilers
|
|
53
|
+
* @typedef {{ service?: string, env?: string, tags: string[] }} Target
|
|
54
|
+
* @typedef {{
|
|
55
|
+
* id: string,
|
|
56
|
+
* profilers: RequestedProfilers,
|
|
57
|
+
* targets: Target[],
|
|
58
|
+
* }} ProfilingConfig
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Apply matching profiling configs; omitted fields use local settings.
|
|
63
|
+
*
|
|
64
|
+
* @param {import('../remote_config')} rc - RemoteConfig instance
|
|
65
|
+
* @param {Config} config - Tracer configuration
|
|
66
|
+
* @param {() => string[]} getRunningProfileTypes - Types of the running profilers
|
|
67
|
+
*/
|
|
68
|
+
function enable (rc, config, getRunningProfileTypes) {
|
|
69
|
+
// The libdatadog fetcher used in agentless mode doesn't know APM_PROFILING yet, and would log an
|
|
70
|
+
// error for it.
|
|
71
|
+
if (config.DD_AGENTLESS_ENABLED) return
|
|
72
|
+
|
|
73
|
+
/** @type {Map<string, ProfilingConfig>} */
|
|
74
|
+
const configs = new Map()
|
|
75
|
+
// Match the initially empty profiling layer.
|
|
76
|
+
let lastSettings = 'null'
|
|
77
|
+
/**
|
|
78
|
+
* Profile types running under local configuration, captured before the first profiling content
|
|
79
|
+
* is applied. Known limitations: a profiler that SSI heuristics start later, or that APM_TRACING
|
|
80
|
+
* enabled earlier, is not told apart from local configuration.
|
|
81
|
+
*
|
|
82
|
+
* @type {Set<string> | undefined}
|
|
83
|
+
*/
|
|
84
|
+
let localProfileTypes
|
|
85
|
+
|
|
86
|
+
rc.subscribeProducts(PRODUCT)
|
|
87
|
+
rc.setBatchHandler([PRODUCT], (transaction) => {
|
|
88
|
+
for (const item of transaction.toUnapply) {
|
|
89
|
+
configs.delete(item.id)
|
|
90
|
+
transaction.ack(item.path)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const item of [...transaction.toApply, ...transaction.toModify]) {
|
|
94
|
+
/** @type {string[]} */
|
|
95
|
+
const problems = []
|
|
96
|
+
const parsed = parse(item.id, item.file, problems)
|
|
97
|
+
if (parsed === undefined) {
|
|
98
|
+
configs.delete(item.id)
|
|
99
|
+
} else {
|
|
100
|
+
configs.set(item.id, parsed)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (problems.length === 0) {
|
|
104
|
+
transaction.ack(item.path)
|
|
105
|
+
} else {
|
|
106
|
+
// Report partial failures while still applying valid fields.
|
|
107
|
+
const reason = problems.join('; ')
|
|
108
|
+
log.debug('[profiling/remote-config] Invalid profiling configuration %s: %s', item.id, reason)
|
|
109
|
+
transaction.error(item.path, reason)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Skip unchanged settings to avoid redundant telemetry and config publishes.
|
|
114
|
+
// toSettings inserts keys in a fixed order, making JSON equality stable.
|
|
115
|
+
const merged = merge(configs.values(), config)
|
|
116
|
+
if (configs.size > 0) {
|
|
117
|
+
localProfileTypes ??= toProfileTypes(getRunningProfileTypes())
|
|
118
|
+
}
|
|
119
|
+
const settings = toSettings(merged, localProfileTypes ?? new Set())
|
|
120
|
+
const serialized = JSON.stringify(settings)
|
|
121
|
+
if (serialized === lastSettings) return
|
|
122
|
+
lastSettings = serialized
|
|
123
|
+
|
|
124
|
+
applyRemoteConfig(config, PRODUCT, settings)
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @param {string} id - Remote config id
|
|
130
|
+
* @param {unknown} file - Remote config payload
|
|
131
|
+
* @param {string[]} problems - Validation errors to report
|
|
132
|
+
* @returns {ProfilingConfig | undefined} undefined for payloads without profiling content or with
|
|
133
|
+
* invalid targets
|
|
134
|
+
*/
|
|
135
|
+
function parse (id, file, problems) {
|
|
136
|
+
if (!isObject(file)) {
|
|
137
|
+
problems.push('payload is not an object')
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const { profilers, settings, targets } = file
|
|
142
|
+
if (profilers === undefined && settings === undefined) return
|
|
143
|
+
|
|
144
|
+
const parsedTargets = parseTargets(targets, problems)
|
|
145
|
+
if (parsedTargets === undefined) return
|
|
146
|
+
|
|
147
|
+
const parsedProfilers = parseProfilers(profilers, problems)
|
|
148
|
+
if (settings !== undefined && !isObject(settings)) problems.push('settings is not an object')
|
|
149
|
+
return { id, profilers: parsedProfilers, targets: parsedTargets }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @param {unknown} profilers - The payload's `profilers` section
|
|
154
|
+
* @param {string[]} problems - Validation errors to report
|
|
155
|
+
* @returns {RequestedProfilers}
|
|
156
|
+
*/
|
|
157
|
+
function parseProfilers (profilers, problems) {
|
|
158
|
+
/** @type {RequestedProfilers} */
|
|
159
|
+
const parsed = {}
|
|
160
|
+
if (!isObject(profilers)) {
|
|
161
|
+
if (profilers !== undefined) problems.push('profilers is not an object')
|
|
162
|
+
return parsed
|
|
163
|
+
}
|
|
164
|
+
for (const type of PROFILE_TYPES) {
|
|
165
|
+
const value = profilers[type]
|
|
166
|
+
if (typeof value === 'boolean') {
|
|
167
|
+
parsed[type] = value
|
|
168
|
+
} else if (value !== undefined) {
|
|
169
|
+
problems.push(`profilers.${type} is not a boolean`)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return parsed
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @param {unknown} targets - The payload's `targets` section
|
|
177
|
+
* @param {string[]} problems - Validation errors to report
|
|
178
|
+
* @returns {Target[] | undefined} undefined if the config must be dropped
|
|
179
|
+
*/
|
|
180
|
+
function parseTargets (targets, problems) {
|
|
181
|
+
if (targets === undefined) return []
|
|
182
|
+
if (!Array.isArray(targets)) {
|
|
183
|
+
problems.push('targets is not an array')
|
|
184
|
+
return
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** @type {Target[]} */
|
|
188
|
+
const parsed = []
|
|
189
|
+
for (let index = 0; index < targets.length; index++) {
|
|
190
|
+
const target = targets[index]
|
|
191
|
+
const { service, env, tags = [] } = isObject(target) ? target : {}
|
|
192
|
+
if (!isObject(target) ||
|
|
193
|
+
(service !== undefined && typeof service !== 'string') ||
|
|
194
|
+
(env !== undefined && typeof env !== 'string') ||
|
|
195
|
+
!Array.isArray(tags) || !tags.every(tag => typeof tag === 'string')) {
|
|
196
|
+
problems.push(`targets[${index}] is invalid`)
|
|
197
|
+
continue
|
|
198
|
+
}
|
|
199
|
+
parsed.push({ service, env, tags })
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Reject an all-invalid target list rather than treating it as untargeted.
|
|
203
|
+
if (parsed.length === 0 && targets.length !== 0) {
|
|
204
|
+
problems.push('no valid targets')
|
|
205
|
+
return
|
|
206
|
+
}
|
|
207
|
+
return parsed
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Merge the received configs field by field, with more specific targets winning. Remote Config only
|
|
212
|
+
* delivers configs that apply to this tracer, so every config is merged; targets only rank them.
|
|
213
|
+
*
|
|
214
|
+
* @param {Iterable<ProfilingConfig>} configs - Parsed remote configs
|
|
215
|
+
* @param {Config} config - Tracer configuration
|
|
216
|
+
*/
|
|
217
|
+
function merge (configs, config) {
|
|
218
|
+
/** @type {{ specificity: number, config: ProfilingConfig }[]} */
|
|
219
|
+
const ranked = []
|
|
220
|
+
for (const profilingConfig of configs) {
|
|
221
|
+
ranked.push({ specificity: getSpecificity(profilingConfig.targets, config), config: profilingConfig })
|
|
222
|
+
}
|
|
223
|
+
// Merge least specific first; break ties by ID so delivery order doesn't matter.
|
|
224
|
+
ranked.sort((a, b) => a.specificity - b.specificity || (a.config.id < b.config.id ? -1 : 1))
|
|
225
|
+
|
|
226
|
+
/** @type {RequestedProfilers} */
|
|
227
|
+
const profilers = {}
|
|
228
|
+
for (const { config: profilingConfig } of ranked) {
|
|
229
|
+
Object.assign(profilers, profilingConfig.profilers)
|
|
230
|
+
}
|
|
231
|
+
return profilers
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Specificity of the most specific target that is consistent with this tracer's service and env,
|
|
236
|
+
* or 0 if there is none. A config's targets can name several scopes, and the one it was delivered
|
|
237
|
+
* for has to be consistent with them. Tag conditions are assumed to hold: the agent has matched
|
|
238
|
+
* them, and the tracer doesn't know every tag it's matched by (e.g. Kubernetes tags).
|
|
239
|
+
*
|
|
240
|
+
* A target ranks by its most specific condition, and then by its number of conditions.
|
|
241
|
+
*
|
|
242
|
+
* @param {Target[]} targets - Targets of one config
|
|
243
|
+
* @param {Config} config - Tracer configuration
|
|
244
|
+
*/
|
|
245
|
+
function getSpecificity (targets, config) {
|
|
246
|
+
let specificity = 0
|
|
247
|
+
for (const { service, env, tags } of targets) {
|
|
248
|
+
const hasService = service !== undefined && service !== '*'
|
|
249
|
+
const hasEnv = env !== undefined && env !== '*'
|
|
250
|
+
// The agent and the backend match normalized values, so compare normalized values too.
|
|
251
|
+
if ((hasService && normalizeService(service) !== normalizeService(config.service)) ||
|
|
252
|
+
(hasEnv && normalizeService(env) !== normalizeService(config.env))) {
|
|
253
|
+
continue
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
let level = 0
|
|
257
|
+
if (hasService) level = LEVEL_SERVICE
|
|
258
|
+
else if (hasEnv) level = LEVEL_ENV
|
|
259
|
+
for (const tag of tags) {
|
|
260
|
+
const separator = tag.indexOf(':')
|
|
261
|
+
const name = (separator === -1 ? tag : tag.slice(0, separator)).toLowerCase()
|
|
262
|
+
level = Math.max(level, LEVEL_BY_TAG_NAME.get(name) ?? LEVEL_OTHER_TAGS)
|
|
263
|
+
}
|
|
264
|
+
const conditions = Number(hasService) + Number(hasEnv) + tags.length
|
|
265
|
+
specificity = Math.max(specificity, level * CONDITIONS_PER_LEVEL + conditions)
|
|
266
|
+
}
|
|
267
|
+
return specificity
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* @param {string[]} runningTypes - Types of the running profilers
|
|
272
|
+
* @returns {Set<string>} The profile types they serve
|
|
273
|
+
*/
|
|
274
|
+
function toProfileTypes (runningTypes) {
|
|
275
|
+
const profileTypes = new Set()
|
|
276
|
+
for (const runningType of runningTypes) {
|
|
277
|
+
const served = PROFILE_TYPES_BY_RUNNING_TYPE[runningType]
|
|
278
|
+
if (served === undefined) continue
|
|
279
|
+
for (const profileType of served) {
|
|
280
|
+
profileTypes.add(profileType)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return profileTypes
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Map payload fields to profiling environment variables.
|
|
288
|
+
*
|
|
289
|
+
* @param {RequestedProfilers} requested - Profile types requested by the merged remote configs
|
|
290
|
+
* @param {Set<string>} localProfileTypes - Profile types running under local configuration
|
|
291
|
+
* @returns {Partial<Record<import('../config/helper').SupportedEnvKey, string>> | null} null if no fields are set
|
|
292
|
+
*/
|
|
293
|
+
function toSettings (requested, localProfileTypes) {
|
|
294
|
+
if (PROFILE_TYPES.every(type => requested[type] === undefined)) return null
|
|
295
|
+
|
|
296
|
+
// Turning profiling on also starts every profile type that is on by default, so omitted types
|
|
297
|
+
// that weren't running locally are turned off; omitted types that were keep their local value.
|
|
298
|
+
/** @type {RequestedProfilers} */
|
|
299
|
+
const profilers = { ...requested }
|
|
300
|
+
const enablesProfiling = PROFILE_TYPES.some(type => requested[type] === true)
|
|
301
|
+
if (enablesProfiling) {
|
|
302
|
+
for (const type of PROFILE_TYPES) {
|
|
303
|
+
if (profilers[type] === undefined && !localProfileTypes.has(type)) profilers[type] = false
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const { cpuTime, wallTime, heapSize, heapObjects, allocations } = profilers
|
|
307
|
+
// A profile type is on when requested, or when omitted and running locally. A type that is on
|
|
308
|
+
// keeps the profiler that collects it running, even if the payload turns another type of that
|
|
309
|
+
// profiler off.
|
|
310
|
+
/** @param {ProfileType} type */
|
|
311
|
+
const isOn = type => profilers[type] ?? localProfileTypes.has(type)
|
|
312
|
+
|
|
313
|
+
/** @type {Partial<Record<import('../config/helper').SupportedEnvKey, string>>} */
|
|
314
|
+
const envs = {}
|
|
315
|
+
// The wall profiler also samples CPU time.
|
|
316
|
+
if (wallTime || cpuTime) {
|
|
317
|
+
envs.DD_PROFILING_WALLTIME_ENABLED = 'true'
|
|
318
|
+
} else if (wallTime === false && !isOn('cpuTime')) {
|
|
319
|
+
envs.DD_PROFILING_WALLTIME_ENABLED = 'false'
|
|
320
|
+
}
|
|
321
|
+
if (cpuTime !== undefined) {
|
|
322
|
+
envs.DD_PROFILING_CPU_ENABLED = String(cpuTime)
|
|
323
|
+
}
|
|
324
|
+
// The heap profiler collects heap sizes, live objects and, in allocation mode, allocations.
|
|
325
|
+
if (heapSize || heapObjects || allocations) {
|
|
326
|
+
envs.DD_PROFILING_HEAP_ENABLED = 'true'
|
|
327
|
+
} else if ((heapSize === false || heapObjects === false) && !HEAP_PROFILE_TYPES.some(isOn)) {
|
|
328
|
+
envs.DD_PROFILING_HEAP_ENABLED = 'false'
|
|
329
|
+
}
|
|
330
|
+
if (allocations !== undefined) {
|
|
331
|
+
envs.DD_PROFILING_ALLOCATION_ENABLED = String(allocations)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Any true enables profiling, and no type left on disables it; otherwise use the local setting.
|
|
335
|
+
if (enablesProfiling) {
|
|
336
|
+
envs.DD_PROFILING_ENABLED = 'true'
|
|
337
|
+
} else if (!PROFILE_TYPES.some(isOn)) {
|
|
338
|
+
envs.DD_PROFILING_ENABLED = 'false'
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return envs
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* @param {unknown} value
|
|
346
|
+
* @returns {value is Record<string, unknown>}
|
|
347
|
+
*/
|
|
348
|
+
function isObject (value) {
|
|
349
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
module.exports = {
|
|
353
|
+
enable,
|
|
354
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { NODE_MAJOR } = require('../../../../version')
|
|
4
|
+
|
|
5
|
+
// Profiling features that depend on the runtime. The tracer configuration turns them off where
|
|
6
|
+
// they're unavailable, and remote configuration ignores requests for the profile types they collect.
|
|
7
|
+
module.exports = {
|
|
8
|
+
// Allocation profiling needs a sampling hook only available on Node.js 26+.
|
|
9
|
+
allocationProfilingAvailable: NODE_MAJOR >= 26,
|
|
10
|
+
cpuProfilingAvailable: process.platform !== 'win32',
|
|
11
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { HTTP_METHOD, HTTP_ROUTE, RESOURCE_NAME, SPAN_TYPE } = require('../../../../ext/tags')
|
|
4
4
|
const { WEB } = require('../../../../ext/types')
|
|
5
|
+
const { INSTRUMENTATION_HTTP_RESOURCE, otelHttpResourceName } = require('../plugins/util/http-otel-semantics')
|
|
5
6
|
|
|
6
7
|
function isWebServerSpan (tags) {
|
|
7
8
|
return tags[SPAN_TYPE] === WEB
|
|
@@ -18,10 +19,9 @@ function endpointNameFromTags (tags) {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
// The endpoint name a web-server span's tag bag yields changes over the span's
|
|
21
|
-
// lifetime: plugins set `http.method` when the request arrives and
|
|
22
|
-
// `http.route`
|
|
23
|
-
//
|
|
24
|
-
// while it is still an interim placeholder.
|
|
22
|
+
// lifetime: plugins set `http.method` when the request arrives and refine
|
|
23
|
+
// `http.route` and `resource.name` as nested framework routes resolve.
|
|
24
|
+
// Returns the current endpoint, or undefined for a method-only placeholder.
|
|
25
25
|
//
|
|
26
26
|
// Consumers that read the tag bag lazily (the wall profiler resolves endpoint
|
|
27
27
|
// labels at serialization time) see the settled value for free and only need
|
|
@@ -44,7 +44,8 @@ function finalEndpoint (tags) {
|
|
|
44
44
|
// the string building inside endpointNameFromTags.
|
|
45
45
|
if (tags[RESOURCE_NAME] == null && tags[HTTP_ROUTE] == null) return
|
|
46
46
|
const endpoint = endpointNameFromTags(tags)
|
|
47
|
-
if (!endpoint || endpoint === tags[HTTP_METHOD]
|
|
47
|
+
if (!endpoint || endpoint === tags[HTTP_METHOD] ||
|
|
48
|
+
(endpoint === tags[INSTRUMENTATION_HTTP_RESOURCE] && endpoint === otelHttpResourceName(tags[HTTP_METHOD]))) return
|
|
48
49
|
return endpoint
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -47,6 +47,13 @@ class PropagationHashManager {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @returns {string | null} The container tags hash the agent last reported, if any
|
|
52
|
+
*/
|
|
53
|
+
getContainerTagsHash () {
|
|
54
|
+
return this._containerTagsHash
|
|
55
|
+
}
|
|
56
|
+
|
|
50
57
|
/**
|
|
51
58
|
* Get the propagation hash as a BigInt
|
|
52
59
|
* @returns {bigint | null} The propagation hash or null if disabled/unavailable
|
|
@@ -5,11 +5,10 @@ const uuid = require('../../../vendor/dist/crypto-randomuuid')
|
|
|
5
5
|
const NoopProxy = require('./noop/proxy')
|
|
6
6
|
const DatadogTracer = require('./tracer')
|
|
7
7
|
const getConfig = require('./config')
|
|
8
|
-
const { getEnvironmentVariable } = require('./config/helper')
|
|
9
8
|
const { reseed } = require('./id')
|
|
10
9
|
const runtimeMetrics = require('./runtime_metrics')
|
|
11
10
|
const log = require('./log')
|
|
12
|
-
const { setStartupLogPluginManager, startupLog } = require('./startup-log')
|
|
11
|
+
const { setStartupLogConfig, setStartupLogPluginManager, startupLog } = require('./startup-log')
|
|
13
12
|
const telemetry = require('./telemetry')
|
|
14
13
|
const nomenclature = require('./service-naming')
|
|
15
14
|
const PluginManager = require('./plugin_manager')
|
|
@@ -23,7 +22,6 @@ const {
|
|
|
23
22
|
} = require('./serverless')
|
|
24
23
|
const { flushServerlessTelemetry, registerTelemetryFlusher } = require('./flush')
|
|
25
24
|
const processTags = require('./process-tags')
|
|
26
|
-
const { isTrue } = require('./util')
|
|
27
25
|
const {
|
|
28
26
|
setBaggageItem,
|
|
29
27
|
getBaggageItem,
|
|
@@ -32,20 +30,6 @@ const {
|
|
|
32
30
|
removeAllBaggageItems,
|
|
33
31
|
} = require('./baggage')
|
|
34
32
|
|
|
35
|
-
const VALIDATION_MANIFEST_ENV = '_DD_TEST_OPTIMIZATION_VALIDATION_MANIFEST_FILE'
|
|
36
|
-
const VALIDATION_MODE_ENV = '_DD_TEST_OPTIMIZATION_VALIDATION_MODE'
|
|
37
|
-
const VALIDATION_OUTPUT_ENV = '_DD_TEST_OPTIMIZATION_VALIDATION_OUTPUT_DIR'
|
|
38
|
-
const ORDINARY_TRACING_DISABLED_MESSAGE =
|
|
39
|
-
'Ordinary dd-trace application tracing initialization is disabled during offline Test Optimization validation. ' +
|
|
40
|
-
'The CI test process must initialize through dd-trace/ci/init.'
|
|
41
|
-
const OFFLINE_VALIDATION_EXPORTERS = new Set([
|
|
42
|
-
'ci_validation',
|
|
43
|
-
'cucumber_worker',
|
|
44
|
-
'jest_worker',
|
|
45
|
-
'mocha_worker',
|
|
46
|
-
'playwright_worker',
|
|
47
|
-
'vitest_worker',
|
|
48
|
-
])
|
|
49
33
|
const OPENFEATURE_STATE_NOOP = 0
|
|
50
34
|
const OPENFEATURE_STATE_LAZY = 1
|
|
51
35
|
const OPENFEATURE_STATE_ACTIVE = 2
|
|
@@ -123,6 +107,9 @@ class Tracer extends NoopProxy {
|
|
|
123
107
|
/** @type {boolean} */
|
|
124
108
|
#configPublished = false
|
|
125
109
|
|
|
110
|
+
/** @type {boolean} */
|
|
111
|
+
#iastUnavailable = false
|
|
112
|
+
|
|
126
113
|
constructor () {
|
|
127
114
|
super()
|
|
128
115
|
|
|
@@ -166,11 +153,6 @@ class Tracer extends NoopProxy {
|
|
|
166
153
|
|
|
167
154
|
this._initialized = true
|
|
168
155
|
|
|
169
|
-
if (isOfflineTestOptimizationValidation() && !isOfflineValidationExporter(options)) {
|
|
170
|
-
process.stderr.write(`${ORDINARY_TRACING_DISABLED_MESSAGE}\n`)
|
|
171
|
-
return this
|
|
172
|
-
}
|
|
173
|
-
|
|
174
156
|
try {
|
|
175
157
|
const config = getConfig(options) // TODO: support dynamic code config
|
|
176
158
|
|
|
@@ -202,7 +184,7 @@ class Tracer extends NoopProxy {
|
|
|
202
184
|
: undefined
|
|
203
185
|
telemetry.start(config, this._pluginManager, telemetryLogOptions)
|
|
204
186
|
|
|
205
|
-
if (config.dogstatsd && !config.DD_AGENTLESS_ENABLED
|
|
187
|
+
if (config.dogstatsd && !config.DD_AGENTLESS_ENABLED) {
|
|
206
188
|
// Custom Metrics
|
|
207
189
|
lazyProxy(this, 'dogstatsd', () => require('./dogstatsd').CustomMetrics, config)
|
|
208
190
|
}
|
|
@@ -227,6 +209,9 @@ class Tracer extends NoopProxy {
|
|
|
227
209
|
this.#updateDebugger(config, rc)
|
|
228
210
|
})
|
|
229
211
|
|
|
212
|
+
// Subscribe even when profiling is off so RC can enable it.
|
|
213
|
+
require('./profiling/remote-config').enable(rc, config, profiler.getRunningProfileTypes)
|
|
214
|
+
|
|
230
215
|
rc.setProductHandler('AGENT_CONFIG', (action, conf) => {
|
|
231
216
|
if (!conf?.name?.startsWith('flare-log-level.')) return
|
|
232
217
|
|
|
@@ -277,14 +262,16 @@ class Tracer extends NoopProxy {
|
|
|
277
262
|
// OTel logs/metrics pipelines must be initialized BEFORE runtimeMetrics.start so that
|
|
278
263
|
// when the OTLP runtime metrics module calls metrics.getMeterProvider(), it gets the
|
|
279
264
|
// real provider, otherwise instruments register on the noop provider and never export.
|
|
265
|
+
let logs
|
|
266
|
+
let metrics
|
|
280
267
|
if (config.DD_LOGS_OTEL_ENABLED) {
|
|
281
268
|
const { initializeOpenTelemetryLogs } = require('./opentelemetry/logs')
|
|
282
|
-
initializeOpenTelemetryLogs(config)
|
|
269
|
+
logs = initializeOpenTelemetryLogs(config)
|
|
283
270
|
}
|
|
284
271
|
|
|
285
272
|
if (config.DD_METRICS_OTEL_ENABLED) {
|
|
286
273
|
const { initializeOpenTelemetryMetrics } = require('./opentelemetry/metrics')
|
|
287
|
-
initializeOpenTelemetryMetrics(config)
|
|
274
|
+
metrics = initializeOpenTelemetryMetrics(config)
|
|
288
275
|
}
|
|
289
276
|
|
|
290
277
|
if (config.runtimeMetrics.enabled) {
|
|
@@ -294,9 +281,12 @@ class Tracer extends NoopProxy {
|
|
|
294
281
|
registerTelemetryFlusher(done => runtimeMetrics.flush(done), { afterTrace: true })
|
|
295
282
|
}
|
|
296
283
|
|
|
297
|
-
this.#updateTracing(config)
|
|
284
|
+
const tracing = this.#updateTracing(config)
|
|
285
|
+
setStartupLogConfig(config, { ...tracing, logs, metrics })
|
|
286
|
+
setStartupLogPluginManager(this._pluginManager)
|
|
287
|
+
startupLog()
|
|
298
288
|
|
|
299
|
-
if (config.iast.DD_IAST_ENABLED) {
|
|
289
|
+
if (config.iast.DD_IAST_ENABLED && !this.#iastUnavailable) {
|
|
300
290
|
this._modules.rewriter.enable(config)
|
|
301
291
|
}
|
|
302
292
|
|
|
@@ -351,6 +341,16 @@ class Tracer extends NoopProxy {
|
|
|
351
341
|
log.error(BUNDLED_OPENSSL_WARNING)
|
|
352
342
|
}
|
|
353
343
|
|
|
344
|
+
// Load code before the image snapshot; identity and metadata storage stay in /run.
|
|
345
|
+
const storeTracerMetadata = require('./tracer_metadata')
|
|
346
|
+
if (config.DD_TRACE_ENABLED) {
|
|
347
|
+
try {
|
|
348
|
+
require('@datadog/libdatadog-extras').maybeLoad('process-discovery')
|
|
349
|
+
} catch {
|
|
350
|
+
// Native metadata is optional; /run retains its existing availability handling.
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
354
|
const ch = channel('http.server.request.start')
|
|
355
355
|
|
|
356
356
|
const onHttpRequest = ({ request }) => {
|
|
@@ -360,7 +360,6 @@ class Tracer extends NoopProxy {
|
|
|
360
360
|
reseed()
|
|
361
361
|
channel('datadog:identity:update').publish(config)
|
|
362
362
|
if (this._tracingInitialized) {
|
|
363
|
-
const storeTracerMetadata = require('./tracer_metadata')
|
|
364
363
|
const metadata = storeTracerMetadata(config)
|
|
365
364
|
if (metadata === undefined) {
|
|
366
365
|
log.warn('Could not store tracer configuration for service discovery')
|
|
@@ -409,8 +408,11 @@ class Tracer extends NoopProxy {
|
|
|
409
408
|
|
|
410
409
|
/**
|
|
411
410
|
* @param {import('./config/config-base')} config - Tracer configuration
|
|
411
|
+
* @returns {import('./opentelemetry/startup-config').Pipelines | undefined}
|
|
412
412
|
*/
|
|
413
413
|
#updateTracing (config) {
|
|
414
|
+
/** @type {import('./opentelemetry/startup-config').Pipelines | undefined} */
|
|
415
|
+
let startupPipelines
|
|
414
416
|
if (config.DD_TRACE_ENABLED !== false) {
|
|
415
417
|
const aiguardEnabled = config.aiguard.DD_AI_GUARD_ENABLED === true &&
|
|
416
418
|
config.DD_API_KEY !== undefined &&
|
|
@@ -430,10 +432,13 @@ class Tracer extends NoopProxy {
|
|
|
430
432
|
? require('./standalone').configure(config)
|
|
431
433
|
: undefined
|
|
432
434
|
this._tracer = new DatadogTracer(config, prioritySampler)
|
|
435
|
+
startupPipelines = this._tracer.getStartupConfig()
|
|
433
436
|
this.dataStreamsCheckpointer = this._tracer.dataStreamsCheckpointer
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
() => this.
|
|
437
|
+
if (!config.isCiVisibility) {
|
|
438
|
+
lazyProxy(this, 'appsec', () => require('./appsec/sdk'), this._tracer, config)
|
|
439
|
+
lazyProxy(this, 'llmobs', () => require('./llmobs/sdk'), this._tracer, this._modules.llmobs, config,
|
|
440
|
+
() => this.openfeature)
|
|
441
|
+
}
|
|
437
442
|
|
|
438
443
|
if (aiguardEnabled) {
|
|
439
444
|
lazyProxy(this, 'aiguard', () => require('./aiguard/sdk'), this._tracer, config)
|
|
@@ -443,8 +448,15 @@ class Tracer extends NoopProxy {
|
|
|
443
448
|
if (aiguardEnabled) {
|
|
444
449
|
this._modules.aiguard.enable(this._tracer, config)
|
|
445
450
|
}
|
|
446
|
-
if (config.iast.DD_IAST_ENABLED) {
|
|
447
|
-
|
|
451
|
+
if (config.iast.DD_IAST_ENABLED && !this.#iastUnavailable) {
|
|
452
|
+
// IAST loads optional native addons that can be missing (e.g. installs without optional
|
|
453
|
+
// dependencies). Disable it for the process lifetime instead of aborting tracer setup.
|
|
454
|
+
try {
|
|
455
|
+
this._modules.iast.enable(config, this._tracer)
|
|
456
|
+
} catch (error) {
|
|
457
|
+
this.#iastUnavailable = true
|
|
458
|
+
log.error('[IAST] Unable to start IAST, it stays disabled', error)
|
|
459
|
+
}
|
|
448
460
|
}
|
|
449
461
|
// This needs to be after the IAST module is enabled
|
|
450
462
|
} else if (this._tracingInitialized) {
|
|
@@ -460,11 +472,10 @@ class Tracer extends NoopProxy {
|
|
|
460
472
|
this._tracer.configure(config)
|
|
461
473
|
this._pluginManager.configure(config)
|
|
462
474
|
dynamicInstrumentation?.configure(config)
|
|
463
|
-
setStartupLogPluginManager(this._pluginManager)
|
|
464
|
-
startupLog()
|
|
465
475
|
}
|
|
466
476
|
|
|
467
477
|
initializeServerlessTelemetry(this._serverlessTelemetry)
|
|
478
|
+
return startupPipelines
|
|
468
479
|
}
|
|
469
480
|
|
|
470
481
|
/**
|
|
@@ -539,25 +550,6 @@ class Tracer extends NoopProxy {
|
|
|
539
550
|
}
|
|
540
551
|
}
|
|
541
552
|
|
|
542
|
-
/**
|
|
543
|
-
* Checks the private filesystem-only Test Optimization validation mode.
|
|
544
|
-
*
|
|
545
|
-
*/
|
|
546
|
-
function isOfflineTestOptimizationValidation () {
|
|
547
|
-
return isTrue(getEnvironmentVariable(VALIDATION_MODE_ENV)) &&
|
|
548
|
-
Boolean(getEnvironmentVariable(VALIDATION_MANIFEST_ENV)) &&
|
|
549
|
-
Boolean(getEnvironmentVariable(VALIDATION_OUTPUT_ENV))
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Checks whether initialization selected a filesystem-only Test Optimization exporter.
|
|
554
|
-
*
|
|
555
|
-
* @param {import('../../../index').TracerOptions} [options] tracer initialization options
|
|
556
|
-
*/
|
|
557
|
-
function isOfflineValidationExporter (options) {
|
|
558
|
-
return OFFLINE_VALIDATION_EXPORTERS.has(options?.experimental?.exporter)
|
|
559
|
-
}
|
|
560
|
-
|
|
561
553
|
/**
|
|
562
554
|
* Discards Node's buffered UUID entropy, so the identity subscribers draw from bytes generated
|
|
563
555
|
* after the clone resumed.
|
|
@@ -31,6 +31,12 @@ function serializeOtlpTraceState (context) {
|
|
|
31
31
|
class SpanProcessor {
|
|
32
32
|
#exportOtlpTraces
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* @readonly
|
|
36
|
+
* @type {import('./opentelemetry/startup-config').InitializedExporter | undefined}
|
|
37
|
+
*/
|
|
38
|
+
#spanMetricsStartupConfig
|
|
39
|
+
|
|
34
40
|
constructor (exporter, prioritySampler, config, otlpStatsExporter) {
|
|
35
41
|
this._exporter = exporter
|
|
36
42
|
this._prioritySampler = prioritySampler
|
|
@@ -42,6 +48,12 @@ class SpanProcessor {
|
|
|
42
48
|
!config.appsec?.DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED) {
|
|
43
49
|
const { SpanStatsProcessor } = require('./span_stats')
|
|
44
50
|
this._stats = new SpanStatsProcessor(config, otlpStatsExporter)
|
|
51
|
+
if (otlpStatsExporter) {
|
|
52
|
+
this.#spanMetricsStartupConfig = {
|
|
53
|
+
protocol: otlpStatsExporter.protocol,
|
|
54
|
+
resourceAttributes: otlpStatsExporter.getStartupResourceAttributes(),
|
|
55
|
+
}
|
|
56
|
+
}
|
|
45
57
|
}
|
|
46
58
|
|
|
47
59
|
this._spanSampler = new SpanSampler(config.sampler)
|
|
@@ -52,6 +64,14 @@ class SpanProcessor {
|
|
|
52
64
|
: false
|
|
53
65
|
}
|
|
54
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Returns the OTLP span-metrics configuration accepted during initialization, if active.
|
|
69
|
+
* @returns {import('./opentelemetry/startup-config').InitializedExporter | undefined}
|
|
70
|
+
*/
|
|
71
|
+
getSpanMetricsStartupConfig () {
|
|
72
|
+
return this.#spanMetricsStartupConfig
|
|
73
|
+
}
|
|
74
|
+
|
|
55
75
|
sample (span) {
|
|
56
76
|
const spanContext = span.context()
|
|
57
77
|
this._prioritySampler.sample(spanContext)
|