dd-trace 5.134.0 → 5.136.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +0 -1
- package/ci/cypress/support.js +15 -1
- package/ci/init.js +2 -22
- package/ci/test-annotations.d.ts +5 -0
- package/ci/test-annotations.js +5 -0
- package/ci/vitest-no-worker-init-annotations.mjs +4 -0
- package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
- package/ci/vitest-no-worker-init-runner-setup.mjs +7 -32
- package/ci/vitest-no-worker-init-setup.mjs +34 -12
- package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
- package/ext/exporters.js +1 -1
- package/index.d.ts +124 -5
- package/initialize.mjs +5 -2
- package/lambda.d.ts +39 -0
- package/lambda.js +3 -0
- package/loader-hook.mjs +53 -0
- package/openfeature/exposure-hook.d.ts +66 -0
- package/openfeature/exposure-hook.js +5 -0
- package/package.json +19 -15
- package/packages/datadog-core/src/storage.js +1 -1
- package/packages/datadog-esbuild/index.js +78 -62
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +56 -19
- package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +29 -20
- package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
- package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -8
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +18 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +58 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +25 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/jest.js +265 -82
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
- package/packages/datadog-instrumentations/src/mariadb.js +13 -6
- package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
- package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
- package/packages/datadog-instrumentations/src/mocha/utils.js +58 -12
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +19 -6
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/oracledb.js +33 -0
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/playwright.js +81 -28
- package/packages/datadog-instrumentations/src/react-router.js +106 -0
- package/packages/datadog-instrumentations/src/typesafe.js +89 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -48
- package/packages/datadog-instrumentations/src/vitest-main.js +26 -0
- package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
- package/packages/datadog-instrumentations/src/vitest.js +10 -8
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-cucumber/src/index.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +296 -55
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
- package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
- package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
- package/packages/datadog-plugin-cypress/src/support.js +1217 -439
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/utils.js +5 -5
- package/packages/datadog-plugin-http/src/client.js +32 -9
- package/packages/datadog-plugin-http2/src/client.js +38 -13
- package/packages/datadog-plugin-jest/src/index.js +25 -3
- package/packages/datadog-plugin-mocha/src/index.js +47 -6
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
- package/packages/datadog-plugin-playwright/src/index.js +4 -0
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-react-router/src/index.js +118 -0
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-typesafe/src/index.js +17 -0
- package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +8 -0
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/dd-trace/src/agent/info.js +2 -1
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/sdk.js +8 -13
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
- package/packages/dd-trace/src/appsec/graphql.js +91 -6
- package/packages/dd-trace/src/appsec/recommended.json +1287 -90
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +24 -18
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +16 -36
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -18
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +10 -15
- package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
- package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
- package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +10 -17
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +9 -3
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -2
- package/packages/dd-trace/src/config/index.js +111 -43
- package/packages/dd-trace/src/config/parsers.js +18 -1
- package/packages/dd-trace/src/config/supported-configurations.json +174 -4
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
- package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
- package/packages/dd-trace/src/encode/0.4.js +2 -2
- package/packages/dd-trace/src/esm-module-load.js +58 -0
- package/packages/dd-trace/src/exporter.js +23 -15
- package/packages/dd-trace/src/exporters/agent/index.js +3 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
- package/packages/dd-trace/src/exporters/common/request.js +83 -50
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
- package/packages/dd-trace/src/exporters/log/index.js +4 -3
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/lambda/facade.js +74 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +3 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
- package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
- package/packages/dd-trace/src/llmobs/index.js +13 -2
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +27 -10
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
- package/packages/dd-trace/src/llmobs/sdk.js +21 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +219 -12
- package/packages/dd-trace/src/llmobs/tagger.js +25 -0
- package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +13 -2
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +68 -6
- package/packages/dd-trace/src/openfeature/configuration_source.js +41 -17
- package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
- package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +58 -14
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
- package/packages/dd-trace/src/openfeature/writers/base.js +63 -30
- package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
- package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +33 -13
- package/packages/dd-trace/src/otel-thread-ctx.js +72 -49
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +45 -14
- package/packages/dd-trace/src/plugins/index.js +9 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +18 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +273 -86
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +77 -50
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +90 -45
- package/packages/dd-trace/src/plugins/util/url.js +10 -2
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
- package/packages/dd-trace/src/plugins/util/web.js +81 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiling/config.js +6 -3
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/proxy.js +48 -57
- package/packages/dd-trace/src/serverless.js +3 -2
- package/packages/dd-trace/src/span_processor.js +41 -9
- package/packages/dd-trace/src/span_stats.js +28 -2
- package/packages/dd-trace/src/startup-log.js +8 -5
- package/packages/dd-trace/src/tagger.js +7 -5
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
- package/packages/dd-trace/src/telemetry/index.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -0
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/util.js +1 -1
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +4 -2
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/{@opentelemetry/resources → @datadog/flagging-core}/LICENSE +22 -2
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -19
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -650
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
- package/vendor/dist/@opentelemetry/resources/index.js +0 -1
|
@@ -5,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
|
|
@@ -117,11 +101,15 @@ function defineLazily (obj, property, getClass, ...args) {
|
|
|
117
101
|
}
|
|
118
102
|
|
|
119
103
|
class Tracer extends NoopProxy {
|
|
104
|
+
#aiguardConfigurationErrorLogged = false
|
|
120
105
|
#openfeatureState = OPENFEATURE_STATE_NOOP
|
|
121
106
|
|
|
122
107
|
/** @type {boolean} */
|
|
123
108
|
#configPublished = false
|
|
124
109
|
|
|
110
|
+
/** @type {boolean} */
|
|
111
|
+
#iastUnavailable = false
|
|
112
|
+
|
|
125
113
|
constructor () {
|
|
126
114
|
super()
|
|
127
115
|
|
|
@@ -165,11 +153,6 @@ class Tracer extends NoopProxy {
|
|
|
165
153
|
|
|
166
154
|
this._initialized = true
|
|
167
155
|
|
|
168
|
-
if (isOfflineTestOptimizationValidation() && !isOfflineValidationExporter(options)) {
|
|
169
|
-
process.stderr.write(`${ORDINARY_TRACING_DISABLED_MESSAGE}\n`)
|
|
170
|
-
return this
|
|
171
|
-
}
|
|
172
|
-
|
|
173
156
|
try {
|
|
174
157
|
const config = getConfig(options) // TODO: support dynamic code config
|
|
175
158
|
|
|
@@ -196,9 +179,12 @@ class Tracer extends NoopProxy {
|
|
|
196
179
|
require('./heap_snapshots').start(config)
|
|
197
180
|
}
|
|
198
181
|
|
|
199
|
-
|
|
182
|
+
const telemetryLogOptions = config.isCiVisibility && config.telemetry.DD_INSTRUMENTATION_TELEMETRY_ENABLED
|
|
183
|
+
? require('./ci-visibility/telemetry-logs')
|
|
184
|
+
: undefined
|
|
185
|
+
telemetry.start(config, this._pluginManager, telemetryLogOptions)
|
|
200
186
|
|
|
201
|
-
if (config.dogstatsd && !config.DD_AGENTLESS_ENABLED
|
|
187
|
+
if (config.dogstatsd && !config.DD_AGENTLESS_ENABLED) {
|
|
202
188
|
// Custom Metrics
|
|
203
189
|
lazyProxy(this, 'dogstatsd', () => require('./dogstatsd').CustomMetrics, config)
|
|
204
190
|
}
|
|
@@ -261,7 +247,7 @@ class Tracer extends NoopProxy {
|
|
|
261
247
|
|
|
262
248
|
// Experimental: mirror the active trace ID, span ID and endpoint into
|
|
263
249
|
// an OTEP-4947 thread-local context record an out-of-process eBPF
|
|
264
|
-
// reader can consume.
|
|
250
|
+
// reader can consume. On by default when appsec is enabled.
|
|
265
251
|
if (config.DD_TRACE_OTEL_CTX_ENABLED) {
|
|
266
252
|
try {
|
|
267
253
|
require('./otel-thread-ctx').start()
|
|
@@ -273,14 +259,16 @@ class Tracer extends NoopProxy {
|
|
|
273
259
|
// OTel logs/metrics pipelines must be initialized BEFORE runtimeMetrics.start so that
|
|
274
260
|
// when the OTLP runtime metrics module calls metrics.getMeterProvider(), it gets the
|
|
275
261
|
// real provider, otherwise instruments register on the noop provider and never export.
|
|
262
|
+
let logs
|
|
263
|
+
let metrics
|
|
276
264
|
if (config.DD_LOGS_OTEL_ENABLED) {
|
|
277
265
|
const { initializeOpenTelemetryLogs } = require('./opentelemetry/logs')
|
|
278
|
-
initializeOpenTelemetryLogs(config)
|
|
266
|
+
logs = initializeOpenTelemetryLogs(config)
|
|
279
267
|
}
|
|
280
268
|
|
|
281
269
|
if (config.DD_METRICS_OTEL_ENABLED) {
|
|
282
270
|
const { initializeOpenTelemetryMetrics } = require('./opentelemetry/metrics')
|
|
283
|
-
initializeOpenTelemetryMetrics(config)
|
|
271
|
+
metrics = initializeOpenTelemetryMetrics(config)
|
|
284
272
|
}
|
|
285
273
|
|
|
286
274
|
if (config.runtimeMetrics.enabled) {
|
|
@@ -290,9 +278,12 @@ class Tracer extends NoopProxy {
|
|
|
290
278
|
registerTelemetryFlusher(done => runtimeMetrics.flush(done), { afterTrace: true })
|
|
291
279
|
}
|
|
292
280
|
|
|
293
|
-
this.#updateTracing(config)
|
|
281
|
+
const tracing = this.#updateTracing(config)
|
|
282
|
+
setStartupLogConfig(config, { ...tracing, logs, metrics })
|
|
283
|
+
setStartupLogPluginManager(this._pluginManager)
|
|
284
|
+
startupLog()
|
|
294
285
|
|
|
295
|
-
if (config.iast.DD_IAST_ENABLED) {
|
|
286
|
+
if (config.iast.DD_IAST_ENABLED && !this.#iastUnavailable) {
|
|
296
287
|
this._modules.rewriter.enable(config)
|
|
297
288
|
}
|
|
298
289
|
|
|
@@ -405,9 +396,19 @@ class Tracer extends NoopProxy {
|
|
|
405
396
|
|
|
406
397
|
/**
|
|
407
398
|
* @param {import('./config/config-base')} config - Tracer configuration
|
|
399
|
+
* @returns {import('./opentelemetry/startup-config').Pipelines | undefined}
|
|
408
400
|
*/
|
|
409
401
|
#updateTracing (config) {
|
|
402
|
+
/** @type {import('./opentelemetry/startup-config').Pipelines | undefined} */
|
|
403
|
+
let startupPipelines
|
|
410
404
|
if (config.DD_TRACE_ENABLED !== false) {
|
|
405
|
+
const aiguardEnabled = config.aiguard.DD_AI_GUARD_ENABLED === true &&
|
|
406
|
+
config.DD_API_KEY !== undefined &&
|
|
407
|
+
config.DD_APP_KEY !== undefined
|
|
408
|
+
if (config.aiguard.DD_AI_GUARD_ENABLED && !aiguardEnabled && !this.#aiguardConfigurationErrorLogged) {
|
|
409
|
+
log.error('AIGuard: missing api and/or app keys, use env DD_API_KEY and DD_APP_KEY')
|
|
410
|
+
this.#aiguardConfigurationErrorLogged = true
|
|
411
|
+
}
|
|
411
412
|
if (config.appsec.DD_APPSEC_ENABLED) {
|
|
412
413
|
this._modules.appsec.enable(config)
|
|
413
414
|
}
|
|
@@ -419,21 +420,31 @@ class Tracer extends NoopProxy {
|
|
|
419
420
|
? require('./standalone').configure(config)
|
|
420
421
|
: undefined
|
|
421
422
|
this._tracer = new DatadogTracer(config, prioritySampler)
|
|
423
|
+
startupPipelines = this._tracer.getStartupConfig()
|
|
422
424
|
this.dataStreamsCheckpointer = this._tracer.dataStreamsCheckpointer
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
() => this.
|
|
425
|
+
if (!config.isCiVisibility) {
|
|
426
|
+
lazyProxy(this, 'appsec', () => require('./appsec/sdk'), this._tracer, config)
|
|
427
|
+
lazyProxy(this, 'llmobs', () => require('./llmobs/sdk'), this._tracer, this._modules.llmobs, config,
|
|
428
|
+
() => this.openfeature)
|
|
429
|
+
}
|
|
426
430
|
|
|
427
|
-
if (
|
|
431
|
+
if (aiguardEnabled) {
|
|
428
432
|
lazyProxy(this, 'aiguard', () => require('./aiguard/sdk'), this._tracer, config)
|
|
429
433
|
}
|
|
430
434
|
this._tracingInitialized = true
|
|
431
435
|
}
|
|
432
|
-
if (
|
|
436
|
+
if (aiguardEnabled) {
|
|
433
437
|
this._modules.aiguard.enable(this._tracer, config)
|
|
434
438
|
}
|
|
435
|
-
if (config.iast.DD_IAST_ENABLED) {
|
|
436
|
-
|
|
439
|
+
if (config.iast.DD_IAST_ENABLED && !this.#iastUnavailable) {
|
|
440
|
+
// IAST loads optional native addons that can be missing (e.g. installs without optional
|
|
441
|
+
// dependencies). Disable it for the process lifetime instead of aborting tracer setup.
|
|
442
|
+
try {
|
|
443
|
+
this._modules.iast.enable(config, this._tracer)
|
|
444
|
+
} catch (error) {
|
|
445
|
+
this.#iastUnavailable = true
|
|
446
|
+
log.error('[IAST] Unable to start IAST, it stays disabled', error)
|
|
447
|
+
}
|
|
437
448
|
}
|
|
438
449
|
// This needs to be after the IAST module is enabled
|
|
439
450
|
} else if (this._tracingInitialized) {
|
|
@@ -449,11 +460,10 @@ class Tracer extends NoopProxy {
|
|
|
449
460
|
this._tracer.configure(config)
|
|
450
461
|
this._pluginManager.configure(config)
|
|
451
462
|
dynamicInstrumentation?.configure(config)
|
|
452
|
-
setStartupLogPluginManager(this._pluginManager)
|
|
453
|
-
startupLog()
|
|
454
463
|
}
|
|
455
464
|
|
|
456
465
|
initializeServerlessTelemetry(this._serverlessTelemetry)
|
|
466
|
+
return startupPipelines
|
|
457
467
|
}
|
|
458
468
|
|
|
459
469
|
/**
|
|
@@ -528,25 +538,6 @@ class Tracer extends NoopProxy {
|
|
|
528
538
|
}
|
|
529
539
|
}
|
|
530
540
|
|
|
531
|
-
/**
|
|
532
|
-
* Checks the private filesystem-only Test Optimization validation mode.
|
|
533
|
-
*
|
|
534
|
-
*/
|
|
535
|
-
function isOfflineTestOptimizationValidation () {
|
|
536
|
-
return isTrue(getEnvironmentVariable(VALIDATION_MODE_ENV)) &&
|
|
537
|
-
Boolean(getEnvironmentVariable(VALIDATION_MANIFEST_ENV)) &&
|
|
538
|
-
Boolean(getEnvironmentVariable(VALIDATION_OUTPUT_ENV))
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Checks whether initialization selected a filesystem-only Test Optimization exporter.
|
|
543
|
-
*
|
|
544
|
-
* @param {import('../../../index').TracerOptions} [options] tracer initialization options
|
|
545
|
-
*/
|
|
546
|
-
function isOfflineValidationExporter (options) {
|
|
547
|
-
return OFFLINE_VALIDATION_EXPORTERS.has(options?.experimental?.exporter)
|
|
548
|
-
}
|
|
549
|
-
|
|
550
541
|
/**
|
|
551
542
|
* Discards Node's buffered UUID entropy, so the identity subscribers draw from bytes generated
|
|
552
543
|
* after the clone resumed.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { getEnvironmentVariable, getValueFromEnvSources } = require('./config/helper')
|
|
4
4
|
|
|
5
|
+
const IS_AWS_LAMBDA = getEnvironmentVariable('AWS_LAMBDA_FUNCTION_NAME') !== undefined
|
|
5
6
|
const IS_AWS_LAMBDA_MICROVM = getEnvironmentVariable('AWS_LAMBDA_MICROVM_IMAGE_ARN') !== undefined
|
|
6
7
|
// Standard Lambda, whose sandbox freezes between invocations. Excludes Lambda Lite (native-http),
|
|
7
8
|
// Managed Instances (lambda-managed-instances) and MicroVMs.
|
|
@@ -46,11 +47,10 @@ function getIsFlexConsumptionAzureFunction () {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
function isInServerlessEnvironment () {
|
|
49
|
-
const inAWSLambda = getEnvironmentVariable('AWS_LAMBDA_FUNCTION_NAME') !== undefined
|
|
50
50
|
const isGCPFunction = getIsGCPFunction()
|
|
51
51
|
const isAzureFunction = getIsAzureFunction()
|
|
52
52
|
|
|
53
|
-
return IS_AWS_LAMBDA_MICROVM ||
|
|
53
|
+
return IS_AWS_LAMBDA_MICROVM || IS_AWS_LAMBDA || isGCPFunction || isAzureFunction
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
@@ -112,6 +112,7 @@ module.exports = {
|
|
|
112
112
|
enableGCPPubSubPushSubscription,
|
|
113
113
|
getIsFlexConsumptionAzureFunction,
|
|
114
114
|
initializeServerlessTelemetry,
|
|
115
|
+
IS_AWS_LAMBDA,
|
|
115
116
|
IS_AWS_LAMBDA_MICROVM,
|
|
116
117
|
IS_STANDARD_AWS_LAMBDA,
|
|
117
118
|
// true only for a Node that bundles its own OpenSSL, whose CSPRNG keeps the snapshot's DRBG
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { channel } = require('dc-polyfill')
|
|
4
|
+
|
|
3
5
|
const { AUTO_KEEP, AUTO_REJECT } = require('../../../ext/priority')
|
|
4
6
|
const log = require('./log')
|
|
7
|
+
const { usesOtlpTraceExporter } = require('./exporter')
|
|
5
8
|
const spanFormat = require('./span_format')
|
|
6
9
|
const SpanSampler = require('./span_sampler')
|
|
7
10
|
const GitMetadataTagger = require('./git_metadata_tagger')
|
|
@@ -10,6 +13,8 @@ const { applyHttpOtelSemantics } = require('./plugins/util/http-otel-semantics')
|
|
|
10
13
|
const TraceState = require('./opentracing/propagation/tracestate')
|
|
11
14
|
const { APM_TRACING_ENABLED_KEY, SDK_OTLP_EXPORT_KEY } = require('./constants')
|
|
12
15
|
|
|
16
|
+
const traceSampledCh = channel('dd-trace:trace:sampled')
|
|
17
|
+
|
|
13
18
|
const startedSpans = new WeakSet()
|
|
14
19
|
const finishedSpans = new WeakSet()
|
|
15
20
|
|
|
@@ -26,17 +31,29 @@ function serializeOtlpTraceState (context) {
|
|
|
26
31
|
class SpanProcessor {
|
|
27
32
|
#exportOtlpTraces
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
/**
|
|
35
|
+
* @readonly
|
|
36
|
+
* @type {import('./opentelemetry/startup-config').InitializedExporter | undefined}
|
|
37
|
+
*/
|
|
38
|
+
#spanMetricsStartupConfig
|
|
39
|
+
|
|
40
|
+
constructor (exporter, prioritySampler, config, otlpStatsExporter) {
|
|
30
41
|
this._exporter = exporter
|
|
31
42
|
this._prioritySampler = prioritySampler
|
|
32
43
|
this._config = config
|
|
33
44
|
this._killAll = false
|
|
34
|
-
this.#exportOtlpTraces =
|
|
45
|
+
this.#exportOtlpTraces = usesOtlpTraceExporter(config)
|
|
35
46
|
|
|
36
47
|
if (config.stats?.DD_TRACE_STATS_COMPUTATION_ENABLED &&
|
|
37
48
|
!config.appsec?.DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED) {
|
|
38
49
|
const { SpanStatsProcessor } = require('./span_stats')
|
|
39
50
|
this._stats = new SpanStatsProcessor(config, otlpStatsExporter)
|
|
51
|
+
if (otlpStatsExporter) {
|
|
52
|
+
this.#spanMetricsStartupConfig = {
|
|
53
|
+
protocol: otlpStatsExporter.protocol,
|
|
54
|
+
resourceAttributes: otlpStatsExporter.getStartupResourceAttributes(),
|
|
55
|
+
}
|
|
56
|
+
}
|
|
40
57
|
}
|
|
41
58
|
|
|
42
59
|
this._spanSampler = new SpanSampler(config.sampler)
|
|
@@ -45,7 +62,14 @@ class SpanProcessor {
|
|
|
45
62
|
this._processTags = config.DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED
|
|
46
63
|
? processTags.serialized
|
|
47
64
|
: false
|
|
48
|
-
|
|
65
|
+
}
|
|
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
|
|
49
73
|
}
|
|
50
74
|
|
|
51
75
|
sample (span) {
|
|
@@ -83,9 +107,18 @@ class SpanProcessor {
|
|
|
83
107
|
this.sample(span)
|
|
84
108
|
this._gitMetadataTagger.tagGitMetadata(spanContext)
|
|
85
109
|
|
|
110
|
+
const discard = this.#isDiscarded(spanContext)
|
|
111
|
+
const willExport = !discard && trace.isRecording !== false
|
|
112
|
+
|
|
113
|
+
if (traceSampledCh.hasSubscribers) {
|
|
114
|
+
traceSampledCh.publish({
|
|
115
|
+
spans: finished,
|
|
116
|
+
willExport,
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
86
120
|
let isFirstSpanInChunk = true
|
|
87
121
|
const stampApmDisabled = this._config.apmTracingEnabled === false
|
|
88
|
-
const discard = this.#isDiscarded(spanContext)
|
|
89
122
|
const exportOtlpTraces = this.#exportOtlpTraces && !(spanContext._sampling.priority < AUTO_KEEP)
|
|
90
123
|
let traceState
|
|
91
124
|
|
|
@@ -102,21 +135,20 @@ class SpanProcessor {
|
|
|
102
135
|
formattedSpan.metrics[APM_TRACING_ENABLED_KEY] = 0
|
|
103
136
|
}
|
|
104
137
|
// Stamped after formatting so a span tag with the same key can't override it.
|
|
105
|
-
if (isFirstSpanInChunk && this
|
|
138
|
+
if (isFirstSpanInChunk && !this.#exportOtlpTraces) {
|
|
106
139
|
formattedSpan.meta[SDK_OTLP_EXPORT_KEY] = 'false'
|
|
107
140
|
}
|
|
108
141
|
isFirstSpanInChunk = false
|
|
109
|
-
// Span stats read Datadog HTTP tag names from the formatted span, so
|
|
110
|
-
// record them before the OTel rename — an export-only transform.
|
|
111
|
-
this._stats?.onSpanFinished(formattedSpan)
|
|
112
142
|
if (this._config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
113
143
|
applyHttpOtelSemantics(formattedSpan)
|
|
114
144
|
}
|
|
145
|
+
// Trace metrics must aggregate the same names and attributes the OTLP exporter emits.
|
|
146
|
+
this._stats?.onSpanFinished(formattedSpan)
|
|
115
147
|
formatted.push(formattedSpan)
|
|
116
148
|
}
|
|
117
149
|
}
|
|
118
150
|
|
|
119
|
-
if (
|
|
151
|
+
if (willExport && formatted.length !== 0) {
|
|
120
152
|
this._exporter.export(formatted)
|
|
121
153
|
}
|
|
122
154
|
|
|
@@ -100,16 +100,42 @@ class SpanAggStats {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Accept canonical decimal strings or numbers in the non-negative int32 range.
|
|
105
|
+
*
|
|
106
|
+
* @param {unknown} value
|
|
107
|
+
*/
|
|
108
|
+
function toStatusCode (value) {
|
|
109
|
+
if (typeof value === 'number') return value === (value | 0) && value >= 0 ? value : undefined
|
|
110
|
+
if (typeof value !== 'string') return
|
|
111
|
+
|
|
112
|
+
const integer = Number(value) | 0
|
|
113
|
+
return integer >= 0 && String(integer) === value ? integer : undefined
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @param {import('./span_format').FormattedSpan} span
|
|
118
|
+
*/
|
|
119
|
+
function httpStatusCode (span) {
|
|
120
|
+
const datadogStatus = span.meta[HTTP_STATUS_CODE]
|
|
121
|
+
if (datadogStatus) return datadogStatus
|
|
122
|
+
|
|
123
|
+
const otelMetaStatus = toStatusCode(span.meta['http.response.status_code'])
|
|
124
|
+
if (otelMetaStatus !== undefined) return otelMetaStatus
|
|
125
|
+
|
|
126
|
+
return toStatusCode(span.metrics?.['http.response.status_code']) ?? 0
|
|
127
|
+
}
|
|
128
|
+
|
|
103
129
|
class SpanAggKey {
|
|
104
130
|
constructor (span) {
|
|
105
131
|
this.name = span.name || DEFAULT_SPAN_NAME
|
|
106
132
|
this.service = span.service || DEFAULT_SERVICE_NAME
|
|
107
133
|
this.resource = span.resource || ''
|
|
108
134
|
this.type = span.type || ''
|
|
109
|
-
this.statusCode = span
|
|
135
|
+
this.statusCode = httpStatusCode(span)
|
|
110
136
|
this.synthetics = span.meta[ORIGIN_KEY] === 'synthetics'
|
|
111
137
|
this.endpoint = span.meta[HTTP_ROUTE] || span.meta[HTTP_ENDPOINT] || ''
|
|
112
|
-
this.method = span.meta[HTTP_METHOD] || ''
|
|
138
|
+
this.method = span.meta[HTTP_METHOD] || span.meta['http.request.method'] || ''
|
|
113
139
|
this.srvSrc = span.meta[SVC_SRC_KEY] || ''
|
|
114
140
|
this.spanKind = span.meta[SPAN_KIND] || ''
|
|
115
141
|
// dd gRPC plugin sets a numeric code via setTag; OTel/manual sets a string name via meta.
|
|
@@ -4,9 +4,11 @@ const os = require('os')
|
|
|
4
4
|
const { inspect } = require('util')
|
|
5
5
|
const tracerVersion = require('../../../package.json').version
|
|
6
6
|
const { warn } = require('./log/writer')
|
|
7
|
+
const startupConfig = require('./opentelemetry/startup-config')
|
|
7
8
|
|
|
8
9
|
const errors = {}
|
|
9
10
|
let config
|
|
11
|
+
let otelConfig
|
|
10
12
|
let pluginManager
|
|
11
13
|
/** @type {import('./sampling_rule')[]} */
|
|
12
14
|
let samplingRules = []
|
|
@@ -100,6 +102,7 @@ function configInfo () {
|
|
|
100
102
|
agent_url: url,
|
|
101
103
|
debug: !!config.debug,
|
|
102
104
|
sample_rate: config.sampler.sampleRate,
|
|
105
|
+
sample_rate_limit: config.sampler.rateLimit,
|
|
103
106
|
sampling_rules: samplingRules,
|
|
104
107
|
tags: config.tags,
|
|
105
108
|
log_injection_enabled: !!config.logInjection,
|
|
@@ -107,9 +110,7 @@ function configInfo () {
|
|
|
107
110
|
profiling_enabled: profilingEnabled === 'true' || profilingEnabled === 'auto',
|
|
108
111
|
appsec_enabled: config.appsec.DD_APPSEC_ENABLED,
|
|
109
112
|
data_streams_enabled: !!config.dsmEnabled,
|
|
110
|
-
|
|
111
|
-
otlp_metrics_export_enabled: !!config.DD_METRICS_OTEL_ENABLED,
|
|
112
|
-
otlp_logs_export_enabled: !!config.DD_LOGS_OTEL_ENABLED,
|
|
113
|
+
...otelConfig,
|
|
113
114
|
}
|
|
114
115
|
if (config.tags?.version) startupLog.dd_version = config.tags.version
|
|
115
116
|
return startupLog
|
|
@@ -126,10 +127,12 @@ function tracerInfo () {
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
/**
|
|
129
|
-
* @param {import('./config')} aConfig
|
|
130
|
+
* @param {ReturnType<import('./config')>} aConfig
|
|
131
|
+
* @param {import('./opentelemetry/startup-config').Pipelines} [pipelines]
|
|
130
132
|
*/
|
|
131
|
-
function setStartupLogConfig (aConfig) {
|
|
133
|
+
function setStartupLogConfig (aConfig, pipelines) {
|
|
132
134
|
config = aConfig
|
|
135
|
+
otelConfig ??= startupConfig(config, samplingRules, pipelines)
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
/**
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
// TODO: Rename and move file. This is a general purpose helper for adding tags to a carrier.
|
|
4
4
|
|
|
5
|
-
function addNonEmpty (carrier, key, value) {
|
|
5
|
+
function addNonEmpty (carrier, key, value, decode) {
|
|
6
6
|
if (key !== '') {
|
|
7
|
-
carrier[key] = value
|
|
7
|
+
carrier[decode ? decodeURIComponent(key) : key] = decode ? decodeURIComponent(value) : value
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function add (carrier, keyValuePairs, valueSeparator = ':') {
|
|
11
|
+
function add (carrier, keyValuePairs, valueSeparator = ':', decode = false) {
|
|
12
12
|
if (typeof keyValuePairs === 'string') {
|
|
13
13
|
let valueStart = 0
|
|
14
14
|
let keyStart = 0
|
|
@@ -25,7 +25,8 @@ function add (carrier, keyValuePairs, valueSeparator = ':') {
|
|
|
25
25
|
addNonEmpty(
|
|
26
26
|
carrier,
|
|
27
27
|
keyValuePairs.slice(keyStart, valueStart).trim(),
|
|
28
|
-
keyValuePairs.slice(valueStart + 1, i).trim()
|
|
28
|
+
keyValuePairs.slice(valueStart + 1, i).trim(),
|
|
29
|
+
decode
|
|
29
30
|
)
|
|
30
31
|
keyStart = i + 1
|
|
31
32
|
valueStart = 0
|
|
@@ -37,7 +38,8 @@ function add (carrier, keyValuePairs, valueSeparator = ':') {
|
|
|
37
38
|
addNonEmpty(
|
|
38
39
|
carrier,
|
|
39
40
|
keyValuePairs.slice(keyStart, valueStart).trim(),
|
|
40
|
-
keyValuePairs.slice(valueStart + 1).trim()
|
|
41
|
+
keyValuePairs.slice(valueStart + 1).trim(),
|
|
42
|
+
decode
|
|
41
43
|
)
|
|
42
44
|
}
|
|
43
45
|
} else if (Array.isArray(keyValuePairs)) {
|
|
@@ -4,6 +4,7 @@ const path = require('path')
|
|
|
4
4
|
const { fileURLToPath } = require('url')
|
|
5
5
|
const dc = require('dc-polyfill')
|
|
6
6
|
const parse = require('../../../../vendor/dist/module-details-from-path')
|
|
7
|
+
const { getPublishedModuleLoads } = require('../esm-module-load')
|
|
7
8
|
const requirePackageJson = require('../require-package-json')
|
|
8
9
|
const { isTrue } = require('../../src/util')
|
|
9
10
|
const { sendData } = require('./send-data')
|
|
@@ -85,6 +86,9 @@ function loadAllTheLoadedModules () {
|
|
|
85
86
|
onModuleLoad({ filename })
|
|
86
87
|
}
|
|
87
88
|
}
|
|
89
|
+
for (const filename of getPublishedModuleLoads()) {
|
|
90
|
+
onModuleLoad({ filename })
|
|
91
|
+
}
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
function onModuleLoad (data) {
|
|
@@ -7,6 +7,12 @@ const logCollector = require('./log-collector')
|
|
|
7
7
|
const telemetryLog = dc.channel('datadog:telemetry:log')
|
|
8
8
|
const errorLog = dc.channel('datadog:log:error:record')
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {object} TelemetryLogOptions
|
|
12
|
+
* @property {string} [tags] Default tags appended to every outgoing log.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
let logOptions
|
|
10
16
|
let enabled = false
|
|
11
17
|
|
|
12
18
|
/**
|
|
@@ -68,10 +74,15 @@ function getErrorType (cause) {
|
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
|
|
77
|
+
/**
|
|
78
|
+
* @param {import('../../config/config-base')} config
|
|
79
|
+
* @param {TelemetryLogOptions} [options]
|
|
80
|
+
*/
|
|
81
|
+
function start (config, options) {
|
|
72
82
|
if (!config.telemetry.DD_TELEMETRY_LOG_COLLECTION_ENABLED || enabled) return
|
|
73
83
|
|
|
74
84
|
enabled = true
|
|
85
|
+
logOptions = options
|
|
75
86
|
|
|
76
87
|
telemetryLog.subscribe(onLog)
|
|
77
88
|
|
|
@@ -80,6 +91,7 @@ function start (config) {
|
|
|
80
91
|
|
|
81
92
|
function stop () {
|
|
82
93
|
enabled = false
|
|
94
|
+
logOptions = undefined
|
|
83
95
|
|
|
84
96
|
if (telemetryLog.hasSubscribers) {
|
|
85
97
|
telemetryLog.unsubscribe(onLog)
|
|
@@ -91,8 +103,15 @@ function stop () {
|
|
|
91
103
|
function send (config, application, host) {
|
|
92
104
|
if (!enabled) return
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
let logs = logCollector.drain()
|
|
95
107
|
if (logs) {
|
|
108
|
+
const tags = logOptions?.tags
|
|
109
|
+
if (tags) {
|
|
110
|
+
logs = logs.map(entry => ({
|
|
111
|
+
...entry,
|
|
112
|
+
tags: entry.tags ? `${entry.tags},${tags}` : tags,
|
|
113
|
+
}))
|
|
114
|
+
}
|
|
96
115
|
sendData(config, application, host, 'logs', { logs })
|
|
97
116
|
}
|
|
98
117
|
}
|
|
@@ -23,6 +23,7 @@ function createHash (logEntry) {
|
|
|
23
23
|
let result = logEntry.level ? hashCode(logEntry.level) : 0
|
|
24
24
|
result = (((prime * result) | 0) + (logEntry.message ? hashCode(logEntry.message) : 0)) | 0
|
|
25
25
|
result = (((prime * result) | 0) + (logEntry.stack_trace ? hashCode(logEntry.stack_trace) : 0)) | 0
|
|
26
|
+
result = (((prime * result) | 0) + (logEntry.tags ? hashCode(logEntry.tags) : 0)) | 0
|
|
26
27
|
return result
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { TELEMETRY_DISTRIBUTION_RELATIVE_ACCURACY } = require('../constants')
|
|
3
4
|
const { sendData } = require('./send-data')
|
|
4
5
|
|
|
5
6
|
let LogCollapsingLowestDenseDDSketch
|
|
@@ -42,7 +43,7 @@ function createSketch () {
|
|
|
42
43
|
if (LogCollapsingLowestDenseDDSketch === undefined) {
|
|
43
44
|
({ LogCollapsingLowestDenseDDSketch } = require('../../../../vendor/dist/@datadog/sketches-js'))
|
|
44
45
|
}
|
|
45
|
-
return new LogCollapsingLowestDenseDDSketch()
|
|
46
|
+
return new LogCollapsingLowestDenseDDSketch({ relativeAccuracy: TELEMETRY_DISTRIBUTION_RELATIVE_ACCURACY })
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
class Metric {
|
|
@@ -203,7 +203,12 @@ function appClosing () {
|
|
|
203
203
|
telemetryAppClosingChannel.publish()
|
|
204
204
|
const { reqType, payload } = createPayload('app-closing')
|
|
205
205
|
sendData(config, application, host, reqType, payload)
|
|
206
|
-
|
|
206
|
+
flush()
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function flush () {
|
|
210
|
+
if (!config?.telemetry.DD_INSTRUMENTATION_TELEMETRY_ENABLED) return
|
|
211
|
+
|
|
207
212
|
metricsManager.send(config, application, host)
|
|
208
213
|
telemetryLogger.send(config, application, host)
|
|
209
214
|
}
|
|
@@ -316,8 +321,9 @@ function extendedHeartbeat (config) {
|
|
|
316
321
|
/**
|
|
317
322
|
* @param {import('../config/config-base')} aConfig
|
|
318
323
|
* @param {PluginManager} thePluginManager
|
|
324
|
+
* @param {import('./logs').TelemetryLogOptions} [logOptions]
|
|
319
325
|
*/
|
|
320
|
-
function start (aConfig, thePluginManager) {
|
|
326
|
+
function start (aConfig, thePluginManager, logOptions) {
|
|
321
327
|
if (!aConfig.telemetry.DD_INSTRUMENTATION_TELEMETRY_ENABLED) {
|
|
322
328
|
if (aConfig.appsec.DD_APPSEC_SCA_ENABLED) {
|
|
323
329
|
logger.warn('DD_APPSEC_SCA_ENABLED requires enabling telemetry to work.')
|
|
@@ -331,7 +337,7 @@ function start (aConfig, thePluginManager) {
|
|
|
331
337
|
integrations = getIntegrations()
|
|
332
338
|
|
|
333
339
|
dependencies.start(config, application, host, getRetryData, updateRetryData)
|
|
334
|
-
telemetryLogger.start(config)
|
|
340
|
+
telemetryLogger.start(config, logOptions)
|
|
335
341
|
endpoints.start(config, application, host, getRetryData, updateRetryData)
|
|
336
342
|
sessionPropagation.start(config)
|
|
337
343
|
|
|
@@ -397,4 +403,5 @@ module.exports = {
|
|
|
397
403
|
updateIntegrations,
|
|
398
404
|
updateConfig,
|
|
399
405
|
appClosing,
|
|
406
|
+
flush,
|
|
400
407
|
}
|
|
@@ -11,7 +11,6 @@ const shimmer = require('../../datadog-shimmer')
|
|
|
11
11
|
const Tracer = require('./opentracing/tracer')
|
|
12
12
|
const Scope = require('./scope')
|
|
13
13
|
const { isError } = require('./util')
|
|
14
|
-
const { setStartupLogConfig } = require('./startup-log')
|
|
15
14
|
const { DataStreamsCheckpointer, DataStreamsManager, DataStreamsProcessor } = require('./datastreams')
|
|
16
15
|
const { IS_SERVERLESS } = require('./serverless')
|
|
17
16
|
const { flushServerlessTelemetry } = require('./flush')
|
|
@@ -33,7 +32,6 @@ class DatadogTracer extends Tracer {
|
|
|
33
32
|
this._dataStreamsManager = new DataStreamsManager(this._dataStreamsProcessor)
|
|
34
33
|
this.dataStreamsCheckpointer = new DataStreamsCheckpointer(this)
|
|
35
34
|
this._scope = new Scope()
|
|
36
|
-
setStartupLogConfig(config)
|
|
37
35
|
flushStartupLogs(log)
|
|
38
36
|
// Curated frameworks (e.g. Next.js) silently no-op when loaded first and their users enable
|
|
39
37
|
// no logging (#5430 / #5432), so surface those unconditionally.
|
|
@@ -167,7 +167,7 @@ function normalizePluginEnvName (envPluginName, makeLowercase = false) {
|
|
|
167
167
|
* @param {number} rate
|
|
168
168
|
*/
|
|
169
169
|
function formatKnuthRate (rate) {
|
|
170
|
-
const string =
|
|
170
|
+
const string = rate.toFixed(6)
|
|
171
171
|
for (let i = string.length - 1; i > 0; i--) {
|
|
172
172
|
if (string[i] === '0') continue
|
|
173
173
|
return string.slice(0, i + (string[i] === '.' ? 0 : 1))
|