dd-trace 6.16.0 → 6.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ci/diagnose.js +0 -23
- package/ci/test-optimization-validation/approval-artifacts.js +0 -3
- package/ci/test-optimization-validation/approval.js +0 -6
- package/ci/test-optimization-validation/artifact-id.js +0 -1
- package/ci/test-optimization-validation/bounded-json.js +0 -1
- package/ci/test-optimization-validation/cli.js +0 -12
- package/ci/test-optimization-validation/command-output-policy.js +0 -1
- package/ci/test-optimization-validation/command-runner.js +0 -3
- package/ci/test-optimization-validation/environment.js +0 -4
- package/ci/test-optimization-validation/executable-approval.js +0 -1
- package/ci/test-optimization-validation/executable.js +0 -5
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -6
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -3
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -6
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -4
- package/ci/test-optimization-validation/generated-test-contract.js +0 -5
- package/ci/test-optimization-validation/generated-verifier.js +0 -1
- package/ci/test-optimization-validation/literal-environment.js +0 -1
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -17
- package/ci/test-optimization-validation/manifest-schema.js +0 -21
- package/ci/test-optimization-validation/offline-fixtures.js +0 -4
- package/ci/test-optimization-validation/plan-writer.js +0 -11
- package/ci/test-optimization-validation/preflight-runner.js +0 -1
- package/ci/test-optimization-validation/redaction.js +0 -4
- package/ci/test-optimization-validation/report-writer.js +0 -16
- package/ci/test-optimization-validation/runner-command.js +0 -3
- package/ci/test-optimization-validation/runner-contract.js +0 -4
- package/ci/test-optimization-validation/safe-files.js +0 -1
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -1
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -1
- package/ci/test-optimization-validation/source-text.js +0 -3
- package/ci/vitest-no-worker-init-setup.mjs +41 -16
- package/index.d.ts +165 -0
- package/package.json +17 -16
- package/packages/datadog-esbuild/src/utils.js +0 -2
- package/packages/datadog-instrumentations/src/aerospike.js +28 -6
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +0 -2
- package/packages/datadog-instrumentations/src/aws-sdk.js +0 -2
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +0 -2
- package/packages/datadog-instrumentations/src/console.js +97 -0
- package/packages/datadog-instrumentations/src/cucumber.js +72 -12
- package/packages/datadog-instrumentations/src/cypress-config.js +0 -23
- package/packages/datadog-instrumentations/src/helpers/channel.js +0 -2
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +0 -5
- package/packages/datadog-instrumentations/src/helpers/hooks.js +8 -0
- package/packages/datadog-instrumentations/src/helpers/instrumentation-utils.js +0 -3
- package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +0 -6
- package/packages/datadog-instrumentations/src/helpers/register.js +4 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +72 -24
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +39 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +3 -17
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +36 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/supabase.js +128 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +16 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +388 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +0 -5
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +0 -1
- package/packages/datadog-instrumentations/src/jest.js +141 -51
- package/packages/datadog-instrumentations/src/knex.js +0 -1
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +0 -24
- package/packages/datadog-instrumentations/src/mariadb.js +0 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +0 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +22 -25
- package/packages/datadog-instrumentations/src/mocha/utils.js +119 -49
- package/packages/datadog-instrumentations/src/mocha/webdriverio-protocol.js +0 -6
- package/packages/datadog-instrumentations/src/mocha/worker.js +14 -17
- package/packages/datadog-instrumentations/src/mysql2.js +0 -2
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +241 -0
- package/packages/datadog-instrumentations/src/openai-realtime/events.js +76 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +301 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +998 -0
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +211 -0
- package/packages/datadog-instrumentations/src/openai.js +51 -12
- package/packages/datadog-instrumentations/src/oracledb.js +9 -3
- package/packages/datadog-instrumentations/src/playwright-reporter.js +3 -16
- package/packages/datadog-instrumentations/src/playwright.js +238 -55
- package/packages/datadog-instrumentations/src/postgres.js +7 -0
- package/packages/datadog-instrumentations/src/router.js +0 -2
- package/packages/datadog-instrumentations/src/rum-browser-scripts.js +0 -2
- package/packages/datadog-instrumentations/src/sequelize.js +0 -1
- package/packages/datadog-instrumentations/src/supabase.js +15 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +18 -18
- package/packages/datadog-instrumentations/src/vitest-main.js +37 -17
- package/packages/datadog-instrumentations/src/vitest-util.js +7 -1
- package/packages/datadog-instrumentations/src/vitest-worker.js +49 -13
- package/packages/datadog-instrumentations/src/webdriverio.js +23 -42
- package/packages/datadog-instrumentations/src/ws.js +0 -1
- package/packages/datadog-plugin-ai/src/utils.js +0 -2
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +0 -1
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +0 -2
- package/packages/datadog-plugin-aws-sdk/src/base.js +0 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +0 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +0 -1
- package/packages/datadog-plugin-aws-sdk/src/util.js +0 -1
- package/packages/datadog-plugin-azure-durable-functions/src/index.js +0 -1
- package/packages/datadog-plugin-cucumber/src/index.js +10 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +171 -75
- package/packages/datadog-plugin-cypress/src/finalization.js +0 -3
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +0 -4
- package/packages/datadog-plugin-cypress/src/support.js +52 -7
- package/packages/datadog-plugin-graphql/src/resolve-error.js +1 -2
- package/packages/datadog-plugin-graphql/src/utils.js +0 -5
- package/packages/datadog-plugin-jest/src/index.js +13 -0
- package/packages/datadog-plugin-kafkajs/src/producer.js +0 -1
- package/packages/datadog-plugin-mocha/src/index.js +39 -11
- package/packages/datadog-plugin-mongodb-core/src/query.js +0 -1
- package/packages/datadog-plugin-openai/src/index.js +16 -1
- package/packages/datadog-plugin-openai/src/realtime.js +144 -0
- package/packages/datadog-plugin-openai-agents/src/integration.js +0 -4
- package/packages/datadog-plugin-openai-agents/src/util.js +0 -1
- package/packages/datadog-plugin-playwright/src/index.js +76 -9
- package/packages/datadog-plugin-postgres/src/index.js +167 -0
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +0 -1
- package/packages/datadog-plugin-redis/src/index.js +15 -1
- package/packages/datadog-plugin-supabase/src/error.js +18 -0
- package/packages/datadog-plugin-supabase/src/index.js +21 -0
- package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +69 -0
- package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +70 -0
- package/packages/datadog-plugin-supabase/src/supabase-postgrest-js-postgrestbuilder-then.js +122 -0
- package/packages/datadog-plugin-supabase/src/supabase-realtime-js-realtimechannel-send.js +66 -0
- package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +93 -0
- package/packages/datadog-plugin-supabase/src/url.js +17 -0
- package/packages/datadog-plugin-vitest/src/index.js +10 -0
- package/packages/datadog-plugin-ws/src/util.js +0 -4
- package/packages/datadog-turbopack/index.js +0 -6
- package/packages/datadog-turbopack/src/loader.js +0 -16
- package/packages/datadog-webpack/src/loader.js +0 -1
- package/packages/dd-trace/src/aiguard/client.js +2 -3
- package/packages/dd-trace/src/aiguard/evaluation.js +6 -12
- package/packages/dd-trace/src/aiguard/index.js +2 -2
- package/packages/dd-trace/src/aiguard/integrations/index.js +1 -1
- package/packages/dd-trace/src/aiguard/integrations/openai.js +81 -7
- package/packages/dd-trace/src/aiguard/messages/anthropic.js +0 -2
- package/packages/dd-trace/src/aiguard/messages/openai.js +64 -1
- package/packages/dd-trace/src/aiguard/messages/utils.js +0 -1
- package/packages/dd-trace/src/aiguard/redaction.js +0 -1
- package/packages/dd-trace/src/aiguard/sdk.js +1 -1
- package/packages/dd-trace/src/appsec/activation.js +1 -1
- package/packages/dd-trace/src/appsec/api_security/normalized-route.js +0 -5
- package/packages/dd-trace/src/appsec/api_security/sampler.js +0 -4
- package/packages/dd-trace/src/appsec/blocking/index.js +3 -3
- package/packages/dd-trace/src/appsec/downstream_requests.js +1 -4
- package/packages/dd-trace/src/appsec/iast/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +5 -5
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +3 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +8 -10
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +2 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +4 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +7 -7
- package/packages/dd-trace/src/appsec/index.js +2 -2
- package/packages/dd-trace/src/appsec/lambda.js +71 -2
- package/packages/dd-trace/src/appsec/rasp/utils.js +5 -1
- package/packages/dd-trace/src/appsec/remote_config.js +8 -6
- package/packages/dd-trace/src/appsec/reporter.js +10 -6
- package/packages/dd-trace/src/appsec/rule_manager.js +3 -3
- package/packages/dd-trace/src/appsec/sdk/track_event.js +0 -2
- package/packages/dd-trace/src/appsec/waf/index.js +2 -2
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +8 -5
- package/packages/dd-trace/src/carrier.js +0 -5
- package/packages/dd-trace/src/ci-visibility/dynamic-atr-retries.js +104 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +0 -2
- package/packages/dd-trace/src/ci-visibility/efd-retry-policy.js +34 -3
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -4
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +37 -15
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +0 -3
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +0 -11
- package/packages/dd-trace/src/ci-visibility/exporters/settings-cache-key.js +0 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +0 -1
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +0 -6
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -2
- package/packages/dd-trace/src/ci-visibility/requests/rate-limit.js +0 -1
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +0 -5
- package/packages/dd-trace/src/ci-visibility/requests/video-request.js +0 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +13 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +0 -1
- package/packages/dd-trace/src/ci-visibility/test-screenshot.js +0 -2
- package/packages/dd-trace/src/ci-visibility/test-video.js +0 -1
- package/packages/dd-trace/src/config/defaults.js +3 -2
- package/packages/dd-trace/src/config/generated-config-types.d.ts +73 -67
- package/packages/dd-trace/src/config/helper.js +0 -1
- package/packages/dd-trace/src/config/index.js +24 -24
- package/packages/dd-trace/src/config/parsers.js +34 -6
- package/packages/dd-trace/src/config/remote_config.js +25 -109
- package/packages/dd-trace/src/config/supported-configurations.json +139 -10
- package/packages/dd-trace/src/datastreams/encoding.js +0 -1
- package/packages/dd-trace/src/datastreams/pathway.js +0 -1
- package/packages/dd-trace/src/debugger/constants.js +10 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +62 -10
- package/packages/dd-trace/src/debugger/devtools_client/config.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/guardrail-metrics.js +15 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +103 -27
- package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +50 -7
- package/packages/dd-trace/src/debugger/devtools_client/log.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +21 -8
- package/packages/dd-trace/src/debugger/devtools_client/send.js +40 -14
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +53 -13
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +118 -71
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +0 -3
- package/packages/dd-trace/src/debugger/devtools_client/status.js +20 -6
- package/packages/dd-trace/src/debugger/guardrail-metrics.js +167 -0
- package/packages/dd-trace/src/debugger/index.js +50 -2
- package/packages/dd-trace/src/debugger/inspect-segment.js +0 -3
- package/packages/dd-trace/src/debugger/probe_sampler.js +133 -9
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +31 -1
- package/packages/dd-trace/src/dogstatsd.js +0 -23
- package/packages/dd-trace/src/encode/0.4-cross-payload.js +0 -3
- package/packages/dd-trace/src/encode/0.4.js +0 -7
- package/packages/dd-trace/src/encode/0.5.js +0 -2
- package/packages/dd-trace/src/encode/tags-processors.js +0 -1
- package/packages/dd-trace/src/evp_proxy/discovery.js +0 -1
- package/packages/dd-trace/src/evp_proxy/path.js +0 -2
- package/packages/dd-trace/src/exporters/agent/writer.js +0 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +0 -1
- package/packages/dd-trace/src/exporters/agentless/intake.js +0 -1
- package/packages/dd-trace/src/exporters/agentless/writer.js +0 -3
- package/packages/dd-trace/src/exporters/common/final-flush-request-tracker.js +0 -6
- package/packages/dd-trace/src/exporters/common/request.js +1 -0
- package/packages/dd-trace/src/exporters/common/url.js +0 -2
- package/packages/dd-trace/src/exporters/common/writer.js +0 -2
- package/packages/dd-trace/src/id.js +0 -11
- package/packages/dd-trace/src/llmobs/audio-codec.js +192 -0
- package/packages/dd-trace/src/llmobs/audio-utils.js +121 -0
- package/packages/dd-trace/src/llmobs/constants/audio.js +35 -0
- package/packages/dd-trace/src/llmobs/constants/prompts.js +14 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +17 -0
- package/packages/dd-trace/src/llmobs/eval-metric.js +0 -6
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +0 -4
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +0 -3
- package/packages/dd-trace/src/llmobs/experiments/index.js +7 -6
- package/packages/dd-trace/src/llmobs/experiments/util.js +1 -11
- package/packages/dd-trace/src/llmobs/index.js +1 -3
- package/packages/dd-trace/src/llmobs/noop.js +10 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +0 -4
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +0 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +0 -4
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +0 -2
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +0 -2
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +4 -6
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +285 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +16 -3
- package/packages/dd-trace/src/llmobs/prompts/cache.js +272 -0
- package/packages/dd-trace/src/llmobs/prompts/manager.js +639 -0
- package/packages/dd-trace/src/llmobs/prompts/noop.js +29 -0
- package/packages/dd-trace/src/llmobs/prompts/prompt.js +92 -0
- package/packages/dd-trace/src/llmobs/sdk.js +21 -6
- package/packages/dd-trace/src/llmobs/span_processor.js +81 -2
- package/packages/dd-trace/src/llmobs/tagger.js +30 -7
- package/packages/dd-trace/src/llmobs/telemetry.js +36 -4
- package/packages/dd-trace/src/llmobs/util.js +0 -34
- package/packages/dd-trace/src/llmobs/writers/base.js +0 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
- package/packages/dd-trace/src/log/channels.js +3 -0
- package/packages/dd-trace/src/log/index.js +23 -5
- package/packages/dd-trace/src/log-submission/log-submission-plugin.js +74 -6
- package/packages/dd-trace/src/msgpack/chunk.js +0 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +0 -12
- package/packages/dd-trace/src/openfeature/encoding.js +0 -2
- package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +0 -1
- package/packages/dd-trace/src/openfeature/index.js +0 -4
- package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +0 -1
- package/packages/dd-trace/src/openfeature/span-enrichment.js +0 -4
- package/packages/dd-trace/src/openfeature/writers/base.js +0 -6
- package/packages/dd-trace/src/openfeature/writers/exposures.js +0 -5
- package/packages/dd-trace/src/openfeature/writers/util.js +0 -4
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +0 -1
- package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +0 -1
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +0 -1
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +0 -2
- package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +0 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +0 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +0 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +1 -14
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +0 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +30 -13
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +0 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +0 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +0 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +0 -3
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +0 -6
- package/packages/dd-trace/src/opentracing/span_context.js +0 -1
- package/packages/dd-trace/src/otel-thread-ctx.js +38 -11
- package/packages/dd-trace/src/payload-tagging/tagging.js +15 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +0 -1
- package/packages/dd-trace/src/plugins/database.js +2 -6
- package/packages/dd-trace/src/plugins/index.js +7 -0
- package/packages/dd-trace/src/plugins/plugin.js +0 -4
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/git.js +1 -3
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +0 -1
- package/packages/dd-trace/src/plugins/util/llm.js +0 -2
- package/packages/dd-trace/src/plugins/util/status-validator.js +0 -1
- package/packages/dd-trace/src/plugins/util/test.js +21 -20
- package/packages/dd-trace/src/plugins/util/url.js +0 -5
- package/packages/dd-trace/src/priority_sampler.js +0 -6
- package/packages/dd-trace/src/process-tags/index.js +0 -1
- package/packages/dd-trace/src/profiler.js +132 -35
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +0 -1
- package/packages/dd-trace/src/profiling/profiler.js +101 -41
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +29 -15
- package/packages/dd-trace/src/propagation-hash/index.js +0 -1
- package/packages/dd-trace/src/proxy.js +21 -45
- package/packages/dd-trace/src/random_sampler.js +0 -4
- package/packages/dd-trace/src/rate_limiter.js +0 -4
- package/packages/dd-trace/src/remote_config/capabilities.js +1 -9
- package/packages/dd-trace/src/remote_config/index.js +0 -1
- package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +0 -3
- package/packages/dd-trace/src/sampler.js +0 -4
- package/packages/dd-trace/src/sampling_rule.js +0 -7
- package/packages/dd-trace/src/serverless/vercel.js +0 -1
- package/packages/dd-trace/src/serverless.js +0 -1
- package/packages/dd-trace/src/service-naming/index.js +0 -1
- package/packages/dd-trace/src/service-naming/schemas/util.js +0 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +7 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +5 -0
- package/packages/dd-trace/src/span_processor.js +2 -2
- package/packages/dd-trace/src/span_sampler.js +0 -1
- package/packages/dd-trace/src/standalone/product.js +2 -2
- package/packages/dd-trace/src/standalone/tracesource.js +0 -1
- package/packages/dd-trace/src/startup-log.js +1 -1
- package/packages/dd-trace/src/telemetry/endpoints.js +0 -8
- package/packages/dd-trace/src/telemetry/logs/index.js +16 -5
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +16 -6
- package/packages/dd-trace/src/telemetry/metrics.js +0 -2
- package/packages/dd-trace/src/telemetry/telemetry.js +4 -1
- package/packages/dd-trace/src/util.js +13 -1
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
|
@@ -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
|
+
isExpectedEmptySession,
|
|
582
584
|
onDone,
|
|
583
585
|
}) => {
|
|
584
586
|
for (const [tag, value] of Object.entries(requestErrorTags)) {
|
|
@@ -587,6 +589,14 @@ class VitestPlugin extends CiPlugin {
|
|
|
587
589
|
}
|
|
588
590
|
this.testSessionSpan.setTag(TEST_STATUS, status)
|
|
589
591
|
this.testModuleSpan.setTag(TEST_STATUS, status)
|
|
592
|
+
if (isExpectedEmptySession) {
|
|
593
|
+
setExpectedEmptyTestSessionTags(
|
|
594
|
+
this.testSessionSpan,
|
|
595
|
+
this.testModuleSpan,
|
|
596
|
+
'No tests were executed',
|
|
597
|
+
'zero_tests'
|
|
598
|
+
)
|
|
599
|
+
}
|
|
590
600
|
if (error) {
|
|
591
601
|
this.testModuleSpan.setTag('error', error)
|
|
592
602
|
this.testSessionSpan.setTag('error', error)
|
|
@@ -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
|
|
@@ -74,7 +74,6 @@ function normalizeConfig (config) {
|
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* @param {unknown} value
|
|
77
|
-
* @returns {boolean}
|
|
78
77
|
*/
|
|
79
78
|
function isObject (value) {
|
|
80
79
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value)
|
|
@@ -146,7 +145,6 @@ function createLoader () {
|
|
|
146
145
|
|
|
147
146
|
/**
|
|
148
147
|
* @param {unknown} value
|
|
149
|
-
* @returns {boolean}
|
|
150
148
|
*/
|
|
151
149
|
function hasDatadogLoader (value) {
|
|
152
150
|
if (Array.isArray(value)) return value.some(hasDatadogLoader)
|
|
@@ -169,15 +167,11 @@ function createPackagePathPattern () {
|
|
|
169
167
|
|
|
170
168
|
/**
|
|
171
169
|
* @param {string} value
|
|
172
|
-
* @returns {string}
|
|
173
170
|
*/
|
|
174
171
|
function escapeRegExp (value) {
|
|
175
172
|
return value.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)
|
|
176
173
|
}
|
|
177
174
|
|
|
178
|
-
/**
|
|
179
|
-
* @returns {number}
|
|
180
|
-
*/
|
|
181
175
|
function getNextMajor () {
|
|
182
176
|
const entrypoints = []
|
|
183
177
|
if (require.main?.filename) entrypoints.push(require.main.filename)
|
|
@@ -120,7 +120,6 @@ module.exports = function loader (source, inputSourceMap) {
|
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* @param {LoaderContext} context
|
|
123
|
-
* @returns {string}
|
|
124
123
|
*/
|
|
125
124
|
function getResourcePath (context) {
|
|
126
125
|
const { resourcePath } = context
|
|
@@ -185,7 +184,6 @@ function getPublications (resourcePath, packageInfo) {
|
|
|
185
184
|
/**
|
|
186
185
|
* @param {string} name
|
|
187
186
|
* @param {string} packageJsonPath
|
|
188
|
-
* @returns {string}
|
|
189
187
|
*/
|
|
190
188
|
function getCommonJsEntrypoint (name, packageJsonPath) {
|
|
191
189
|
const cached = entrypoints.get(packageJsonPath)
|
|
@@ -228,7 +226,6 @@ function getRewriter (dcModule) {
|
|
|
228
226
|
|
|
229
227
|
/**
|
|
230
228
|
* @param {string} source
|
|
231
|
-
* @returns {boolean}
|
|
232
229
|
*/
|
|
233
230
|
function hasUnsafeCommonJsBindings (source) {
|
|
234
231
|
try {
|
|
@@ -248,7 +245,6 @@ function hasUnsafeCommonJsBindings (source) {
|
|
|
248
245
|
* @param {number} shadowedBindings
|
|
249
246
|
* @param {object} [parent]
|
|
250
247
|
* @param {string} [parentKey]
|
|
251
|
-
* @returns {boolean}
|
|
252
248
|
*/
|
|
253
249
|
function hasUnsafeNode (node, functionDepth, shadowedBindings, parent, parentKey) {
|
|
254
250
|
if (functionDepth === 0 && hasCommonJsDeclaration(node, parent)) return true
|
|
@@ -286,7 +282,6 @@ function hasUnsafeNode (node, functionDepth, shadowedBindings, parent, parentKey
|
|
|
286
282
|
/**
|
|
287
283
|
* @param {object} node
|
|
288
284
|
* @param {object} [parent]
|
|
289
|
-
* @returns {boolean}
|
|
290
285
|
*/
|
|
291
286
|
function hasCommonJsDeclaration (node, parent) {
|
|
292
287
|
if (node.type === 'VariableDeclarator') {
|
|
@@ -301,7 +296,6 @@ function hasCommonJsDeclaration (node, parent) {
|
|
|
301
296
|
/**
|
|
302
297
|
* @param {object} node
|
|
303
298
|
* @param {number} shadowedBindings
|
|
304
|
-
* @returns {boolean}
|
|
305
299
|
*/
|
|
306
300
|
function mutatesCommonJsBinding (node, shadowedBindings) {
|
|
307
301
|
return Boolean(getBindingMask(node) & COMMONJS_BINDINGS & ~shadowedBindings)
|
|
@@ -309,7 +303,6 @@ function mutatesCommonJsBinding (node, shadowedBindings) {
|
|
|
309
303
|
|
|
310
304
|
/**
|
|
311
305
|
* @param {object} node
|
|
312
|
-
* @returns {number}
|
|
313
306
|
*/
|
|
314
307
|
function getBindingMask (node) {
|
|
315
308
|
if (!node) return 0
|
|
@@ -337,7 +330,6 @@ function getBindingMask (node) {
|
|
|
337
330
|
|
|
338
331
|
/**
|
|
339
332
|
* @param {object} node
|
|
340
|
-
* @returns {number}
|
|
341
333
|
*/
|
|
342
334
|
function getFunctionBindings (node) {
|
|
343
335
|
let bindings = node.type === 'ArrowFunctionExpression' ? 0 : ARGUMENTS_BINDING
|
|
@@ -348,7 +340,6 @@ function getFunctionBindings (node) {
|
|
|
348
340
|
|
|
349
341
|
/**
|
|
350
342
|
* @param {object} node
|
|
351
|
-
* @returns {number}
|
|
352
343
|
*/
|
|
353
344
|
function getVarBindings (node) {
|
|
354
345
|
if (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionDeclaration' ||
|
|
@@ -373,7 +364,6 @@ function getVarBindings (node) {
|
|
|
373
364
|
|
|
374
365
|
/**
|
|
375
366
|
* @param {object} node
|
|
376
|
-
* @returns {number}
|
|
377
367
|
*/
|
|
378
368
|
function getLexicalBindings (node) {
|
|
379
369
|
let bindings = 0
|
|
@@ -397,7 +387,6 @@ function getLexicalBindings (node) {
|
|
|
397
387
|
|
|
398
388
|
/**
|
|
399
389
|
* @param {object} node
|
|
400
|
-
* @returns {number}
|
|
401
390
|
*/
|
|
402
391
|
function getStatementBindings (node) {
|
|
403
392
|
if (node.type === 'VariableDeclaration') return getLexicalDeclarationBindings(node)
|
|
@@ -407,7 +396,6 @@ function getStatementBindings (node) {
|
|
|
407
396
|
|
|
408
397
|
/**
|
|
409
398
|
* @param {object} [node]
|
|
410
|
-
* @returns {number}
|
|
411
399
|
*/
|
|
412
400
|
function getLexicalDeclarationBindings (node) {
|
|
413
401
|
if (node?.type !== 'VariableDeclaration' || node.kind === 'var') return 0
|
|
@@ -419,7 +407,6 @@ function getLexicalDeclarationBindings (node) {
|
|
|
419
407
|
/**
|
|
420
408
|
* @param {object} parent
|
|
421
409
|
* @param {string} parentKey
|
|
422
|
-
* @returns {boolean}
|
|
423
410
|
*/
|
|
424
411
|
function isReferencedIdentifier (parent, parentKey) {
|
|
425
412
|
if (parent.type === 'MemberExpression' && parentKey === 'property' && !parent.computed) return false
|
|
@@ -434,7 +421,6 @@ function isReferencedIdentifier (parent, parentKey) {
|
|
|
434
421
|
* @param {string} source
|
|
435
422
|
* @param {Array<{ package: string, path: string, version: string }>} payloads
|
|
436
423
|
* @param {string} dcModule
|
|
437
|
-
* @returns {string}
|
|
438
424
|
*/
|
|
439
425
|
function appendCommonJsPublications (source, payloads, dcModule) {
|
|
440
426
|
let publications = ''
|
|
@@ -466,7 +452,6 @@ ${publications} }
|
|
|
466
452
|
* @param {{ package: string, path: string, version: string }} payload
|
|
467
453
|
* @param {string} dcModule
|
|
468
454
|
* @param {boolean} esm
|
|
469
|
-
* @returns {string}
|
|
470
455
|
*/
|
|
471
456
|
function appendActivation (source, payload, dcModule, esm) {
|
|
472
457
|
if (esm) {
|
|
@@ -491,7 +476,6 @@ import ddTraceTurbopackDc from ${JSON.stringify(dcModule)}
|
|
|
491
476
|
/**
|
|
492
477
|
* @param {string} from
|
|
493
478
|
* @param {string} to
|
|
494
|
-
* @returns {string}
|
|
495
479
|
*/
|
|
496
480
|
function relativeImport (from, to) {
|
|
497
481
|
let value = path.relative(from, to).replaceAll('\\', '/')
|
|
@@ -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
|
/**
|
|
@@ -9,6 +9,7 @@ const { keepTrace } = require('../priority_sampler')
|
|
|
9
9
|
const { extractIp } = require('../plugins/util/ip_extractor')
|
|
10
10
|
const { AI_GUARD } = require('../standalone/product')
|
|
11
11
|
const telemetryMetrics = require('../telemetry/metrics')
|
|
12
|
+
const { truncateString } = require('../util')
|
|
12
13
|
const { normalizeRedactionReplacements, redactMessages } = require('./redaction')
|
|
13
14
|
const TAGS = require('./tags')
|
|
14
15
|
|
|
@@ -96,7 +97,6 @@ function parseEvaluationResponse (body) {
|
|
|
96
97
|
*
|
|
97
98
|
* @param {boolean} block
|
|
98
99
|
* @param {{ action: string, blockingEnabled: boolean }} evaluation
|
|
99
|
-
* @returns {boolean}
|
|
100
100
|
*/
|
|
101
101
|
function shouldBlockEvaluation (block, evaluation) {
|
|
102
102
|
return block && evaluation.blockingEnabled && evaluation.action !== ALLOW
|
|
@@ -158,9 +158,9 @@ class EvaluationReporter {
|
|
|
158
158
|
*/
|
|
159
159
|
constructor (config) {
|
|
160
160
|
this.#config = config
|
|
161
|
-
this.#maxMessagesLength = config.
|
|
162
|
-
this.#maxContentSize = config.
|
|
163
|
-
this.#redactionEnabled = config.
|
|
161
|
+
this.#maxMessagesLength = config.aiguard.DD_AI_GUARD_MAX_MESSAGES_LENGTH
|
|
162
|
+
this.#maxContentSize = config.aiguard.DD_AI_GUARD_MAX_CONTENT_SIZE
|
|
163
|
+
this.#redactionEnabled = config.aiguard.DD_AI_GUARD_REDACTION_ENABLED
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
/**
|
|
@@ -211,7 +211,6 @@ class EvaluationReporter {
|
|
|
211
211
|
*
|
|
212
212
|
* @param {EvaluationReport} report
|
|
213
213
|
* @param {string} errorType
|
|
214
|
-
* @returns {void}
|
|
215
214
|
*/
|
|
216
215
|
fail (report, errorType) {
|
|
217
216
|
report.metaStruct.messages = this.#buildMessagesForMetaStruct(report.messages, report.telemetryTags)
|
|
@@ -224,7 +223,6 @@ class EvaluationReporter {
|
|
|
224
223
|
*
|
|
225
224
|
* @param {EvaluationReport} report
|
|
226
225
|
* @param {EvaluationOutcome} outcome
|
|
227
|
-
* @returns {void}
|
|
228
226
|
*/
|
|
229
227
|
finish (report, outcome) {
|
|
230
228
|
const { result, redaction, shouldBlock } = outcome
|
|
@@ -299,14 +297,13 @@ class EvaluationReporter {
|
|
|
299
297
|
* Truncates text in a cloned message to one shared content-size limit.
|
|
300
298
|
*
|
|
301
299
|
* @param {{ content?: string|ContentPart[] }} message
|
|
302
|
-
* @returns {boolean}
|
|
303
300
|
*/
|
|
304
301
|
#truncateMessageContent (message) {
|
|
305
302
|
const { content } = message
|
|
306
303
|
if (typeof content === 'string') {
|
|
307
304
|
if (content.length <= this.#maxContentSize) return false
|
|
308
305
|
|
|
309
|
-
message.content = content
|
|
306
|
+
message.content = truncateString(content, this.#maxContentSize)
|
|
310
307
|
return true
|
|
311
308
|
}
|
|
312
309
|
|
|
@@ -319,7 +316,7 @@ class EvaluationReporter {
|
|
|
319
316
|
if (typeof text !== 'string') continue
|
|
320
317
|
|
|
321
318
|
if (text.length > remainingContentSize) {
|
|
322
|
-
part.text = text
|
|
319
|
+
part.text = truncateString(text, remainingContentSize)
|
|
323
320
|
truncated = true
|
|
324
321
|
remainingContentSize = 0
|
|
325
322
|
} else {
|
|
@@ -333,7 +330,6 @@ class EvaluationReporter {
|
|
|
333
330
|
* Returns whether a message represents a tool call or tool output.
|
|
334
331
|
*
|
|
335
332
|
* @param {Message} message
|
|
336
|
-
* @returns {boolean}
|
|
337
333
|
*/
|
|
338
334
|
#isToolCall (message) {
|
|
339
335
|
return Boolean(message.tool_calls || message.tool_call_id)
|
|
@@ -370,7 +366,6 @@ class EvaluationReporter {
|
|
|
370
366
|
* Adds missing client IP tags to the service entry span.
|
|
371
367
|
*
|
|
372
368
|
* @param {Span} rootSpan
|
|
373
|
-
* @returns {void}
|
|
374
369
|
*/
|
|
375
370
|
#setRootSpanClientIpTags (rootSpan) {
|
|
376
371
|
const currentTags = rootSpan.context().getTags()
|
|
@@ -411,7 +406,6 @@ class EvaluationReporter {
|
|
|
411
406
|
*
|
|
412
407
|
* @param {Span} guardSpan
|
|
413
408
|
* @param {Span} rootSpan
|
|
414
|
-
* @returns {void}
|
|
415
409
|
*/
|
|
416
410
|
#copyServiceEntryTagsToGuardSpan (guardSpan, rootSpan) {
|
|
417
411
|
const rootTags = rootSpan.context().getTags()
|
|
@@ -17,8 +17,8 @@ function enable (tracer, config) {
|
|
|
17
17
|
|
|
18
18
|
try {
|
|
19
19
|
aiguard = new AIGuard(tracer, config)
|
|
20
|
-
const block = config.
|
|
21
|
-
const analyzeStreamResponses = config.DD_AI_GUARD_ANALYZE_STREAM_RESPONSES_ENABLED
|
|
20
|
+
const block = config.aiguard.DD_AI_GUARD_BLOCK !== false
|
|
21
|
+
const analyzeStreamResponses = config.aiguard.DD_AI_GUARD_ANALYZE_STREAM_RESPONSES_ENABLED
|
|
22
22
|
|
|
23
23
|
incomingHttpRequestStart.subscribe(onIncomingHttpRequestStart)
|
|
24
24
|
integrations.enable(aiguard, block, analyzeStreamResponses)
|
|
@@ -17,7 +17,7 @@ function enable (aiguard, block, analyzeStreamResponses) {
|
|
|
17
17
|
if (isEnabled) return
|
|
18
18
|
|
|
19
19
|
anthropic.enable(aiguard, block)
|
|
20
|
-
openai.enable(aiguard, block)
|
|
20
|
+
openai.enable(aiguard, block, analyzeStreamResponses)
|
|
21
21
|
vercelAi.enable(aiguard, block, analyzeStreamResponses)
|
|
22
22
|
|
|
23
23
|
isEnabled = true
|