dd-trace 6.24.0 → 6.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/ci/cypress/support.js +2 -1
- package/ci/init.js +2 -22
- package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-setup.mjs +729 -724
- package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
- package/ext/exporters.js +0 -1
- package/index.d.ts +105 -5
- package/initialize.mjs +5 -2
- package/package.json +41 -36
- package/packages/datadog-esbuild/index.js +16 -70
- package/packages/datadog-esbuild/src/log.js +2 -29
- package/packages/datadog-instrumentations/src/ai.js +6 -1
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +20 -17
- package/packages/datadog-instrumentations/src/helpers/bundler-esm-exports.js +582 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +576 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-client.js +30 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +61 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +80 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +23 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/microgateway-core.js +1 -2
- package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -1
- package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +41 -0
- package/packages/datadog-instrumentations/src/next.js +203 -26
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/router.js +35 -12
- package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/arn.js +41 -0
- package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -13
- package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-express/src/code_origin.js +2 -2
- package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +20 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +21 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +11 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-http/src/client.js +34 -10
- package/packages/datadog-plugin-http2/src/client.js +40 -14
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
- package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-postgres/src/index.js +118 -41
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
- package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
- package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +3 -2
- package/packages/datadog-plugin-ws/src/close.js +3 -5
- package/packages/datadog-plugin-ws/src/producer.js +1 -4
- package/packages/datadog-plugin-ws/src/receiver.js +3 -5
- package/packages/datadog-plugin-ws/src/server.js +44 -13
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-vite/index.js +537 -0
- package/packages/datadog-vite/src/log.js +5 -0
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/datadog-webpack/src/log.js +2 -29
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/index.js +1 -1
- package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
- package/packages/dd-trace/src/aiguard/sdk.js +8 -2
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +21 -1
- package/packages/dd-trace/src/appsec/channels.js +7 -0
- package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
- package/packages/dd-trace/src/appsec/graphql.js +89 -7
- package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
- package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
- package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
- package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
- package/packages/dd-trace/src/appsec/index.js +6 -0
- package/packages/dd-trace/src/appsec/lambda.js +17 -17
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
- package/packages/dd-trace/src/appsec/rasp/index.js +8 -1
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
- package/packages/dd-trace/src/appsec/rasp/utils.js +33 -3
- package/packages/dd-trace/src/appsec/recommended.json +1358 -94
- package/packages/dd-trace/src/appsec/reporter.js +9 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
- package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
- package/packages/dd-trace/src/appsec/waf/index.js +65 -6
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +5 -0
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -4
- package/packages/dd-trace/src/config/index.js +63 -31
- package/packages/dd-trace/src/config/parsers.js +44 -0
- package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
- package/packages/dd-trace/src/config/remote_config.js +2 -1
- package/packages/dd-trace/src/config/supported-configurations.json +172 -10
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/datastreams/fnv.js +27 -0
- package/packages/dd-trace/src/datastreams/pathway.js +113 -28
- package/packages/dd-trace/src/datastreams/processor.js +5 -4
- package/packages/dd-trace/src/debugger/config.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +2 -2
- package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +6 -2
- package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
- package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
- package/packages/dd-trace/src/exporter.js +0 -11
- package/packages/dd-trace/src/exporters/common/request.js +81 -48
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/git_metadata.js +2 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/index.js +6 -3
- package/packages/dd-trace/src/lambda/facade.js +75 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +54 -3
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +81 -1
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/sdk.js +19 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
- package/packages/dd-trace/src/llmobs/tagger.js +22 -0
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +6 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +7 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +55 -27
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
- package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +24 -0
- package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +143 -17
- package/packages/dd-trace/src/plugins/index.js +8 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +52 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +263 -82
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +80 -56
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +92 -40
- package/packages/dd-trace/src/plugins/util/url.js +18 -7
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +6 -6
- package/packages/dd-trace/src/plugins/util/web.js +65 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiler.js +74 -12
- package/packages/dd-trace/src/profiling/profiler.js +30 -2
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/profiling/remote-config.js +354 -0
- package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/propagation-hash/index.js +7 -0
- package/packages/dd-trace/src/proxy.js +46 -54
- package/packages/dd-trace/src/span_processor.js +20 -0
- package/packages/dd-trace/src/startup-log.js +8 -6
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +220 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/vite.d.ts +7 -0
- package/vite.js +3 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -18
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -649
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/datadog-esbuild/src/utils.js +0 -318
- package/packages/datadog-plugin-cypress/src/support.js +0 -1348
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { channel } = require('dc-polyfill')
|
|
4
|
+
|
|
5
|
+
const { storage } = require('../../datadog-core')
|
|
6
|
+
const ElevenLabsLLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/elevenlabs')
|
|
7
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
8
|
+
const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
|
|
9
|
+
|
|
10
|
+
const annotate = channel('apm:elevenlabs:annotate')
|
|
11
|
+
|
|
12
|
+
/** @typedef {import('../../datadog-instrumentations/src/elevenlabs/session').Scope} Scope */
|
|
13
|
+
/** @typedef {import('../../datadog-core/src/storage').Store<unknown>} Store */
|
|
14
|
+
|
|
15
|
+
class ElevenLabsTracingPlugin extends TracingPlugin {
|
|
16
|
+
static id = 'elevenlabs'
|
|
17
|
+
static prefix = 'tracing:apm:elevenlabs:span'
|
|
18
|
+
|
|
19
|
+
constructor (...args) {
|
|
20
|
+
super(...args)
|
|
21
|
+
this.addSub('dd-trace:elevenlabs:capture-context', message => {
|
|
22
|
+
const scope = /** @type {Scope} */ (message)
|
|
23
|
+
// An absent store intentionally restores an explicit root context.
|
|
24
|
+
const store = /** @type {Store} */ (storage('legacy').getStore())
|
|
25
|
+
const previous = scope.runInContext ?? (fn => fn())
|
|
26
|
+
scope.runInContext = fn => previous(() => storage('legacy').run(store, fn))
|
|
27
|
+
})
|
|
28
|
+
this.addSub('apm:elevenlabs:finish', ctx => this.finish(ctx))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @param {object} ctx */
|
|
32
|
+
bindStart (ctx) {
|
|
33
|
+
this.startSpan('elevenlabs.request', {
|
|
34
|
+
service: this.config.service,
|
|
35
|
+
resource: ctx.name,
|
|
36
|
+
type: 'llm',
|
|
37
|
+
kind: 'client',
|
|
38
|
+
startTime: ctx.startTime,
|
|
39
|
+
}, ctx)
|
|
40
|
+
return ctx.currentStore
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @param {object} ctx */
|
|
44
|
+
end (ctx) { if (!ctx.deferred) this.finish(ctx) }
|
|
45
|
+
|
|
46
|
+
/** @param {object} ctx */
|
|
47
|
+
finish (ctx) {
|
|
48
|
+
if (ctx.finished) return
|
|
49
|
+
const span = ctx.currentStore?.span
|
|
50
|
+
// Configuration changes can reorder subscribers. Keep deferred spans, speech phases, and
|
|
51
|
+
// asynchronous tools annotated before serialization through one explicit completion owner.
|
|
52
|
+
annotate.publish(ctx)
|
|
53
|
+
if (ctx.error) this.addError(ctx.error, span)
|
|
54
|
+
if (ctx.turn.failed && ['elevenlabs audio turn', 'elevenlabs response'].includes(ctx.name)) {
|
|
55
|
+
span?.setTag('error', 1)
|
|
56
|
+
}
|
|
57
|
+
span?.finish(ctx.finishTime)
|
|
58
|
+
ctx.finished = true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
class ElevenLabsPlugin extends CompositePlugin {
|
|
63
|
+
static id = 'elevenlabs'
|
|
64
|
+
static get plugins () {
|
|
65
|
+
return { llmobs: ElevenLabsLLMObsPlugin, tracing: ElevenLabsTracingPlugin }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = ElevenLabsPlugin
|
|
@@ -9,8 +9,8 @@ const web = require('../../dd-trace/src/plugins/util/web')
|
|
|
9
9
|
class ExpressCodeOriginForSpansPlugin extends Plugin {
|
|
10
10
|
static id = 'express'
|
|
11
11
|
|
|
12
|
-
constructor (
|
|
13
|
-
super(
|
|
12
|
+
constructor (tracer, tracerConfig) {
|
|
13
|
+
super(tracer, tracerConfig)
|
|
14
14
|
|
|
15
15
|
const layerTags = new WeakMap()
|
|
16
16
|
|
|
@@ -11,8 +11,8 @@ const kCodeOriginForSpansTagsSym = Symbol('datadog.codeOriginForSpansTags')
|
|
|
11
11
|
class FastifyCodeOriginForSpansPlugin extends Plugin {
|
|
12
12
|
static id = 'fastify'
|
|
13
13
|
|
|
14
|
-
constructor (
|
|
15
|
-
super(
|
|
14
|
+
constructor (tracer, tracerConfig) {
|
|
15
|
+
super(tracer, tracerConfig)
|
|
16
16
|
|
|
17
17
|
this.addSub('apm:fastify:request:handle', ({ req, routeConfig }) => {
|
|
18
18
|
const tags = routeConfig?.[kCodeOriginForSpansTagsSym]
|
|
@@ -4,6 +4,7 @@ const { getHeadersSize, getSizeOrZero } = require('../../dd-trace/src/datastream
|
|
|
4
4
|
const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
|
|
5
5
|
const { storage } = require('../../datadog-core')
|
|
6
6
|
const reconstructPubSubRequestContext = require('./pubsub-request-context')
|
|
7
|
+
const { getSubscriptionName, getTopicName } = require('./resource-names')
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* PULL SUBSCRIPTION: Service explicitly pulls messages from Pub/Sub and processes them.
|
|
@@ -104,9 +105,12 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
|
|
|
104
105
|
|
|
105
106
|
let childOf = this.tracer.extract('text_map', message.attributes)
|
|
106
107
|
|
|
108
|
+
let pubsubRequestContext
|
|
107
109
|
const isFirstMessage = batchIndex === 0
|
|
108
110
|
if (isFirstMessage && batchRequestSpanId) {
|
|
109
|
-
|
|
111
|
+
pubsubRequestContext = reconstructPubSubRequestContext(
|
|
112
|
+
message.attributes, childOf, this._tracerConfig.DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT
|
|
113
|
+
)
|
|
110
114
|
if (pubsubRequestContext) {
|
|
111
115
|
childOf = pubsubRequestContext
|
|
112
116
|
}
|
|
@@ -125,14 +129,21 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
|
|
|
125
129
|
'messaging.operation': 'receive',
|
|
126
130
|
}
|
|
127
131
|
|
|
132
|
+
// The topic is only known from cached subscription metadata or the name the producer propagated.
|
|
133
|
+
const topicFullName = getTopicName(topic)
|
|
134
|
+
if (topicFullName) meta['gcp.pubsub.topic.name'] = topicFullName
|
|
135
|
+
// Before 4.0 a subscription created with an auto-detected project keeps `{{projectId}}` in its name; the
|
|
136
|
+
// subscriber resolved it to open the stream that delivered this message.
|
|
137
|
+
const subscriptionFullName = getSubscriptionName(subscription.name) ??
|
|
138
|
+
getSubscriptionName(message._subscriber?.name)
|
|
139
|
+
if (subscriptionFullName) meta['gcp.pubsub.subscription.name'] = subscriptionFullName
|
|
140
|
+
|
|
141
|
+
let batchContext
|
|
128
142
|
if (batchRequestTraceId && batchRequestSpanId) {
|
|
129
143
|
meta['pubsub.batch.request_trace_id'] = batchRequestTraceId
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
span_id: batchRequestSpanId,
|
|
134
|
-
flags: 0,
|
|
135
|
-
}])
|
|
144
|
+
batchContext = pubsubRequestContext || reconstructPubSubRequestContext(
|
|
145
|
+
message.attributes, null, this._tracerConfig.DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT
|
|
146
|
+
)
|
|
136
147
|
}
|
|
137
148
|
|
|
138
149
|
const metrics = {
|
|
@@ -161,6 +172,8 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
|
|
|
161
172
|
metrics,
|
|
162
173
|
}, ctx)
|
|
163
174
|
|
|
175
|
+
if (batchContext) span.addLink({ context: batchContext })
|
|
176
|
+
|
|
164
177
|
if (message.publishTime) {
|
|
165
178
|
span.setTag('pubsub.publish_time', message.publishTime.toISOString())
|
|
166
179
|
}
|
|
@@ -5,13 +5,12 @@ const {
|
|
|
5
5
|
readDatadogSamplingPriority,
|
|
6
6
|
readDatadogTraceId,
|
|
7
7
|
readTraceparent,
|
|
8
|
-
writeDatadogParentId,
|
|
9
|
-
writeDatadogSamplingPriority,
|
|
10
|
-
writeDatadogTraceId,
|
|
11
8
|
} = require('../../dd-trace/src/carrier')
|
|
12
9
|
const { DsmPathwayCodec, getHeadersSize } = require('../../dd-trace/src/datastreams')
|
|
13
10
|
const id = require('../../dd-trace/src/id')
|
|
11
|
+
const SpanContext = require('../../dd-trace/src/opentracing/span_context')
|
|
14
12
|
const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
|
|
13
|
+
const { getTopicName } = require('./resource-names')
|
|
15
14
|
|
|
16
15
|
class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
17
16
|
static id = 'google-cloud-pubsub'
|
|
@@ -71,6 +70,9 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
71
70
|
const topic = request.topic
|
|
72
71
|
const messageCount = messages.length
|
|
73
72
|
const hasTraceContext = messages[0]?.attributes && readDatadogTraceId(messages[0].attributes)
|
|
73
|
+
const parentContext = hasTraceContext && readDatadogParentId(messages[0].attributes)
|
|
74
|
+
? this.tracer.extract('text_map', messages[0].attributes)
|
|
75
|
+
: undefined
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* Batch Publishing Strategy:
|
|
@@ -81,30 +83,18 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
81
83
|
* - Inject batch span context + metadata into all message attributes for downstream
|
|
82
84
|
* consumers to reconstruct the trace and understand batch relationships
|
|
83
85
|
*/
|
|
84
|
-
const
|
|
86
|
+
const spanLinks = []
|
|
85
87
|
if (hasTraceContext) {
|
|
86
88
|
for (let i = 1; i < messageCount; i++) {
|
|
87
89
|
const link = this.#extractSpanLink(messages[i].attributes)
|
|
88
|
-
if (link)
|
|
90
|
+
if (link) spanLinks.push(link)
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
const firstAttrs = messages[0]?.attributes
|
|
93
|
-
const traceId = firstAttrs && readDatadogTraceId(firstAttrs)
|
|
94
|
-
const spanId = firstAttrs && readDatadogParentId(firstAttrs)
|
|
95
|
-
const parentData = traceId && spanId
|
|
96
|
-
? {
|
|
97
|
-
traceId,
|
|
98
|
-
spanId,
|
|
99
|
-
traceIdUpper: firstAttrs['_dd.p.tid'],
|
|
100
|
-
samplingPriority: readDatadogSamplingPriority(firstAttrs),
|
|
101
|
-
}
|
|
102
|
-
: null
|
|
103
|
-
|
|
104
94
|
const lastSlash = topic.lastIndexOf('/')
|
|
105
95
|
const topicName = lastSlash === -1 ? topic : topic.slice(lastSlash + 1)
|
|
106
96
|
const batchSpan = this.startSpan({
|
|
107
|
-
childOf:
|
|
97
|
+
childOf: parentContext,
|
|
108
98
|
resource: `${api} to Topic ${topicName}`,
|
|
109
99
|
meta: {
|
|
110
100
|
'gcloud.project_id': projectId,
|
|
@@ -113,8 +103,9 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
113
103
|
'span.kind': 'producer',
|
|
114
104
|
'_dd.base_service': this.tracer._service,
|
|
115
105
|
'_dd.serviceoverride.type': 'integration',
|
|
116
|
-
'pubsub.linked_message_count':
|
|
106
|
+
'pubsub.linked_message_count': spanLinks.length || undefined,
|
|
117
107
|
operation: messageCount > 1 ? 'batched.pubsub.request' : 'pubsub.request',
|
|
108
|
+
'gcp.pubsub.topic.name': getTopicName(topic),
|
|
118
109
|
},
|
|
119
110
|
metrics: {
|
|
120
111
|
'pubsub.batch.message_count': messageCount,
|
|
@@ -130,15 +121,7 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
130
121
|
const batchTraceIdHex = fullTraceIdHex.slice(-16)
|
|
131
122
|
const batchTraceIdUpper = spanCtx._trace.tags['_dd.p.tid']
|
|
132
123
|
|
|
133
|
-
if (
|
|
134
|
-
batchSpan.setTag('_dd.span_links', JSON.stringify(
|
|
135
|
-
spanLinkData.map(link => ({
|
|
136
|
-
trace_id: link.traceId,
|
|
137
|
-
span_id: link.spanId,
|
|
138
|
-
flags: link.samplingPriority || 0,
|
|
139
|
-
}))
|
|
140
|
-
))
|
|
141
|
-
}
|
|
124
|
+
if (spanLinks.length) batchSpan.addLinks(spanLinks)
|
|
142
125
|
|
|
143
126
|
const messageCountStr = String(messageCount)
|
|
144
127
|
const startTimeStr = String(Math.floor(batchSpan._startTime))
|
|
@@ -189,34 +172,20 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
189
172
|
const spanId = readDatadogParentId(attrs)
|
|
190
173
|
if (!traceId || !spanId) return null
|
|
191
174
|
|
|
192
|
-
// Convert to hex strings
|
|
193
|
-
const lowerHex = id(traceId).toString(16)
|
|
194
|
-
const spanIdHex = id(spanId).toString(16)
|
|
195
|
-
|
|
196
|
-
// Build full 128-bit trace ID
|
|
197
|
-
const traceIdHex = attrs['_dd.p.tid']
|
|
198
|
-
? attrs['_dd.p.tid'] + lowerHex
|
|
199
|
-
: lowerHex.padStart(32, '0')
|
|
200
|
-
|
|
201
175
|
const samplingPriority = readDatadogSamplingPriority(attrs)
|
|
202
176
|
return {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
? Number.parseInt(samplingPriority, 10)
|
|
207
|
-
:
|
|
177
|
+
context: new SpanContext({
|
|
178
|
+
traceId: id(traceId, 10),
|
|
179
|
+
spanId: id(spanId, 10),
|
|
180
|
+
sampling: { priority: samplingPriority ? Number.parseInt(samplingPriority, 10) : 0 },
|
|
181
|
+
trace: {
|
|
182
|
+
started: [],
|
|
183
|
+
finished: [],
|
|
184
|
+
tags: attrs['_dd.p.tid'] ? { '_dd.p.tid': attrs['_dd.p.tid'] } : {},
|
|
185
|
+
},
|
|
186
|
+
}),
|
|
208
187
|
}
|
|
209
188
|
}
|
|
210
|
-
|
|
211
|
-
#extractParentContext (data) {
|
|
212
|
-
const carrier = /** @type {Record<string, unknown>} */ ({})
|
|
213
|
-
writeDatadogTraceId(carrier, data.traceId)
|
|
214
|
-
writeDatadogParentId(carrier, data.spanId)
|
|
215
|
-
if (data.traceIdUpper) carrier['_dd.p.tid'] = data.traceIdUpper
|
|
216
|
-
if (data.samplingPriority) writeDatadogSamplingPriority(carrier, String(data.samplingPriority))
|
|
217
|
-
|
|
218
|
-
return this.tracer.extract('text_map', carrier)
|
|
219
|
-
}
|
|
220
189
|
}
|
|
221
190
|
|
|
222
191
|
module.exports = GoogleCloudPubsubProducerPlugin
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
|
|
4
4
|
const log = require('../../dd-trace/src/log')
|
|
5
5
|
const reconstructPubSubRequestContext = require('./pubsub-request-context')
|
|
6
|
+
const { getSubscriptionName, getTopicName } = require('./resource-names')
|
|
6
7
|
|
|
7
8
|
// WeakMap to track push receive spans by request
|
|
8
9
|
const pushReceiveSpans = new WeakMap()
|
|
@@ -68,9 +69,11 @@ class GoogleCloudPubsubPushSubscriptionPlugin extends TracingPlugin {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
const originalContext = this.#extractContext(messageData)
|
|
71
|
-
const pubsubRequestContext = reconstructPubSubRequestContext(
|
|
72
|
+
const pubsubRequestContext = reconstructPubSubRequestContext(
|
|
73
|
+
messageData.attrs, originalContext, this._tracerConfig.DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT
|
|
74
|
+
) || originalContext
|
|
72
75
|
const isSameTrace = pubsubRequestContext &&
|
|
73
|
-
originalContext?.toTraceId() === pubsubRequestContext.toTraceId()
|
|
76
|
+
originalContext?.toTraceId(true) === pubsubRequestContext.toTraceId(true)
|
|
74
77
|
|
|
75
78
|
/**
|
|
76
79
|
* Create receive span, choosing parent context:
|
|
@@ -136,6 +139,12 @@ class GoogleCloudPubsubPushSubscriptionPlugin extends TracingPlugin {
|
|
|
136
139
|
return null
|
|
137
140
|
}
|
|
138
141
|
|
|
142
|
+
// The topic is only known from the name the producer propagated, never from the placeholder.
|
|
143
|
+
const topicFullName = getTopicName(attrs['pubsub.topic'])
|
|
144
|
+
if (topicFullName) span.setTag('gcp.pubsub.topic.name', topicFullName)
|
|
145
|
+
const subscriptionFullName = getSubscriptionName(subscription)
|
|
146
|
+
if (subscriptionFullName) span.setTag('gcp.pubsub.subscription.name', subscriptionFullName)
|
|
147
|
+
|
|
139
148
|
span._integrationName = 'google-cloud-pubsub'
|
|
140
149
|
// Calculate delivery latency (queue time from publish to delivery)
|
|
141
150
|
if (publishStartTime) {
|
|
@@ -5,9 +5,11 @@ const id = require('../../dd-trace/src/id')
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @param {Record<string, string>} attributes
|
|
8
|
+
* @param {SpanContext | null | undefined} originalContext
|
|
9
|
+
* @param {import('../../dd-trace/src/config/config-base')['DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT']} propagationBehavior
|
|
8
10
|
* @returns {import('../../dd-trace/src/opentracing/span_context') | null}
|
|
9
11
|
*/
|
|
10
|
-
function reconstructPubSubRequestContext (attributes) {
|
|
12
|
+
function reconstructPubSubRequestContext (attributes, originalContext, propagationBehavior) {
|
|
11
13
|
const traceIdLower = attributes['_dd.pubsub_request.trace_id']
|
|
12
14
|
const spanId = attributes['_dd.pubsub_request.span_id']
|
|
13
15
|
const traceIdUpper = attributes['_dd.pubsub_request.p.tid']
|
|
@@ -15,16 +17,35 @@ function reconstructPubSubRequestContext (attributes) {
|
|
|
15
17
|
if (!traceIdLower || !spanId) return null
|
|
16
18
|
|
|
17
19
|
const traceId128 = traceIdUpper ? traceIdUpper + traceIdLower : traceIdLower.padStart(32, '0')
|
|
18
|
-
const traceId = id(traceId128, 16)
|
|
19
20
|
const parentId = id(spanId, 16)
|
|
20
21
|
|
|
22
|
+
if (originalContext?.toTraceId(true) === traceId128) {
|
|
23
|
+
if (propagationBehavior !== 'restart') {
|
|
24
|
+
originalContext._spanId = parentId
|
|
25
|
+
return originalContext
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Restart links reference the extracted context, so preserve its original span ID.
|
|
29
|
+
return new SpanContext({
|
|
30
|
+
traceId: originalContext._traceId,
|
|
31
|
+
spanId: parentId,
|
|
32
|
+
isRemote: originalContext._isRemote,
|
|
33
|
+
sampling: originalContext._sampling,
|
|
34
|
+
baggageItems: originalContext._baggageItems,
|
|
35
|
+
trace: originalContext._trace,
|
|
36
|
+
traceparent: originalContext._traceparent,
|
|
37
|
+
tracestate: originalContext._tracestate,
|
|
38
|
+
links: originalContext._links,
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
21
42
|
const tags = {}
|
|
22
43
|
if (traceIdUpper) tags['_dd.p.tid'] = traceIdUpper
|
|
23
44
|
|
|
24
45
|
return new SpanContext({
|
|
25
|
-
traceId,
|
|
46
|
+
traceId: id(traceId128, 16),
|
|
26
47
|
spanId: parentId,
|
|
27
|
-
tags,
|
|
48
|
+
trace: { started: [], finished: [], tags },
|
|
28
49
|
})
|
|
29
50
|
}
|
|
30
51
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Full resource names: https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names
|
|
4
|
+
// Project IDs never contain braces; the client library uses `{{projectId}}` until it resolved the project.
|
|
5
|
+
const TOPIC_NAME = /^projects\/[^/{}]+\/topics\/[^/]+$/
|
|
6
|
+
const SUBSCRIPTION_NAME = /^projects\/[^/{}]+\/subscriptions\/[^/]+$/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {unknown} value
|
|
10
|
+
* @returns {string | undefined} `value` when it is a full `projects/<project>/topics/<topic>` name.
|
|
11
|
+
*/
|
|
12
|
+
function getTopicName (value) {
|
|
13
|
+
return typeof value === 'string' && TOPIC_NAME.test(value) ? value : undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {unknown} value
|
|
18
|
+
* @returns {string | undefined} `value` when it is a full `projects/<project>/subscriptions/<subscription>` name.
|
|
19
|
+
*/
|
|
20
|
+
function getSubscriptionName (value) {
|
|
21
|
+
return typeof value === 'string' && SUBSCRIPTION_NAME.test(value) ? value : undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = { getSubscriptionName, getTopicName }
|
|
@@ -8,8 +8,13 @@ const tags = require('../../../ext/tags')
|
|
|
8
8
|
const formats = require('../../../ext/formats')
|
|
9
9
|
const HTTP_HEADERS = formats.HTTP_HEADERS
|
|
10
10
|
const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
|
|
11
|
+
const {
|
|
12
|
+
HTTP_STATUS_ERROR,
|
|
13
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
14
|
+
otelHttpResourceName,
|
|
15
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
11
16
|
const { getClientStatusValidator } = require('../../dd-trace/src/plugins/util/status-validator')
|
|
12
|
-
const { buildClientHttpUrl } = require('../../dd-trace/src/plugins/util/url')
|
|
17
|
+
const { buildClientHttpUrl, getQsObfuscator } = require('../../dd-trace/src/plugins/util/url')
|
|
13
18
|
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
14
19
|
const { CLIENT_PORT_KEY, COMPONENT, ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
|
|
15
20
|
|
|
@@ -40,21 +45,36 @@ class HttpClientPlugin extends ClientPlugin {
|
|
|
40
45
|
|
|
41
46
|
const method = (options.method || 'GET').toUpperCase()
|
|
42
47
|
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
48
|
+
let otelUrl = uri
|
|
49
|
+
if (otelSemantics) {
|
|
50
|
+
const otelHostname = hostname.includes(':') && !hostname.startsWith('[') ? `[${hostname}]` : hostname
|
|
51
|
+
const otelHost = options.port ? `${otelHostname}:${options.port}` : otelHostname
|
|
52
|
+
const auth = typeof options.auth === 'string' && options.auth ? 'REDACTED:REDACTED@' : ''
|
|
53
|
+
const otelBase = `${protocol}//${auth}${otelHost}`
|
|
54
|
+
otelUrl = buildClientHttpUrl(this.config, otelBase, pathname, `${otelBase}${path}`)
|
|
55
|
+
}
|
|
43
56
|
const childOf = store && allowed ? store.span : null
|
|
44
57
|
// TODO delegate to super.startspan
|
|
58
|
+
const meta = {
|
|
59
|
+
[COMPONENT]: this.component,
|
|
60
|
+
'span.kind': 'client',
|
|
61
|
+
'resource.name': method,
|
|
62
|
+
'span.type': 'http',
|
|
63
|
+
'http.method': method,
|
|
64
|
+
'http.url': otelUrl,
|
|
65
|
+
'out.host': hostname,
|
|
66
|
+
}
|
|
67
|
+
if (otelSemantics) {
|
|
68
|
+
const resource = otelHttpResourceName(method)
|
|
69
|
+
meta['resource.name'] = resource
|
|
70
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
71
|
+
}
|
|
72
|
+
|
|
45
73
|
const span = this.startSpan(this.operationName(), {
|
|
46
74
|
childOf,
|
|
47
75
|
integrationName: this.component,
|
|
48
76
|
service: this.serviceName({ pluginConfig: this.config, sessionDetails: extractSessionDetails(options) }),
|
|
49
|
-
meta
|
|
50
|
-
[COMPONENT]: this.component,
|
|
51
|
-
'span.kind': 'client',
|
|
52
|
-
'resource.name': method,
|
|
53
|
-
'span.type': 'http',
|
|
54
|
-
'http.method': method,
|
|
55
|
-
'http.url': otelSemantics ? buildClientHttpUrl(this.config, base, pathname, uri) : uri,
|
|
56
|
-
'out.host': hostname,
|
|
57
|
-
},
|
|
77
|
+
meta,
|
|
58
78
|
metrics: {
|
|
59
79
|
[CLIENT_PORT_KEY]: Number.parseInt(options.port, 10),
|
|
60
80
|
},
|
|
@@ -99,6 +119,9 @@ class HttpClientPlugin extends ClientPlugin {
|
|
|
99
119
|
|
|
100
120
|
if (!this.config.validateStatus(status)) {
|
|
101
121
|
span.setTag('error', 1)
|
|
122
|
+
if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
123
|
+
span.setTag(HTTP_STATUS_ERROR, String(status))
|
|
124
|
+
}
|
|
102
125
|
}
|
|
103
126
|
|
|
104
127
|
addResponseHeaders(res, span, this.config)
|
|
@@ -175,6 +198,7 @@ function normalizeClientConfig (config) {
|
|
|
175
198
|
|
|
176
199
|
return {
|
|
177
200
|
...config,
|
|
201
|
+
queryStringObfuscation: config.DD_TRACE_OTEL_SEMANTICS_ENABLED && getQsObfuscator(config),
|
|
178
202
|
validateStatus,
|
|
179
203
|
filter,
|
|
180
204
|
propagationFilter,
|
|
@@ -9,8 +9,13 @@ const kinds = require('../../../ext/kinds')
|
|
|
9
9
|
const formats = require('../../../ext/formats')
|
|
10
10
|
const { COMPONENT, CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
11
11
|
const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
|
|
12
|
+
const {
|
|
13
|
+
HTTP_STATUS_ERROR,
|
|
14
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
15
|
+
otelHttpResourceName,
|
|
16
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
12
17
|
const { getClientStatusValidator } = require('../../dd-trace/src/plugins/util/status-validator')
|
|
13
|
-
const { buildClientHttpUrl } = require('../../dd-trace/src/plugins/util/url')
|
|
18
|
+
const { buildClientHttpUrl, getQsObfuscator } = require('../../dd-trace/src/plugins/util/url')
|
|
14
19
|
|
|
15
20
|
const HTTP_HEADERS = formats.HTTP_HEADERS
|
|
16
21
|
const HTTP_STATUS_CODE = tags.HTTP_STATUS_CODE
|
|
@@ -30,30 +35,41 @@ class Http2ClientPlugin extends ClientPlugin {
|
|
|
30
35
|
|
|
31
36
|
bindStart (message) {
|
|
32
37
|
const { authority, options, headers = {} } = message
|
|
33
|
-
const
|
|
38
|
+
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
39
|
+
const sessionDetails = extractSessionDetails(authority, options, otelSemantics)
|
|
34
40
|
const path = headers[HTTP2_HEADER_PATH] || '/'
|
|
35
41
|
const pathname = path.split(/[?#]/, 1)[0]
|
|
36
42
|
const method = headers[HTTP2_HEADER_METHOD] || HTTP2_METHOD_GET
|
|
37
43
|
const base = `${sessionDetails.protocol}//${sessionDetails.host}:${sessionDetails.port}`
|
|
38
44
|
const uri = `${base}${pathname}`
|
|
39
45
|
const allowed = this.config.filter(uri)
|
|
40
|
-
const
|
|
46
|
+
const otelBase = sessionDetails.hasAuth
|
|
47
|
+
? `${sessionDetails.protocol}//REDACTED:REDACTED@${sessionDetails.host}:${sessionDetails.port}`
|
|
48
|
+
: base
|
|
49
|
+
const otelUri = sessionDetails.hasAuth ? `${otelBase}${pathname}` : uri
|
|
41
50
|
|
|
42
51
|
const store = storage('legacy').getStore()
|
|
43
52
|
const childOf = store && allowed ? store.span : null
|
|
53
|
+
const meta = {
|
|
54
|
+
[COMPONENT]: this.constructor.id,
|
|
55
|
+
[SPAN_KIND]: CLIENT,
|
|
56
|
+
'resource.name': method,
|
|
57
|
+
'span.type': 'http',
|
|
58
|
+
'http.method': method,
|
|
59
|
+
'http.url': otelSemantics ? buildClientHttpUrl(this.config, otelBase, path, otelUri) : uri,
|
|
60
|
+
'out.host': sessionDetails.host,
|
|
61
|
+
}
|
|
62
|
+
if (otelSemantics) {
|
|
63
|
+
const resource = otelHttpResourceName(method)
|
|
64
|
+
meta['resource.name'] = resource
|
|
65
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
66
|
+
}
|
|
67
|
+
|
|
44
68
|
const span = this.startSpan(this.operationName(), {
|
|
45
69
|
childOf,
|
|
46
70
|
integrationName: this.constructor.id,
|
|
47
71
|
service: this.serviceName({ pluginConfig: this.config, sessionDetails }),
|
|
48
|
-
meta
|
|
49
|
-
[COMPONENT]: this.constructor.id,
|
|
50
|
-
[SPAN_KIND]: CLIENT,
|
|
51
|
-
'resource.name': method,
|
|
52
|
-
'span.type': 'http',
|
|
53
|
-
'http.method': method,
|
|
54
|
-
'http.url': otelSemantics ? buildClientHttpUrl(this.config, base, path, uri) : uri,
|
|
55
|
-
'out.host': sessionDetails.host,
|
|
56
|
-
},
|
|
72
|
+
meta,
|
|
57
73
|
metrics: {
|
|
58
74
|
[CLIENT_PORT_KEY]: Number.parseInt(sessionDetails.port, 10),
|
|
59
75
|
},
|
|
@@ -108,6 +124,9 @@ class Http2ClientPlugin extends ClientPlugin {
|
|
|
108
124
|
|
|
109
125
|
if (!this.config.validateStatus(status)) {
|
|
110
126
|
storage('legacy').run(store, () => this.addError())
|
|
127
|
+
if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
128
|
+
store.span.setTag(HTTP_STATUS_ERROR, String(status))
|
|
129
|
+
}
|
|
111
130
|
}
|
|
112
131
|
|
|
113
132
|
addHeaderTags(store.span, headers, HTTP_RESPONSE_HEADERS, this.config)
|
|
@@ -123,7 +142,12 @@ class Http2ClientPlugin extends ClientPlugin {
|
|
|
123
142
|
}
|
|
124
143
|
}
|
|
125
144
|
|
|
126
|
-
|
|
145
|
+
/**
|
|
146
|
+
* @param {string | URL | import('node:http2').ClientSessionOptions} authority
|
|
147
|
+
* @param {import('node:http2').SecureClientSessionOptions} options
|
|
148
|
+
* @param {boolean} otelSemantics
|
|
149
|
+
*/
|
|
150
|
+
function extractSessionDetails (authority, options, otelSemantics) {
|
|
127
151
|
if (typeof authority === 'string') {
|
|
128
152
|
authority = new URL(authority)
|
|
129
153
|
}
|
|
@@ -139,7 +163,8 @@ function extractSessionDetails (authority, options) {
|
|
|
139
163
|
host = options.host || host
|
|
140
164
|
}
|
|
141
165
|
|
|
142
|
-
|
|
166
|
+
const hasAuth = otelSemantics && Boolean(authority.username || authority.password)
|
|
167
|
+
return { protocol, port, host, hasAuth }
|
|
143
168
|
}
|
|
144
169
|
|
|
145
170
|
function hasAmazonSignature (headers, path) {
|
|
@@ -172,6 +197,7 @@ function normalizeConfig (config) {
|
|
|
172
197
|
|
|
173
198
|
return {
|
|
174
199
|
...config,
|
|
200
|
+
queryStringObfuscation: config.DD_TRACE_OTEL_SEMANTICS_ENABLED && getQsObfuscator(config),
|
|
175
201
|
validateStatus,
|
|
176
202
|
filter,
|
|
177
203
|
headers,
|
|
@@ -5,6 +5,7 @@ const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
|
|
|
5
5
|
|
|
6
6
|
const {
|
|
7
7
|
DISTRIBUTED_TRACE_META_KEY,
|
|
8
|
+
setErrorTags,
|
|
8
9
|
tagErrorResult,
|
|
9
10
|
} = require('./utils')
|
|
10
11
|
|
|
@@ -133,6 +134,11 @@ class McpServerRequestPlugin extends McpPlugin {
|
|
|
133
134
|
onEnd (span, ctx) {
|
|
134
135
|
if (ctx.error) {
|
|
135
136
|
span.setTag('error', ctx.error)
|
|
137
|
+
} else if (ctx.extra?.mcpReq?.signal?.aborted) {
|
|
138
|
+
// SDK 2.x drops the result of a handler whose connection closed, so the client never gets it.
|
|
139
|
+
setErrorTags(span, 'Connection closed')
|
|
140
|
+
} else if (ctx.result?.resultType === 'input_required') {
|
|
141
|
+
span.setTag('mcp.input_required', true)
|
|
136
142
|
} else {
|
|
137
143
|
tagErrorResult(span, ctx.result)
|
|
138
144
|
}
|
|
@@ -160,14 +166,34 @@ class McpServerToolCallPlugin extends McpPlugin {
|
|
|
160
166
|
onEnd (span, ctx) { tagErrorResult(span, ctx.result) }
|
|
161
167
|
}
|
|
162
168
|
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
class McpServerV2ToolCallPlugin extends McpServerToolCallPlugin {
|
|
170
|
+
static id = 'modelcontextprotocol_server_tool_v2'
|
|
171
|
+
static component = McpServerToolCallPlugin.id
|
|
172
|
+
static prefix = 'tracing:orchestrion:@modelcontextprotocol/server:McpServer_executeToolHandler'
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const clientPlugins = [
|
|
165
176
|
McpToolCallPlugin,
|
|
166
177
|
McpListToolsPlugin,
|
|
167
178
|
McpListResourcesPlugin,
|
|
168
179
|
McpReadResourcePlugin,
|
|
169
180
|
McpListPromptsPlugin,
|
|
170
181
|
McpGetPromptPlugin,
|
|
182
|
+
]
|
|
183
|
+
|
|
184
|
+
// SDK 2.x clients publish on the `@modelcontextprotocol/client` channels. The copies keep the 1.x component, so spans
|
|
185
|
+
// do not depend on the SDK major version.
|
|
186
|
+
const clientV2Plugins = clientPlugins.map(Plugin => class extends Plugin {
|
|
187
|
+
static id = `${Plugin.id}_v2`
|
|
188
|
+
static component = Plugin.id
|
|
189
|
+
static prefix = Plugin.prefix.replace('@modelcontextprotocol/sdk', '@modelcontextprotocol/client')
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
module.exports = [
|
|
193
|
+
McpPropagationPlugin,
|
|
194
|
+
...clientPlugins,
|
|
195
|
+
...clientV2Plugins,
|
|
171
196
|
McpServerRequestPlugin,
|
|
172
197
|
McpServerToolCallPlugin,
|
|
198
|
+
McpServerV2ToolCallPlugin,
|
|
173
199
|
]
|