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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { isMap, isRegExp } = require('node:util').types
|
|
4
4
|
|
|
5
5
|
const DatabasePlugin = require('../../dd-trace/src/plugins/database')
|
|
6
|
+
const { storage } = require('../../datadog-core')
|
|
6
7
|
|
|
7
8
|
class MongodbCoreQueryPlugin extends DatabasePlugin {
|
|
8
9
|
static id = 'mongodb-core'
|
|
@@ -31,7 +32,8 @@ class MongodbCoreQueryPlugin extends DatabasePlugin {
|
|
|
31
32
|
const { ns, ops, options = {}, name } = ctx
|
|
32
33
|
// heartbeat commands can be disabled if this.config.heartbeatEnabled is false
|
|
33
34
|
if (!this.config.heartbeatEnabled && isHeartbeat(ops, this.config)) {
|
|
34
|
-
|
|
35
|
+
ctx.parentStore = storage('legacy').getStore()
|
|
36
|
+
return ctx.parentStore
|
|
35
37
|
}
|
|
36
38
|
const query = getQuery(ops, this.config.obfuscateQuery)
|
|
37
39
|
const resource = truncate(getResource(this, ns, query, name))
|
|
@@ -57,6 +59,20 @@ class MongodbCoreQueryPlugin extends DatabasePlugin {
|
|
|
57
59
|
return ctx.currentStore
|
|
58
60
|
}
|
|
59
61
|
|
|
62
|
+
/**
|
|
63
|
+
* @param {{ currentStore?: { span: import('../../..').Span } }} ctx
|
|
64
|
+
*/
|
|
65
|
+
finish (ctx) {
|
|
66
|
+
if (ctx.currentStore) super.finish(ctx)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {{ currentStore?: { span: import('../../..').Span }, error?: unknown }} ctx
|
|
71
|
+
*/
|
|
72
|
+
error (ctx) {
|
|
73
|
+
if (ctx.currentStore) super.error(ctx)
|
|
74
|
+
}
|
|
75
|
+
|
|
60
76
|
/**
|
|
61
77
|
* @override
|
|
62
78
|
*/
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { channel } = require('dc-polyfill')
|
|
4
|
+
|
|
3
5
|
const ServerPlugin = require('../../dd-trace/src/plugins/server')
|
|
4
6
|
const { storage } = require('../../datadog-core')
|
|
5
7
|
const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
|
|
6
8
|
const { COMPONENT, SVC_SRC_KEY } = require('../../dd-trace/src/constants')
|
|
9
|
+
const {
|
|
10
|
+
HTTP_STATUS_ERROR,
|
|
11
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
12
|
+
isInstrumentationOwnedResource,
|
|
13
|
+
NETWORK_PEER_ADDRESS,
|
|
14
|
+
otelHttpResourceName,
|
|
15
|
+
setInstrumentationHttpResource,
|
|
16
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
7
17
|
const web = require('../../dd-trace/src/plugins/util/web')
|
|
8
18
|
const { HTTP_ROUTE, RESOURCE_NAME } = require('../../../ext/tags')
|
|
19
|
+
const { extractURL, obfuscateQs } = require('../../dd-trace/src/plugins/util/url')
|
|
9
20
|
|
|
10
21
|
const errorPages = new Set(['/404', '/500', '/_error', '/_not-found', '/_not-found/page'])
|
|
11
22
|
const reusedNextRequestStores = new WeakSet()
|
|
12
23
|
const nextParentRoutes = new WeakMap()
|
|
24
|
+
const requestMeta = Symbol.for('NextInternalRequestMeta')
|
|
25
|
+
const finishChannel = channel('apm:next:request:finish')
|
|
13
26
|
|
|
14
27
|
/**
|
|
15
28
|
* @typedef {Record<string, unknown> & {
|
|
@@ -18,8 +31,7 @@ const nextParentRoutes = new WeakMap()
|
|
|
18
31
|
* backgroundRevalidationRequest?: import('node:http').IncomingMessage
|
|
19
32
|
* }} NextRequestStore
|
|
20
33
|
*
|
|
21
|
-
* @typedef {
|
|
22
|
-
* @property {unknown} [error]
|
|
34
|
+
* @typedef {Request & { error?: unknown }} NextRequest
|
|
23
35
|
*
|
|
24
36
|
* @typedef {object} NextRequestContext
|
|
25
37
|
* @property {import('node:http').IncomingMessage} req
|
|
@@ -47,6 +59,33 @@ class NextPlugin extends ServerPlugin {
|
|
|
47
59
|
backgroundRevalidationRequest: req,
|
|
48
60
|
}))
|
|
49
61
|
this.addSub('apm:next:page:load', message => this.pageLoad(message))
|
|
62
|
+
for (const operation of ['imageRequest', 'imageRequestWithMiddleware']) {
|
|
63
|
+
const prefix = `tracing:orchestrion:next:${operation}`
|
|
64
|
+
this.addBind(`${prefix}:start`, ctx => {
|
|
65
|
+
const args = ctx.arguments
|
|
66
|
+
const pathname = (args[3] || args[2])?.pathname
|
|
67
|
+
if (!pathname?.startsWith('/_next/image')) return storage('legacy').getStore()
|
|
68
|
+
if (operation === 'imageRequestWithMiddleware' && args[0][requestMeta]?.middlewareInvoke) {
|
|
69
|
+
return storage('legacy').getStore()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ctx.req = args[0].originalRequest || args[0]
|
|
73
|
+
ctx.res = args[1].originalResponse || args[1]
|
|
74
|
+
ctx.currentStore = this.bindStart(ctx)
|
|
75
|
+
return ctx.currentStore
|
|
76
|
+
})
|
|
77
|
+
this.addSub(`${prefix}:start`, ctx => {
|
|
78
|
+
if (ctx.currentStore) this.pageLoad({ page: '/_next/image' })
|
|
79
|
+
})
|
|
80
|
+
this.addSub(`${prefix}:asyncEnd`, ctx => {
|
|
81
|
+
if (!ctx.currentStore) return
|
|
82
|
+
if (ctx.error && !ctx.res.destroyed && !reusedNextRequestStores.has(ctx.currentStore)) {
|
|
83
|
+
ctx.res.once('close', () => finishChannel.publish(ctx))
|
|
84
|
+
} else {
|
|
85
|
+
this.finish(ctx)
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
}
|
|
50
89
|
}
|
|
51
90
|
|
|
52
91
|
/** @param {NextRequestContext} ctx */
|
|
@@ -76,6 +115,11 @@ class NextPlugin extends ServerPlugin {
|
|
|
76
115
|
'http.method': req.method,
|
|
77
116
|
}
|
|
78
117
|
if (serviceSource !== undefined) tags[SVC_SRC_KEY] = serviceSource
|
|
118
|
+
if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
119
|
+
const resource = otelHttpResourceName(req.method)
|
|
120
|
+
tags['resource.name'] = resource
|
|
121
|
+
tags[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
122
|
+
}
|
|
79
123
|
|
|
80
124
|
const span = this.tracer.startSpan(this.operationName(), {
|
|
81
125
|
childOf,
|
|
@@ -83,6 +127,8 @@ class NextPlugin extends ServerPlugin {
|
|
|
83
127
|
integrationName: this.constructor.id,
|
|
84
128
|
})
|
|
85
129
|
|
|
130
|
+
if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) addOtelRequestTags(span, this.config, req)
|
|
131
|
+
|
|
86
132
|
this.stampIntegrationService(span, serviceName)
|
|
87
133
|
|
|
88
134
|
analyticsSampler.sample(span, this.config.measured, true)
|
|
@@ -104,14 +150,14 @@ class NextPlugin extends ServerPlugin {
|
|
|
104
150
|
|
|
105
151
|
/** @param {NextRequestContext} ctx */
|
|
106
152
|
finish (ctx) {
|
|
107
|
-
const { req, res, nextRequest
|
|
153
|
+
const { req, res, nextRequest } = ctx
|
|
108
154
|
const store = ctx.currentStore ?? storage('legacy').getStore()
|
|
109
155
|
|
|
110
156
|
if (!store || reusedNextRequestStores.has(store)) return
|
|
111
157
|
|
|
112
158
|
const span = store.span
|
|
113
159
|
const error = ctx.error ?? span.context().getTag('error')
|
|
114
|
-
const requestError = req.error || nextRequest
|
|
160
|
+
const requestError = req.error || nextRequest?.error
|
|
115
161
|
|
|
116
162
|
if (requestError) {
|
|
117
163
|
// prioritize user-set errors from API routes
|
|
@@ -124,6 +170,9 @@ class NextPlugin extends ServerPlugin {
|
|
|
124
170
|
} else if (!this.config.validateStatus(res.statusCode)) {
|
|
125
171
|
// where there's no error, we still need to validate status
|
|
126
172
|
span.setTag('error', true)
|
|
173
|
+
if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
174
|
+
span.setTag(HTTP_STATUS_ERROR, String(res.statusCode))
|
|
175
|
+
}
|
|
127
176
|
web.addError(req, true)
|
|
128
177
|
}
|
|
129
178
|
|
|
@@ -146,11 +195,11 @@ class NextPlugin extends ServerPlugin {
|
|
|
146
195
|
// safeguard against missing req in complicated timeout scenarios
|
|
147
196
|
if (!req) return
|
|
148
197
|
|
|
149
|
-
//
|
|
198
|
+
// Nested requests, static loads, and error pages must preserve the matched route.
|
|
150
199
|
const current = span.context().getTag('next.page')
|
|
151
200
|
const isErrorPage = errorPages.has(page)
|
|
152
201
|
|
|
153
|
-
if (current && isErrorPage) {
|
|
202
|
+
if (current && (isErrorPage || isStatic || reusedNextRequestStores.has(store))) {
|
|
154
203
|
return
|
|
155
204
|
}
|
|
156
205
|
|
|
@@ -167,13 +216,24 @@ class NextPlugin extends ServerPlugin {
|
|
|
167
216
|
: '/public/*'
|
|
168
217
|
}
|
|
169
218
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
219
|
+
let resource = `${req.method} ${page}`.trim()
|
|
220
|
+
span.setTag(COMPONENT, this.constructor.id)
|
|
221
|
+
span.setTag('next.page', page)
|
|
222
|
+
if (this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED) {
|
|
223
|
+
resource = otelHttpResourceName(req.method, page)
|
|
224
|
+
span.setTag(HTTP_ROUTE, page)
|
|
225
|
+
setInstrumentationHttpResourceIfOwned(span, resource)
|
|
226
|
+
} else {
|
|
227
|
+
span.setTag(RESOURCE_NAME, resource)
|
|
228
|
+
}
|
|
175
229
|
web.setRouteOrEndpointTag(req)
|
|
176
|
-
setHttpParentRoute(
|
|
230
|
+
setHttpParentRoute(
|
|
231
|
+
httpParentSpan,
|
|
232
|
+
page,
|
|
233
|
+
isStatic,
|
|
234
|
+
this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED,
|
|
235
|
+
resource
|
|
236
|
+
)
|
|
177
237
|
web.setRoute(req, page)
|
|
178
238
|
}
|
|
179
239
|
|
|
@@ -200,7 +260,14 @@ function normalizeAppPath (page) {
|
|
|
200
260
|
return page
|
|
201
261
|
}
|
|
202
262
|
|
|
203
|
-
|
|
263
|
+
/**
|
|
264
|
+
* @param {import('../../dd-trace/src/opentracing/span') | undefined} span
|
|
265
|
+
* @param {string | undefined} page
|
|
266
|
+
* @param {boolean} isStatic
|
|
267
|
+
* @param {boolean} otelSemanticsEnabled
|
|
268
|
+
* @param {string} resource
|
|
269
|
+
*/
|
|
270
|
+
function setHttpParentRoute (span, page, isStatic, otelSemanticsEnabled, resource) {
|
|
204
271
|
if (!span) return
|
|
205
272
|
const currentRoute = span.context().getTag(HTTP_ROUTE)
|
|
206
273
|
|
|
@@ -208,7 +275,38 @@ function setHttpParentRoute (span, method, page, isStatic) {
|
|
|
208
275
|
if (currentRoute && (nextParentRoutes.get(span) !== currentRoute || isStatic)) return
|
|
209
276
|
|
|
210
277
|
span.setTag(HTTP_ROUTE, page)
|
|
211
|
-
|
|
278
|
+
if (otelSemanticsEnabled) {
|
|
279
|
+
setInstrumentationHttpResourceIfOwned(span, resource)
|
|
280
|
+
} else {
|
|
281
|
+
span.setTag(RESOURCE_NAME, resource)
|
|
282
|
+
}
|
|
212
283
|
nextParentRoutes.set(span, page)
|
|
213
284
|
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @param {import('../../dd-trace/src/opentracing/span')} span
|
|
288
|
+
* @param {string} resource
|
|
289
|
+
*/
|
|
290
|
+
function setInstrumentationHttpResourceIfOwned (span, resource) {
|
|
291
|
+
const context = span.context()
|
|
292
|
+
if (isInstrumentationOwnedResource(
|
|
293
|
+
context.getTag(RESOURCE_NAME),
|
|
294
|
+
context.getTag(INSTRUMENTATION_HTTP_RESOURCE)
|
|
295
|
+
)) {
|
|
296
|
+
setInstrumentationHttpResource(span, resource)
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* @param {import('../../dd-trace/src/opentracing/span')} span
|
|
301
|
+
* @param {Record<string, unknown>} config
|
|
302
|
+
* @param {import('node:http').IncomingMessage} req
|
|
303
|
+
*/
|
|
304
|
+
function addOtelRequestTags (span, config, req) {
|
|
305
|
+
const userAgent = req.headers['user-agent']
|
|
306
|
+
const peerAddress = req.socket?.remoteAddress
|
|
307
|
+
span.setTag('http.url', obfuscateQs(config, extractURL(req)))
|
|
308
|
+
if (userAgent !== undefined) span.setTag('http.useragent', userAgent)
|
|
309
|
+
if (peerAddress) span.setTag(NETWORK_PEER_ADDRESS, peerAddress)
|
|
310
|
+
}
|
|
311
|
+
|
|
214
312
|
module.exports = NextPlugin
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { performance } = require('node:perf_hooks')
|
|
4
|
+
const { Readable, Writable } = require('node:stream')
|
|
4
5
|
|
|
5
6
|
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
6
7
|
const DatabasePlugin = require('../../dd-trace/src/plugins/database')
|
|
@@ -8,10 +9,11 @@ const Plugin = require('../../dd-trace/src/plugins/plugin')
|
|
|
8
9
|
|
|
9
10
|
const ACQUIRE_START_CHANNEL = 'tracing:orchestrion:postgres:query:acquire:start'
|
|
10
11
|
const PREPARE_START_CHANNEL = 'tracing:orchestrion:postgres:query:prepare:start'
|
|
12
|
+
const COPY_START_CHANNEL = 'tracing:orchestrion:postgres:query:copy:start'
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* @typedef {object} PostgresContext
|
|
14
|
-
* @property {
|
|
16
|
+
* @property {PostgresStore} currentStore
|
|
15
17
|
* @property {string} database
|
|
16
18
|
* @property {unknown} [error]
|
|
17
19
|
* @property {string} [host]
|
|
@@ -23,16 +25,36 @@ const PREPARE_START_CHANNEL = 'tracing:orchestrion:postgres:query:prepare:start'
|
|
|
23
25
|
* @property {string} [statement]
|
|
24
26
|
* @property {string} user
|
|
25
27
|
*
|
|
26
|
-
* @typedef {object}
|
|
27
|
-
* @property {
|
|
28
|
+
* @typedef {object} PostgresStore
|
|
29
|
+
* @property {import('../../..').Span} span
|
|
30
|
+
* @property {string} [dbmService]
|
|
28
31
|
* @property {string} [statement]
|
|
29
32
|
*
|
|
30
33
|
* @typedef {object} PostgresPreparationContext
|
|
34
|
+
* @property {string} [host]
|
|
35
|
+
* @property {number} [port]
|
|
31
36
|
* @property {boolean} prepared
|
|
32
|
-
* @property {PostgresQuery} query
|
|
37
|
+
* @property {PostgresQuery | NativePostgresContext} query
|
|
38
|
+
* @property {string} [resource]
|
|
33
39
|
* @property {string} statement
|
|
34
40
|
*
|
|
41
|
+
* @typedef {object} PostgresCopyContext
|
|
42
|
+
* @property {Error | null} error
|
|
43
|
+
* @property {NativePostgresContext} query
|
|
44
|
+
*
|
|
35
45
|
* @typedef {object} PostgresQuery
|
|
46
|
+
*
|
|
47
|
+
* @typedef {object} NativePostgresContext
|
|
48
|
+
* @property {PostgresStore} [currentStore]
|
|
49
|
+
* @property {string} database
|
|
50
|
+
* @property {Error} [error]
|
|
51
|
+
* @property {string | null} host
|
|
52
|
+
* @property {number | null} port
|
|
53
|
+
* @property {string | null} query
|
|
54
|
+
* @property {number} queued
|
|
55
|
+
* @property {unknown} [result]
|
|
56
|
+
* @property {number | null} sent
|
|
57
|
+
* @property {string} user
|
|
36
58
|
*/
|
|
37
59
|
|
|
38
60
|
class PostgresPreparationPlugin extends Plugin {
|
|
@@ -49,6 +71,20 @@ class PostgresPreparationPlugin extends Plugin {
|
|
|
49
71
|
}
|
|
50
72
|
}
|
|
51
73
|
|
|
74
|
+
class PostgresCopyPlugin extends Plugin {
|
|
75
|
+
static id = 'postgres'
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {(ctx: PostgresCopyContext) => void} finish
|
|
79
|
+
* @param {object} tracer
|
|
80
|
+
* @param {import('../../dd-trace/src/config/config-base')} tracerConfig
|
|
81
|
+
*/
|
|
82
|
+
constructor (finish, tracer, tracerConfig) {
|
|
83
|
+
super(tracer, tracerConfig)
|
|
84
|
+
this.addSub(COPY_START_CHANNEL, finish)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
52
88
|
class PostgresPlugin extends DatabasePlugin {
|
|
53
89
|
static id = 'postgres'
|
|
54
90
|
static prefix = 'tracing:orchestrion:postgres:query'
|
|
@@ -56,8 +92,8 @@ class PostgresPlugin extends DatabasePlugin {
|
|
|
56
92
|
/** @type {boolean} */
|
|
57
93
|
#dbmEnabled = false
|
|
58
94
|
|
|
59
|
-
/** @type {WeakMap<PostgresQuery,
|
|
60
|
-
#
|
|
95
|
+
/** @type {WeakMap<PostgresQuery, PostgresContext>} */
|
|
96
|
+
#contexts = new WeakMap()
|
|
61
97
|
|
|
62
98
|
/** @type {PostgresPreparationPlugin} */
|
|
63
99
|
#preparation
|
|
@@ -65,12 +101,6 @@ class PostgresPlugin extends DatabasePlugin {
|
|
|
65
101
|
/** @type {{ name: string, source: string | undefined }} */
|
|
66
102
|
#service
|
|
67
103
|
|
|
68
|
-
/** @type {WeakMap<PostgresQuery, import('../../..').Span>} */
|
|
69
|
-
#spans = new WeakMap()
|
|
70
|
-
|
|
71
|
-
/** @type {WeakMap<PostgresQuery, PostgresContext>} */
|
|
72
|
-
#waitContexts = new WeakMap()
|
|
73
|
-
|
|
74
104
|
/**
|
|
75
105
|
* @param {object} tracer
|
|
76
106
|
* @param {import('../../dd-trace/src/config/config-base')} tracerConfig
|
|
@@ -78,7 +108,22 @@ class PostgresPlugin extends DatabasePlugin {
|
|
|
78
108
|
constructor (tracer, tracerConfig) {
|
|
79
109
|
super(tracer, tracerConfig)
|
|
80
110
|
this.addSub(ACQUIRE_START_CHANNEL, ctx => this.#finishPoolWait(ctx.query))
|
|
111
|
+
this.addBind('tracing:postgres:query:start', ctx => this.#nativeStart(ctx))
|
|
112
|
+
this.addSub('tracing:postgres:query:error', ctx => {
|
|
113
|
+
if (ctx.currentStore) this.addError(ctx.error, ctx.currentStore.span)
|
|
114
|
+
})
|
|
115
|
+
this.addSub('tracing:postgres:query:asyncEnd', ctx => {
|
|
116
|
+
if (!(ctx.result instanceof Readable || ctx.result instanceof Writable)) this.#finishNative(ctx)
|
|
117
|
+
})
|
|
81
118
|
this.#preparation = new PostgresPreparationPlugin(this.#prepare.bind(this), tracer, tracerConfig)
|
|
119
|
+
const copy = new PostgresCopyPlugin(ctx => {
|
|
120
|
+
const store = ctx.query.currentStore
|
|
121
|
+
if (store === undefined) return
|
|
122
|
+
if (ctx.error) this.addError(ctx.error, store.span)
|
|
123
|
+
this.#finishNative(ctx.query)
|
|
124
|
+
}, tracer, tracerConfig)
|
|
125
|
+
// Complete in-flight COPY spans even after this plugin is disabled.
|
|
126
|
+
copy.configure(true)
|
|
82
127
|
}
|
|
83
128
|
|
|
84
129
|
/**
|
|
@@ -99,7 +144,15 @@ class PostgresPlugin extends DatabasePlugin {
|
|
|
99
144
|
* @returns {object}
|
|
100
145
|
*/
|
|
101
146
|
bindStart (ctx) {
|
|
102
|
-
|
|
147
|
+
this.#contexts.set(ctx.query, ctx)
|
|
148
|
+
return this.#start(ctx)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @param {PostgresContext | NativePostgresContext} ctx
|
|
153
|
+
*/
|
|
154
|
+
#start (ctx) {
|
|
155
|
+
const { database, host, port, user } = ctx
|
|
103
156
|
const service = this.#service
|
|
104
157
|
|
|
105
158
|
const span = this.startSpan(this.operationName(), {
|
|
@@ -113,29 +166,53 @@ class PostgresPlugin extends DatabasePlugin {
|
|
|
113
166
|
},
|
|
114
167
|
}, ctx)
|
|
115
168
|
|
|
116
|
-
if (host
|
|
169
|
+
if (host != null) {
|
|
117
170
|
span.addTags({
|
|
118
171
|
'out.host': host,
|
|
119
172
|
[CLIENT_PORT_KEY]: port,
|
|
120
173
|
})
|
|
121
174
|
}
|
|
122
175
|
|
|
123
|
-
this.#
|
|
124
|
-
this.#waitContexts.set(query, ctx)
|
|
125
|
-
if (this.#dbmEnabled) {
|
|
126
|
-
this.#dbmQueries.set(query, { service: service.name })
|
|
127
|
-
}
|
|
176
|
+
if (this.#dbmEnabled) ctx.currentStore.dbmService = service.name
|
|
128
177
|
return ctx.currentStore
|
|
129
178
|
}
|
|
130
179
|
|
|
180
|
+
/**
|
|
181
|
+
* @param {NativePostgresContext} ctx
|
|
182
|
+
*/
|
|
183
|
+
#nativeStart (ctx) {
|
|
184
|
+
const store = this.#start(ctx)
|
|
185
|
+
if (typeof ctx.query === 'string') {
|
|
186
|
+
store.span.setTag('resource.name', this.maybeTruncate(ctx.query))
|
|
187
|
+
}
|
|
188
|
+
return store
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @param {NativePostgresContext} ctx
|
|
193
|
+
*/
|
|
194
|
+
#finishNative (ctx) {
|
|
195
|
+
const store = ctx.currentStore
|
|
196
|
+
if (store === undefined) return
|
|
197
|
+
const { span } = store
|
|
198
|
+
|
|
199
|
+
if (ctx.host !== null) {
|
|
200
|
+
span.addTags({ 'out.host': ctx.host, [CLIENT_PORT_KEY]: ctx.port })
|
|
201
|
+
}
|
|
202
|
+
span.setTag('db.pool.wait_time_ms', ctx.sent === null ? 0 : ctx.sent - ctx.queued)
|
|
203
|
+
if (store.statement === undefined && typeof ctx.query === 'string') {
|
|
204
|
+
span.setTag('resource.name', this.maybeTruncate(ctx.query))
|
|
205
|
+
}
|
|
206
|
+
this.finish(ctx)
|
|
207
|
+
}
|
|
208
|
+
|
|
131
209
|
/**
|
|
132
210
|
* @param {PostgresQuery} query
|
|
133
211
|
*/
|
|
134
212
|
#finishPoolWait (query) {
|
|
135
|
-
const ctx = this.#
|
|
136
|
-
if (ctx === undefined) return
|
|
213
|
+
const ctx = this.#contexts.get(query)
|
|
214
|
+
if (ctx === undefined || ctx.poolWaitFinished) return
|
|
137
215
|
|
|
138
|
-
this.#waitContexts.delete(query)
|
|
139
216
|
ctx.poolWaitFinished = true
|
|
140
217
|
const waitTime = ctx.poolWaitStartMs === undefined ? 0 : performance.now() - ctx.poolWaitStartMs
|
|
141
218
|
ctx.currentStore.span.setTag('db.pool.wait_time_ms', waitTime)
|
|
@@ -145,20 +222,23 @@ class PostgresPlugin extends DatabasePlugin {
|
|
|
145
222
|
* @param {PostgresPreparationContext} ctx
|
|
146
223
|
*/
|
|
147
224
|
#prepare (ctx) {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
225
|
+
const store = ctx.query.currentStore ?? this.#contexts.get(ctx.query)?.currentStore
|
|
226
|
+
if (store?.dbmService === undefined) return
|
|
227
|
+
const { span } = store
|
|
151
228
|
|
|
152
|
-
|
|
153
|
-
span.setTag('resource.name', this.maybeTruncate(
|
|
154
|
-
|
|
229
|
+
store.statement = ctx.resource ?? ctx.statement
|
|
230
|
+
span.setTag('resource.name', this.maybeTruncate(store.statement))
|
|
231
|
+
if (ctx.host !== undefined) {
|
|
232
|
+
span.addTags({ 'out.host': ctx.host, [CLIENT_PORT_KEY]: ctx.port })
|
|
233
|
+
}
|
|
234
|
+
ctx.statement = this.injectDbmQuery(span, ctx.statement, store.dbmService, ctx.prepared)
|
|
155
235
|
}
|
|
156
236
|
|
|
157
237
|
/**
|
|
158
|
-
* @param {PostgresContext} ctx
|
|
238
|
+
* @param {Pick<PostgresContext, 'query' | 'error'>} ctx
|
|
159
239
|
*/
|
|
160
240
|
error (ctx) {
|
|
161
|
-
const span = this.#
|
|
241
|
+
const span = this.#contexts.get(ctx.query)?.currentStore.span
|
|
162
242
|
if (span !== undefined) {
|
|
163
243
|
this.addError(ctx.error, span)
|
|
164
244
|
}
|
|
@@ -168,23 +248,20 @@ class PostgresPlugin extends DatabasePlugin {
|
|
|
168
248
|
* @param {PostgresContext} result
|
|
169
249
|
*/
|
|
170
250
|
asyncEnd (result) {
|
|
171
|
-
const { query } = result
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
this.#dbmQueries.delete(query)
|
|
176
|
-
if (span === undefined) return
|
|
251
|
+
const { query, statement, pid } = result
|
|
252
|
+
const ctx = this.#contexts.get(query)
|
|
253
|
+
if (ctx === undefined) return
|
|
254
|
+
const { currentStore: { span, statement: originalStatement } } = ctx
|
|
177
255
|
|
|
178
256
|
this.#finishPoolWait(query)
|
|
179
|
-
this.#
|
|
257
|
+
this.#contexts.delete(query)
|
|
180
258
|
|
|
181
|
-
|
|
182
|
-
if (dbmState?.statement === undefined && typeof statement === 'string') {
|
|
259
|
+
if (originalStatement === undefined && typeof statement === 'string') {
|
|
183
260
|
span.setTag('resource.name', this.maybeTruncate(statement))
|
|
184
261
|
}
|
|
185
262
|
|
|
186
|
-
span.setTag('db.pid',
|
|
187
|
-
this.finish(
|
|
263
|
+
span.setTag('db.pid', pid)
|
|
264
|
+
this.finish(ctx)
|
|
188
265
|
}
|
|
189
266
|
}
|
|
190
267
|
|
|
@@ -56,7 +56,7 @@ class DatadogTracingHelper {
|
|
|
56
56
|
* @param {object[]} spans
|
|
57
57
|
*/
|
|
58
58
|
dispatchEngineSpans (spans) {
|
|
59
|
-
if (!spans?.length) {
|
|
59
|
+
if (!spans?.length || this.#prismaClient.config?.engine === false) {
|
|
60
60
|
return
|
|
61
61
|
}
|
|
62
62
|
const childrenByParent = new Map()
|
|
@@ -90,8 +90,10 @@ class DatadogTracingHelper {
|
|
|
90
90
|
* @returns {unknown}
|
|
91
91
|
*/
|
|
92
92
|
runInChildSpan (options, callback) {
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
// Skipping here rather than in the plugin's `bindStart` avoids finishing the parent span, which
|
|
94
|
+
// `finish()` would fall back to when no client span was started.
|
|
95
|
+
if (!clientCH.start?.hasSubscribers || this.#prismaClient.config?.client === false) {
|
|
96
|
+
return callback()
|
|
95
97
|
}
|
|
96
98
|
if (typeof options === 'string') {
|
|
97
99
|
options = {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
|
+
const {
|
|
5
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
6
|
+
otelHttpResourceName,
|
|
7
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
4
8
|
const { extractPathFromUrl } = require('../../dd-trace/src/plugins/util/url')
|
|
5
9
|
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
6
10
|
const normalizeError = require('./error')
|
|
@@ -23,18 +27,24 @@ class SupabaseGoTrueClientGetUserPlugin extends ClientPlugin {
|
|
|
23
27
|
bindStart (ctx) {
|
|
24
28
|
const method = 'GET'
|
|
25
29
|
const url = stripQueryAndFragment(`${ctx.self?.url}/user`)
|
|
30
|
+
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
31
|
+
const resource = otelSemantics ? otelHttpResourceName(method) : `${method} ${extractPathFromUrl(url)}`
|
|
32
|
+
const meta = {
|
|
33
|
+
component: 'supabase',
|
|
34
|
+
'span.kind': 'client',
|
|
35
|
+
'http.method': method,
|
|
36
|
+
'http.url': url,
|
|
37
|
+
'out.host': getHostname(url),
|
|
38
|
+
}
|
|
39
|
+
if (otelSemantics) {
|
|
40
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
41
|
+
}
|
|
26
42
|
|
|
27
43
|
this.startSpan('supabase.http.getuser', {
|
|
28
44
|
service: { name: this.tracer._service },
|
|
29
45
|
type: 'http',
|
|
30
|
-
resource
|
|
31
|
-
meta
|
|
32
|
-
component: 'supabase',
|
|
33
|
-
'span.kind': 'client',
|
|
34
|
-
'http.method': method,
|
|
35
|
-
'http.url': url,
|
|
36
|
-
'out.host': getHostname(url),
|
|
37
|
-
},
|
|
46
|
+
resource,
|
|
47
|
+
meta,
|
|
38
48
|
}, ctx)
|
|
39
49
|
|
|
40
50
|
return ctx.currentStore
|
package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { URL } = require('node:url')
|
|
4
|
+
|
|
3
5
|
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
INSTRUMENTATION_HTTP_RESOURCE,
|
|
8
|
+
otelHttpResourceName,
|
|
9
|
+
} = require('../../dd-trace/src/plugins/util/http-otel-semantics')
|
|
10
|
+
const { buildClientHttpUrl, extractPathFromUrl, getQsObfuscator } = require('../../dd-trace/src/plugins/util/url')
|
|
5
11
|
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
12
|
+
const log = require('../../dd-trace/src/log')
|
|
6
13
|
const normalizeError = require('./error')
|
|
7
14
|
const getHostname = require('./url')
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
17
|
* @typedef {{
|
|
11
|
-
* arguments: { [index: number]: unknown, length: number, 0?: string, 1?: { method?: string } },
|
|
12
|
-
* self: { url: string },
|
|
18
|
+
* arguments: { [index: number]: unknown, length: number, 0?: string, 1?: { method?: string, region?: string } },
|
|
19
|
+
* self: { url: string, region?: string },
|
|
13
20
|
* currentStore?: { span: import('../../..').Span },
|
|
14
21
|
* result?: { error?: Error | { message?: string } | null, response?: { status?: number } },
|
|
15
22
|
* error?: unknown
|
|
@@ -20,24 +27,53 @@ class SupabaseFunctionsClientInvokePlugin extends ClientPlugin {
|
|
|
20
27
|
static id = 'supabase'
|
|
21
28
|
static prefix = 'tracing:orchestrion:@supabase/functions-js:FunctionsClient_invoke'
|
|
22
29
|
|
|
30
|
+
configure (config) {
|
|
31
|
+
if (typeof config === 'boolean') return super.configure(config)
|
|
32
|
+
return super.configure({
|
|
33
|
+
...config,
|
|
34
|
+
queryStringObfuscation: config.DD_TRACE_OTEL_SEMANTICS_ENABLED && getQsObfuscator(config),
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
23
38
|
/** @param {FunctionsContext} ctx */
|
|
24
39
|
bindStart (ctx) {
|
|
25
40
|
const functionName = ctx.arguments?.[0]
|
|
26
41
|
const method = String(ctx.arguments?.[1]?.method || 'POST').toUpperCase()
|
|
27
|
-
const
|
|
42
|
+
const rawUrl = `${ctx.self?.url}/${functionName}`
|
|
43
|
+
const url = stripQueryAndFragment(rawUrl)
|
|
44
|
+
const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
|
|
45
|
+
const resource = otelSemantics ? otelHttpResourceName(method) : `${method} ${extractPathFromUrl(url)}`
|
|
46
|
+
let httpUrl = url
|
|
47
|
+
if (otelSemantics) {
|
|
48
|
+
try {
|
|
49
|
+
const requestUrl = new URL(rawUrl)
|
|
50
|
+
const region = ctx.arguments?.[1]?.region || ctx.self?.region
|
|
51
|
+
if (region && region !== 'any') {
|
|
52
|
+
requestUrl.searchParams.set('forceFunctionRegion', region)
|
|
53
|
+
}
|
|
54
|
+
requestUrl.hash = ''
|
|
55
|
+
httpUrl = buildClientHttpUrl(this.config, '', requestUrl.href, url)
|
|
56
|
+
} catch (error) {
|
|
57
|
+
log.debug('Could not build Supabase function request URL: %s', error.message)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const meta = {
|
|
61
|
+
component: 'supabase',
|
|
62
|
+
'span.kind': 'client',
|
|
63
|
+
'http.method': method,
|
|
64
|
+
'http.url': httpUrl,
|
|
65
|
+
'out.host': getHostname(url),
|
|
66
|
+
'faas.invoked_name': functionName,
|
|
67
|
+
}
|
|
68
|
+
if (otelSemantics) {
|
|
69
|
+
meta[INSTRUMENTATION_HTTP_RESOURCE] = resource
|
|
70
|
+
}
|
|
28
71
|
|
|
29
72
|
this.startSpan('supabase.http.invoke', {
|
|
30
73
|
service: { name: this.tracer._service },
|
|
31
74
|
type: 'http',
|
|
32
|
-
resource
|
|
33
|
-
meta
|
|
34
|
-
component: 'supabase',
|
|
35
|
-
'span.kind': 'client',
|
|
36
|
-
'http.method': method,
|
|
37
|
-
'http.url': url,
|
|
38
|
-
'out.host': getHostname(url),
|
|
39
|
-
'faas.invoked_name': functionName,
|
|
40
|
-
},
|
|
75
|
+
resource,
|
|
76
|
+
meta,
|
|
41
77
|
}, ctx)
|
|
42
78
|
|
|
43
79
|
return ctx.currentStore
|