dd-trace 6.16.0 → 6.18.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/ci/diagnose.js +0 -23
- package/ci/test-optimization-validation/approval-artifacts.js +0 -3
- package/ci/test-optimization-validation/approval.js +0 -6
- package/ci/test-optimization-validation/artifact-id.js +0 -1
- package/ci/test-optimization-validation/bounded-json.js +0 -1
- package/ci/test-optimization-validation/cli.js +0 -12
- package/ci/test-optimization-validation/command-output-policy.js +0 -1
- package/ci/test-optimization-validation/command-runner.js +0 -3
- package/ci/test-optimization-validation/environment.js +0 -4
- package/ci/test-optimization-validation/executable-approval.js +0 -1
- package/ci/test-optimization-validation/executable.js +0 -5
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -6
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -3
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -6
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -4
- package/ci/test-optimization-validation/generated-test-contract.js +0 -5
- package/ci/test-optimization-validation/generated-verifier.js +0 -1
- package/ci/test-optimization-validation/literal-environment.js +0 -1
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -17
- package/ci/test-optimization-validation/manifest-schema.js +0 -21
- package/ci/test-optimization-validation/offline-fixtures.js +0 -4
- package/ci/test-optimization-validation/plan-writer.js +0 -11
- package/ci/test-optimization-validation/preflight-runner.js +0 -1
- package/ci/test-optimization-validation/redaction.js +0 -4
- package/ci/test-optimization-validation/report-writer.js +0 -16
- package/ci/test-optimization-validation/runner-command.js +0 -3
- package/ci/test-optimization-validation/runner-contract.js +0 -4
- package/ci/test-optimization-validation/safe-files.js +0 -1
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -1
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -1
- package/ci/test-optimization-validation/source-text.js +0 -3
- package/ci/vitest-no-worker-init-setup.mjs +41 -16
- package/index.d.ts +208 -0
- package/package.json +17 -16
- package/packages/datadog-esbuild/src/utils.js +0 -2
- package/packages/datadog-instrumentations/src/aerospike.js +28 -6
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +0 -2
- package/packages/datadog-instrumentations/src/aws-sdk.js +0 -2
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +0 -2
- package/packages/datadog-instrumentations/src/console.js +97 -0
- package/packages/datadog-instrumentations/src/cucumber.js +77 -12
- package/packages/datadog-instrumentations/src/cypress-config.js +27 -38
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +6 -0
- package/packages/datadog-instrumentations/src/helpers/channel.js +0 -2
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +0 -5
- package/packages/datadog-instrumentations/src/helpers/hooks.js +8 -6
- package/packages/datadog-instrumentations/src/helpers/instrumentation-utils.js +0 -3
- package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +0 -6
- package/packages/datadog-instrumentations/src/helpers/register.js +24 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +111 -26
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +3 -17
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +55 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +36 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/supabase.js +128 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +13 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +28 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +20 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +388 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +0 -5
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +0 -1
- package/packages/datadog-instrumentations/src/jest.js +165 -51
- package/packages/datadog-instrumentations/src/knex.js +0 -1
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +0 -24
- package/packages/datadog-instrumentations/src/mariadb.js +0 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +0 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +25 -26
- package/packages/datadog-instrumentations/src/mocha/utils.js +119 -49
- package/packages/datadog-instrumentations/src/mocha/webdriverio-protocol.js +0 -6
- package/packages/datadog-instrumentations/src/mocha/worker.js +14 -17
- package/packages/datadog-instrumentations/src/mysql2.js +0 -2
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +241 -0
- package/packages/datadog-instrumentations/src/openai-realtime/events.js +76 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +301 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +998 -0
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +211 -0
- package/packages/datadog-instrumentations/src/openai.js +51 -12
- package/packages/datadog-instrumentations/src/oracledb.js +9 -3
- package/packages/datadog-instrumentations/src/playwright-reporter.js +6 -20
- package/packages/datadog-instrumentations/src/playwright.js +280 -56
- package/packages/datadog-instrumentations/src/{azure-cosmos.js → postgres.js} +1 -1
- package/packages/datadog-instrumentations/src/router.js +0 -2
- package/packages/datadog-instrumentations/src/rum-browser-scripts.js +0 -2
- package/packages/datadog-instrumentations/src/sequelize.js +0 -1
- package/packages/datadog-instrumentations/src/supabase.js +15 -0
- package/packages/datadog-instrumentations/src/undici.js +7 -3
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +18 -18
- package/packages/datadog-instrumentations/src/vitest-main.js +121 -30
- package/packages/datadog-instrumentations/src/vitest-util.js +7 -1
- package/packages/datadog-instrumentations/src/vitest-worker.js +49 -13
- package/packages/datadog-instrumentations/src/webdriverio.js +44 -47
- package/packages/datadog-instrumentations/src/ws.js +41 -2
- package/packages/datadog-plugin-ai/src/utils.js +0 -2
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +0 -1
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +0 -2
- package/packages/datadog-plugin-aws-sdk/src/base.js +0 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +0 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +0 -1
- package/packages/datadog-plugin-aws-sdk/src/util.js +0 -1
- package/packages/datadog-plugin-azure-durable-functions/src/index.js +0 -1
- package/packages/datadog-plugin-cucumber/src/index.js +9 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +211 -85
- package/packages/datadog-plugin-cypress/src/finalization.js +0 -3
- package/packages/datadog-plugin-cypress/src/index.js +3 -1
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +0 -4
- package/packages/datadog-plugin-cypress/src/support.js +52 -7
- package/packages/datadog-plugin-graphql/src/resolve-error.js +1 -2
- package/packages/datadog-plugin-graphql/src/utils.js +0 -5
- package/packages/datadog-plugin-jest/src/index.js +12 -0
- package/packages/datadog-plugin-kafkajs/src/producer.js +0 -1
- package/packages/datadog-plugin-mocha/src/index.js +38 -11
- package/packages/datadog-plugin-mongodb-core/src/query.js +0 -1
- package/packages/datadog-plugin-openai/src/index.js +16 -1
- package/packages/datadog-plugin-openai/src/realtime.js +144 -0
- package/packages/datadog-plugin-openai-agents/src/integration.js +0 -4
- package/packages/datadog-plugin-openai-agents/src/util.js +0 -1
- package/packages/datadog-plugin-playwright/src/index.js +81 -9
- package/packages/datadog-plugin-postgres/src/index.js +167 -0
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +0 -1
- package/packages/datadog-plugin-redis/src/index.js +15 -1
- package/packages/datadog-plugin-supabase/src/error.js +18 -0
- package/packages/datadog-plugin-supabase/src/index.js +21 -0
- package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +69 -0
- package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +70 -0
- package/packages/datadog-plugin-supabase/src/supabase-postgrest-js-postgrestbuilder-then.js +122 -0
- package/packages/datadog-plugin-supabase/src/supabase-realtime-js-realtimechannel-send.js +66 -0
- package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +93 -0
- package/packages/datadog-plugin-supabase/src/url.js +17 -0
- package/packages/datadog-plugin-vitest/src/index.js +9 -0
- package/packages/datadog-plugin-ws/src/producer.js +1 -1
- package/packages/datadog-plugin-ws/src/util.js +0 -4
- package/packages/datadog-shimmer/src/shimmer.js +14 -10
- package/packages/datadog-turbopack/index.js +4 -7
- package/packages/datadog-turbopack/src/loader.js +6 -18
- package/packages/datadog-webpack/src/loader.js +0 -1
- package/packages/dd-trace/src/agent/info.js +5 -4
- package/packages/dd-trace/src/aiguard/client.js +2 -3
- package/packages/dd-trace/src/aiguard/evaluation.js +6 -12
- package/packages/dd-trace/src/aiguard/index.js +2 -2
- package/packages/dd-trace/src/aiguard/integrations/index.js +1 -1
- package/packages/dd-trace/src/aiguard/integrations/openai.js +81 -7
- package/packages/dd-trace/src/aiguard/messages/anthropic.js +0 -2
- package/packages/dd-trace/src/aiguard/messages/openai.js +64 -1
- package/packages/dd-trace/src/aiguard/messages/utils.js +0 -1
- package/packages/dd-trace/src/aiguard/redaction.js +0 -1
- package/packages/dd-trace/src/aiguard/sdk.js +1 -1
- package/packages/dd-trace/src/appsec/activation.js +1 -1
- package/packages/dd-trace/src/appsec/api_security/normalized-route.js +0 -5
- package/packages/dd-trace/src/appsec/api_security/sampler.js +0 -4
- package/packages/dd-trace/src/appsec/blocking/index.js +3 -3
- package/packages/dd-trace/src/appsec/downstream_requests.js +1 -4
- package/packages/dd-trace/src/appsec/iast/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +5 -5
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +3 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +8 -10
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +2 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +4 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +7 -7
- package/packages/dd-trace/src/appsec/index.js +2 -2
- package/packages/dd-trace/src/appsec/lambda.js +71 -2
- package/packages/dd-trace/src/appsec/rasp/utils.js +5 -1
- package/packages/dd-trace/src/appsec/remote_config.js +8 -6
- package/packages/dd-trace/src/appsec/reporter.js +10 -6
- package/packages/dd-trace/src/appsec/rule_manager.js +3 -3
- package/packages/dd-trace/src/appsec/sdk/track_event.js +0 -2
- package/packages/dd-trace/src/appsec/waf/index.js +2 -2
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +8 -5
- package/packages/dd-trace/src/carrier.js +0 -5
- package/packages/dd-trace/src/ci-visibility/dynamic-atr-retries.js +104 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +0 -2
- package/packages/dd-trace/src/ci-visibility/efd-retry-policy.js +34 -3
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -4
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +37 -15
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +0 -3
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +0 -11
- package/packages/dd-trace/src/ci-visibility/exporters/settings-cache-key.js +0 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +0 -1
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +0 -6
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -2
- package/packages/dd-trace/src/ci-visibility/requests/rate-limit.js +0 -1
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +0 -5
- package/packages/dd-trace/src/ci-visibility/requests/video-request.js +0 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +13 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +0 -1
- package/packages/dd-trace/src/ci-visibility/test-screenshot.js +0 -2
- package/packages/dd-trace/src/ci-visibility/test-video.js +0 -1
- package/packages/dd-trace/src/config/defaults.js +3 -2
- package/packages/dd-trace/src/config/generated-config-types.d.ts +88 -82
- package/packages/dd-trace/src/config/helper.js +0 -1
- package/packages/dd-trace/src/config/index.js +31 -30
- package/packages/dd-trace/src/config/parsers.js +34 -6
- package/packages/dd-trace/src/config/remote_config.js +25 -109
- package/packages/dd-trace/src/config/supported-configurations.json +150 -10
- package/packages/dd-trace/src/datastreams/encoding.js +0 -1
- package/packages/dd-trace/src/datastreams/pathway.js +0 -1
- package/packages/dd-trace/src/debugger/constants.js +10 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +62 -10
- package/packages/dd-trace/src/debugger/devtools_client/config.js +4 -1
- package/packages/dd-trace/src/debugger/devtools_client/guardrail-metrics.js +15 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +103 -27
- package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +50 -7
- package/packages/dd-trace/src/debugger/devtools_client/log.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +21 -8
- package/packages/dd-trace/src/debugger/devtools_client/send.js +41 -15
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +53 -13
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +118 -71
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +5 -3
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +0 -3
- package/packages/dd-trace/src/debugger/devtools_client/status.js +21 -7
- package/packages/dd-trace/src/debugger/guardrail-metrics.js +167 -0
- package/packages/dd-trace/src/debugger/index.js +51 -3
- package/packages/dd-trace/src/debugger/inspect-segment.js +0 -3
- package/packages/dd-trace/src/debugger/probe_sampler.js +133 -9
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +31 -1
- package/packages/dd-trace/src/dogstatsd.js +0 -23
- package/packages/dd-trace/src/encode/0.4-cross-payload.js +0 -3
- package/packages/dd-trace/src/encode/0.4.js +0 -7
- package/packages/dd-trace/src/encode/0.5.js +0 -2
- package/packages/dd-trace/src/encode/tags-processors.js +0 -1
- package/packages/dd-trace/src/evp_proxy/constants.js +2 -0
- package/packages/dd-trace/src/evp_proxy/direct.js +17 -13
- package/packages/dd-trace/src/evp_proxy/discovery.js +14 -11
- package/packages/dd-trace/src/evp_proxy/path.js +21 -9
- package/packages/dd-trace/src/exporters/agent/writer.js +0 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +0 -1
- package/packages/dd-trace/src/exporters/agentless/intake.js +0 -1
- package/packages/dd-trace/src/exporters/agentless/writer.js +0 -3
- package/packages/dd-trace/src/exporters/common/final-flush-request-tracker.js +0 -6
- package/packages/dd-trace/src/exporters/common/request.js +1 -0
- package/packages/dd-trace/src/exporters/common/url.js +33 -4
- package/packages/dd-trace/src/exporters/common/writer.js +0 -2
- package/packages/dd-trace/src/id.js +0 -11
- package/packages/dd-trace/src/llmobs/audio-codec.js +192 -0
- package/packages/dd-trace/src/llmobs/audio-utils.js +121 -0
- package/packages/dd-trace/src/llmobs/constants/audio.js +35 -0
- package/packages/dd-trace/src/llmobs/constants/prompts.js +14 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +17 -0
- package/packages/dd-trace/src/llmobs/eval-metric.js +0 -6
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +0 -4
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +0 -3
- package/packages/dd-trace/src/llmobs/experiments/index.js +7 -6
- package/packages/dd-trace/src/llmobs/experiments/util.js +1 -11
- package/packages/dd-trace/src/llmobs/index.js +1 -3
- package/packages/dd-trace/src/llmobs/noop.js +10 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +0 -4
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +0 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +0 -4
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +0 -2
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +0 -2
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +4 -6
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +285 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +16 -3
- package/packages/dd-trace/src/llmobs/prompts/cache.js +272 -0
- package/packages/dd-trace/src/llmobs/prompts/manager.js +647 -0
- package/packages/dd-trace/src/llmobs/prompts/noop.js +29 -0
- package/packages/dd-trace/src/llmobs/prompts/prompt.js +158 -0
- package/packages/dd-trace/src/llmobs/sdk.js +21 -6
- package/packages/dd-trace/src/llmobs/span_processor.js +81 -2
- package/packages/dd-trace/src/llmobs/tagger.js +39 -11
- package/packages/dd-trace/src/llmobs/telemetry.js +36 -4
- package/packages/dd-trace/src/llmobs/util.js +0 -34
- package/packages/dd-trace/src/llmobs/writers/base.js +0 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
- package/packages/dd-trace/src/log/channels.js +3 -0
- package/packages/dd-trace/src/log/index.js +23 -5
- package/packages/dd-trace/src/log-submission/log-submission-plugin.js +74 -6
- package/packages/dd-trace/src/msgpack/chunk.js +0 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +0 -12
- package/packages/dd-trace/src/openfeature/configuration_source.js +4 -1
- package/packages/dd-trace/src/openfeature/encoding.js +0 -2
- package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +0 -1
- package/packages/dd-trace/src/openfeature/flagging_provider.js +3 -3
- package/packages/dd-trace/src/openfeature/index.js +6 -6
- package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +0 -1
- package/packages/dd-trace/src/openfeature/span-enrichment.js +0 -4
- package/packages/dd-trace/src/openfeature/writers/base.js +90 -23
- package/packages/dd-trace/src/openfeature/writers/exposures.js +4 -5
- package/packages/dd-trace/src/openfeature/writers/util.js +104 -37
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +0 -1
- package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +0 -1
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +0 -1
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +0 -2
- package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +0 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +0 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +0 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +1 -14
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +0 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +30 -13
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +0 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +0 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +0 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +0 -3
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +0 -6
- package/packages/dd-trace/src/opentracing/span_context.js +0 -1
- package/packages/dd-trace/src/opentracing/tracer.js +3 -3
- package/packages/dd-trace/src/otel-thread-ctx.js +38 -11
- package/packages/dd-trace/src/payload-tagging/tagging.js +15 -3
- package/packages/dd-trace/src/plugin_manager.js +27 -8
- package/packages/dd-trace/src/plugins/ci_plugin.js +1 -2
- package/packages/dd-trace/src/plugins/database.js +2 -6
- package/packages/dd-trace/src/plugins/index.js +7 -0
- package/packages/dd-trace/src/plugins/plugin.js +0 -4
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/git.js +1 -3
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +0 -1
- package/packages/dd-trace/src/plugins/util/llm.js +0 -2
- package/packages/dd-trace/src/plugins/util/status-validator.js +0 -1
- package/packages/dd-trace/src/plugins/util/test.js +26 -20
- package/packages/dd-trace/src/plugins/util/url.js +0 -5
- package/packages/dd-trace/src/priority_sampler.js +0 -6
- package/packages/dd-trace/src/process-tags/index.js +0 -1
- package/packages/dd-trace/src/profiler.js +132 -35
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +0 -1
- package/packages/dd-trace/src/profiling/profiler.js +101 -41
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +29 -15
- package/packages/dd-trace/src/propagation-hash/index.js +0 -1
- package/packages/dd-trace/src/proxy.js +23 -47
- package/packages/dd-trace/src/random_sampler.js +0 -4
- package/packages/dd-trace/src/rate_limiter.js +0 -4
- package/packages/dd-trace/src/remote_config/capabilities.js +1 -9
- package/packages/dd-trace/src/remote_config/index.js +0 -1
- package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +0 -3
- package/packages/dd-trace/src/sampler.js +0 -4
- package/packages/dd-trace/src/sampling_rule.js +0 -7
- package/packages/dd-trace/src/serverless/vercel.js +0 -1
- package/packages/dd-trace/src/serverless.js +0 -1
- package/packages/dd-trace/src/service-naming/index.js +0 -1
- package/packages/dd-trace/src/service-naming/schemas/util.js +0 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +7 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +5 -0
- package/packages/dd-trace/src/span_processor.js +2 -2
- package/packages/dd-trace/src/span_sampler.js +0 -1
- package/packages/dd-trace/src/standalone/product.js +2 -2
- package/packages/dd-trace/src/standalone/tracesource.js +0 -1
- package/packages/dd-trace/src/startup-log.js +1 -1
- package/packages/dd-trace/src/telemetry/endpoints.js +0 -8
- package/packages/dd-trace/src/telemetry/logs/index.js +16 -5
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +16 -6
- package/packages/dd-trace/src/telemetry/metrics.js +0 -2
- package/packages/dd-trace/src/telemetry/send-data.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +4 -1
- package/packages/dd-trace/src/tracer.js +5 -4
- package/packages/dd-trace/src/util.js +13 -1
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/packages/datadog-instrumentations/src/bullmq.js +0 -11
- package/packages/datadog-instrumentations/src/langchain.js +0 -7
- package/packages/datadog-instrumentations/src/langgraph.js +0 -7
- package/packages/datadog-instrumentations/src/mercurius.js +0 -11
|
@@ -56,6 +56,7 @@ const {
|
|
|
56
56
|
TEST_HAS_DYNAMIC_NAME,
|
|
57
57
|
DYNAMIC_NAME_RE,
|
|
58
58
|
TEST_FINAL_STATUS,
|
|
59
|
+
setExpectedEmptyTestSessionTags,
|
|
59
60
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
60
61
|
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
61
62
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
@@ -69,13 +70,14 @@ const log = require('../../dd-trace/src/log')
|
|
|
69
70
|
|
|
70
71
|
const PLAYWRIGHT_FAILURE_SCREENSHOT_RE = /^test-failed-\d+\.png$/
|
|
71
72
|
const PLAYWRIGHT_VIDEO_CONTENT_TYPES = new Set(['video/mp4', 'video/webm'])
|
|
73
|
+
const RETRY_TEST_ID = '_dd.playwright.retry_test_id'
|
|
74
|
+
const DEFER_FINAL_STATUS = '_dd.playwright.defer_final_status'
|
|
72
75
|
const noop = () => {}
|
|
73
76
|
|
|
74
77
|
/**
|
|
75
78
|
* Returns whether an attachment is an automatic Playwright failure screenshot.
|
|
76
79
|
*
|
|
77
80
|
* @param {object} attachment - Playwright test attachment
|
|
78
|
-
* @returns {boolean}
|
|
79
81
|
*/
|
|
80
82
|
function isPlaywrightFailureScreenshot (attachment) {
|
|
81
83
|
return attachment?.name === 'screenshot' &&
|
|
@@ -88,7 +90,6 @@ function isPlaywrightFailureScreenshot (attachment) {
|
|
|
88
90
|
* Returns whether an attachment is a Playwright test video.
|
|
89
91
|
*
|
|
90
92
|
* @param {object} attachment - Playwright test attachment
|
|
91
|
-
* @returns {boolean}
|
|
92
93
|
*/
|
|
93
94
|
function isPlaywrightFailureVideo (attachment) {
|
|
94
95
|
return attachment?.name === 'video' &&
|
|
@@ -102,6 +103,7 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
102
103
|
#isFinalizingAfterError = false
|
|
103
104
|
#finishPendingTestFinishes
|
|
104
105
|
#pendingTestFinishCallbacks = new Map()
|
|
106
|
+
#pendingRetryTestFinishes = new Map()
|
|
105
107
|
|
|
106
108
|
constructor (...args) {
|
|
107
109
|
super(...args)
|
|
@@ -182,9 +184,13 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
182
184
|
isEarlyFlakeDetectionEnabled,
|
|
183
185
|
isEarlyFlakeDetectionFaulty,
|
|
184
186
|
isTestManagementTestsEnabled,
|
|
187
|
+
testSessionEmptyReason,
|
|
185
188
|
error,
|
|
186
189
|
onDone,
|
|
187
190
|
}) => {
|
|
191
|
+
for (const finish of this.#pendingRetryTestFinishes.values()) finish(true)
|
|
192
|
+
this.#pendingRetryTestFinishes.clear()
|
|
193
|
+
|
|
188
194
|
if (error) {
|
|
189
195
|
this.#isFinalizingAfterError = true
|
|
190
196
|
for (const testSuiteSpan of this._testSuiteSpansByTestSuiteAbsolutePath.values()) {
|
|
@@ -204,6 +210,14 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
204
210
|
this.testModuleSpan.setTag(TEST_STATUS, status)
|
|
205
211
|
this.testSessionSpan.setTag(TEST_STATUS, status)
|
|
206
212
|
|
|
213
|
+
if (testSessionEmptyReason) {
|
|
214
|
+
setExpectedEmptyTestSessionTags(
|
|
215
|
+
this.testSessionSpan,
|
|
216
|
+
this.testModuleSpan,
|
|
217
|
+
testSessionEmptyReason
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
|
|
207
221
|
if (isEarlyFlakeDetectionEnabled) {
|
|
208
222
|
this.testSessionSpan.setTag(TEST_EARLY_FLAKE_ENABLED, 'true')
|
|
209
223
|
}
|
|
@@ -372,12 +386,37 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
372
386
|
formattedTraces.push(formattedTrace)
|
|
373
387
|
}
|
|
374
388
|
|
|
389
|
+
const retryTestId = formattedTestSpan?.meta[RETRY_TEST_ID]
|
|
390
|
+
const deferFinalStatus = formattedTestSpan?.meta[DEFER_FINAL_STATUS] === 'true'
|
|
391
|
+
if (retryTestId !== undefined) {
|
|
392
|
+
delete formattedTestSpan.meta[RETRY_TEST_ID]
|
|
393
|
+
delete formattedTestSpan.meta[DEFER_FINAL_STATUS]
|
|
394
|
+
}
|
|
395
|
+
let readyToExport = false
|
|
396
|
+
let isFinalExecution
|
|
375
397
|
const exportTraces = () => {
|
|
398
|
+
readyToExport = true
|
|
399
|
+
if (deferFinalStatus && isFinalExecution === undefined) return
|
|
376
400
|
for (const trace of formattedTraces) {
|
|
377
401
|
this.tracer._exporter.export(trace)
|
|
378
402
|
}
|
|
379
403
|
}
|
|
380
404
|
|
|
405
|
+
if (retryTestId !== undefined) {
|
|
406
|
+
// Keep at most one execution while another attempt is possible. Media uploads
|
|
407
|
+
// can finish before or after finality is known, so track readiness separately.
|
|
408
|
+
const finishPrevious = this.#pendingRetryTestFinishes.get(retryTestId)
|
|
409
|
+
finishPrevious?.(false)
|
|
410
|
+
this.#pendingRetryTestFinishes.delete(retryTestId)
|
|
411
|
+
if (deferFinalStatus) {
|
|
412
|
+
this.#pendingRetryTestFinishes.set(retryTestId, (isFinal) => {
|
|
413
|
+
isFinalExecution = isFinal
|
|
414
|
+
if (!isFinal) delete formattedTestSpan.meta[TEST_FINAL_STATUS]
|
|
415
|
+
if (readyToExport) exportTraces()
|
|
416
|
+
})
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
381
420
|
if (!formattedTestSpan || (!screenshots && !videos) || this.#isFinalizingAfterError) {
|
|
382
421
|
exportTraces()
|
|
383
422
|
return
|
|
@@ -484,6 +523,8 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
484
523
|
this.addSub('ci:playwright:test:finish', ({
|
|
485
524
|
span,
|
|
486
525
|
testStatus,
|
|
526
|
+
isExpectedFailure,
|
|
527
|
+
hasNonRetriableError,
|
|
487
528
|
steps,
|
|
488
529
|
error,
|
|
489
530
|
extraTags,
|
|
@@ -501,6 +542,8 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
501
542
|
isAtrRetry,
|
|
502
543
|
isModified,
|
|
503
544
|
finalStatus,
|
|
545
|
+
retryTestId,
|
|
546
|
+
deferFinalStatus,
|
|
504
547
|
earlyFlakeAbortReason,
|
|
505
548
|
onDone,
|
|
506
549
|
}) => {
|
|
@@ -510,6 +553,8 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
510
553
|
}
|
|
511
554
|
|
|
512
555
|
const isRUMActive = span.context().getTag(TEST_IS_RUM_ACTIVE)
|
|
556
|
+
const isDeferredMainTest = !this._tracerConfig.DD_PLAYWRIGHT_WORKER &&
|
|
557
|
+
retryTestId !== undefined && deferFinalStatus
|
|
513
558
|
|
|
514
559
|
span.setTag(TEST_STATUS, testStatus)
|
|
515
560
|
|
|
@@ -519,6 +564,12 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
519
564
|
if (extraTags) {
|
|
520
565
|
span.addTags(extraTags)
|
|
521
566
|
}
|
|
567
|
+
if (isExpectedFailure) {
|
|
568
|
+
span.setTag('test.result', 'xfail')
|
|
569
|
+
}
|
|
570
|
+
if (hasNonRetriableError === true) {
|
|
571
|
+
span.setTag('test.playwright.has_non_retriable_error', 'true')
|
|
572
|
+
}
|
|
522
573
|
if (isNew) {
|
|
523
574
|
span.setTag(TEST_IS_NEW, 'true')
|
|
524
575
|
if (isEfdRetry) {
|
|
@@ -565,9 +616,14 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
565
616
|
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.efd)
|
|
566
617
|
}
|
|
567
618
|
}
|
|
568
|
-
if (finalStatus) {
|
|
619
|
+
if (finalStatus && !isDeferredMainTest) {
|
|
569
620
|
span.setTag(TEST_FINAL_STATUS, finalStatus)
|
|
570
621
|
}
|
|
622
|
+
if (retryTestId !== undefined && this._tracerConfig.DD_PLAYWRIGHT_WORKER) {
|
|
623
|
+
// This identifier is removed by the main process before exporting the trace.
|
|
624
|
+
span.setTag(RETRY_TEST_ID, retryTestId)
|
|
625
|
+
if (deferFinalStatus) span.setTag(DEFER_FINAL_STATUS, 'true')
|
|
626
|
+
}
|
|
571
627
|
if (earlyFlakeAbortReason) {
|
|
572
628
|
span.setTag(TEST_EARLY_FLAKE_ABORT_REASON, earlyFlakeAbortReason)
|
|
573
629
|
}
|
|
@@ -591,10 +647,6 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
591
647
|
}
|
|
592
648
|
stepSpan.finish(stepStartTime + stepDuration)
|
|
593
649
|
}
|
|
594
|
-
if (finalStatus === 'fail') {
|
|
595
|
-
this.numFailedTests++
|
|
596
|
-
}
|
|
597
|
-
|
|
598
650
|
this.telemetry.ciVisEvent(
|
|
599
651
|
TELEMETRY_EVENT_FINISHED,
|
|
600
652
|
'test',
|
|
@@ -608,6 +660,28 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
608
660
|
isModified,
|
|
609
661
|
}
|
|
610
662
|
)
|
|
663
|
+
if (retryTestId !== undefined && !this._tracerConfig.DD_PLAYWRIGHT_WORKER) {
|
|
664
|
+
const finishPrevious = this.#pendingRetryTestFinishes.get(retryTestId)
|
|
665
|
+
finishPrevious?.(false)
|
|
666
|
+
this.#pendingRetryTestFinishes.delete(retryTestId)
|
|
667
|
+
if (isDeferredMainTest) {
|
|
668
|
+
// Legacy spans have no worker report. Retain the last execution until a
|
|
669
|
+
// successor arrives or session end confirms that its retry was canceled.
|
|
670
|
+
const finishTime = span._getTime()
|
|
671
|
+
finishAllTraceSpans(span)
|
|
672
|
+
this.#pendingRetryTestFinishes.set(retryTestId, (isFinal) => {
|
|
673
|
+
if (isFinal) {
|
|
674
|
+
span.setTag(TEST_FINAL_STATUS, finalStatus)
|
|
675
|
+
if (finalStatus === 'fail') this.numFailedTests++
|
|
676
|
+
}
|
|
677
|
+
span.finish(finishTime)
|
|
678
|
+
})
|
|
679
|
+
return
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
if (finalStatus === 'fail') {
|
|
683
|
+
this.numFailedTests++
|
|
684
|
+
}
|
|
611
685
|
span.finish()
|
|
612
686
|
|
|
613
687
|
finishAllTraceSpans(span)
|
|
@@ -682,7 +756,6 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
682
756
|
* @param {string} options.traceId - Test trace id used as the screenshot key
|
|
683
757
|
* @param {AbortSignal} options.signal - Signal used to cancel uploads during error finalization
|
|
684
758
|
* @param {(result: string|undefined) => void} onDone - Completion callback
|
|
685
|
-
* @returns {boolean} Whether at least one upload was started
|
|
686
759
|
*/
|
|
687
760
|
uploadTestScreenshots ({ screenshots, traceId, signal }, onDone) {
|
|
688
761
|
const exporter = this.tracer?._exporter
|
|
@@ -735,7 +808,6 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
735
808
|
* @param {string} options.traceId - Test trace id used as the video key
|
|
736
809
|
* @param {AbortSignal} options.signal - Signal used to cancel uploads during error finalization
|
|
737
810
|
* @param {(result: string|undefined) => void} onDone - Completion callback
|
|
738
|
-
* @returns {boolean} Whether at least one upload was started
|
|
739
811
|
*/
|
|
740
812
|
uploadTestVideos ({ videos, traceId, signal }, onDone) {
|
|
741
813
|
const exporter = this.tracer?._exporter
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
4
|
+
const DatabasePlugin = require('../../dd-trace/src/plugins/database')
|
|
5
|
+
const Plugin = require('../../dd-trace/src/plugins/plugin')
|
|
6
|
+
|
|
7
|
+
const PREPARE_START_CHANNEL = 'tracing:orchestrion:postgres:query:prepare:start'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {object} PostgresContext
|
|
11
|
+
* @property {{ span: import('../../..').Span }} currentStore
|
|
12
|
+
* @property {string} database
|
|
13
|
+
* @property {unknown} [error]
|
|
14
|
+
* @property {string} [host]
|
|
15
|
+
* @property {number} [pid]
|
|
16
|
+
* @property {number} [port]
|
|
17
|
+
* @property {PostgresQuery} query
|
|
18
|
+
* @property {string} [statement]
|
|
19
|
+
* @property {string} user
|
|
20
|
+
*
|
|
21
|
+
* @typedef {object} PostgresDbmState
|
|
22
|
+
* @property {string} service
|
|
23
|
+
* @property {string} [statement]
|
|
24
|
+
*
|
|
25
|
+
* @typedef {object} PostgresPreparationContext
|
|
26
|
+
* @property {boolean} prepared
|
|
27
|
+
* @property {PostgresQuery} query
|
|
28
|
+
* @property {string} statement
|
|
29
|
+
*
|
|
30
|
+
* @typedef {object} PostgresQuery
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
class PostgresPreparationPlugin extends Plugin {
|
|
34
|
+
static id = 'postgres'
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {(ctx: PostgresPreparationContext) => void} prepare
|
|
38
|
+
* @param {object} tracer
|
|
39
|
+
* @param {import('../../dd-trace/src/config/config-base')} tracerConfig
|
|
40
|
+
*/
|
|
41
|
+
constructor (prepare, tracer, tracerConfig) {
|
|
42
|
+
super(tracer, tracerConfig)
|
|
43
|
+
this.addSub(PREPARE_START_CHANNEL, prepare)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class PostgresPlugin extends DatabasePlugin {
|
|
48
|
+
static id = 'postgres'
|
|
49
|
+
static prefix = 'tracing:orchestrion:postgres:query'
|
|
50
|
+
|
|
51
|
+
/** @type {boolean} */
|
|
52
|
+
#dbmEnabled = false
|
|
53
|
+
|
|
54
|
+
/** @type {WeakMap<PostgresQuery, PostgresDbmState>} */
|
|
55
|
+
#dbmQueries = new WeakMap()
|
|
56
|
+
|
|
57
|
+
/** @type {PostgresPreparationPlugin} */
|
|
58
|
+
#preparation
|
|
59
|
+
|
|
60
|
+
/** @type {{ name: string, source: string | undefined }} */
|
|
61
|
+
#service
|
|
62
|
+
|
|
63
|
+
/** @type {WeakMap<PostgresQuery, import('../../..').Span>} */
|
|
64
|
+
#spans = new WeakMap()
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {object} tracer
|
|
68
|
+
* @param {import('../../dd-trace/src/config/config-base')} tracerConfig
|
|
69
|
+
*/
|
|
70
|
+
constructor (tracer, tracerConfig) {
|
|
71
|
+
super(tracer, tracerConfig)
|
|
72
|
+
this.#preparation = new PostgresPreparationPlugin(this.#prepare.bind(this), tracer, tracerConfig)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @override
|
|
77
|
+
* @param {boolean | import('../../dd-trace/src/config/config-base') & {enabled: boolean}} config
|
|
78
|
+
*/
|
|
79
|
+
configure (config) {
|
|
80
|
+
super.configure(config)
|
|
81
|
+
|
|
82
|
+
this.#service = this.serviceName({ pluginConfig: this.config })
|
|
83
|
+
const mode = this.config.dbmPropagationMode
|
|
84
|
+
this.#dbmEnabled = mode === 'service' || mode === 'full' || mode === 'dynamic_service'
|
|
85
|
+
this.#preparation.configure(this.config.enabled === true && this.#dbmEnabled)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {PostgresContext} ctx
|
|
90
|
+
* @returns {object}
|
|
91
|
+
*/
|
|
92
|
+
bindStart (ctx) {
|
|
93
|
+
const { database, host, port, query, user } = ctx
|
|
94
|
+
const service = this.#service
|
|
95
|
+
|
|
96
|
+
const span = this.startSpan(this.operationName(), {
|
|
97
|
+
service,
|
|
98
|
+
type: 'sql',
|
|
99
|
+
kind: 'client',
|
|
100
|
+
meta: {
|
|
101
|
+
'db.type': this.system,
|
|
102
|
+
'db.name': database,
|
|
103
|
+
'db.user': user,
|
|
104
|
+
},
|
|
105
|
+
}, ctx)
|
|
106
|
+
|
|
107
|
+
if (host !== undefined) {
|
|
108
|
+
span.addTags({
|
|
109
|
+
'out.host': host,
|
|
110
|
+
[CLIENT_PORT_KEY]: port,
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
this.#spans.set(query, span)
|
|
115
|
+
if (this.#dbmEnabled) {
|
|
116
|
+
this.#dbmQueries.set(query, { service: service.name })
|
|
117
|
+
}
|
|
118
|
+
return ctx.currentStore
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param {PostgresPreparationContext} ctx
|
|
123
|
+
*/
|
|
124
|
+
#prepare (ctx) {
|
|
125
|
+
const state = this.#dbmQueries.get(ctx.query)
|
|
126
|
+
const span = this.#spans.get(ctx.query)
|
|
127
|
+
if (state === undefined || span === undefined) return
|
|
128
|
+
|
|
129
|
+
state.statement = ctx.statement
|
|
130
|
+
span.setTag('resource.name', this.maybeTruncate(ctx.statement))
|
|
131
|
+
ctx.statement = this.injectDbmQuery(span, ctx.statement, state.service, ctx.prepared)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @param {PostgresContext} ctx
|
|
136
|
+
*/
|
|
137
|
+
error (ctx) {
|
|
138
|
+
const span = this.#spans.get(ctx.query)
|
|
139
|
+
if (span !== undefined) {
|
|
140
|
+
this.addError(ctx.error, span)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @param {PostgresContext} result
|
|
146
|
+
*/
|
|
147
|
+
asyncEnd (result) {
|
|
148
|
+
const { query } = result
|
|
149
|
+
const dbmState = this.#dbmQueries.get(query)
|
|
150
|
+
const span = this.#spans.get(query)
|
|
151
|
+
|
|
152
|
+
this.#dbmQueries.delete(query)
|
|
153
|
+
if (span === undefined) return
|
|
154
|
+
|
|
155
|
+
this.#spans.delete(query)
|
|
156
|
+
|
|
157
|
+
const statement = dbmState?.statement ?? result.statement
|
|
158
|
+
if (dbmState?.statement === undefined && typeof statement === 'string') {
|
|
159
|
+
span.setTag('resource.name', this.maybeTruncate(statement))
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
span.setTag('db.pid', result.pid)
|
|
163
|
+
this.finish({ currentStore: { span } })
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
module.exports = PostgresPlugin
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
4
4
|
const CachePlugin = require('../../dd-trace/src/plugins/cache')
|
|
5
5
|
const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
|
|
6
|
+
const { truncateString } = require('../../dd-trace/src/util')
|
|
6
7
|
|
|
7
8
|
const MAX_ARG_LENGTH = 100
|
|
9
|
+
const MAX_ARG_LENGTH_WITHOUT_COPY = 256
|
|
8
10
|
const MAX_COMMAND_LENGTH = 1000
|
|
9
11
|
|
|
10
12
|
class RedisPlugin extends CachePlugin {
|
|
@@ -95,15 +97,27 @@ function formatCommand (command, args, argsStartIndex = 0) {
|
|
|
95
97
|
return result
|
|
96
98
|
}
|
|
97
99
|
|
|
100
|
+
/**
|
|
101
|
+
* @param {unknown} arg
|
|
102
|
+
*/
|
|
98
103
|
function formatArg (arg) {
|
|
99
104
|
if (typeof arg === 'string') {
|
|
100
|
-
return arg.length > MAX_ARG_LENGTH ? arg
|
|
105
|
+
return arg.length > MAX_ARG_LENGTH ? truncateArg(arg) : arg
|
|
101
106
|
}
|
|
102
107
|
// Number stringification is bounded (~23 chars max), so it never hits MAX_ARG_LENGTH.
|
|
103
108
|
if (typeof arg === 'number') return String(arg)
|
|
104
109
|
return '?'
|
|
105
110
|
}
|
|
106
111
|
|
|
112
|
+
/**
|
|
113
|
+
* @param {string} arg
|
|
114
|
+
*/
|
|
115
|
+
function truncateArg (arg) {
|
|
116
|
+
return arg.length > MAX_ARG_LENGTH_WITHOUT_COPY
|
|
117
|
+
? truncateString(arg, MAX_ARG_LENGTH, '...')
|
|
118
|
+
: arg.slice(0, MAX_ARG_LENGTH - 3) + '...'
|
|
119
|
+
}
|
|
120
|
+
|
|
107
121
|
function normalizeConfig (config) {
|
|
108
122
|
if (config.allowlist) uppercaseAllEntries(config.allowlist)
|
|
109
123
|
if (config.whitelist) uppercaseAllEntries(config.whitelist)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {Error | { message?: string } | string | null | undefined} error Supabase operation error.
|
|
5
|
+
* @param {string} type Error type used for non-Error SDK results.
|
|
6
|
+
* @param {string} [message] Error message used for non-Error SDK results.
|
|
7
|
+
* @returns {Error | undefined}
|
|
8
|
+
*/
|
|
9
|
+
function normalizeError (error, type, message) {
|
|
10
|
+
if (!error) return
|
|
11
|
+
if (error instanceof Error) return error
|
|
12
|
+
|
|
13
|
+
const normalizedError = new Error(message || error?.message || String(error))
|
|
14
|
+
normalizedError.name = type
|
|
15
|
+
return normalizedError
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = normalizeError
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
4
|
+
const SupabaseGoTrueClientGetUserPlugin = require('./supabase-auth-js-gotrueclient-getuser')
|
|
5
|
+
const SupabaseStorageHandleRequestPlugin = require('./supabase-storage-js-handle-request')
|
|
6
|
+
const SupabaseRealtimeChannelSendPlugin = require('./supabase-realtime-js-realtimechannel-send')
|
|
7
|
+
const SupabaseFunctionsClientInvokePlugin = require('./supabase-functions-js-functionsclient-invoke')
|
|
8
|
+
const SupabasePostgrestBuilderThenPlugin = require('./supabase-postgrest-js-postgrestbuilder-then')
|
|
9
|
+
|
|
10
|
+
class SupabasePlugin extends CompositePlugin {
|
|
11
|
+
static id = 'supabase'
|
|
12
|
+
static plugins = {
|
|
13
|
+
SupabaseGoTrueClientGetUserPlugin,
|
|
14
|
+
SupabaseStorageHandleRequestPlugin,
|
|
15
|
+
SupabaseRealtimeChannelSendPlugin,
|
|
16
|
+
SupabaseFunctionsClientInvokePlugin,
|
|
17
|
+
SupabasePostgrestBuilderThenPlugin,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = SupabasePlugin
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
|
+
const { extractPathFromUrl } = require('../../dd-trace/src/plugins/util/url')
|
|
5
|
+
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
6
|
+
const normalizeError = require('./error')
|
|
7
|
+
const getHostname = require('./url')
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {{
|
|
11
|
+
* self: { url: string },
|
|
12
|
+
* currentStore?: { span: import('../../..').Span },
|
|
13
|
+
* result?: { error?: (Error & { status?: number }) | null },
|
|
14
|
+
* error?: Error & { status?: number }
|
|
15
|
+
* }} AuthContext
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
class SupabaseGoTrueClientGetUserPlugin extends ClientPlugin {
|
|
19
|
+
static id = 'supabase'
|
|
20
|
+
static prefix = 'tracing:orchestrion:@supabase/auth-js:GoTrueClient_getUser'
|
|
21
|
+
|
|
22
|
+
/** @param {AuthContext} ctx */
|
|
23
|
+
bindStart (ctx) {
|
|
24
|
+
const method = 'GET'
|
|
25
|
+
const url = stripQueryAndFragment(`${ctx.self?.url}/user`)
|
|
26
|
+
|
|
27
|
+
this.startSpan('supabase.http.getuser', {
|
|
28
|
+
service: { name: this.tracer._service },
|
|
29
|
+
type: 'http',
|
|
30
|
+
resource: `${method} ${extractPathFromUrl(url)}`,
|
|
31
|
+
meta: {
|
|
32
|
+
component: 'supabase',
|
|
33
|
+
'span.kind': 'client',
|
|
34
|
+
'http.method': method,
|
|
35
|
+
'http.url': url,
|
|
36
|
+
'out.host': getHostname(url),
|
|
37
|
+
},
|
|
38
|
+
}, ctx)
|
|
39
|
+
|
|
40
|
+
return ctx.currentStore
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @param {AuthContext} ctx */
|
|
44
|
+
asyncEnd (ctx) {
|
|
45
|
+
this.finish(ctx)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// You may modify this method, but the guard below is REQUIRED and MUST NOT be removed!
|
|
49
|
+
/** @param {AuthContext} ctx */
|
|
50
|
+
finish (ctx) {
|
|
51
|
+
// CRITICAL GUARD - DO NOT REMOVE: Ensures span only finishes when operation completes
|
|
52
|
+
if (!ctx.hasOwnProperty('result') && !ctx.hasOwnProperty('error')) return
|
|
53
|
+
|
|
54
|
+
const error = normalizeError(ctx.result?.error, 'AuthError')
|
|
55
|
+
if (error) {
|
|
56
|
+
ctx.error = error
|
|
57
|
+
super.error(ctx)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const status = ctx.result?.error?.status ??
|
|
61
|
+
ctx.error?.status ??
|
|
62
|
+
(ctx.result && !ctx.result.error ? 200 : undefined)
|
|
63
|
+
if (status) ctx.currentStore?.span.setTag('http.status_code', status)
|
|
64
|
+
|
|
65
|
+
super.finish(ctx)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = SupabaseGoTrueClientGetUserPlugin
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
|
+
const { extractPathFromUrl } = require('../../dd-trace/src/plugins/util/url')
|
|
5
|
+
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
6
|
+
const normalizeError = require('./error')
|
|
7
|
+
const getHostname = require('./url')
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {{
|
|
11
|
+
* arguments: { [index: number]: unknown, length: number, 0?: string, 1?: { method?: string } },
|
|
12
|
+
* self: { url: string },
|
|
13
|
+
* currentStore?: { span: import('../../..').Span },
|
|
14
|
+
* result?: { error?: Error | { message?: string } | null, response?: { status?: number } },
|
|
15
|
+
* error?: unknown
|
|
16
|
+
* }} FunctionsContext
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
class SupabaseFunctionsClientInvokePlugin extends ClientPlugin {
|
|
20
|
+
static id = 'supabase'
|
|
21
|
+
static prefix = 'tracing:orchestrion:@supabase/functions-js:FunctionsClient_invoke'
|
|
22
|
+
|
|
23
|
+
/** @param {FunctionsContext} ctx */
|
|
24
|
+
bindStart (ctx) {
|
|
25
|
+
const functionName = ctx.arguments?.[0]
|
|
26
|
+
const method = String(ctx.arguments?.[1]?.method || 'POST').toUpperCase()
|
|
27
|
+
const url = stripQueryAndFragment(`${ctx.self?.url}/${functionName}`)
|
|
28
|
+
|
|
29
|
+
this.startSpan('supabase.http.invoke', {
|
|
30
|
+
service: { name: this.tracer._service },
|
|
31
|
+
type: 'http',
|
|
32
|
+
resource: `${method} ${extractPathFromUrl(url)}`,
|
|
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
|
+
},
|
|
41
|
+
}, ctx)
|
|
42
|
+
|
|
43
|
+
return ctx.currentStore
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** @param {FunctionsContext} ctx */
|
|
47
|
+
asyncEnd (ctx) {
|
|
48
|
+
this.finish(ctx)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// You may modify this method, but the guard below is REQUIRED and MUST NOT be removed!
|
|
52
|
+
/** @param {FunctionsContext} ctx */
|
|
53
|
+
finish (ctx) {
|
|
54
|
+
// CRITICAL GUARD - DO NOT REMOVE: Ensures span only finishes when operation completes
|
|
55
|
+
if (!ctx.hasOwnProperty('result') && !ctx.hasOwnProperty('error')) return
|
|
56
|
+
|
|
57
|
+
const error = normalizeError(ctx.result?.error, 'FunctionsError')
|
|
58
|
+
if (error) {
|
|
59
|
+
ctx.error = error
|
|
60
|
+
super.error(ctx)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const status = ctx.result?.response?.status
|
|
64
|
+
if (status) ctx.currentStore?.span.setTag('http.status_code', status)
|
|
65
|
+
|
|
66
|
+
super.finish(ctx)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = SupabaseFunctionsClientInvokePlugin
|