dd-trace 5.135.0 → 5.137.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
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const StoragePlugin = require('../../dd-trace/src/plugins/storage')
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
6
|
+
otelHttpResourceName,
|
|
7
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
8
|
+
const {
|
|
9
|
+
buildClientHttpUrl,
|
|
10
|
+
extractPathFromUrl,
|
|
11
|
+
getQsObfuscator,
|
|
12
|
+
} = require('../../dd-trace/src/plugins/util/url')
|
|
5
13
|
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
6
14
|
const getHostname = require('./url')
|
|
7
15
|
|
|
@@ -50,22 +58,39 @@ class SupabaseStorageHandleRequestPlugin extends StoragePlugin {
|
|
|
50
58
|
static id = 'supabase'
|
|
51
59
|
static prefix = 'tracing:orchestrion:@supabase/storage-js:handleRequest'
|
|
52
60
|
|
|
61
|
+
configure (config) {
|
|
62
|
+
if (typeof config === 'boolean') return super.configure(config)
|
|
63
|
+
return super.configure({
|
|
64
|
+
...config,
|
|
65
|
+
queryStringObfuscation: config.DD_TRACE_OTEL_SEMANTICS_ENABLED && getQsObfuscator(config),
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
53
69
|
/** @param {StorageContext} ctx */
|
|
54
70
|
bindStart (ctx) {
|
|
55
71
|
const method = String(ctx.arguments?.[1] || 'GET').toUpperCase()
|
|
56
72
|
const url = ctx.arguments?.[2]
|
|
73
|
+
const rawUrl = String(url)
|
|
74
|
+
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
75
|
+
const resource = otelSemantics ? otelHttpResourceName(method) : `${method} ${getStorageRoute(url)}`
|
|
76
|
+
const meta = {
|
|
77
|
+
component: 'supabase',
|
|
78
|
+
'span.kind': 'client',
|
|
79
|
+
'http.method': method,
|
|
80
|
+
'http.url': otelSemantics
|
|
81
|
+
? buildClientHttpUrl(this.config, '', rawUrl, rawUrl)
|
|
82
|
+
: stripQueryAndFragment(rawUrl),
|
|
83
|
+
'out.host': getHostname(url),
|
|
84
|
+
}
|
|
85
|
+
if (otelSemantics) {
|
|
86
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
87
|
+
}
|
|
57
88
|
|
|
58
89
|
this.startSpan('supabase.storage.request', {
|
|
59
90
|
service: { name: this.tracer._service },
|
|
60
91
|
type: 'storage',
|
|
61
|
-
resource
|
|
62
|
-
meta
|
|
63
|
-
component: 'supabase',
|
|
64
|
-
'span.kind': 'client',
|
|
65
|
-
'http.method': method,
|
|
66
|
-
'http.url': stripQueryAndFragment(String(url)),
|
|
67
|
-
'out.host': getHostname(url),
|
|
68
|
-
},
|
|
92
|
+
resource,
|
|
93
|
+
meta,
|
|
69
94
|
}, ctx)
|
|
70
95
|
|
|
71
96
|
return ctx.currentStore
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
4
|
+
const TrpcProcedurePlugin = require('./procedure')
|
|
5
|
+
const TrpcRequestPlugin = require('./request')
|
|
6
|
+
|
|
7
|
+
class TrpcPlugin extends CompositePlugin {
|
|
8
|
+
static id = 'trpc'
|
|
9
|
+
static plugins = {
|
|
10
|
+
request: TrpcRequestPlugin,
|
|
11
|
+
procedure: TrpcProcedurePlugin,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = TrpcPlugin
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { storage } = require('../../datadog-core')
|
|
4
|
+
const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
|
|
5
|
+
|
|
6
|
+
const legacyStorage = storage('legacy')
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {{
|
|
10
|
+
* arguments: [{ path?: string, type?: string }],
|
|
11
|
+
* currentStore?: { span: import('../../dd-trace/src/opentracing/span') },
|
|
12
|
+
* error?: unknown
|
|
13
|
+
* }} ProcedureContext
|
|
14
|
+
* @typedef {{ currentStore?: { span: import('../../../').Span }, error?: unknown }}
|
|
15
|
+
* ProcedureCompletionContext
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
class TrpcProcedurePlugin extends TracingPlugin {
|
|
19
|
+
static id = 'trpc'
|
|
20
|
+
static prefix = 'tracing:orchestrion:@trpc/server:procedure'
|
|
21
|
+
|
|
22
|
+
/** @param {ProcedureContext} ctx */
|
|
23
|
+
bindStart (ctx) {
|
|
24
|
+
const { path, type } = ctx.arguments[0]
|
|
25
|
+
if (typeof path !== 'string' || (type !== 'query' && type !== 'mutation')) {
|
|
26
|
+
return legacyStorage.getStore()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.startSpan('trpc.procedure', {
|
|
30
|
+
service: this.config.service,
|
|
31
|
+
resource: `${type} ${path}`,
|
|
32
|
+
kind: 'internal',
|
|
33
|
+
}, ctx)
|
|
34
|
+
return ctx.currentStore
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @param {ProcedureCompletionContext} ctx */
|
|
38
|
+
error (ctx) {
|
|
39
|
+
ctx.currentStore?.span.setTag('error', ctx.error)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @param {ProcedureCompletionContext} ctx */
|
|
43
|
+
asyncEnd (ctx) {
|
|
44
|
+
ctx.currentStore?.span.finish()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = TrpcProcedurePlugin
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { storage } = require('../../datadog-core')
|
|
4
|
+
const Plugin = require('../../dd-trace/src/plugins/plugin')
|
|
5
|
+
const web = require('../../dd-trace/src/plugins/util/web')
|
|
6
|
+
const { HTTP_ROUTE } = require('../../../ext/tags')
|
|
7
|
+
|
|
8
|
+
const legacyStorage = storage('legacy')
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import('node:http').IncomingMessage} IncomingMessage
|
|
12
|
+
* @typedef {{ req?: IncomingMessage, batch?: boolean, path?: string, named?: boolean }} RequestCarrier
|
|
13
|
+
* @typedef {{ arguments: [{ req: IncomingMessage }] }} RequestContext
|
|
14
|
+
* @typedef {{ result?: {
|
|
15
|
+
* isBatchCall: boolean,
|
|
16
|
+
* path?: string,
|
|
17
|
+
* calls?: Array<{ path: string }>
|
|
18
|
+
* } }} RequestInfoContext
|
|
19
|
+
* @typedef {{ arguments: [{ path?: string }], currentStore?: { trpcCarrier?: RequestCarrier } }}
|
|
20
|
+
* ProcedureContext
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
class TrpcRequestPlugin extends Plugin {
|
|
24
|
+
static id = 'trpc'
|
|
25
|
+
|
|
26
|
+
/** @type {WeakMap<IncomingMessage, RequestCarrier>} */
|
|
27
|
+
#carriers = new WeakMap()
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {object} tracer
|
|
31
|
+
* @param {import('../../dd-trace/src/config/config-base')} tracerConfig
|
|
32
|
+
*/
|
|
33
|
+
constructor (tracer, tracerConfig) {
|
|
34
|
+
super(tracer, tracerConfig)
|
|
35
|
+
|
|
36
|
+
this.addBind('tracing:orchestrion:@trpc/server:request:start',
|
|
37
|
+
/** @param {RequestContext} ctx */ ctx => {
|
|
38
|
+
const { req } = ctx.arguments[0]
|
|
39
|
+
const carrier = { req }
|
|
40
|
+
this.#carriers.set(req, carrier)
|
|
41
|
+
return { ...legacyStorage.getStore(), trpcCarrier: carrier }
|
|
42
|
+
})
|
|
43
|
+
this.addSub('tracing:orchestrion:@trpc/server:requestInfo:asyncEnd', this.#setRequestInfo)
|
|
44
|
+
this.addSub('tracing:orchestrion:@trpc/server:procedure:asyncEnd', this.#nameRoute)
|
|
45
|
+
this.addSub('apm:http:server:request:finish', this.#finishRequest)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** @param {RequestInfoContext} ctx */
|
|
49
|
+
#setRequestInfo (ctx) {
|
|
50
|
+
const carrier = /** @type {RequestCarrier | undefined} */ (legacyStorage.getStore()?.trpcCarrier)
|
|
51
|
+
const result = ctx.result
|
|
52
|
+
if (!carrier?.req || !result) return
|
|
53
|
+
|
|
54
|
+
carrier.batch = result.isBatchCall
|
|
55
|
+
carrier.path = result.path ?? (result.calls?.length === 1 ? result.calls[0].path : undefined)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** @param {ProcedureContext} ctx */
|
|
59
|
+
#nameRoute (ctx) {
|
|
60
|
+
const carrier = ctx.currentStore?.trpcCarrier
|
|
61
|
+
const path = ctx.arguments[0]?.path
|
|
62
|
+
if (!carrier?.req || typeof path !== 'string' || carrier.batch || carrier.path !== path || carrier.named) return
|
|
63
|
+
|
|
64
|
+
const context = web.getContext(carrier.req)
|
|
65
|
+
if (!context?.paths?.length || context.span?.context().hasTag(HTTP_ROUTE)) return
|
|
66
|
+
|
|
67
|
+
web.enterRoute(carrier.req, `/${path}`)
|
|
68
|
+
carrier.named = true
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** @param {{ req: IncomingMessage }} ctx */
|
|
72
|
+
#finishRequest ({ req }) {
|
|
73
|
+
const carrier = this.#carriers.get(req)
|
|
74
|
+
if (!carrier) return
|
|
75
|
+
|
|
76
|
+
carrier.req = undefined
|
|
77
|
+
this.#carriers.delete(req)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = TrpcRequestPlugin
|
|
@@ -9,6 +9,11 @@ const { getClientStatusValidator } = require('../../dd-trace/src/plugins/util/st
|
|
|
9
9
|
const { buildClientHttpUrl } = require('../../dd-trace/src/plugins/util/url')
|
|
10
10
|
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
11
11
|
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
12
|
+
const {
|
|
13
|
+
HTTP_STATUS_ERROR,
|
|
14
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
15
|
+
otelHttpResourceName,
|
|
16
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
12
17
|
|
|
13
18
|
const {
|
|
14
19
|
HTTP_STATUS_CODE,
|
|
@@ -73,21 +78,28 @@ class UndiciPlugin extends HttpClientPlugin {
|
|
|
73
78
|
|
|
74
79
|
const allowed = this.config.filter(uri)
|
|
75
80
|
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
81
|
+
let resource = method
|
|
76
82
|
const childOf = store && allowed ? store.span : null
|
|
77
83
|
|
|
84
|
+
const meta = {
|
|
85
|
+
'span.kind': 'client',
|
|
86
|
+
'http.method': method,
|
|
87
|
+
'http.url': otelSemantics ? buildClientHttpUrl(this.config, base, path, uri) : uri,
|
|
88
|
+
'out.host': hostname,
|
|
89
|
+
}
|
|
90
|
+
if (otelSemantics) {
|
|
91
|
+
resource = otelHttpResourceName(method)
|
|
92
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
93
|
+
}
|
|
94
|
+
|
|
78
95
|
const span = this.startSpan(this.operationName(), {
|
|
79
96
|
childOf,
|
|
80
|
-
meta
|
|
81
|
-
'span.kind': 'client',
|
|
82
|
-
'http.method': method,
|
|
83
|
-
'http.url': otelSemantics ? buildClientHttpUrl(this.config, base, path, uri) : uri,
|
|
84
|
-
'out.host': hostname,
|
|
85
|
-
},
|
|
97
|
+
meta,
|
|
86
98
|
metrics: {
|
|
87
99
|
[CLIENT_PORT_KEY]: port ? Number.parseInt(port, 10) : undefined,
|
|
88
100
|
},
|
|
89
101
|
service: this.serviceName({ pluginConfig: this.config, sessionDetails: { host: hostname, port } }),
|
|
90
|
-
resource
|
|
102
|
+
resource,
|
|
91
103
|
type: 'http',
|
|
92
104
|
}, false)
|
|
93
105
|
|
|
@@ -140,6 +152,9 @@ class UndiciPlugin extends HttpClientPlugin {
|
|
|
140
152
|
|
|
141
153
|
if (!this.config.validateStatus(statusCode)) {
|
|
142
154
|
span.setTag('error', 1)
|
|
155
|
+
if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
156
|
+
span.setTag(HTTP_STATUS_ERROR, String(statusCode))
|
|
157
|
+
}
|
|
143
158
|
}
|
|
144
159
|
}
|
|
145
160
|
|
|
@@ -96,6 +96,8 @@ class VitestPlugin extends CiPlugin {
|
|
|
96
96
|
constructor (...args) {
|
|
97
97
|
super(...args)
|
|
98
98
|
|
|
99
|
+
this.filterDiBreakpointHitByStack = true
|
|
100
|
+
|
|
99
101
|
this.taskToFinishTime = new WeakMap()
|
|
100
102
|
|
|
101
103
|
this.addSub('ci:vitest:session:configuration', ({ onDone }) => {
|
|
@@ -204,9 +206,8 @@ class VitestPlugin extends CiPlugin {
|
|
|
204
206
|
ctx.parentStore = store
|
|
205
207
|
ctx.currentStore = { ...store, span }
|
|
206
208
|
|
|
207
|
-
// TODO: there might be multiple tests for which mightHitProbe is true, so activeTestSpan
|
|
208
|
-
// might be wrongly overwritten.
|
|
209
209
|
if (mightHitProbe) {
|
|
210
|
+
this.queueDiBreakpointHitSpan(span)
|
|
210
211
|
this.activeTestSpan = span
|
|
211
212
|
}
|
|
212
213
|
|
|
@@ -6,7 +6,6 @@ const {
|
|
|
6
6
|
SPAN_POINTER_DIRECTION,
|
|
7
7
|
SPAN_POINTER_DIRECTION_NAME,
|
|
8
8
|
} = require('../../dd-trace/src/constants')
|
|
9
|
-
const { getSegment } = require('../../dd-trace/src/util')
|
|
10
9
|
const {
|
|
11
10
|
incrementWebSocketCounter,
|
|
12
11
|
buildWebSocketSpanPointerHash,
|
|
@@ -30,12 +29,11 @@ class WSClosePlugin extends TracingPlugin {
|
|
|
30
29
|
|
|
31
30
|
const spanKind = isPeerClose ? 'consumer' : 'producer'
|
|
32
31
|
const spanTags = socket.spanTags
|
|
33
|
-
const path = getSegment(spanTags['resource.name'], ' ', 1)
|
|
34
32
|
const service = this.serviceName({ pluginConfig: this.config })
|
|
35
33
|
const span = this.startSpan(this.operationName(), {
|
|
36
34
|
service,
|
|
37
35
|
meta: {
|
|
38
|
-
'resource.name':
|
|
36
|
+
'resource.name': spanTags.messageResource,
|
|
39
37
|
'span.type': 'websocket',
|
|
40
38
|
'span.kind': spanKind,
|
|
41
39
|
'websocket.close.code': code,
|
|
@@ -48,8 +46,8 @@ class WSClosePlugin extends TracingPlugin {
|
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
if (isPeerClose && traceWebsocketMessagesInheritSampling && traceWebsocketMessagesSeparateTraces) {
|
|
51
|
-
span.setTag('_dd.dm.service', spanTags['service.name']
|
|
52
|
-
span.setTag('_dd.dm.resource', spanTags['resource.name']
|
|
49
|
+
span.setTag('_dd.dm.service', spanTags['service.name'])
|
|
50
|
+
span.setTag('_dd.dm.resource', spanTags['resource.name'])
|
|
53
51
|
span.setTag('_dd.dm.inherited', 1)
|
|
54
52
|
}
|
|
55
53
|
|
|
@@ -6,7 +6,6 @@ const {
|
|
|
6
6
|
SPAN_POINTER_DIRECTION,
|
|
7
7
|
SPAN_POINTER_DIRECTION_NAME,
|
|
8
8
|
} = require('../../dd-trace/src/constants')
|
|
9
|
-
const { getSegment } = require('../../dd-trace/src/util')
|
|
10
9
|
const {
|
|
11
10
|
incrementWebSocketCounter,
|
|
12
11
|
buildWebSocketSpanPointerHash,
|
|
@@ -23,8 +22,6 @@ class WSProducerPlugin extends TracingPlugin {
|
|
|
23
22
|
const { byteLength, socket, binary } = ctx
|
|
24
23
|
if (!socket?.spanContext) return
|
|
25
24
|
|
|
26
|
-
const spanTags = socket.spanTags
|
|
27
|
-
const path = getSegment(spanTags['resource.name'], ' ', 1)
|
|
28
25
|
const opCode = binary ? 'binary' : 'text'
|
|
29
26
|
const service = this.serviceName({ pluginConfig: this.config })
|
|
30
27
|
const span = this.startSpan(this.operationName(), {
|
|
@@ -32,7 +29,7 @@ class WSProducerPlugin extends TracingPlugin {
|
|
|
32
29
|
meta: {
|
|
33
30
|
'span.type': 'websocket',
|
|
34
31
|
'span.kind': 'producer',
|
|
35
|
-
'resource.name':
|
|
32
|
+
'resource.name': socket.spanTags.messageResource,
|
|
36
33
|
'websocket.message.type': opCode,
|
|
37
34
|
|
|
38
35
|
},
|
|
@@ -6,7 +6,6 @@ const {
|
|
|
6
6
|
SPAN_POINTER_DIRECTION,
|
|
7
7
|
SPAN_POINTER_DIRECTION_NAME,
|
|
8
8
|
} = require('../../dd-trace/src/constants')
|
|
9
|
-
const { getSegment } = require('../../dd-trace/src/util')
|
|
10
9
|
const {
|
|
11
10
|
incrementWebSocketCounter,
|
|
12
11
|
buildWebSocketSpanPointerHash,
|
|
@@ -29,7 +28,6 @@ class WSReceiverPlugin extends TracingPlugin {
|
|
|
29
28
|
if (!socket.spanContext) return
|
|
30
29
|
|
|
31
30
|
const spanTags = socket.spanTags
|
|
32
|
-
const path = getSegment(spanTags['resource.name'], ' ', 1)
|
|
33
31
|
const opCode = binary ? 'binary' : 'text'
|
|
34
32
|
|
|
35
33
|
const service = this.serviceName({ pluginConfig: this.config })
|
|
@@ -38,7 +36,7 @@ class WSReceiverPlugin extends TracingPlugin {
|
|
|
38
36
|
meta: {
|
|
39
37
|
'span.type': 'websocket',
|
|
40
38
|
'span.kind': 'consumer',
|
|
41
|
-
'resource.name':
|
|
39
|
+
'resource.name': spanTags.messageResource,
|
|
42
40
|
'websocket.duration.style': 'handler',
|
|
43
41
|
'websocket.message.type': opCode,
|
|
44
42
|
},
|
|
@@ -49,8 +47,8 @@ class WSReceiverPlugin extends TracingPlugin {
|
|
|
49
47
|
}, ctx)
|
|
50
48
|
|
|
51
49
|
if (traceWebsocketMessagesInheritSampling && traceWebsocketMessagesSeparateTraces) {
|
|
52
|
-
span.setTag('_dd.dm.service', spanTags['service.name']
|
|
53
|
-
span.setTag('_dd.dm.resource', spanTags['resource.name']
|
|
50
|
+
span.setTag('_dd.dm.service', spanTags['service.name'])
|
|
51
|
+
span.setTag('_dd.dm.resource', spanTags['resource.name'])
|
|
54
52
|
span.setTag('_dd.dm.inherited', 1)
|
|
55
53
|
}
|
|
56
54
|
|
|
@@ -4,6 +4,12 @@ const TracingPlugin = require('../../dd-trace/src/plugins/tracing.js')
|
|
|
4
4
|
const tags = require('../../../ext/tags.js')
|
|
5
5
|
const { HTTP_HEADERS } = require('../../../ext/formats')
|
|
6
6
|
const { getSegment } = require('../../dd-trace/src/util')
|
|
7
|
+
const { getQsObfuscator, obfuscateQs } = require('../../dd-trace/src/plugins/util/url')
|
|
8
|
+
const {
|
|
9
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
10
|
+
NETWORK_PEER_ADDRESS,
|
|
11
|
+
otelHttpResourceName,
|
|
12
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
7
13
|
const {
|
|
8
14
|
createWebSocketSpanContext,
|
|
9
15
|
hasTraceHeaders,
|
|
@@ -26,6 +32,16 @@ class WSServerPlugin extends TracingPlugin {
|
|
|
26
32
|
this.addBind('tracing:ws:server:connect:setSocket', () => {})
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
/**
|
|
36
|
+
* @param {object} config
|
|
37
|
+
*/
|
|
38
|
+
configure (config) {
|
|
39
|
+
return super.configure({
|
|
40
|
+
...config,
|
|
41
|
+
queryStringObfuscation: config.DD_TRACE_OTEL_SEMANTICS_ENABLED && getQsObfuscator(config),
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
29
45
|
bindStart (ctx) {
|
|
30
46
|
const req = ctx.req
|
|
31
47
|
|
|
@@ -38,9 +54,13 @@ class WSServerPlugin extends TracingPlugin {
|
|
|
38
54
|
const host = options.headers.host
|
|
39
55
|
const url = req.url
|
|
40
56
|
const indexOfParam = url.indexOf('?')
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
57
|
+
const path = indexOfParam === -1 ? url : url.slice(0, indexOfParam)
|
|
58
|
+
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
59
|
+
const requestTarget = otelSemantics
|
|
60
|
+
? obfuscateQs(this.config, url)
|
|
61
|
+
: path
|
|
62
|
+
const uri = `${protocol}//${host}${requestTarget}`
|
|
63
|
+
const resourceName = otelSemantics ? otelHttpResourceName(options.method) : `${options.method} ${path}`
|
|
44
64
|
|
|
45
65
|
ctx.args = { options }
|
|
46
66
|
|
|
@@ -48,24 +68,35 @@ class WSServerPlugin extends TracingPlugin {
|
|
|
48
68
|
const childOf = this.tracer.extract(HTTP_HEADERS, req.headers)
|
|
49
69
|
|
|
50
70
|
const service = this.serviceName({ pluginConfig: this.config })
|
|
71
|
+
const meta = {
|
|
72
|
+
'span.type': 'websocket',
|
|
73
|
+
'http.upgraded': 'websocket',
|
|
74
|
+
'http.method': options.method,
|
|
75
|
+
'http.url': uri,
|
|
76
|
+
'resource.name': resourceName,
|
|
77
|
+
'span.kind': 'server',
|
|
78
|
+
}
|
|
79
|
+
if (otelSemantics) {
|
|
80
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resourceName
|
|
81
|
+
|
|
82
|
+
const userAgent = options.headers['user-agent']
|
|
83
|
+
if (userAgent !== undefined) meta['http.useragent'] = userAgent
|
|
84
|
+
|
|
85
|
+
const peerAddress = req.socket?.remoteAddress
|
|
86
|
+
if (peerAddress) meta[NETWORK_PEER_ADDRESS] = peerAddress
|
|
87
|
+
}
|
|
88
|
+
|
|
51
89
|
const span = this.startSpan(this.operationName(), {
|
|
52
90
|
service,
|
|
53
91
|
childOf,
|
|
54
|
-
meta
|
|
55
|
-
'span.type': 'websocket',
|
|
56
|
-
'http.upgraded': 'websocket',
|
|
57
|
-
'http.method': options.method,
|
|
58
|
-
'http.url': uri,
|
|
59
|
-
'resource.name': resourceName,
|
|
60
|
-
'span.kind': 'server',
|
|
61
|
-
},
|
|
62
|
-
|
|
92
|
+
meta,
|
|
63
93
|
}, ctx)
|
|
64
94
|
ctx.span = span
|
|
65
95
|
|
|
66
96
|
ctx.socket.spanTags = {
|
|
97
|
+
messageResource: `websocket ${path}`,
|
|
67
98
|
'resource.name': resourceName,
|
|
68
|
-
'service.name': service,
|
|
99
|
+
'service.name': span.context().getTag('service.name'),
|
|
69
100
|
}
|
|
70
101
|
ctx.socket.spanContext = createWebSocketSpanContext(ctx.span._spanContext)
|
|
71
102
|
ctx.socket.hasTraceHeaders = hasTraceHeaders(req.headers)
|
|
@@ -5,17 +5,14 @@ const Module = require('node:module')
|
|
|
5
5
|
const path = require('node:path')
|
|
6
6
|
|
|
7
7
|
const satisfies = require('../../vendor/dist/semifies')
|
|
8
|
-
const
|
|
9
|
-
const { getRewriteTargetNames } = require('../datadog-instrumentations/src/helpers/rewriter/targets')
|
|
8
|
+
const { packagePathPattern } = require('../datadog-instrumentations/src/helpers/bundler-transform')
|
|
10
9
|
const { SYNTHETIC_EXTENSION } = require('./src/constants')
|
|
11
10
|
|
|
12
|
-
const BUILTIN_MODULES = new Set(Module.builtinModules)
|
|
13
11
|
const loader = path.join(__dirname, 'src/loader.js')
|
|
14
12
|
const EXTENSIONLESS_PATH_PATTERN = /(?:^|\/)[^/.]+$/
|
|
15
13
|
const PHASE_PRODUCTION_SERVER = 'phase-production-server'
|
|
16
14
|
const SOURCE_EXTENSIONS = ['*.js', '*.cjs', '*.mjs', '*.jsx', '*.ts', '*.cts', '*.mts', '*.tsx']
|
|
17
15
|
const SOURCE_PATH_PATTERN = /\.(?:cjs|cts|js|jsx|mjs|mts|ts|tsx)$/
|
|
18
|
-
const PACKAGE_PATH_PATTERN = createPackagePathPattern()
|
|
19
16
|
|
|
20
17
|
/**
|
|
21
18
|
* Adds Datadog instrumentation to a Next.js Turbopack configuration.
|
|
@@ -88,14 +85,14 @@ function addModernRules (turbopack) {
|
|
|
88
85
|
const rules = { ...turbopack.rules }
|
|
89
86
|
for (const extension of SOURCE_EXTENSIONS) {
|
|
90
87
|
appendRule(rules, extension, {
|
|
91
|
-
condition: { all: ['node', 'foreign', { path:
|
|
88
|
+
condition: { all: ['node', 'foreign', { path: packagePathPattern }] },
|
|
92
89
|
loaders: [createLoader()],
|
|
93
90
|
})
|
|
94
91
|
}
|
|
95
92
|
appendRule(rules, '*', {
|
|
96
93
|
as: `*${SYNTHETIC_EXTENSION}`,
|
|
97
94
|
condition: {
|
|
98
|
-
all: ['node', 'foreign', { path:
|
|
95
|
+
all: ['node', 'foreign', { path: packagePathPattern }, { path: EXTENSIONLESS_PATH_PATTERN }],
|
|
99
96
|
},
|
|
100
97
|
loaders: [createLoader()],
|
|
101
98
|
})
|
|
@@ -129,7 +126,7 @@ function addLegacyRule (turbopack) {
|
|
|
129
126
|
}
|
|
130
127
|
conditions[name] = {
|
|
131
128
|
all: [
|
|
132
|
-
{ path:
|
|
129
|
+
{ path: packagePathPattern },
|
|
133
130
|
{ any: [{ path: SOURCE_PATH_PATTERN }, { path: EXTENSIONLESS_PATH_PATTERN }] },
|
|
134
131
|
],
|
|
135
132
|
}
|
|
@@ -154,27 +151,6 @@ function hasDatadogLoader (value) {
|
|
|
154
151
|
return Object.values(value).some(hasDatadogLoader)
|
|
155
152
|
}
|
|
156
153
|
|
|
157
|
-
/**
|
|
158
|
-
* @returns {RegExp}
|
|
159
|
-
*/
|
|
160
|
-
function createPackagePathPattern () {
|
|
161
|
-
const names = []
|
|
162
|
-
const targetPackages = new Set(Object.keys(hooks))
|
|
163
|
-
for (const name of getRewriteTargetNames()) targetPackages.add(name)
|
|
164
|
-
for (const name of targetPackages) {
|
|
165
|
-
if (!name.startsWith('.') && !BUILTIN_MODULES.has(name)) names.push(escapeRegExp(name))
|
|
166
|
-
}
|
|
167
|
-
names.sort()
|
|
168
|
-
return new RegExp(`(?:^|/)(?:${names.join('|')})(?:/|$)`)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @param {string} value
|
|
173
|
-
*/
|
|
174
|
-
function escapeRegExp (value) {
|
|
175
|
-
return value.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
154
|
function getNextMajor () {
|
|
179
155
|
const entrypoints = []
|
|
180
156
|
if (require.main?.filename) entrypoints.push(require.main.filename)
|