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,122 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { storage } = require('../../datadog-core')
|
|
4
|
+
const log = require('../../dd-trace/src/log')
|
|
5
|
+
const DatabasePlugin = require('../../dd-trace/src/plugins/database')
|
|
6
|
+
const { extractPathFromUrl } = require('../../dd-trace/src/plugins/util/url')
|
|
7
|
+
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
8
|
+
const normalizeError = require('./error')
|
|
9
|
+
|
|
10
|
+
const spanFinished = Symbol('spanFinished')
|
|
11
|
+
|
|
12
|
+
const operationByMethod = {
|
|
13
|
+
DELETE: 'DELETE',
|
|
14
|
+
GET: 'SELECT',
|
|
15
|
+
HEAD: 'SELECT',
|
|
16
|
+
PATCH: 'UPDATE',
|
|
17
|
+
POST: 'INSERT',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {{
|
|
22
|
+
* arguments: { [index: number]: unknown, length: number, 0?: Function, 1?: Function },
|
|
23
|
+
* self: { method: string, url: URL, schema?: string },
|
|
24
|
+
* currentStore?: { span: import('../../..').Span },
|
|
25
|
+
* parentStore: import('../../datadog-core/src/storage').Store<unknown>,
|
|
26
|
+
* result?: { error?: Error | { message?: string } | null },
|
|
27
|
+
* error?: unknown
|
|
28
|
+
* } & Record<symbol, boolean | undefined>} PostgrestContext
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
function finishSafely (plugin, ctx, hasError = false) {
|
|
32
|
+
try {
|
|
33
|
+
if (hasError) plugin.error(ctx)
|
|
34
|
+
plugin.finish(ctx)
|
|
35
|
+
} catch (error) {
|
|
36
|
+
log.error('Error in plugin handler:', error)
|
|
37
|
+
log.info('Disabling plugin: %s', plugin.constructor.name)
|
|
38
|
+
plugin.configure(false)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class SupabasePostgrestBuilderThenPlugin extends DatabasePlugin {
|
|
43
|
+
static id = 'supabase'
|
|
44
|
+
static prefix = 'tracing:orchestrion:@supabase/postgrest-js:PostgrestBuilder_then'
|
|
45
|
+
|
|
46
|
+
/** @param {PostgrestContext} ctx */
|
|
47
|
+
bindStart (ctx) {
|
|
48
|
+
const method = ctx.self?.method
|
|
49
|
+
const requestUrl = ctx.self?.url
|
|
50
|
+
const url = stripQueryAndFragment(String(requestUrl))
|
|
51
|
+
const path = extractPathFromUrl(url)
|
|
52
|
+
const operation = path.includes('/rpc/') ? 'CALL' : operationByMethod[method] || method
|
|
53
|
+
const resource = `${operation} ${path.slice(path.lastIndexOf('/') + 1)}`
|
|
54
|
+
|
|
55
|
+
this.startSpan('supabase.database.query', {
|
|
56
|
+
service: { name: this.tracer._service },
|
|
57
|
+
type: 'sql',
|
|
58
|
+
resource,
|
|
59
|
+
meta: {
|
|
60
|
+
component: 'supabase',
|
|
61
|
+
'span.kind': 'client',
|
|
62
|
+
'db.type': 'postgres',
|
|
63
|
+
'db.name': ctx.self?.schema || 'public',
|
|
64
|
+
'db.operation': operation,
|
|
65
|
+
'out.host': requestUrl?.hostname,
|
|
66
|
+
},
|
|
67
|
+
}, ctx)
|
|
68
|
+
|
|
69
|
+
// PostgrestBuilder.then owns both the request and consumer callbacks. Finish the request span and
|
|
70
|
+
// restore its parent before invoking a callback so application failures and latency stay outside it.
|
|
71
|
+
const onFulfilled = ctx.arguments?.[0]
|
|
72
|
+
if (typeof onFulfilled === 'function') {
|
|
73
|
+
const plugin = this
|
|
74
|
+
ctx.arguments[0] = function (result) {
|
|
75
|
+
ctx.result = result
|
|
76
|
+
finishSafely(plugin, ctx)
|
|
77
|
+
return storage('legacy').run(ctx.parentStore, () => onFulfilled.apply(this, arguments))
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const onRejected = ctx.arguments?.[1]
|
|
82
|
+
if (typeof onRejected === 'function') {
|
|
83
|
+
const plugin = this
|
|
84
|
+
ctx.arguments[1] = function (error) {
|
|
85
|
+
ctx.error = error
|
|
86
|
+
finishSafely(plugin, ctx, true)
|
|
87
|
+
return storage('legacy').run(ctx.parentStore, () => onRejected.apply(this, arguments))
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return ctx.currentStore
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** @param {PostgrestContext} ctx */
|
|
95
|
+
asyncEnd (ctx) {
|
|
96
|
+
this.finish(ctx)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** @param {PostgrestContext} ctx */
|
|
100
|
+
error (ctx) {
|
|
101
|
+
if (ctx[spanFinished]) return
|
|
102
|
+
super.error(ctx)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// You may modify this method, but the guard below is REQUIRED and MUST NOT be removed!
|
|
106
|
+
/** @param {PostgrestContext} ctx */
|
|
107
|
+
finish (ctx) {
|
|
108
|
+
// CRITICAL GUARD - DO NOT REMOVE: Ensures span only finishes when operation completes
|
|
109
|
+
if (ctx[spanFinished] || !ctx.hasOwnProperty('result') && !ctx.hasOwnProperty('error')) return
|
|
110
|
+
|
|
111
|
+
const error = normalizeError(ctx.result?.error, 'PostgrestError')
|
|
112
|
+
if (error) {
|
|
113
|
+
ctx.error = error
|
|
114
|
+
super.error(ctx)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
ctx[spanFinished] = true
|
|
118
|
+
super.finish(ctx)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = SupabasePostgrestBuilderThenPlugin
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
|
|
4
|
+
const normalizeError = require('./error')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {{
|
|
8
|
+
* self: { subTopic: string },
|
|
9
|
+
* currentStore?: { span: import('../../..').Span },
|
|
10
|
+
* result?: 'ok' | 'error' | 'timed out',
|
|
11
|
+
* error?: unknown
|
|
12
|
+
* }} RealtimeContext
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
class SupabaseRealtimeChannelSendPlugin extends ProducerPlugin {
|
|
16
|
+
static id = 'supabase'
|
|
17
|
+
static prefix = 'tracing:orchestrion:@supabase/realtime-js:RealtimeChannel_send'
|
|
18
|
+
static peerServicePrecursors = ['messaging.destination.name']
|
|
19
|
+
|
|
20
|
+
/** @param {RealtimeContext} ctx */
|
|
21
|
+
bindStart (ctx) {
|
|
22
|
+
const destination = ctx.self?.subTopic
|
|
23
|
+
|
|
24
|
+
this.startSpan({
|
|
25
|
+
service: { name: this.tracer._service },
|
|
26
|
+
type: 'messaging',
|
|
27
|
+
resource: destination,
|
|
28
|
+
meta: {
|
|
29
|
+
component: 'supabase',
|
|
30
|
+
'span.kind': 'producer',
|
|
31
|
+
'messaging.system': 'supabase',
|
|
32
|
+
'messaging.destination.name': destination,
|
|
33
|
+
'messaging.destination.kind': 'topic',
|
|
34
|
+
'messaging.operation': 'send',
|
|
35
|
+
},
|
|
36
|
+
}, ctx)
|
|
37
|
+
|
|
38
|
+
return ctx.currentStore
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
operationName () {
|
|
42
|
+
return 'supabase.messaging.send'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @param {RealtimeContext} ctx */
|
|
46
|
+
asyncEnd (ctx) {
|
|
47
|
+
this.finish(ctx)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// You may modify this method, but the guard below is REQUIRED and MUST NOT be removed!
|
|
51
|
+
/** @param {RealtimeContext} ctx */
|
|
52
|
+
finish (ctx) {
|
|
53
|
+
// CRITICAL GUARD - DO NOT REMOVE: Ensures span only finishes when operation completes
|
|
54
|
+
if (!ctx.hasOwnProperty('result') && !ctx.hasOwnProperty('error')) return
|
|
55
|
+
|
|
56
|
+
const result = ctx.result
|
|
57
|
+
if (result === 'error' || result === 'timed out') {
|
|
58
|
+
ctx.error = normalizeError(result, 'RealtimeSendError', `Realtime send returned ${result}`)
|
|
59
|
+
super.error(ctx)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
super.finish(ctx)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = SupabaseRealtimeChannelSendPlugin
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const StoragePlugin = require('../../dd-trace/src/plugins/storage')
|
|
4
|
+
const { extractPathFromUrl } = require('../../dd-trace/src/plugins/util/url')
|
|
5
|
+
const { stripQueryAndFragment } = require('../../dd-trace/src/util')
|
|
6
|
+
const getHostname = require('./url')
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {{
|
|
10
|
+
* arguments: { [index: number]: unknown, length: number, 1: string, 2: string | URL },
|
|
11
|
+
* currentStore?: { span: import('../../..').Span },
|
|
12
|
+
* result?: unknown,
|
|
13
|
+
* error?: Error & { status?: number }
|
|
14
|
+
* }} StorageContext
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const storageRoutes = [
|
|
18
|
+
'object/upload/sign',
|
|
19
|
+
'object/list-v2',
|
|
20
|
+
'object/list',
|
|
21
|
+
'object/sign',
|
|
22
|
+
'object/info',
|
|
23
|
+
'object/copy',
|
|
24
|
+
'object/move',
|
|
25
|
+
'render/image',
|
|
26
|
+
'bucket',
|
|
27
|
+
'object',
|
|
28
|
+
'cdn',
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns a low-cardinality storage route for a request URL.
|
|
33
|
+
*
|
|
34
|
+
* @param {string|URL} url Request URL.
|
|
35
|
+
*/
|
|
36
|
+
function getStorageRoute (url) {
|
|
37
|
+
const path = extractPathFromUrl(stripQueryAndFragment(String(url)))
|
|
38
|
+
const marker = '/storage/v1/'
|
|
39
|
+
const markerIndex = path.indexOf(marker)
|
|
40
|
+
const storagePath = markerIndex === -1 ? path.replace(/^\/+/, '') : path.slice(markerIndex + marker.length)
|
|
41
|
+
|
|
42
|
+
for (const route of storageRoutes) {
|
|
43
|
+
if (storagePath === route || storagePath.startsWith(`${route}/`)) return route
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return 'storage'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class SupabaseStorageHandleRequestPlugin extends StoragePlugin {
|
|
50
|
+
static id = 'supabase'
|
|
51
|
+
static prefix = 'tracing:orchestrion:@supabase/storage-js:handleRequest'
|
|
52
|
+
|
|
53
|
+
/** @param {StorageContext} ctx */
|
|
54
|
+
bindStart (ctx) {
|
|
55
|
+
const method = String(ctx.arguments?.[1] || 'GET').toUpperCase()
|
|
56
|
+
const url = ctx.arguments?.[2]
|
|
57
|
+
|
|
58
|
+
this.startSpan('supabase.storage.request', {
|
|
59
|
+
service: { name: this.tracer._service },
|
|
60
|
+
type: 'storage',
|
|
61
|
+
resource: `${method} ${getStorageRoute(url)}`,
|
|
62
|
+
meta: {
|
|
63
|
+
component: 'supabase',
|
|
64
|
+
'span.kind': 'client',
|
|
65
|
+
'http.method': method,
|
|
66
|
+
'http.url': stripQueryAndFragment(String(url)),
|
|
67
|
+
'out.host': getHostname(url),
|
|
68
|
+
},
|
|
69
|
+
}, ctx)
|
|
70
|
+
|
|
71
|
+
return ctx.currentStore
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** @param {StorageContext} ctx */
|
|
75
|
+
error (ctx) {
|
|
76
|
+
const status = ctx.error?.status
|
|
77
|
+
if (status) ctx.currentStore?.span.setTag('http.status_code', status)
|
|
78
|
+
super.error(ctx)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** @param {StorageContext} ctx */
|
|
82
|
+
asyncEnd (ctx) {
|
|
83
|
+
this.finish(ctx)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** @param {StorageContext} ctx */
|
|
87
|
+
finish (ctx) {
|
|
88
|
+
if (!ctx.hasOwnProperty('result') && !ctx.hasOwnProperty('error')) return
|
|
89
|
+
super.finish(ctx)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = SupabaseStorageHandleRequestPlugin
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { URL } = require('node:url')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Extracts a hostname without allowing malformed SDK input to break instrumentation.
|
|
7
|
+
*
|
|
8
|
+
* @param {string|URL} url Request URL.
|
|
9
|
+
* @returns {string|undefined} Parsed hostname.
|
|
10
|
+
*/
|
|
11
|
+
function getHostname (url) {
|
|
12
|
+
try {
|
|
13
|
+
return new URL(url).hostname
|
|
14
|
+
} catch {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = getHostname
|
|
@@ -44,6 +44,7 @@ const {
|
|
|
44
44
|
TEST_ITR_UNSKIPPABLE,
|
|
45
45
|
TEST_ITR_FORCED_RUN,
|
|
46
46
|
ITR_CORRELATION_ID,
|
|
47
|
+
setExpectedEmptyTestSessionTags,
|
|
47
48
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
48
49
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
49
50
|
const id = require('../../dd-trace/src/id')
|
|
@@ -579,6 +580,7 @@ class VitestPlugin extends CiPlugin {
|
|
|
579
580
|
requestErrorTags,
|
|
580
581
|
vitestPool,
|
|
581
582
|
isVitestNoWorkerInitActive,
|
|
583
|
+
testSessionEmptyReason,
|
|
582
584
|
onDone,
|
|
583
585
|
}) => {
|
|
584
586
|
for (const [tag, value] of Object.entries(requestErrorTags)) {
|
|
@@ -587,6 +589,13 @@ class VitestPlugin extends CiPlugin {
|
|
|
587
589
|
}
|
|
588
590
|
this.testSessionSpan.setTag(TEST_STATUS, status)
|
|
589
591
|
this.testModuleSpan.setTag(TEST_STATUS, status)
|
|
592
|
+
if (testSessionEmptyReason) {
|
|
593
|
+
setExpectedEmptyTestSessionTags(
|
|
594
|
+
this.testSessionSpan,
|
|
595
|
+
this.testModuleSpan,
|
|
596
|
+
testSessionEmptyReason
|
|
597
|
+
)
|
|
598
|
+
}
|
|
590
599
|
if (error) {
|
|
591
600
|
this.testModuleSpan.setTag('error', error)
|
|
592
601
|
this.testSessionSpan.setTag('error', error)
|
|
@@ -21,7 +21,7 @@ class WSProducerPlugin extends TracingPlugin {
|
|
|
21
21
|
|
|
22
22
|
bindStart (ctx) {
|
|
23
23
|
const { byteLength, socket, binary } = ctx
|
|
24
|
-
if (!socket
|
|
24
|
+
if (!socket?.spanContext) return
|
|
25
25
|
|
|
26
26
|
const spanTags = socket.spanTags
|
|
27
27
|
const path = getSegment(spanTags['resource.name'], ' ', 1)
|
|
@@ -36,7 +36,6 @@ function createWebSocketSpanContext (spanContext) {
|
|
|
36
36
|
/**
|
|
37
37
|
* Returns whether distributed trace headers are present.
|
|
38
38
|
* @param {Record<string, string | string[] | undefined>} headers
|
|
39
|
-
* @returns {boolean}
|
|
40
39
|
*/
|
|
41
40
|
function hasTraceHeaders (headers) {
|
|
42
41
|
return !!(headers && (readDatadogTraceId(headers) || readTraceparent(headers)))
|
|
@@ -59,7 +58,6 @@ function initWebSocketMessageCounters (socket) {
|
|
|
59
58
|
* Increments and returns the WebSocket message counter.
|
|
60
59
|
* @param {object} socket - The WebSocket socket object
|
|
61
60
|
* @param {string} counterType - Either 'receiveCounter' or 'sendCounter'
|
|
62
|
-
* @returns {number} The incremented counter value
|
|
63
61
|
*/
|
|
64
62
|
function incrementWebSocketCounter (socket, counterType) {
|
|
65
63
|
if (!socketCounters.has(socket)) {
|
|
@@ -81,7 +79,6 @@ function incrementWebSocketCounter (socket, counterType) {
|
|
|
81
79
|
* @param {number} counter - The message counter
|
|
82
80
|
* @param {boolean} isServer - Whether this is a server (true) or client (false)
|
|
83
81
|
* @param {boolean} isIncoming - Whether this is an incoming message (true) or outgoing (false)
|
|
84
|
-
* @returns {string} The span pointer hash
|
|
85
82
|
*/
|
|
86
83
|
function buildWebSocketSpanPointerHash (handshakeTraceId, handshakeSpanId, counter, isServer, isIncoming) {
|
|
87
84
|
// Determine prefix based on server/client and incoming/outgoing
|
|
@@ -110,7 +107,6 @@ function buildWebSocketSpanPointerHash (handshakeTraceId, handshakeSpanId, count
|
|
|
110
107
|
*
|
|
111
108
|
* @param {DatadogSpanContext} spanContext - The handshake span context
|
|
112
109
|
* @param {{ hasTraceHeaders?: boolean } | undefined} socket - The WebSocket socket object
|
|
113
|
-
* @returns {boolean} True if the span has distributed tracing context
|
|
114
110
|
*/
|
|
115
111
|
function hasDistributedTracingContext (spanContext, socket) {
|
|
116
112
|
if (!spanContext) return false
|
|
@@ -53,8 +53,15 @@ function copyProperties (original, wrapped) {
|
|
|
53
53
|
const descriptor = /** @type {Descriptor} */ (Object.getOwnPropertyDescriptor(original, key))
|
|
54
54
|
if (descriptor.writable && descriptor.enumerable && descriptor.configurable) {
|
|
55
55
|
wrapped[key] = original[key]
|
|
56
|
-
} else
|
|
57
|
-
|
|
56
|
+
} else {
|
|
57
|
+
try {
|
|
58
|
+
Object.defineProperty(wrapped, key, descriptor)
|
|
59
|
+
} catch (error) {
|
|
60
|
+
const wrappedDescriptor = Object.getOwnPropertyDescriptor(wrapped, key)
|
|
61
|
+
if (wrappedDescriptor?.configurable !== false || wrappedDescriptor.writable) {
|
|
62
|
+
throw error
|
|
63
|
+
}
|
|
64
|
+
}
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
}
|
|
@@ -320,19 +327,16 @@ function assertMethod (target, name, method) {
|
|
|
320
327
|
}
|
|
321
328
|
|
|
322
329
|
/**
|
|
323
|
-
* Asserts that a target is not
|
|
330
|
+
* Asserts that a target is not an identifiable class constructor.
|
|
324
331
|
*
|
|
325
332
|
* @param {Function} target - The target function.
|
|
326
|
-
* @throws {
|
|
333
|
+
* @throws {TypeError} If the target is an identifiable class constructor.
|
|
327
334
|
*/
|
|
328
335
|
function assertNotClass (target) {
|
|
329
|
-
//
|
|
330
|
-
// writable one and arrows / async / method-shorthand have none at all. The
|
|
331
|
-
// `'prototype' in target` gate skips the descriptor lookup for the no-prototype
|
|
332
|
-
// shapes; the `in` operator is cheaper than reading `target.prototype` since
|
|
333
|
-
// it returns a boolean instead of materialising the prototype reference.
|
|
336
|
+
// Frozen functions also have a non-writable `prototype`; inspect their source only then.
|
|
334
337
|
if ('prototype' in target &&
|
|
335
|
-
Object.getOwnPropertyDescriptor(target, 'prototype').writable === false
|
|
338
|
+
Object.getOwnPropertyDescriptor(target, 'prototype').writable === false &&
|
|
339
|
+
(!Object.isFrozen(target) || Function.prototype.toString.call(target).startsWith('class'))) {
|
|
336
340
|
throw new TypeError('Target is a native class constructor and cannot be wrapped.')
|
|
337
341
|
}
|
|
338
342
|
}
|
|
@@ -6,6 +6,7 @@ const path = require('node:path')
|
|
|
6
6
|
|
|
7
7
|
const satisfies = require('../../vendor/dist/semifies')
|
|
8
8
|
const hooks = require('../datadog-instrumentations/src/helpers/hooks')
|
|
9
|
+
const { getRewriteTargetNames } = require('../datadog-instrumentations/src/helpers/rewriter/targets')
|
|
9
10
|
const { SYNTHETIC_EXTENSION } = require('./src/constants')
|
|
10
11
|
|
|
11
12
|
const BUILTIN_MODULES = new Set(Module.builtinModules)
|
|
@@ -74,7 +75,6 @@ function normalizeConfig (config) {
|
|
|
74
75
|
|
|
75
76
|
/**
|
|
76
77
|
* @param {unknown} value
|
|
77
|
-
* @returns {boolean}
|
|
78
78
|
*/
|
|
79
79
|
function isObject (value) {
|
|
80
80
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value)
|
|
@@ -146,7 +146,6 @@ function createLoader () {
|
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
* @param {unknown} value
|
|
149
|
-
* @returns {boolean}
|
|
150
149
|
*/
|
|
151
150
|
function hasDatadogLoader (value) {
|
|
152
151
|
if (Array.isArray(value)) return value.some(hasDatadogLoader)
|
|
@@ -160,7 +159,9 @@ function hasDatadogLoader (value) {
|
|
|
160
159
|
*/
|
|
161
160
|
function createPackagePathPattern () {
|
|
162
161
|
const names = []
|
|
163
|
-
|
|
162
|
+
const targetPackages = new Set(Object.keys(hooks))
|
|
163
|
+
for (const name of getRewriteTargetNames()) targetPackages.add(name)
|
|
164
|
+
for (const name of targetPackages) {
|
|
164
165
|
if (!name.startsWith('.') && !BUILTIN_MODULES.has(name)) names.push(escapeRegExp(name))
|
|
165
166
|
}
|
|
166
167
|
names.sort()
|
|
@@ -169,15 +170,11 @@ function createPackagePathPattern () {
|
|
|
169
170
|
|
|
170
171
|
/**
|
|
171
172
|
* @param {string} value
|
|
172
|
-
* @returns {string}
|
|
173
173
|
*/
|
|
174
174
|
function escapeRegExp (value) {
|
|
175
175
|
return value.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
/**
|
|
179
|
-
* @returns {number}
|
|
180
|
-
*/
|
|
181
178
|
function getNextMajor () {
|
|
182
179
|
const entrypoints = []
|
|
183
180
|
if (require.main?.filename) entrypoints.push(require.main.filename)
|
|
@@ -11,7 +11,10 @@ const hooks = require('../../datadog-instrumentations/src/helpers/hooks')
|
|
|
11
11
|
const instrumentations = require('../../datadog-instrumentations/src/helpers/instrumentations')
|
|
12
12
|
const { filename, matchesInstrumentation } = require('../../datadog-instrumentations/src/helpers/instrumentation-utils')
|
|
13
13
|
const { createBundlerRewriter } = require('../../datadog-instrumentations/src/helpers/rewriter')
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
getRewriteTarget,
|
|
16
|
+
getRewriteTargetNames,
|
|
17
|
+
} = require('../../datadog-instrumentations/src/helpers/rewriter/targets')
|
|
15
18
|
const { isESMFile } = require('../../datadog-esbuild/src/utils')
|
|
16
19
|
const { SYNTHETIC_EXTENSION } = require('./constants')
|
|
17
20
|
|
|
@@ -21,6 +24,7 @@ const MODULE_BINDING = 2
|
|
|
21
24
|
const REQUIRE_BINDING = 4
|
|
22
25
|
const COMMONJS_BINDINGS = MODULE_BINDING | REQUIRE_BINDING
|
|
23
26
|
const targetPackages = new Set(Object.keys(hooks))
|
|
27
|
+
for (const name of getRewriteTargetNames()) targetPackages.add(name)
|
|
24
28
|
const entrypoints = new Map()
|
|
25
29
|
const loadedHooks = new Set()
|
|
26
30
|
const packageCache = new Map()
|
|
@@ -98,7 +102,7 @@ module.exports = function loader (source, inputSourceMap) {
|
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
if (publications.length > 0) code = appendCommonJsPublications(code, publications, dcModule)
|
|
101
|
-
if (rewritten && publications.length === 0) {
|
|
105
|
+
if (rewritten && publications.length === 0 && (rewriteTarget.activate || hooks[rewriteTarget.moduleName])) {
|
|
102
106
|
if (!esm && hasUnsafeCommonJsBindings(code)) {
|
|
103
107
|
this.emitWarning?.(new Error(`Skipped CommonJS activation for unsafe wrapper bindings in ${resourcePath}`))
|
|
104
108
|
this.callback(undefined, source, inputSourceMap)
|
|
@@ -120,7 +124,6 @@ module.exports = function loader (source, inputSourceMap) {
|
|
|
120
124
|
|
|
121
125
|
/**
|
|
122
126
|
* @param {LoaderContext} context
|
|
123
|
-
* @returns {string}
|
|
124
127
|
*/
|
|
125
128
|
function getResourcePath (context) {
|
|
126
129
|
const { resourcePath } = context
|
|
@@ -185,7 +188,6 @@ function getPublications (resourcePath, packageInfo) {
|
|
|
185
188
|
/**
|
|
186
189
|
* @param {string} name
|
|
187
190
|
* @param {string} packageJsonPath
|
|
188
|
-
* @returns {string}
|
|
189
191
|
*/
|
|
190
192
|
function getCommonJsEntrypoint (name, packageJsonPath) {
|
|
191
193
|
const cached = entrypoints.get(packageJsonPath)
|
|
@@ -228,7 +230,6 @@ function getRewriter (dcModule) {
|
|
|
228
230
|
|
|
229
231
|
/**
|
|
230
232
|
* @param {string} source
|
|
231
|
-
* @returns {boolean}
|
|
232
233
|
*/
|
|
233
234
|
function hasUnsafeCommonJsBindings (source) {
|
|
234
235
|
try {
|
|
@@ -248,7 +249,6 @@ function hasUnsafeCommonJsBindings (source) {
|
|
|
248
249
|
* @param {number} shadowedBindings
|
|
249
250
|
* @param {object} [parent]
|
|
250
251
|
* @param {string} [parentKey]
|
|
251
|
-
* @returns {boolean}
|
|
252
252
|
*/
|
|
253
253
|
function hasUnsafeNode (node, functionDepth, shadowedBindings, parent, parentKey) {
|
|
254
254
|
if (functionDepth === 0 && hasCommonJsDeclaration(node, parent)) return true
|
|
@@ -286,7 +286,6 @@ function hasUnsafeNode (node, functionDepth, shadowedBindings, parent, parentKey
|
|
|
286
286
|
/**
|
|
287
287
|
* @param {object} node
|
|
288
288
|
* @param {object} [parent]
|
|
289
|
-
* @returns {boolean}
|
|
290
289
|
*/
|
|
291
290
|
function hasCommonJsDeclaration (node, parent) {
|
|
292
291
|
if (node.type === 'VariableDeclarator') {
|
|
@@ -301,7 +300,6 @@ function hasCommonJsDeclaration (node, parent) {
|
|
|
301
300
|
/**
|
|
302
301
|
* @param {object} node
|
|
303
302
|
* @param {number} shadowedBindings
|
|
304
|
-
* @returns {boolean}
|
|
305
303
|
*/
|
|
306
304
|
function mutatesCommonJsBinding (node, shadowedBindings) {
|
|
307
305
|
return Boolean(getBindingMask(node) & COMMONJS_BINDINGS & ~shadowedBindings)
|
|
@@ -309,7 +307,6 @@ function mutatesCommonJsBinding (node, shadowedBindings) {
|
|
|
309
307
|
|
|
310
308
|
/**
|
|
311
309
|
* @param {object} node
|
|
312
|
-
* @returns {number}
|
|
313
310
|
*/
|
|
314
311
|
function getBindingMask (node) {
|
|
315
312
|
if (!node) return 0
|
|
@@ -337,7 +334,6 @@ function getBindingMask (node) {
|
|
|
337
334
|
|
|
338
335
|
/**
|
|
339
336
|
* @param {object} node
|
|
340
|
-
* @returns {number}
|
|
341
337
|
*/
|
|
342
338
|
function getFunctionBindings (node) {
|
|
343
339
|
let bindings = node.type === 'ArrowFunctionExpression' ? 0 : ARGUMENTS_BINDING
|
|
@@ -348,7 +344,6 @@ function getFunctionBindings (node) {
|
|
|
348
344
|
|
|
349
345
|
/**
|
|
350
346
|
* @param {object} node
|
|
351
|
-
* @returns {number}
|
|
352
347
|
*/
|
|
353
348
|
function getVarBindings (node) {
|
|
354
349
|
if (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionDeclaration' ||
|
|
@@ -373,7 +368,6 @@ function getVarBindings (node) {
|
|
|
373
368
|
|
|
374
369
|
/**
|
|
375
370
|
* @param {object} node
|
|
376
|
-
* @returns {number}
|
|
377
371
|
*/
|
|
378
372
|
function getLexicalBindings (node) {
|
|
379
373
|
let bindings = 0
|
|
@@ -397,7 +391,6 @@ function getLexicalBindings (node) {
|
|
|
397
391
|
|
|
398
392
|
/**
|
|
399
393
|
* @param {object} node
|
|
400
|
-
* @returns {number}
|
|
401
394
|
*/
|
|
402
395
|
function getStatementBindings (node) {
|
|
403
396
|
if (node.type === 'VariableDeclaration') return getLexicalDeclarationBindings(node)
|
|
@@ -407,7 +400,6 @@ function getStatementBindings (node) {
|
|
|
407
400
|
|
|
408
401
|
/**
|
|
409
402
|
* @param {object} [node]
|
|
410
|
-
* @returns {number}
|
|
411
403
|
*/
|
|
412
404
|
function getLexicalDeclarationBindings (node) {
|
|
413
405
|
if (node?.type !== 'VariableDeclaration' || node.kind === 'var') return 0
|
|
@@ -419,7 +411,6 @@ function getLexicalDeclarationBindings (node) {
|
|
|
419
411
|
/**
|
|
420
412
|
* @param {object} parent
|
|
421
413
|
* @param {string} parentKey
|
|
422
|
-
* @returns {boolean}
|
|
423
414
|
*/
|
|
424
415
|
function isReferencedIdentifier (parent, parentKey) {
|
|
425
416
|
if (parent.type === 'MemberExpression' && parentKey === 'property' && !parent.computed) return false
|
|
@@ -434,7 +425,6 @@ function isReferencedIdentifier (parent, parentKey) {
|
|
|
434
425
|
* @param {string} source
|
|
435
426
|
* @param {Array<{ package: string, path: string, version: string }>} payloads
|
|
436
427
|
* @param {string} dcModule
|
|
437
|
-
* @returns {string}
|
|
438
428
|
*/
|
|
439
429
|
function appendCommonJsPublications (source, payloads, dcModule) {
|
|
440
430
|
let publications = ''
|
|
@@ -466,7 +456,6 @@ ${publications} }
|
|
|
466
456
|
* @param {{ package: string, path: string, version: string }} payload
|
|
467
457
|
* @param {string} dcModule
|
|
468
458
|
* @param {boolean} esm
|
|
469
|
-
* @returns {string}
|
|
470
459
|
*/
|
|
471
460
|
function appendActivation (source, payload, dcModule, esm) {
|
|
472
461
|
if (esm) {
|
|
@@ -491,7 +480,6 @@ import ddTraceTurbopackDc from ${JSON.stringify(dcModule)}
|
|
|
491
480
|
/**
|
|
492
481
|
* @param {string} from
|
|
493
482
|
* @param {string} to
|
|
494
|
-
* @returns {string}
|
|
495
483
|
*/
|
|
496
484
|
function relativeImport (from, to) {
|
|
497
485
|
let value = path.relative(from, to).replaceAll('\\', '/')
|
|
@@ -17,21 +17,22 @@ module.exports = {
|
|
|
17
17
|
* Fetches agent information from the /info endpoint
|
|
18
18
|
* @param {URL} url - The agent URL
|
|
19
19
|
* @param {Function} callback - Callback function with signature (err, agentInfo)
|
|
20
|
-
* @param {{ deadline?: number, signal?: AbortSignal }} [options]
|
|
20
|
+
* @param {{ deadline?: number, signal?: AbortSignal, path?: string, retry?: boolean }} [options]
|
|
21
|
+
* Request finalization and routing options
|
|
21
22
|
* @param {Function} [makeRequest] - Request implementation
|
|
22
23
|
*/
|
|
23
24
|
function fetchAgentInfo (url, callback, options = {}, makeRequest = request) {
|
|
24
|
-
const urlKey = url.href
|
|
25
|
+
const urlKey = JSON.stringify([url.href, options.path ?? '/info'])
|
|
25
26
|
|
|
26
27
|
if (cachedUrl !== null && cachedUrl !== urlKey) {
|
|
27
|
-
//
|
|
28
|
+
// Different consumers may query different paths on the same Agent URL.
|
|
28
29
|
clearCache()
|
|
29
30
|
} else if (cachedData !== null && (Date.now() - cachedTimestamp) < CACHE_TTL_MS) {
|
|
30
31
|
// Return cached result if still valid
|
|
31
32
|
return process.nextTick(callback, null, cachedData)
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
options.path
|
|
35
|
+
options.path ??= '/info'
|
|
35
36
|
options.url = url
|
|
36
37
|
makeRequest('', options, (err, res) => {
|
|
37
38
|
if (err) {
|
|
@@ -9,7 +9,6 @@ const TAGS = require('./tags')
|
|
|
9
9
|
* Resolves the AI Guard host for a Datadog site.
|
|
10
10
|
*
|
|
11
11
|
* @param {string} site
|
|
12
|
-
* @returns {string}
|
|
13
12
|
*/
|
|
14
13
|
function aiGuardHost (site) {
|
|
15
14
|
return site.split('.').length === 2 ? `app.${site}` : site
|
|
@@ -60,9 +59,9 @@ class AIGuardClient {
|
|
|
60
59
|
'DD-AI-GUARD-SOURCE': 'SDK',
|
|
61
60
|
'DD-AI-GUARD-LANGUAGE': 'nodejs',
|
|
62
61
|
}
|
|
63
|
-
const endpoint = config.
|
|
62
|
+
const endpoint = config.aiguard.DD_AI_GUARD_ENDPOINT || `https://${aiGuardHost(config.site)}/api/v2/ai-guard`
|
|
64
63
|
this.#evaluateUrl = `${endpoint}/evaluate`
|
|
65
|
-
this.#timeout = config.
|
|
64
|
+
this.#timeout = config.aiguard.DD_AI_GUARD_TIMEOUT
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
/**
|