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
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs')
|
|
4
4
|
const exporters = require('../../../ext/exporters')
|
|
5
|
-
const { getEnvironmentVariable } = require('../../dd-trace/src/config/helper')
|
|
6
5
|
const constants = require('./constants')
|
|
7
|
-
const { isTrue } = require('./util')
|
|
8
6
|
|
|
9
7
|
module.exports = function getExporter (name) {
|
|
10
8
|
switch (name) {
|
|
9
|
+
case exporters.LLMOBS:
|
|
10
|
+
return usesLambdaLogExporter() ? require('./exporters/log') : require('./exporters/llmobs')
|
|
11
11
|
case exporters.ELECTRON:
|
|
12
12
|
return require('./exporters/electron')
|
|
13
13
|
case exporters.LOG:
|
|
@@ -20,9 +20,6 @@ module.exports = function getExporter (name) {
|
|
|
20
20
|
return require('./ci-visibility/exporters/agentless')
|
|
21
21
|
case exporters.AGENT_PROXY:
|
|
22
22
|
return require('./ci-visibility/exporters/agent-proxy')
|
|
23
|
-
case exporters.CI_VALIDATION:
|
|
24
|
-
if (hasCiValidationEnvironment()) return require('./ci-visibility/exporters/ci-validation')
|
|
25
|
-
break
|
|
26
23
|
case exporters.JEST_WORKER:
|
|
27
24
|
case exporters.CUCUMBER_WORKER:
|
|
28
25
|
case exporters.MOCHA_WORKER:
|
|
@@ -31,16 +28,27 @@ module.exports = function getExporter (name) {
|
|
|
31
28
|
return require('./ci-visibility/exporters/test-worker')
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
const usingAgent = inAWSLambda && (
|
|
36
|
-
fs.existsSync(constants.DATADOG_LAMBDA_EXTENSION_PATH) ||
|
|
37
|
-
fs.existsSync(constants.DATADOG_MINI_AGENT_PATH)
|
|
38
|
-
)
|
|
39
|
-
return inAWSLambda && !usingAgent ? require('./exporters/log') : require('./exporters/agent')
|
|
31
|
+
return usesLambdaLogExporter() ? require('./exporters/log') : require('./exporters/agent')
|
|
40
32
|
}
|
|
41
33
|
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
function usesLambdaLogExporter () {
|
|
35
|
+
const { IS_AWS_LAMBDA } = require('./serverless')
|
|
36
|
+
return IS_AWS_LAMBDA &&
|
|
37
|
+
!fs.existsSync(constants.DATADOG_LAMBDA_EXTENSION_PATH) &&
|
|
38
|
+
!fs.existsSync(constants.DATADOG_MINI_AGENT_PATH)
|
|
46
39
|
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Whether the tracer effectively uses OTLP for APM spans.
|
|
43
|
+
* Test Optimization and Electron do not support OTLP even when `OTEL_TRACES_EXPORTER` is `otlp`.
|
|
44
|
+
*
|
|
45
|
+
* @param {import('./config')} config
|
|
46
|
+
*/
|
|
47
|
+
function usesOtlpTraceExporter (config) {
|
|
48
|
+
return config.OTEL_TRACES_EXPORTER === 'otlp' &&
|
|
49
|
+
!config.isCiVisibility &&
|
|
50
|
+
config.tracing.DD_TRACE_EXPERIMENTAL_EXPORTER !== exporters.ELECTRON &&
|
|
51
|
+
config.tracing.DD_TRACE_EXPERIMENTAL_EXPORTER !== exporters.AGENTLESS
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports.usesOtlpTraceExporter = usesOtlpTraceExporter
|
|
@@ -44,7 +44,7 @@ class AgentExporter {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export (spans) {
|
|
47
|
-
this._writer.append(spans)
|
|
47
|
+
const appended = this._writer.append(spans)
|
|
48
48
|
|
|
49
49
|
const { flushInterval } = this._config
|
|
50
50
|
|
|
@@ -57,6 +57,8 @@ class AgentExporter {
|
|
|
57
57
|
}, flushInterval)
|
|
58
58
|
this.#timer.unref?.()
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
return appended
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
flush (done) {
|
|
@@ -86,7 +86,7 @@ class AgentlessExporter {
|
|
|
86
86
|
* @param {object[]} spans - Array of spans (all from the same trace)
|
|
87
87
|
*/
|
|
88
88
|
export (spans) {
|
|
89
|
-
this._writer.append(spans)
|
|
89
|
+
const appended = this._writer.append(spans)
|
|
90
90
|
|
|
91
91
|
const { flushInterval } = this.#config
|
|
92
92
|
|
|
@@ -107,6 +107,8 @@ class AgentlessExporter {
|
|
|
107
107
|
}, flushInterval)
|
|
108
108
|
this.#timer.unref?.()
|
|
109
109
|
}
|
|
110
|
+
|
|
111
|
+
return appended
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
/**
|
|
@@ -29,42 +29,84 @@ const maxActiveBufferSize = 1024 * 1024 * 64
|
|
|
29
29
|
let activeBufferSize = 0
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* @typedef {Omit<import('node:http').RequestOptions, 'agent'> & {
|
|
33
|
+
* agent?: import('node:http').Agent|false,
|
|
34
|
+
* url?: string|URL|object,
|
|
35
|
+
* retry?: boolean,
|
|
36
|
+
* deferTimeoutAbort?: boolean,
|
|
37
|
+
* keepProcessAlive?: boolean,
|
|
38
|
+
* includeErrorResponseBody?: boolean
|
|
39
|
+
* }} RequestOptions
|
|
36
40
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {RequestOptions} options
|
|
44
|
+
* @param {number} contentLength
|
|
45
|
+
* @returns {RequestOptions}
|
|
46
|
+
*/
|
|
47
|
+
function prepareRequestOptions (options, contentLength) {
|
|
48
|
+
const connectionOptions = { ...options }
|
|
41
49
|
|
|
42
50
|
if (options.url) {
|
|
43
51
|
const url = parseUrl(options.url)
|
|
44
52
|
if (url.protocol === 'unix:') {
|
|
45
|
-
options.
|
|
53
|
+
if (options.protocol !== undefined) connectionOptions.protocol = undefined
|
|
54
|
+
if (options.hostname !== undefined) connectionOptions.hostname = undefined
|
|
55
|
+
if (options.host !== undefined) connectionOptions.host = undefined
|
|
56
|
+
if (options.port !== undefined) connectionOptions.port = undefined
|
|
57
|
+
connectionOptions.socketPath = url.pathname
|
|
46
58
|
} else {
|
|
47
|
-
if (
|
|
48
|
-
options.
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
if (options.socketPath !== undefined) connectionOptions.socketPath = undefined
|
|
60
|
+
if (options.host !== undefined) connectionOptions.host = undefined
|
|
61
|
+
connectionOptions.protocol = url.protocol
|
|
62
|
+
connectionOptions.hostname = url.hostname
|
|
63
|
+
connectionOptions.port = url.port
|
|
64
|
+
if (!options.path) connectionOptions.path = url.path
|
|
51
65
|
}
|
|
52
66
|
}
|
|
67
|
+
if (connectionOptions.protocol !== undefined &&
|
|
68
|
+
connectionOptions.protocol !== 'http:' &&
|
|
69
|
+
connectionOptions.protocol !== 'https:') {
|
|
70
|
+
throw Object.assign(
|
|
71
|
+
new TypeError(`Unsupported request protocol: ${connectionOptions.protocol}`),
|
|
72
|
+
{ code: 'ERR_INVALID_PROTOCOL' }
|
|
73
|
+
)
|
|
74
|
+
}
|
|
53
75
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
76
|
+
const sourceHeaders = options.headers ?? {}
|
|
77
|
+
const headers = { ...sourceHeaders }
|
|
78
|
+
const isSecure = connectionOptions.protocol === 'https:'
|
|
79
|
+
const hasApiKey = sourceHeaders['dd-api-key'] !== undefined || sourceHeaders['DD-API-KEY'] !== undefined
|
|
80
|
+
|
|
81
|
+
// Local agents proxy with their own key. Strip unsafe keys instead of dropping the request.
|
|
82
|
+
if (hasApiKey && !canSendApiKey(connectionOptions.protocol, connectionOptions.hostname)) {
|
|
60
83
|
log.error(
|
|
61
84
|
'Not sending the Datadog API key over a non-TLS connection to %s. Configure an https intake URL.',
|
|
62
|
-
|
|
85
|
+
connectionOptions.hostname
|
|
63
86
|
)
|
|
64
|
-
delete
|
|
65
|
-
delete
|
|
87
|
+
delete headers['dd-api-key']
|
|
88
|
+
delete headers['DD-API-KEY']
|
|
66
89
|
}
|
|
67
90
|
|
|
91
|
+
headers['Content-Length'] = contentLength
|
|
92
|
+
docker.inject(headers)
|
|
93
|
+
connectionOptions.headers = headers
|
|
94
|
+
|
|
95
|
+
const directAgent = options.agent ?? (isSecure ? httpsAgent : httpAgent)
|
|
96
|
+
connectionOptions.agent = hasApiKey && isSecure
|
|
97
|
+
? getHttpsProxyAgent(connectionOptions, directAgent)
|
|
98
|
+
: directAgent
|
|
99
|
+
|
|
100
|
+
return connectionOptions
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {Buffer|string|Readable|Array<Buffer|string>} data
|
|
105
|
+
* @param {RequestOptions} options
|
|
106
|
+
* @param {(error: Error|null, result?: string|null, statusCode?: number,
|
|
107
|
+
* headers?: import('node:http').IncomingHttpHeaders, dropped?: boolean) => void} callback
|
|
108
|
+
*/
|
|
109
|
+
function request (data, options, callback) {
|
|
68
110
|
if (data instanceof Readable) {
|
|
69
111
|
const chunks = []
|
|
70
112
|
|
|
@@ -84,25 +126,16 @@ function request (data, options, callback) {
|
|
|
84
126
|
|
|
85
127
|
// The timeout should be kept low to avoid excessive queueing.
|
|
86
128
|
const timeout = options.timeout || 2000
|
|
87
|
-
const isSecure = options.protocol === 'https:'
|
|
88
|
-
const client = isSecure ? https : http
|
|
89
129
|
const dataArray = Array.isArray(data) ? data : [data]
|
|
90
130
|
const contentLength = byteLength(dataArray)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
agent = getHttpsProxyAgent(options, agent)
|
|
99
|
-
} catch (error) {
|
|
100
|
-
callback(error)
|
|
101
|
-
return
|
|
102
|
-
}
|
|
131
|
+
let connectionOptions
|
|
132
|
+
try {
|
|
133
|
+
connectionOptions = prepareRequestOptions(options, contentLength)
|
|
134
|
+
} catch (error) {
|
|
135
|
+
callback(error)
|
|
136
|
+
return
|
|
103
137
|
}
|
|
104
|
-
|
|
105
|
-
const connectionOptions = { ...options, agent }
|
|
138
|
+
const client = connectionOptions.protocol === 'https:' ? https : http
|
|
106
139
|
|
|
107
140
|
/**
|
|
108
141
|
* @param {import('node:http').IncomingMessage} res
|
|
@@ -111,7 +144,7 @@ function request (data, options, callback) {
|
|
|
111
144
|
* @param {(error: Error) => void} handleError
|
|
112
145
|
*/
|
|
113
146
|
const onResponse = (res, complete, handleError) => {
|
|
114
|
-
markEndpointReached(
|
|
147
|
+
markEndpointReached(connectionOptions)
|
|
115
148
|
|
|
116
149
|
const chunks = []
|
|
117
150
|
|
|
@@ -153,8 +186,8 @@ function request (data, options, callback) {
|
|
|
153
186
|
let errorMessage = ''
|
|
154
187
|
try {
|
|
155
188
|
const fullUrl = new URL(
|
|
156
|
-
|
|
157
|
-
|
|
189
|
+
String(connectionOptions.path),
|
|
190
|
+
connectionOptions.url || connectionOptions.hostname || `http://localhost:${connectionOptions.port}`
|
|
158
191
|
).href
|
|
159
192
|
errorMessage = `Error from ${fullUrl}: ${res.statusCode} ${http.STATUS_CODES[res.statusCode]}.`
|
|
160
193
|
} catch {
|
|
@@ -219,15 +252,15 @@ function request (data, options, callback) {
|
|
|
219
252
|
if (settled) return
|
|
220
253
|
clearImmediate(timeoutImmediate)
|
|
221
254
|
|
|
222
|
-
if (
|
|
223
|
-
attemptIndex < getMaxAttempts(
|
|
255
|
+
if (connectionOptions.retry !== false &&
|
|
256
|
+
attemptIndex < getMaxAttempts(connectionOptions) &&
|
|
224
257
|
isRetriableNetworkError(error)) {
|
|
225
258
|
settled = true
|
|
226
259
|
finalize()
|
|
227
|
-
|
|
228
|
-
//
|
|
229
|
-
//
|
|
230
|
-
|
|
260
|
+
const retryTimer = setTimeout(attempt, getRetryDelay(connectionOptions, attemptIndex), attemptIndex + 1)
|
|
261
|
+
// Background retries must not keep the host process alive. Lifecycle-owned
|
|
262
|
+
// requests can opt in when their final result must be observed.
|
|
263
|
+
if (!connectionOptions.keepProcessAlive) retryTimer.unref?.()
|
|
231
264
|
} else {
|
|
232
265
|
complete(error)
|
|
233
266
|
}
|
|
@@ -236,7 +269,7 @@ function request (data, options, callback) {
|
|
|
236
269
|
const req = client.request(connectionOptions, (res) => onResponse(res, complete, handleError))
|
|
237
270
|
|
|
238
271
|
req.once('close', finalize)
|
|
239
|
-
if (!
|
|
272
|
+
if (!connectionOptions.deferTimeoutAbort) req.once('timeout', finalize)
|
|
240
273
|
req.once('error', handleError)
|
|
241
274
|
|
|
242
275
|
const abortRequest = () => {
|
|
@@ -253,7 +286,7 @@ function request (data, options, callback) {
|
|
|
253
286
|
}
|
|
254
287
|
|
|
255
288
|
req.setTimeout(timeout, () => {
|
|
256
|
-
if (!
|
|
289
|
+
if (!connectionOptions.deferTimeoutAbort) {
|
|
257
290
|
abortRequest()
|
|
258
291
|
return
|
|
259
292
|
}
|
|
@@ -262,7 +295,7 @@ function request (data, options, callback) {
|
|
|
262
295
|
abortRequest()
|
|
263
296
|
finalize()
|
|
264
297
|
})
|
|
265
|
-
if (!
|
|
298
|
+
if (!connectionOptions.keepProcessAlive) timeoutImmediate.unref?.()
|
|
266
299
|
})
|
|
267
300
|
|
|
268
301
|
for (const buffer of dataArray) req.write(buffer)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { parseUrl } = require('./url')
|
|
4
|
+
|
|
3
5
|
const RATE_LIMIT_MAX_WAIT_MS = 30_000
|
|
4
6
|
|
|
5
7
|
const SINGLE_RETRY_BASE_MS = 5000
|
|
@@ -29,10 +31,11 @@ const reachedEndpoints = new Set()
|
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* @typedef {object} EndpointOptions
|
|
32
|
-
* @property {string} [
|
|
33
|
-
* @property {string} [
|
|
34
|
-
* @property {string} [
|
|
35
|
-
* @property {string|
|
|
34
|
+
* @property {string|URL|object} [url]
|
|
35
|
+
* @property {string|null} [socketPath]
|
|
36
|
+
* @property {string|null} [hostname]
|
|
37
|
+
* @property {string|null} [host]
|
|
38
|
+
* @property {string|number|null} [port]
|
|
36
39
|
*/
|
|
37
40
|
|
|
38
41
|
/**
|
|
@@ -47,9 +50,7 @@ function singleJitteredDelay () {
|
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
/**
|
|
50
|
-
* Stable
|
|
51
|
-
* per endpoint. UDS path beats host:port because both can coexist on the same
|
|
52
|
-
* options object after `parseUrl` runs.
|
|
53
|
+
* Stable destination key for prepared transport options.
|
|
53
54
|
*
|
|
54
55
|
* @param {EndpointOptions} options
|
|
55
56
|
*/
|
|
@@ -63,6 +64,10 @@ function getEndpointKey (options) {
|
|
|
63
64
|
*/
|
|
64
65
|
function inStartupPhase (options) {
|
|
65
66
|
if ((Date.now() - startedAtMs) >= STARTUP_GRACE_MS) return false
|
|
67
|
+
if (options.url) {
|
|
68
|
+
const url = parseUrl(options.url)
|
|
69
|
+
return !reachedEndpoints.has(url.protocol === 'unix:' ? url.pathname : getEndpointKey(url))
|
|
70
|
+
}
|
|
66
71
|
return !reachedEndpoints.has(getEndpointKey(options))
|
|
67
72
|
}
|
|
68
73
|
|
|
@@ -21,7 +21,7 @@ function isLoopbackHost (hostname) {
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @param {string|undefined} protocol
|
|
24
|
-
* @param {string|undefined} hostname
|
|
24
|
+
* @param {string|undefined|null} hostname
|
|
25
25
|
*/
|
|
26
26
|
function canSendApiKey (protocol, hostname) {
|
|
27
27
|
return protocol === 'https:' || protocol === 'unix:' ||
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { fetchAgentInfo } = require('../../agent/info')
|
|
4
|
+
const { getValueFromEnvSources } = require('../../config/helper')
|
|
5
|
+
const { LLMOBS_META_STRUCT_KEY } = require('../../llmobs/constants/tags')
|
|
6
|
+
const logger = require('../../log')
|
|
7
|
+
const AgentExporter = require('../agent')
|
|
8
|
+
const AgentlessExporter = require('../agentless')
|
|
9
|
+
const BufferingExporter = require('../common/buffering-exporter')
|
|
10
|
+
|
|
11
|
+
const MAX_BUFFERED_SPANS = 1000
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Buffers traces until LLMObs transport discovery selects either the Agent or
|
|
15
|
+
* agentless APM exporter.
|
|
16
|
+
*/
|
|
17
|
+
class LLMObsExporter extends BufferingExporter {
|
|
18
|
+
#agentless = false
|
|
19
|
+
#bufferLimitWarned = false
|
|
20
|
+
#bufferedSpanCount = 0
|
|
21
|
+
#exporter
|
|
22
|
+
/** @type {Array<Function | undefined>} */
|
|
23
|
+
#pendingFlushes = []
|
|
24
|
+
#prioritySampler
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {import('../../config/config-base')} config
|
|
28
|
+
* @param {import('../../priority_sampler')} prioritySampler
|
|
29
|
+
*/
|
|
30
|
+
constructor (config, prioritySampler) {
|
|
31
|
+
super(config)
|
|
32
|
+
this.#prioritySampler = prioritySampler
|
|
33
|
+
this._url = undefined
|
|
34
|
+
|
|
35
|
+
const globalAgentlessEnabled = getValueFromEnvSources('DD_AGENTLESS_ENABLED', true)
|
|
36
|
+
|
|
37
|
+
const exporter = config.tracing.DD_TRACE_EXPERIMENTAL_EXPORTER
|
|
38
|
+
const useAgentlessExporter = exporter === 'agentless' ? true : exporter === 'agent' ? false : undefined
|
|
39
|
+
|
|
40
|
+
const agentlessEnabled = useAgentlessExporter ?? globalAgentlessEnabled ?? config.llmobs.DD_LLMOBS_AGENTLESS_ENABLED
|
|
41
|
+
|
|
42
|
+
if (agentlessEnabled === undefined) {
|
|
43
|
+
fetchAgentInfo(config.url, (err) => {
|
|
44
|
+
this.#initialize(err != null)
|
|
45
|
+
}, { keepProcessAlive: true })
|
|
46
|
+
} else {
|
|
47
|
+
this.#initialize(agentlessEnabled)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param {boolean} useAgentless
|
|
54
|
+
*/
|
|
55
|
+
#initialize (useAgentless) {
|
|
56
|
+
const Exporter = useAgentless ? AgentlessExporter : AgentExporter
|
|
57
|
+
const pendingUrl = this._url
|
|
58
|
+
this.#agentless = useAgentless
|
|
59
|
+
this.#exporter = new Exporter(this._config, this.#prioritySampler)
|
|
60
|
+
if (pendingUrl !== undefined) this.#exporter.setUrl?.(pendingUrl)
|
|
61
|
+
this._url = this.#exporter._url
|
|
62
|
+
|
|
63
|
+
this._isInitialized = true
|
|
64
|
+
this.exportUncodedTraces()
|
|
65
|
+
this.#bufferedSpanCount = 0
|
|
66
|
+
|
|
67
|
+
const pendingFlushes = this.#pendingFlushes
|
|
68
|
+
this.#pendingFlushes = []
|
|
69
|
+
for (const done of pendingFlushes) this.#exporter.flush(done)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** @param {object[]} trace */
|
|
73
|
+
export (trace) {
|
|
74
|
+
if (!this._isInitialized) {
|
|
75
|
+
if (trace.length > MAX_BUFFERED_SPANS) {
|
|
76
|
+
this.#warnBufferLimit()
|
|
77
|
+
return false
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (this.#bufferedSpanCount + trace.length > MAX_BUFFERED_SPANS) this.#warnBufferLimit()
|
|
81
|
+
while (this.#bufferedSpanCount + trace.length > MAX_BUFFERED_SPANS) {
|
|
82
|
+
this.#bufferedSpanCount -= this._traceBuffer.shift().length
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this._traceBuffer.push(trace)
|
|
86
|
+
this.#bufferedSpanCount += trace.length
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (this.#agentless) this.#normalizeTagKeys(trace)
|
|
91
|
+
return this.#exporter.export(trace)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#warnBufferLimit () {
|
|
95
|
+
if (this.#bufferLimitWarned) return
|
|
96
|
+
|
|
97
|
+
this.#bufferLimitWarned = true
|
|
98
|
+
logger.warn('LLMObs exporter trace buffer full (limit is %d spans), dropping trace data', MAX_BUFFERED_SPANS)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** @param {object[]} trace */
|
|
102
|
+
#normalizeTagKeys (trace) {
|
|
103
|
+
for (const span of trace) {
|
|
104
|
+
const llmobs = span.meta_struct?.[LLMOBS_META_STRUCT_KEY]
|
|
105
|
+
if (!llmobs?.tags) continue
|
|
106
|
+
|
|
107
|
+
const tags = {}
|
|
108
|
+
for (const [key, value] of Object.entries(llmobs.tags)) {
|
|
109
|
+
tags[key.replaceAll('.', '_')] = value
|
|
110
|
+
}
|
|
111
|
+
llmobs.tags = tags
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** @param {Function} [done] */
|
|
116
|
+
flush (done) {
|
|
117
|
+
if (this._isInitialized) {
|
|
118
|
+
this.#exporter.flush(done)
|
|
119
|
+
} else {
|
|
120
|
+
this.#pendingFlushes.push(done)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** @param {string | URL} url */
|
|
125
|
+
setUrl (url) {
|
|
126
|
+
if (this._isInitialized) {
|
|
127
|
+
this.#exporter.setUrl?.(url)
|
|
128
|
+
this._url = this.#exporter._url
|
|
129
|
+
} else {
|
|
130
|
+
this._url = url
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
module.exports = LLMObsExporter
|
|
@@ -16,16 +16,17 @@ class LogExporter {
|
|
|
16
16
|
|
|
17
17
|
for (const span of spans) {
|
|
18
18
|
const spanStr = JSON.stringify(span)
|
|
19
|
-
|
|
19
|
+
const spanSize = Buffer.byteLength(spanStr, 'utf8')
|
|
20
|
+
if (spanSize + TRACE_FORMAT_OVERHEAD > MAX_SIZE) {
|
|
20
21
|
log.debug('Span too large to send to logs, dropping')
|
|
21
22
|
continue
|
|
22
23
|
}
|
|
23
|
-
if (
|
|
24
|
+
if (spanSize + size > MAX_SIZE) {
|
|
24
25
|
this._printSpans(queue)
|
|
25
26
|
queue = []
|
|
26
27
|
size = TRACE_FORMAT_OVERHEAD
|
|
27
28
|
}
|
|
28
|
-
size +=
|
|
29
|
+
size += spanSize + 1 // includes length of ',' character
|
|
29
30
|
queue.push(spanStr)
|
|
30
31
|
}
|
|
31
32
|
if (queue.length > 0) {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const tracer = require('../../../..')
|
|
4
|
+
const { AUTO_KEEP } = require('../../../../ext/priority')
|
|
5
|
+
const { writeDatadogTraceId, writeDatadogParentId, writeDatadogSamplingPriority } = require('../carrier')
|
|
6
|
+
const { wrapLambdaHandler } = require('./wrap')
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns Datadog propagation headers for the active Lambda invocation span.
|
|
10
|
+
*
|
|
11
|
+
* @returns {Record<string, string>} Trace propagation headers, or an empty object outside an invocation.
|
|
12
|
+
*/
|
|
13
|
+
function getTraceHeaders () {
|
|
14
|
+
const span = tracer.scope().active()
|
|
15
|
+
if (!span) return {}
|
|
16
|
+
|
|
17
|
+
// Ported from datadog-lambda-js's TraceContextService.currentTraceHeaders and
|
|
18
|
+
// SpanContextWrapper.sampleMode. This fixed Datadog carrier must not depend on the configured
|
|
19
|
+
// injection styles or force a sampling decision as tracer.inject() does.
|
|
20
|
+
const context = span.context()
|
|
21
|
+
const headers = {}
|
|
22
|
+
writeDatadogTraceId(headers, context.toTraceId())
|
|
23
|
+
writeDatadogParentId(headers, context.toSpanId())
|
|
24
|
+
writeDatadogSamplingPriority(headers, String(context._sampling?.priority ?? AUTO_KEEP))
|
|
25
|
+
return headers
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Submits a custom Lambda distribution metric.
|
|
30
|
+
*/
|
|
31
|
+
function sendDistributionMetric () {
|
|
32
|
+
throw new Error(notImplemented('sendDistributionMetric'))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Submits a timestamped custom Lambda distribution metric.
|
|
37
|
+
*/
|
|
38
|
+
function sendDistributionMetricWithDate () {
|
|
39
|
+
throw new Error(notImplemented('sendDistributionMetricWithDate'))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Renders a handler-load failure (error span + error metric) for a failure the plugin lifecycle
|
|
44
|
+
* cannot observe: the customer module failed during evaluation, so there is no invocation.
|
|
45
|
+
*
|
|
46
|
+
* @param {{ error: Error, functionName: string, startTime: number }} failure Init failure details.
|
|
47
|
+
*/
|
|
48
|
+
function reportInitFailure (failure) {
|
|
49
|
+
throw new Error(notImplemented('reportInitFailure'))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Builds the message for a facade entry point whose implementation has not landed yet.
|
|
54
|
+
*
|
|
55
|
+
* The five-function surface is a cross-major contract, so the names are reserved from the first
|
|
56
|
+
* release of the facade. Throwing keeps the gap loud: a silent no-op here would drop customer
|
|
57
|
+
* metrics with no error anywhere, which is the failure mode this migration exists to avoid.
|
|
58
|
+
* The shim's integration lands only after these are implemented, so the throw never ships to a
|
|
59
|
+
* shim user.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} name Facade entry point.
|
|
62
|
+
*/
|
|
63
|
+
function notImplemented (name) {
|
|
64
|
+
return `dd-trace/lambda ${name}() is not implemented yet: Lambda metrics land with the metrics ` +
|
|
65
|
+
'pipeline (migration PR 12). Keep using datadog-lambda-js for custom metrics until then.'
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = {
|
|
69
|
+
getTraceHeaders,
|
|
70
|
+
reportInitFailure,
|
|
71
|
+
sendDistributionMetric,
|
|
72
|
+
sendDistributionMetricWithDate,
|
|
73
|
+
wrap: wrapLambdaHandler,
|
|
74
|
+
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { types: { isProxy } } = require('node:util')
|
|
4
|
-
|
|
5
3
|
const { channel } = require('../../../datadog-instrumentations/src/helpers/instrument')
|
|
4
|
+
const { copyHandlerMetadata, getDataProperty } =
|
|
5
|
+
require('../../../datadog-instrumentations/src/helpers/lambda-handler')
|
|
6
6
|
const { ERROR_MESSAGE, ERROR_TYPE } = require('../constants')
|
|
7
7
|
const log = require('../log')
|
|
8
8
|
const { ImpendingTimeout } = require('./runtime/errors')
|
|
9
9
|
const { extractContext } = require('./context')
|
|
10
10
|
|
|
11
|
-
const HANDLER_STREAMING = Symbol.for('aws.lambda.runtime.handler.streaming')
|
|
12
|
-
const HANDLER_HIGHWATERMARK = Symbol.for('aws.lambda.runtime.handler.streaming.highWaterMark')
|
|
13
11
|
const BEFORE_EXIT = Symbol.for('aws.lambda.beforeExit')
|
|
14
12
|
const timeoutChannel = channel('apm:aws:lambda:timeout')
|
|
15
13
|
const monitoredContexts = new WeakSet()
|
|
@@ -171,28 +169,7 @@ exports.datadog = function datadog (lambdaHandler, normalized = false) {
|
|
|
171
169
|
|
|
172
170
|
if (normalized) return monitored
|
|
173
171
|
|
|
174
|
-
|
|
175
|
-
Object.defineProperty(monitored, 'length', { value: getDataProperty(lambdaHandler, 'length') ?? 0 })
|
|
176
|
-
for (const name of [HANDLER_STREAMING, HANDLER_HIGHWATERMARK, '_ddWrapped']) {
|
|
177
|
-
const value = getDataProperty(lambdaHandler, name)
|
|
178
|
-
if (value !== undefined) monitored[name] = value
|
|
179
|
-
}
|
|
180
|
-
if (!isProxy(lambdaHandler)) {
|
|
181
|
-
for (const name of Reflect.ownKeys(lambdaHandler)) {
|
|
182
|
-
if (name === 'arguments' || name === 'caller') continue
|
|
183
|
-
const descriptor = Object.getOwnPropertyDescriptor(lambdaHandler, name)
|
|
184
|
-
if (!Object.hasOwn(descriptor, 'value')) continue
|
|
185
|
-
const existing = Object.getOwnPropertyDescriptor(monitored, name)
|
|
186
|
-
if (existing?.configurable === false) {
|
|
187
|
-
// Intrinsic function slots such as prototype cannot change their descriptor shape.
|
|
188
|
-
if (existing.writable) {
|
|
189
|
-
Object.defineProperty(monitored, name, { value: descriptor.value, writable: descriptor.writable })
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
Object.defineProperty(monitored, name, descriptor)
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
172
|
+
copyHandlerMetadata(lambdaHandler, monitored)
|
|
196
173
|
return monitored
|
|
197
174
|
}
|
|
198
175
|
|
|
@@ -226,18 +203,3 @@ function onCompletion (callback, clear) {
|
|
|
226
203
|
return Reflect.apply(callback, this, args)
|
|
227
204
|
}
|
|
228
205
|
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Reads metadata without executing application getters or Proxy traps.
|
|
232
|
-
*
|
|
233
|
-
* @param {unknown} target
|
|
234
|
-
* @param {string | symbol} name
|
|
235
|
-
*/
|
|
236
|
-
function getDataProperty (target, name) {
|
|
237
|
-
if (target === null || (typeof target !== 'object' && typeof target !== 'function')) return
|
|
238
|
-
while (target !== null && !isProxy(target)) {
|
|
239
|
-
const descriptor = Object.getOwnPropertyDescriptor(target, name)
|
|
240
|
-
if (descriptor) return descriptor.value
|
|
241
|
-
target = Object.getPrototypeOf(target)
|
|
242
|
-
}
|
|
243
|
-
}
|