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
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const versionRange = '>=2.112.2'
|
|
4
|
+
|
|
5
|
+
module.exports = [
|
|
6
|
+
{
|
|
7
|
+
module: {
|
|
8
|
+
name: '@supabase/storage-js',
|
|
9
|
+
versionRange,
|
|
10
|
+
filePath: 'dist/index.cjs',
|
|
11
|
+
},
|
|
12
|
+
functionQuery: { functionName: '_handleRequest', kind: 'Async' },
|
|
13
|
+
channelName: 'handleRequest',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
module: {
|
|
17
|
+
name: '@supabase/storage-js',
|
|
18
|
+
versionRange,
|
|
19
|
+
filePath: 'dist/index.mjs',
|
|
20
|
+
},
|
|
21
|
+
functionQuery: { functionName: '_handleRequest', kind: 'Async' },
|
|
22
|
+
channelName: 'handleRequest',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
module: {
|
|
26
|
+
name: '@supabase/auth-js',
|
|
27
|
+
versionRange,
|
|
28
|
+
filePath: 'dist/main/GoTrueClient.js',
|
|
29
|
+
},
|
|
30
|
+
functionQuery: {
|
|
31
|
+
methodName: 'getUser',
|
|
32
|
+
className: 'GoTrueClient',
|
|
33
|
+
kind: 'Async',
|
|
34
|
+
},
|
|
35
|
+
channelName: 'GoTrueClient_getUser',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
module: {
|
|
39
|
+
name: '@supabase/auth-js',
|
|
40
|
+
versionRange,
|
|
41
|
+
filePath: 'dist/module/GoTrueClient.js',
|
|
42
|
+
},
|
|
43
|
+
functionQuery: {
|
|
44
|
+
methodName: 'getUser',
|
|
45
|
+
className: 'GoTrueClient',
|
|
46
|
+
kind: 'Async',
|
|
47
|
+
},
|
|
48
|
+
channelName: 'GoTrueClient_getUser',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
module: {
|
|
52
|
+
name: '@supabase/realtime-js',
|
|
53
|
+
versionRange,
|
|
54
|
+
filePath: 'dist/main/RealtimeChannel.js',
|
|
55
|
+
},
|
|
56
|
+
functionQuery: {
|
|
57
|
+
methodName: 'send',
|
|
58
|
+
className: 'RealtimeChannel',
|
|
59
|
+
kind: 'Async',
|
|
60
|
+
},
|
|
61
|
+
channelName: 'RealtimeChannel_send',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
module: {
|
|
65
|
+
name: '@supabase/realtime-js',
|
|
66
|
+
versionRange,
|
|
67
|
+
filePath: 'dist/module/RealtimeChannel.js',
|
|
68
|
+
},
|
|
69
|
+
functionQuery: {
|
|
70
|
+
methodName: 'send',
|
|
71
|
+
className: 'RealtimeChannel',
|
|
72
|
+
kind: 'Async',
|
|
73
|
+
},
|
|
74
|
+
channelName: 'RealtimeChannel_send',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
module: {
|
|
78
|
+
name: '@supabase/functions-js',
|
|
79
|
+
versionRange,
|
|
80
|
+
filePath: 'dist/main/FunctionsClient.js',
|
|
81
|
+
},
|
|
82
|
+
functionQuery: {
|
|
83
|
+
methodName: 'invoke',
|
|
84
|
+
className: 'FunctionsClient',
|
|
85
|
+
kind: 'Async',
|
|
86
|
+
},
|
|
87
|
+
channelName: 'FunctionsClient_invoke',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
module: {
|
|
91
|
+
name: '@supabase/functions-js',
|
|
92
|
+
versionRange,
|
|
93
|
+
filePath: 'dist/module/FunctionsClient.js',
|
|
94
|
+
},
|
|
95
|
+
functionQuery: {
|
|
96
|
+
methodName: 'invoke',
|
|
97
|
+
className: 'FunctionsClient',
|
|
98
|
+
kind: 'Async',
|
|
99
|
+
},
|
|
100
|
+
channelName: 'FunctionsClient_invoke',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
module: {
|
|
104
|
+
name: '@supabase/postgrest-js',
|
|
105
|
+
versionRange,
|
|
106
|
+
filePath: 'dist/index.cjs',
|
|
107
|
+
},
|
|
108
|
+
functionQuery: {
|
|
109
|
+
methodName: 'then',
|
|
110
|
+
className: 'PostgrestBuilder',
|
|
111
|
+
kind: 'Async',
|
|
112
|
+
},
|
|
113
|
+
channelName: 'PostgrestBuilder_then',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
module: {
|
|
117
|
+
name: '@supabase/postgrest-js',
|
|
118
|
+
versionRange,
|
|
119
|
+
filePath: 'dist/index.mjs',
|
|
120
|
+
},
|
|
121
|
+
functionQuery: {
|
|
122
|
+
methodName: 'then',
|
|
123
|
+
className: 'PostgrestBuilder',
|
|
124
|
+
kind: 'Async',
|
|
125
|
+
},
|
|
126
|
+
channelName: 'PostgrestBuilder_then',
|
|
127
|
+
},
|
|
128
|
+
]
|
package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
module.exports = [
|
|
4
|
+
{
|
|
5
|
+
module: {
|
|
6
|
+
name: '@wdio/config',
|
|
7
|
+
versionRange: '>=9.0.0',
|
|
8
|
+
filePath: 'build/node/index.js',
|
|
9
|
+
},
|
|
10
|
+
functionQuery: {
|
|
11
|
+
className: 'ConfigParser',
|
|
12
|
+
methodName: 'shard',
|
|
13
|
+
kind: 'Sync',
|
|
14
|
+
},
|
|
15
|
+
channelName: 'ConfigParser_shard',
|
|
16
|
+
},
|
|
4
17
|
{
|
|
5
18
|
module: {
|
|
6
19
|
name: '@wdio/cli',
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// targets.json is generated by scripts/generate-rewriter-targets.js from ./instrumentation-registry.
|
|
4
4
|
const targets = require('./targets.json')
|
|
5
|
+
const rewriteTargetNames = new Set(Object.values(targets))
|
|
5
6
|
|
|
6
7
|
const NODE_MODULES = '/node_modules/'
|
|
7
8
|
|
|
@@ -9,6 +10,7 @@ const NODE_MODULES = '/node_modules/'
|
|
|
9
10
|
* @typedef {object} RewriteTarget
|
|
10
11
|
* @property {string} moduleName
|
|
11
12
|
* @property {string} filePath
|
|
13
|
+
* @property {boolean} [activate]
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -20,13 +22,36 @@ function getRewriteTarget (filename) {
|
|
|
20
22
|
if (nodeModulesIndex === -1) return
|
|
21
23
|
|
|
22
24
|
const modulePath = filename.slice(nodeModulesIndex + NODE_MODULES.length)
|
|
25
|
+
if (!Object.hasOwn(targets, modulePath)) return
|
|
23
26
|
const moduleName = targets[modulePath]
|
|
24
27
|
if (typeof moduleName !== 'string') return
|
|
28
|
+
const activate = isRewriteActivationEnabled(moduleName)
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
const rewriteTarget = {
|
|
27
31
|
moduleName,
|
|
28
32
|
filePath: modulePath.slice(moduleName.length + 1),
|
|
29
33
|
}
|
|
34
|
+
if (activate) rewriteTarget.activate = true
|
|
35
|
+
return rewriteTarget
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
function getRewriteTargetNames () {
|
|
39
|
+
return rewriteTargetNames.values()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} name
|
|
44
|
+
*/
|
|
45
|
+
function isRewriteTargetName (name) {
|
|
46
|
+
return rewriteTargetNames.has(name)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} moduleName
|
|
51
|
+
*/
|
|
52
|
+
function isRewriteActivationEnabled (moduleName) {
|
|
53
|
+
// Keep target-name-only consumers from loading every instrumentation descriptor.
|
|
54
|
+
return require('./instrumentation-registry').isRewriteActivationEnabled(moduleName)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = { getRewriteTarget, getRewriteTargetNames, isRewriteActivationEnabled, isRewriteTargetName }
|
|
@@ -30,7 +30,19 @@
|
|
|
30
30
|
"@modelcontextprotocol/sdk/dist/esm/server/mcp.js": "@modelcontextprotocol/sdk",
|
|
31
31
|
"@openai/agents-openai/dist/openaiChatCompletionsModel.js": "@openai/agents-openai",
|
|
32
32
|
"@openai/agents-openai/dist/openaiChatCompletionsModel.mjs": "@openai/agents-openai",
|
|
33
|
+
"@playwright/test/lib/reporters/multiplexer.js": "@playwright/test",
|
|
34
|
+
"@supabase/auth-js/dist/main/GoTrueClient.js": "@supabase/auth-js",
|
|
35
|
+
"@supabase/auth-js/dist/module/GoTrueClient.js": "@supabase/auth-js",
|
|
36
|
+
"@supabase/functions-js/dist/main/FunctionsClient.js": "@supabase/functions-js",
|
|
37
|
+
"@supabase/functions-js/dist/module/FunctionsClient.js": "@supabase/functions-js",
|
|
38
|
+
"@supabase/postgrest-js/dist/index.cjs": "@supabase/postgrest-js",
|
|
39
|
+
"@supabase/postgrest-js/dist/index.mjs": "@supabase/postgrest-js",
|
|
40
|
+
"@supabase/realtime-js/dist/main/RealtimeChannel.js": "@supabase/realtime-js",
|
|
41
|
+
"@supabase/realtime-js/dist/module/RealtimeChannel.js": "@supabase/realtime-js",
|
|
42
|
+
"@supabase/storage-js/dist/index.cjs": "@supabase/storage-js",
|
|
43
|
+
"@supabase/storage-js/dist/index.mjs": "@supabase/storage-js",
|
|
33
44
|
"@wdio/cli/build/index.js": "@wdio/cli",
|
|
45
|
+
"@wdio/config/build/node/index.js": "@wdio/config",
|
|
34
46
|
"@wdio/jasmine-framework/build/index.js": "@wdio/jasmine-framework",
|
|
35
47
|
"@wdio/local-runner/build/index.js": "@wdio/local-runner",
|
|
36
48
|
"@wdio/runner/build/index.js": "@wdio/runner",
|
|
@@ -67,6 +79,14 @@
|
|
|
67
79
|
"playwright-core/lib/coreBundle.js": "playwright-core",
|
|
68
80
|
"playwright/lib/index.js": "playwright",
|
|
69
81
|
"playwright/lib/runner/index.js": "playwright",
|
|
82
|
+
"playwright/lib/runner/lastRun.js": "playwright",
|
|
83
|
+
"playwright/lib/runner/runner.js": "playwright",
|
|
84
|
+
"postgres/cjs/src/connection.js": "postgres",
|
|
85
|
+
"postgres/cjs/src/index.js": "postgres",
|
|
86
|
+
"postgres/cjs/src/query.js": "postgres",
|
|
87
|
+
"postgres/src/connection.js": "postgres",
|
|
88
|
+
"postgres/src/index.js": "postgres",
|
|
89
|
+
"postgres/src/query.js": "postgres",
|
|
70
90
|
"webdriver/build/index.js": "webdriver",
|
|
71
91
|
"webdriver/build/node.js": "webdriver",
|
|
72
92
|
"webdriverio/build/index.js": "webdriverio",
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert')
|
|
4
|
+
|
|
5
|
+
const { parse, query } = require('../compiler')
|
|
6
|
+
|
|
7
|
+
const POSTGRES_OPTIONS = '__ddTracePostgresOptions'
|
|
8
|
+
const POSTGRES_QUERY_REGISTRY = '__ddTracePostgresQueries'
|
|
9
|
+
const POSTGRES_QUERY_REGISTRY_SYMBOL = '__ddTracePostgresQueriesSymbol'
|
|
10
|
+
const POSTGRES_READY = '__ddTracePostgresQueryReady'
|
|
11
|
+
const POSTGRES_SIMPLE_DBM_QUERIES = '__ddTracePostgresSimpleDbmQueries'
|
|
12
|
+
const POSTGRES_STATEMENT = 'this.string ?? (this.tagged && this.strings?.length !== 1 ? undefined : this.strings?.[0])'
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
postgresQueryHandlers,
|
|
16
|
+
postgresQueryLifecycle,
|
|
17
|
+
postgresQueryPreparation,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Starts a Postgres.js query at the pool handler that owns its connection options.
|
|
22
|
+
*
|
|
23
|
+
* @param {object} state
|
|
24
|
+
* @param {import('estree').Program} program
|
|
25
|
+
*/
|
|
26
|
+
function postgresQueryHandlers (state, program) {
|
|
27
|
+
const channelVariable = injectPostgresTracingChannel(state, program)
|
|
28
|
+
injectPostgresReadyCheck(program, findPostgresQueryIdentifier(program))
|
|
29
|
+
capturePostgresOptions(program)
|
|
30
|
+
|
|
31
|
+
const handlers = query(program, 'FunctionDeclaration[id.name="handler"]')
|
|
32
|
+
assert(handlers.length >= 2 && handlers.length <= 3, 'postgresQueryHandlers: unexpected handler count')
|
|
33
|
+
|
|
34
|
+
for (const handler of handlers) {
|
|
35
|
+
const queryParameter = handler.params[0]
|
|
36
|
+
assert(queryParameter?.type === 'Identifier', 'postgresQueryHandlers: handler query parameter changed')
|
|
37
|
+
wrapPostgresHandler(handler, queryParameter.name, channelVariable)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Publishes the final Postgres.js query settlement without changing its Promise implementation.
|
|
43
|
+
*
|
|
44
|
+
* @param {object} state
|
|
45
|
+
* @param {import('estree').Program} program
|
|
46
|
+
*/
|
|
47
|
+
function postgresQueryLifecycle (state, program) {
|
|
48
|
+
const channelVariable = injectPostgresTracingChannel(state, program)
|
|
49
|
+
injectPostgresQueryRegistration(program)
|
|
50
|
+
|
|
51
|
+
const resolveAssignments = query(
|
|
52
|
+
program,
|
|
53
|
+
'AssignmentExpression[left.object.type="ThisExpression"][left.property.name="resolve"]'
|
|
54
|
+
)
|
|
55
|
+
const rejectAssignments = query(
|
|
56
|
+
program,
|
|
57
|
+
'AssignmentExpression[left.object.type="ThisExpression"][left.property.name="reject"]'
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
assert(resolveAssignments.length === 2, 'postgresQueryLifecycle: unexpected resolve assignment count')
|
|
61
|
+
assert(rejectAssignments.length === 2, 'postgresQueryLifecycle: unexpected reject assignment count')
|
|
62
|
+
|
|
63
|
+
for (const assignment of resolveAssignments) {
|
|
64
|
+
wrapPostgresResolution(assignment, channelVariable)
|
|
65
|
+
}
|
|
66
|
+
for (const assignment of rejectAssignments) {
|
|
67
|
+
wrapPostgresRejection(assignment, channelVariable)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Injects DBM data after Postgres.js builds the final statement and before it creates wire messages.
|
|
73
|
+
*
|
|
74
|
+
* @param {object} state
|
|
75
|
+
* @param {import('estree').Program} program
|
|
76
|
+
*/
|
|
77
|
+
function postgresQueryPreparation (state, program) {
|
|
78
|
+
const channelVariable = injectPostgresTracingChannel(state, program)
|
|
79
|
+
const buildFunctions = query(program, 'FunctionDeclaration[id.name="build"]')
|
|
80
|
+
const toBufferFunctions = query(program, 'FunctionDeclaration[id.name="toBuffer"]')
|
|
81
|
+
|
|
82
|
+
assert(buildFunctions.length === 1, 'postgresQueryPreparation: build function changed')
|
|
83
|
+
assert(toBufferFunctions.length === 1, 'postgresQueryPreparation: toBuffer function changed')
|
|
84
|
+
|
|
85
|
+
const build = buildFunctions[0]
|
|
86
|
+
const queryParameter = build.params[0]
|
|
87
|
+
assert(queryParameter?.type === 'Identifier', 'postgresQueryPreparation: build query parameter changed')
|
|
88
|
+
assert(build.body.type === 'BlockStatement', 'postgresQueryPreparation: build body changed')
|
|
89
|
+
|
|
90
|
+
const queryName = queryParameter.name
|
|
91
|
+
const body = build.body.body
|
|
92
|
+
const stringDeclaration = body.find(statement =>
|
|
93
|
+
statement.type === 'VariableDeclaration' &&
|
|
94
|
+
statement.declarations.some(({ id }) => id.type === 'Identifier' && id.name === 'string')
|
|
95
|
+
)
|
|
96
|
+
assert(stringDeclaration?.kind === 'const', 'postgresQueryPreparation: string declaration changed')
|
|
97
|
+
|
|
98
|
+
const prepareIndex = body.findIndex(statement =>
|
|
99
|
+
statement.type === 'ExpressionStatement' &&
|
|
100
|
+
statement.expression.type === 'AssignmentExpression' &&
|
|
101
|
+
statement.expression.left.type === 'MemberExpression' &&
|
|
102
|
+
statement.expression.left.object.type === 'Identifier' &&
|
|
103
|
+
statement.expression.left.object.name === queryName &&
|
|
104
|
+
statement.expression.left.property.type === 'Identifier' &&
|
|
105
|
+
statement.expression.left.property.name === 'prepare'
|
|
106
|
+
)
|
|
107
|
+
assert(prepareIndex !== -1, 'postgresQueryPreparation: prepare assignment changed')
|
|
108
|
+
|
|
109
|
+
const legacySimpleString = findLegacyPostgresSimpleString(toBufferFunctions[0], queryName)
|
|
110
|
+
const contextStatements = parse(`
|
|
111
|
+
if (${channelVariable}.start.hasSubscribers) {
|
|
112
|
+
const __ddTraceContext = {
|
|
113
|
+
query: ${queryName},
|
|
114
|
+
statement: string,
|
|
115
|
+
prepared: Boolean(${queryName}.prepare && !${queryName}.options.simple)
|
|
116
|
+
};
|
|
117
|
+
${channelVariable}.start.publish(__ddTraceContext);
|
|
118
|
+
${legacySimpleString === undefined
|
|
119
|
+
? ''
|
|
120
|
+
: `if (${queryName}.options.simple && __ddTraceContext.statement !== string) {
|
|
121
|
+
${POSTGRES_SIMPLE_DBM_QUERIES}.add(${queryName});
|
|
122
|
+
}`}
|
|
123
|
+
string = __ddTraceContext.statement;
|
|
124
|
+
}
|
|
125
|
+
`).body
|
|
126
|
+
|
|
127
|
+
stringDeclaration.kind = 'let'
|
|
128
|
+
body.splice(prepareIndex + 1, 0, ...contextStatements)
|
|
129
|
+
|
|
130
|
+
if (legacySimpleString !== undefined) {
|
|
131
|
+
injectPostgresModuleStatements(
|
|
132
|
+
program,
|
|
133
|
+
parse(`const ${POSTGRES_SIMPLE_DBM_QUERIES} = new WeakSet();`).body
|
|
134
|
+
)
|
|
135
|
+
const replacement = parse(`
|
|
136
|
+
${channelVariable}.start.hasSubscribers && ${POSTGRES_SIMPLE_DBM_QUERIES}.delete(${queryName})
|
|
137
|
+
? ${queryName}.string
|
|
138
|
+
: ${queryName}.strings[0]
|
|
139
|
+
`).body[0].expression
|
|
140
|
+
|
|
141
|
+
for (const key of Object.keys(legacySimpleString)) {
|
|
142
|
+
delete legacySimpleString[key]
|
|
143
|
+
}
|
|
144
|
+
Object.assign(legacySimpleString, replacement)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @param {import('estree').FunctionDeclaration|import('estree').ArrowFunctionExpression} handler
|
|
150
|
+
* @param {string} queryParameter
|
|
151
|
+
* @param {string} channelVariable
|
|
152
|
+
*/
|
|
153
|
+
function wrapPostgresHandler (handler, queryParameter, channelVariable) {
|
|
154
|
+
assert(handler.body.type === 'BlockStatement', 'postgresQueryHandlers: handler body changed')
|
|
155
|
+
assert(!handler.async && !handler.generator, 'postgresQueryHandlers: unsupported handler kind')
|
|
156
|
+
|
|
157
|
+
const originalBody = handler.body.body
|
|
158
|
+
const wrapperBody = parse(`
|
|
159
|
+
function wrapper () {
|
|
160
|
+
if (${channelVariable}.start.hasSubscribers && ${POSTGRES_READY} && !${queryParameter}.cancelled) {
|
|
161
|
+
const __ddTraceContext = {
|
|
162
|
+
query: ${queryParameter},
|
|
163
|
+
database: ${POSTGRES_OPTIONS}.database,
|
|
164
|
+
user: ${POSTGRES_OPTIONS}.user
|
|
165
|
+
};
|
|
166
|
+
if (${POSTGRES_OPTIONS}.host.length === 1 && !${POSTGRES_OPTIONS}.path) {
|
|
167
|
+
__ddTraceContext.host = ${POSTGRES_OPTIONS}.host[0];
|
|
168
|
+
__ddTraceContext.port = ${POSTGRES_OPTIONS}.port[0];
|
|
169
|
+
}
|
|
170
|
+
return ${channelVariable}.start.runStores(__ddTraceContext, () => {});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
`).body[0].body.body
|
|
174
|
+
|
|
175
|
+
wrapperBody[0].consequent.body.at(-1).argument.arguments[1].body.body = originalBody
|
|
176
|
+
handler.body.body = [...wrapperBody, ...originalBody]
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @param {import('estree').Program} program
|
|
181
|
+
*/
|
|
182
|
+
function capturePostgresOptions (program) {
|
|
183
|
+
const postgresFunctions = query(program, 'FunctionDeclaration[id.name="Postgres"]')
|
|
184
|
+
assert(postgresFunctions.length === 1, 'postgresQueryHandlers: Postgres function changed')
|
|
185
|
+
|
|
186
|
+
const body = postgresFunctions[0].body.body
|
|
187
|
+
const optionsIndex = body.findIndex(statement =>
|
|
188
|
+
statement.type === 'VariableDeclaration' && statement.declarations.some(({ id }) => id.name === 'options')
|
|
189
|
+
)
|
|
190
|
+
assert(optionsIndex !== -1, 'postgresQueryHandlers: options declaration changed')
|
|
191
|
+
|
|
192
|
+
const capture = parse(`const ${POSTGRES_OPTIONS} = options;`).body[0]
|
|
193
|
+
body.splice(optionsIndex + 1, 0, capture)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @param {import('estree').Program} program
|
|
198
|
+
* @param {string} queryIdentifier
|
|
199
|
+
*/
|
|
200
|
+
function injectPostgresReadyCheck (program, queryIdentifier) {
|
|
201
|
+
const statements = parse(`
|
|
202
|
+
const ${POSTGRES_QUERY_REGISTRY} = globalThis[Symbol.for('dd-trace:postgres:query')];
|
|
203
|
+
const ${POSTGRES_READY} = ${POSTGRES_QUERY_REGISTRY} instanceof WeakSet &&
|
|
204
|
+
${POSTGRES_QUERY_REGISTRY}.has(${queryIdentifier});
|
|
205
|
+
`).body
|
|
206
|
+
injectPostgresModuleStatements(program, statements)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @param {import('estree').FunctionDeclaration} toBuffer
|
|
211
|
+
* @param {string} queryName
|
|
212
|
+
* @returns {import('estree').MemberExpression | undefined}
|
|
213
|
+
*/
|
|
214
|
+
function findLegacyPostgresSimpleString (toBuffer, queryName) {
|
|
215
|
+
const simpleConditions = query(toBuffer, 'ConditionalExpression').filter(({ test }) =>
|
|
216
|
+
test.type === 'MemberExpression' &&
|
|
217
|
+
test.object.type === 'MemberExpression' &&
|
|
218
|
+
test.object.object.type === 'Identifier' &&
|
|
219
|
+
test.object.object.name === queryName &&
|
|
220
|
+
test.object.property.type === 'Identifier' &&
|
|
221
|
+
test.object.property.name === 'options' &&
|
|
222
|
+
test.property.type === 'Identifier' &&
|
|
223
|
+
test.property.name === 'simple'
|
|
224
|
+
)
|
|
225
|
+
assert(simpleConditions.length === 1, 'postgresQueryPreparation: simple query branch changed')
|
|
226
|
+
|
|
227
|
+
const legacyStrings = query(simpleConditions[0].consequent, 'MemberExpression').filter(node =>
|
|
228
|
+
node.computed &&
|
|
229
|
+
node.object.type === 'MemberExpression' &&
|
|
230
|
+
node.object.object.type === 'Identifier' &&
|
|
231
|
+
node.object.object.name === queryName &&
|
|
232
|
+
node.object.property.type === 'Identifier' &&
|
|
233
|
+
node.object.property.name === 'strings' &&
|
|
234
|
+
node.property.type === 'Literal' &&
|
|
235
|
+
node.property.value === 0
|
|
236
|
+
)
|
|
237
|
+
assert(legacyStrings.length <= 1, 'postgresQueryPreparation: simple query string changed')
|
|
238
|
+
return legacyStrings[0]
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @param {import('estree').Program} program
|
|
243
|
+
* @param {import('estree').Statement[]} statements
|
|
244
|
+
*/
|
|
245
|
+
function injectPostgresModuleStatements (program, statements) {
|
|
246
|
+
let importIndex = program.body.length - 1
|
|
247
|
+
while (importIndex >= 0) {
|
|
248
|
+
const statement = program.body[importIndex]
|
|
249
|
+
if (statement.type === 'ImportDeclaration' || statement.type === 'VariableDeclaration') break
|
|
250
|
+
importIndex--
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
program.body.splice(importIndex + 1, 0, ...statements)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @param {import('estree').Program} program
|
|
258
|
+
*/
|
|
259
|
+
function findPostgresQueryIdentifier (program) {
|
|
260
|
+
const identifiers = []
|
|
261
|
+
|
|
262
|
+
const imports = query(program, 'ImportDeclaration')
|
|
263
|
+
for (const declaration of imports) {
|
|
264
|
+
if (declaration.source.value !== './query.js') continue
|
|
265
|
+
|
|
266
|
+
for (const specifier of declaration.specifiers) {
|
|
267
|
+
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'Query') {
|
|
268
|
+
identifiers.push(specifier.local.name)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const declarations = query(program, 'VariableDeclarator[id.type="ObjectPattern"]')
|
|
274
|
+
for (const declaration of declarations) {
|
|
275
|
+
if (declaration.init?.type !== 'CallExpression' || declaration.init.callee.name !== 'require') continue
|
|
276
|
+
if (declaration.init.arguments[0]?.value !== './query.js') continue
|
|
277
|
+
|
|
278
|
+
for (const property of declaration.id.properties) {
|
|
279
|
+
if (property.type === 'Property' && property.key.name === 'Query' && property.value.type === 'Identifier') {
|
|
280
|
+
identifiers.push(property.value.name)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
assert(identifiers.length === 1, 'postgresQueryHandlers: Query import changed')
|
|
286
|
+
return identifiers[0]
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* @param {import('estree').Program} program
|
|
291
|
+
*/
|
|
292
|
+
function injectPostgresQueryRegistration (program) {
|
|
293
|
+
const queryClassIndex = program.body.findIndex(statement =>
|
|
294
|
+
statement.type === 'VariableDeclaration' &&
|
|
295
|
+
statement.declarations.some(({ id }) => id.type === 'Identifier' && id.name === 'Query') ||
|
|
296
|
+
statement.type === 'ExportNamedDeclaration' && statement.declaration?.type === 'ClassDeclaration' &&
|
|
297
|
+
statement.declaration.id?.name === 'Query'
|
|
298
|
+
)
|
|
299
|
+
assert(queryClassIndex !== -1, 'postgresQueryLifecycle: Query class changed')
|
|
300
|
+
|
|
301
|
+
const statements = parse(`
|
|
302
|
+
const ${POSTGRES_QUERY_REGISTRY_SYMBOL} = Symbol.for('dd-trace:postgres:query');
|
|
303
|
+
const ${POSTGRES_QUERY_REGISTRY} = globalThis[${POSTGRES_QUERY_REGISTRY_SYMBOL}] instanceof WeakSet
|
|
304
|
+
? globalThis[${POSTGRES_QUERY_REGISTRY_SYMBOL}]
|
|
305
|
+
: (globalThis[${POSTGRES_QUERY_REGISTRY_SYMBOL}] = new WeakSet());
|
|
306
|
+
${POSTGRES_QUERY_REGISTRY}.add(Query);
|
|
307
|
+
`).body
|
|
308
|
+
program.body.splice(queryClassIndex + 1, 0, ...statements)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @param {import('estree').AssignmentExpression} assignment
|
|
313
|
+
* @param {string} channelVariable
|
|
314
|
+
*/
|
|
315
|
+
function wrapPostgresResolution (assignment, channelVariable) {
|
|
316
|
+
const resolution = assignment.right
|
|
317
|
+
assert(
|
|
318
|
+
resolution.type === 'ArrowFunctionExpression' && resolution.body.type !== 'BlockStatement',
|
|
319
|
+
'postgresQueryLifecycle: resolve function changed'
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
const originalBody = resolution.body
|
|
323
|
+
const body = parse(`
|
|
324
|
+
function wrapper () {
|
|
325
|
+
if (${channelVariable}.asyncEnd.hasSubscribers && (!this.streaming || !this.active)) {
|
|
326
|
+
const statement = ${POSTGRES_STATEMENT};
|
|
327
|
+
${channelVariable}.asyncEnd.publish({ query: this, statement, pid: this.state?.pid });
|
|
328
|
+
}
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
`).body[0].body
|
|
332
|
+
resolution.body = body
|
|
333
|
+
resolution.expression = false
|
|
334
|
+
body.body.at(-1).argument = originalBody
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* @param {import('estree').AssignmentExpression} assignment
|
|
339
|
+
* @param {string} channelVariable
|
|
340
|
+
*/
|
|
341
|
+
function wrapPostgresRejection (assignment, channelVariable) {
|
|
342
|
+
const rejection = assignment.right
|
|
343
|
+
assert(
|
|
344
|
+
rejection.type === 'ArrowFunctionExpression' &&
|
|
345
|
+
rejection.body.type !== 'BlockStatement',
|
|
346
|
+
'postgresQueryLifecycle: reject function changed'
|
|
347
|
+
)
|
|
348
|
+
const errorParameter = rejection.params[0]
|
|
349
|
+
assert(errorParameter?.type === 'Identifier', 'postgresQueryLifecycle: reject parameter changed')
|
|
350
|
+
|
|
351
|
+
const originalBody = rejection.body
|
|
352
|
+
const body = parse(`
|
|
353
|
+
function wrapper () {
|
|
354
|
+
if (${channelVariable}.error.hasSubscribers || ${channelVariable}.asyncEnd.hasSubscribers) {
|
|
355
|
+
const statement = ${POSTGRES_STATEMENT};
|
|
356
|
+
const __ddTraceContext = { query: this, error: ${errorParameter.name}, statement, pid: this.state?.pid };
|
|
357
|
+
if (${channelVariable}.error.hasSubscribers) {
|
|
358
|
+
${channelVariable}.error.publish(__ddTraceContext);
|
|
359
|
+
}
|
|
360
|
+
if (${channelVariable}.asyncEnd.hasSubscribers) {
|
|
361
|
+
${channelVariable}.asyncEnd.publish(__ddTraceContext);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return undefined;
|
|
365
|
+
}
|
|
366
|
+
`).body[0].body
|
|
367
|
+
rejection.body = body
|
|
368
|
+
rejection.expression = false
|
|
369
|
+
body.body.at(-1).argument = originalBody
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @param {object} state
|
|
374
|
+
* @param {import('estree').Program} program
|
|
375
|
+
*/
|
|
376
|
+
function injectPostgresTracingChannel (state, program) {
|
|
377
|
+
state.transforms.tracingChannelDeclaration(state, program)
|
|
378
|
+
|
|
379
|
+
const channelName = `orchestrion:${state.module.name}:${state.channelName}`
|
|
380
|
+
const declarations = query(
|
|
381
|
+
program,
|
|
382
|
+
'VariableDeclarator[init.type="CallExpression"][init.callee.name="tr_ch_apm_tracingChannel"]'
|
|
383
|
+
).filter(({ init }) => init.arguments[0]?.value === channelName)
|
|
384
|
+
|
|
385
|
+
assert(declarations.length === 1, 'postgres: tracing channel declaration changed')
|
|
386
|
+
assert(declarations[0].id.type === 'Identifier', 'postgres: tracing channel identifier changed')
|
|
387
|
+
return declarations[0].id.name
|
|
388
|
+
}
|
|
@@ -41,7 +41,6 @@ module.exports = {
|
|
|
41
41
|
* @param {import('estree').FunctionExpression} node
|
|
42
42
|
* @param {import('estree').Node} _parent
|
|
43
43
|
* @param {import('estree').Node[]} ancestry
|
|
44
|
-
* @returns {void}
|
|
45
44
|
*/
|
|
46
45
|
function publishDurableOrchestrationFailure (state, node, _parent, ancestry) {
|
|
47
46
|
// Class queries also visit the owning ClassDeclaration so Orchestrion can
|
|
@@ -108,7 +107,6 @@ function publishDurableOrchestrationFailure (state, node, _parent, ancestry) {
|
|
|
108
107
|
* } node
|
|
109
108
|
* @param {import('estree').Node} _parent
|
|
110
109
|
* @param {import('estree').Node[]} ancestry
|
|
111
|
-
* @returns {void}
|
|
112
110
|
*/
|
|
113
111
|
function awaitContextCallback (state, node, _parent, ancestry) {
|
|
114
112
|
let insertionTarget
|
|
@@ -358,7 +356,6 @@ function replaceIdentifier (root, name, replacement) {
|
|
|
358
356
|
* @param {import('estree').Node} root
|
|
359
357
|
* @param {import('estree').Node} target
|
|
360
358
|
* @param {import('estree').Node[]} statements
|
|
361
|
-
* @returns {boolean}
|
|
362
359
|
*/
|
|
363
360
|
function insertBeforeStatement (root, target, statements) {
|
|
364
361
|
for (const key of Object.keys(root)) {
|
|
@@ -668,7 +665,6 @@ function configureMercuriusRequest (_state, node) {
|
|
|
668
665
|
*
|
|
669
666
|
* @param {object} _state
|
|
670
667
|
* @param {import('estree').CallExpression} node
|
|
671
|
-
* @returns {void}
|
|
672
668
|
*/
|
|
673
669
|
function waitForAsyncEnd (_state, node) {
|
|
674
670
|
const onFulfilled = node.arguments[0]
|
|
@@ -688,7 +684,6 @@ function waitForAsyncEnd (_state, node) {
|
|
|
688
684
|
* @param {import('estree').BlockStatement} body
|
|
689
685
|
* @param {'ReturnStatement'|'ThrowStatement'} exitType
|
|
690
686
|
* @param {'resolveCallback'|'rejectCallback'} callbackProperty
|
|
691
|
-
* @returns {void}
|
|
692
687
|
*/
|
|
693
688
|
function injectAsyncEndCallbackWait (body, exitType, callbackProperty) {
|
|
694
689
|
const callbackVariable = `__apm$${callbackProperty}`
|