dd-trace 6.16.0 → 6.17.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 +165 -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 +72 -12
- package/packages/datadog-instrumentations/src/cypress-config.js +0 -23
- package/packages/datadog-instrumentations/src/helpers/channel.js +0 -2
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +0 -5
- package/packages/datadog-instrumentations/src/helpers/hooks.js +8 -0
- 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 +4 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +72 -24
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +39 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +3 -17
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +12 -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/targets.json +16 -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 +141 -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 +22 -25
- 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 +3 -16
- package/packages/datadog-instrumentations/src/playwright.js +238 -55
- package/packages/datadog-instrumentations/src/postgres.js +7 -0
- 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/vitest-main-no-worker-init.js +18 -18
- package/packages/datadog-instrumentations/src/vitest-main.js +37 -17
- 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 +23 -42
- package/packages/datadog-instrumentations/src/ws.js +0 -1
- 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 +10 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +171 -75
- package/packages/datadog-plugin-cypress/src/finalization.js +0 -3
- 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 +13 -0
- package/packages/datadog-plugin-kafkajs/src/producer.js +0 -1
- package/packages/datadog-plugin-mocha/src/index.js +39 -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 +76 -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 +10 -0
- package/packages/datadog-plugin-ws/src/util.js +0 -4
- package/packages/datadog-turbopack/index.js +0 -6
- package/packages/datadog-turbopack/src/loader.js +0 -16
- package/packages/datadog-webpack/src/loader.js +0 -1
- 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 +73 -67
- package/packages/dd-trace/src/config/helper.js +0 -1
- package/packages/dd-trace/src/config/index.js +24 -24
- 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 +139 -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 +2 -0
- 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 +40 -14
- 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-pruner.js +0 -3
- package/packages/dd-trace/src/debugger/devtools_client/status.js +20 -6
- package/packages/dd-trace/src/debugger/guardrail-metrics.js +167 -0
- package/packages/dd-trace/src/debugger/index.js +50 -2
- 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/discovery.js +0 -1
- package/packages/dd-trace/src/evp_proxy/path.js +0 -2
- 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 +0 -2
- 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 +639 -0
- package/packages/dd-trace/src/llmobs/prompts/noop.js +29 -0
- package/packages/dd-trace/src/llmobs/prompts/prompt.js +92 -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 +30 -7
- 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/encoding.js +0 -2
- package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +0 -1
- package/packages/dd-trace/src/openfeature/index.js +0 -4
- 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 +0 -6
- package/packages/dd-trace/src/openfeature/writers/exposures.js +0 -5
- package/packages/dd-trace/src/openfeature/writers/util.js +0 -4
- 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/otel-thread-ctx.js +38 -11
- package/packages/dd-trace/src/payload-tagging/tagging.js +15 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +0 -1
- 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 +21 -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 +21 -45
- 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/telemetry.js +4 -1
- package/packages/dd-trace/src/util.js +13 -1
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
|
@@ -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,16 @@ 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 EMPTY_SHARD_SKIP_REASON = 'No tests were assigned to this shard'
|
|
74
|
+
const EMPTY_SHARD_REASON = 'zero_test_shard'
|
|
75
|
+
const RETRY_TEST_ID = '_dd.playwright.retry_test_id'
|
|
76
|
+
const DEFER_FINAL_STATUS = '_dd.playwright.defer_final_status'
|
|
72
77
|
const noop = () => {}
|
|
73
78
|
|
|
74
79
|
/**
|
|
75
80
|
* Returns whether an attachment is an automatic Playwright failure screenshot.
|
|
76
81
|
*
|
|
77
82
|
* @param {object} attachment - Playwright test attachment
|
|
78
|
-
* @returns {boolean}
|
|
79
83
|
*/
|
|
80
84
|
function isPlaywrightFailureScreenshot (attachment) {
|
|
81
85
|
return attachment?.name === 'screenshot' &&
|
|
@@ -88,7 +92,6 @@ function isPlaywrightFailureScreenshot (attachment) {
|
|
|
88
92
|
* Returns whether an attachment is a Playwright test video.
|
|
89
93
|
*
|
|
90
94
|
* @param {object} attachment - Playwright test attachment
|
|
91
|
-
* @returns {boolean}
|
|
92
95
|
*/
|
|
93
96
|
function isPlaywrightFailureVideo (attachment) {
|
|
94
97
|
return attachment?.name === 'video' &&
|
|
@@ -102,6 +105,7 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
102
105
|
#isFinalizingAfterError = false
|
|
103
106
|
#finishPendingTestFinishes
|
|
104
107
|
#pendingTestFinishCallbacks = new Map()
|
|
108
|
+
#pendingRetryTestFinishes = new Map()
|
|
105
109
|
|
|
106
110
|
constructor (...args) {
|
|
107
111
|
super(...args)
|
|
@@ -182,9 +186,13 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
182
186
|
isEarlyFlakeDetectionEnabled,
|
|
183
187
|
isEarlyFlakeDetectionFaulty,
|
|
184
188
|
isTestManagementTestsEnabled,
|
|
189
|
+
isExpectedEmptyShard,
|
|
185
190
|
error,
|
|
186
191
|
onDone,
|
|
187
192
|
}) => {
|
|
193
|
+
for (const finish of this.#pendingRetryTestFinishes.values()) finish(true)
|
|
194
|
+
this.#pendingRetryTestFinishes.clear()
|
|
195
|
+
|
|
188
196
|
if (error) {
|
|
189
197
|
this.#isFinalizingAfterError = true
|
|
190
198
|
for (const testSuiteSpan of this._testSuiteSpansByTestSuiteAbsolutePath.values()) {
|
|
@@ -204,6 +212,15 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
204
212
|
this.testModuleSpan.setTag(TEST_STATUS, status)
|
|
205
213
|
this.testSessionSpan.setTag(TEST_STATUS, status)
|
|
206
214
|
|
|
215
|
+
if (isExpectedEmptyShard) {
|
|
216
|
+
setExpectedEmptyTestSessionTags(
|
|
217
|
+
this.testSessionSpan,
|
|
218
|
+
this.testModuleSpan,
|
|
219
|
+
EMPTY_SHARD_SKIP_REASON,
|
|
220
|
+
EMPTY_SHARD_REASON
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
207
224
|
if (isEarlyFlakeDetectionEnabled) {
|
|
208
225
|
this.testSessionSpan.setTag(TEST_EARLY_FLAKE_ENABLED, 'true')
|
|
209
226
|
}
|
|
@@ -372,12 +389,37 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
372
389
|
formattedTraces.push(formattedTrace)
|
|
373
390
|
}
|
|
374
391
|
|
|
392
|
+
const retryTestId = formattedTestSpan?.meta[RETRY_TEST_ID]
|
|
393
|
+
const deferFinalStatus = formattedTestSpan?.meta[DEFER_FINAL_STATUS] === 'true'
|
|
394
|
+
if (retryTestId !== undefined) {
|
|
395
|
+
delete formattedTestSpan.meta[RETRY_TEST_ID]
|
|
396
|
+
delete formattedTestSpan.meta[DEFER_FINAL_STATUS]
|
|
397
|
+
}
|
|
398
|
+
let readyToExport = false
|
|
399
|
+
let isFinalExecution
|
|
375
400
|
const exportTraces = () => {
|
|
401
|
+
readyToExport = true
|
|
402
|
+
if (deferFinalStatus && isFinalExecution === undefined) return
|
|
376
403
|
for (const trace of formattedTraces) {
|
|
377
404
|
this.tracer._exporter.export(trace)
|
|
378
405
|
}
|
|
379
406
|
}
|
|
380
407
|
|
|
408
|
+
if (retryTestId !== undefined) {
|
|
409
|
+
// Keep at most one execution while another attempt is possible. Media uploads
|
|
410
|
+
// can finish before or after finality is known, so track readiness separately.
|
|
411
|
+
const finishPrevious = this.#pendingRetryTestFinishes.get(retryTestId)
|
|
412
|
+
finishPrevious?.(false)
|
|
413
|
+
this.#pendingRetryTestFinishes.delete(retryTestId)
|
|
414
|
+
if (deferFinalStatus) {
|
|
415
|
+
this.#pendingRetryTestFinishes.set(retryTestId, (isFinal) => {
|
|
416
|
+
isFinalExecution = isFinal
|
|
417
|
+
if (!isFinal) delete formattedTestSpan.meta[TEST_FINAL_STATUS]
|
|
418
|
+
if (readyToExport) exportTraces()
|
|
419
|
+
})
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
381
423
|
if (!formattedTestSpan || (!screenshots && !videos) || this.#isFinalizingAfterError) {
|
|
382
424
|
exportTraces()
|
|
383
425
|
return
|
|
@@ -501,6 +543,8 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
501
543
|
isAtrRetry,
|
|
502
544
|
isModified,
|
|
503
545
|
finalStatus,
|
|
546
|
+
retryTestId,
|
|
547
|
+
deferFinalStatus,
|
|
504
548
|
earlyFlakeAbortReason,
|
|
505
549
|
onDone,
|
|
506
550
|
}) => {
|
|
@@ -510,6 +554,8 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
510
554
|
}
|
|
511
555
|
|
|
512
556
|
const isRUMActive = span.context().getTag(TEST_IS_RUM_ACTIVE)
|
|
557
|
+
const isDeferredMainTest = !this._tracerConfig.DD_PLAYWRIGHT_WORKER &&
|
|
558
|
+
retryTestId !== undefined && deferFinalStatus
|
|
513
559
|
|
|
514
560
|
span.setTag(TEST_STATUS, testStatus)
|
|
515
561
|
|
|
@@ -565,9 +611,14 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
565
611
|
span.setTag(TEST_RETRY_REASON, TEST_RETRY_REASON_TYPES.efd)
|
|
566
612
|
}
|
|
567
613
|
}
|
|
568
|
-
if (finalStatus) {
|
|
614
|
+
if (finalStatus && !isDeferredMainTest) {
|
|
569
615
|
span.setTag(TEST_FINAL_STATUS, finalStatus)
|
|
570
616
|
}
|
|
617
|
+
if (retryTestId !== undefined && this._tracerConfig.DD_PLAYWRIGHT_WORKER) {
|
|
618
|
+
// This identifier is removed by the main process before exporting the trace.
|
|
619
|
+
span.setTag(RETRY_TEST_ID, retryTestId)
|
|
620
|
+
if (deferFinalStatus) span.setTag(DEFER_FINAL_STATUS, 'true')
|
|
621
|
+
}
|
|
571
622
|
if (earlyFlakeAbortReason) {
|
|
572
623
|
span.setTag(TEST_EARLY_FLAKE_ABORT_REASON, earlyFlakeAbortReason)
|
|
573
624
|
}
|
|
@@ -591,10 +642,6 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
591
642
|
}
|
|
592
643
|
stepSpan.finish(stepStartTime + stepDuration)
|
|
593
644
|
}
|
|
594
|
-
if (finalStatus === 'fail') {
|
|
595
|
-
this.numFailedTests++
|
|
596
|
-
}
|
|
597
|
-
|
|
598
645
|
this.telemetry.ciVisEvent(
|
|
599
646
|
TELEMETRY_EVENT_FINISHED,
|
|
600
647
|
'test',
|
|
@@ -608,6 +655,28 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
608
655
|
isModified,
|
|
609
656
|
}
|
|
610
657
|
)
|
|
658
|
+
if (retryTestId !== undefined && !this._tracerConfig.DD_PLAYWRIGHT_WORKER) {
|
|
659
|
+
const finishPrevious = this.#pendingRetryTestFinishes.get(retryTestId)
|
|
660
|
+
finishPrevious?.(false)
|
|
661
|
+
this.#pendingRetryTestFinishes.delete(retryTestId)
|
|
662
|
+
if (isDeferredMainTest) {
|
|
663
|
+
// Legacy spans have no worker report. Retain the last execution until a
|
|
664
|
+
// successor arrives or session end confirms that its retry was canceled.
|
|
665
|
+
const finishTime = span._getTime()
|
|
666
|
+
finishAllTraceSpans(span)
|
|
667
|
+
this.#pendingRetryTestFinishes.set(retryTestId, (isFinal) => {
|
|
668
|
+
if (isFinal) {
|
|
669
|
+
span.setTag(TEST_FINAL_STATUS, finalStatus)
|
|
670
|
+
if (finalStatus === 'fail') this.numFailedTests++
|
|
671
|
+
}
|
|
672
|
+
span.finish(finishTime)
|
|
673
|
+
})
|
|
674
|
+
return
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
if (finalStatus === 'fail') {
|
|
678
|
+
this.numFailedTests++
|
|
679
|
+
}
|
|
611
680
|
span.finish()
|
|
612
681
|
|
|
613
682
|
finishAllTraceSpans(span)
|
|
@@ -682,7 +751,6 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
682
751
|
* @param {string} options.traceId - Test trace id used as the screenshot key
|
|
683
752
|
* @param {AbortSignal} options.signal - Signal used to cancel uploads during error finalization
|
|
684
753
|
* @param {(result: string|undefined) => void} onDone - Completion callback
|
|
685
|
-
* @returns {boolean} Whether at least one upload was started
|
|
686
754
|
*/
|
|
687
755
|
uploadTestScreenshots ({ screenshots, traceId, signal }, onDone) {
|
|
688
756
|
const exporter = this.tracer?._exporter
|
|
@@ -735,7 +803,6 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
735
803
|
* @param {string} options.traceId - Test trace id used as the video key
|
|
736
804
|
* @param {AbortSignal} options.signal - Signal used to cancel uploads during error finalization
|
|
737
805
|
* @param {(result: string|undefined) => void} onDone - Completion callback
|
|
738
|
-
* @returns {boolean} Whether at least one upload was started
|
|
739
806
|
*/
|
|
740
807
|
uploadTestVideos ({ videos, traceId, signal }, onDone) {
|
|
741
808
|
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
|