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,121 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Building `audioPart`s for LLM Observability messages: mapping provider audio formats to MIME
|
|
4
|
+
// types, and keeping inline audio within the per-span-event size budget. The raw-audio primitives
|
|
5
|
+
// these build on (WAV wrapping, G.711 decoding, byte rates) live in `audio-codec.js`.
|
|
6
|
+
|
|
7
|
+
const log = require('../log')
|
|
8
|
+
const { LLMOBS_AUDIO_INLINE_MAX_BYTES } = require('./constants/audio')
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {{ mimeType: string, content: string }} AudioPart
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// Raw audio formats the UI cannot render as a player. For these we keep the transcript as the
|
|
15
|
+
// message content and skip the inline audio part, since raw bytes would only bloat the payload.
|
|
16
|
+
const NON_RENDERABLE_AUDIO_MIME_TYPES = new Set([
|
|
17
|
+
'audio/pcm',
|
|
18
|
+
'audio/pcm16',
|
|
19
|
+
'audio/l16',
|
|
20
|
+
'audio/pcmu',
|
|
21
|
+
'audio/pcma',
|
|
22
|
+
'audio/g711_ulaw',
|
|
23
|
+
'audio/g711_alaw',
|
|
24
|
+
'audio/basic',
|
|
25
|
+
])
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Length of `byteLength` bytes after standard base64 encoding: 4 characters per 3 bytes, padded.
|
|
29
|
+
*
|
|
30
|
+
* @param {number} byteLength
|
|
31
|
+
*/
|
|
32
|
+
function base64EncodedLength (byteLength) {
|
|
33
|
+
return Math.ceil(byteLength / 3) * 4
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Maps an audio `format` (e.g. "wav", "mp3") to a MIME type. Defaults to `audio/wav` when the
|
|
37
|
+
// format is missing. Provider-specific overrides (e.g. OpenAI's mp3 -> audio/mpeg) are passed in
|
|
38
|
+
// via `mimeTypeLookup` so this stays provider-agnostic. A non-string `format` is treated as missing
|
|
39
|
+
// so a malformed auto-instrumented payload can't throw and disable the plugin.
|
|
40
|
+
/**
|
|
41
|
+
* @param {string} fmt
|
|
42
|
+
* @param {Record<string, string>} [mimeTypeLookup]
|
|
43
|
+
*/
|
|
44
|
+
function audioMimeTypeFromFormat (fmt, mimeTypeLookup = {}) {
|
|
45
|
+
fmt = typeof fmt === 'string' ? fmt.trim().toLowerCase() : ''
|
|
46
|
+
if (!fmt) return 'audio/wav'
|
|
47
|
+
// `hasOwn` rather than a plain lookup: a format of "constructor" would otherwise resolve to
|
|
48
|
+
// something off Object.prototype and be returned as the MIME type.
|
|
49
|
+
return Object.hasOwn(mimeTypeLookup, fmt) ? mimeTypeLookup[fmt] : `audio/${fmt}`
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Whether a MIME type can be rendered as an audio player in the UI. Raw PCM cannot.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} mimeType
|
|
56
|
+
*/
|
|
57
|
+
function isRenderableAudioMime (mimeType) {
|
|
58
|
+
return typeof mimeType === 'string' &&
|
|
59
|
+
mimeType.length > 0 &&
|
|
60
|
+
!NON_RENDERABLE_AUDIO_MIME_TYPES.has(mimeType.trim().toLowerCase())
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Builds an audio part from raw audio bytes (base64-encoded) or an existing base64 string. Only
|
|
64
|
+
// Buffer/Uint8Array inputs are base64-encoded; any other shape is passed through so a malformed
|
|
65
|
+
// auto-instrumented payload can't throw (the tagger soft-skips a non-string `content`).
|
|
66
|
+
/**
|
|
67
|
+
* @param {Buffer | Uint8Array | string} data
|
|
68
|
+
* @param {string} mimeType
|
|
69
|
+
* @returns {AudioPart}
|
|
70
|
+
*/
|
|
71
|
+
function formatAudioPart (data, mimeType) {
|
|
72
|
+
const content = Buffer.isBuffer(data) || ArrayBuffer.isView(data)
|
|
73
|
+
? Buffer.from(data).toString('base64')
|
|
74
|
+
: data
|
|
75
|
+
return { mimeType, content }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Whether `byteLength` bytes of audio fit the inline budget once base64-encoded.
|
|
80
|
+
*
|
|
81
|
+
* Compares the *encoded* size: `formatAudioPart` base64-encodes the bytes (~4/3 expansion), and it
|
|
82
|
+
* is that encoded content which counts against the per-span-event limit. Exposed separately so a
|
|
83
|
+
* caller that has to allocate to produce those bytes — decoding G.711 to PCM16, wrapping raw PCM in
|
|
84
|
+
* a WAV container — can check the size it is about to produce before paying for it.
|
|
85
|
+
*
|
|
86
|
+
* @param {number} byteLength
|
|
87
|
+
* @param {number} [maxBytes]
|
|
88
|
+
*/
|
|
89
|
+
function fitsInlineAudioBudget (byteLength, maxBytes = LLMOBS_AUDIO_INLINE_MAX_BYTES) {
|
|
90
|
+
const encodedLength = base64EncodedLength(byteLength)
|
|
91
|
+
if (encodedLength <= maxBytes) return true
|
|
92
|
+
|
|
93
|
+
log.debug('Audio (%d encoded bytes) exceeds inline budget %d; omitting inline audio content',
|
|
94
|
+
encodedLength, maxBytes)
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Build a playable audio part, but only for renderable formats within the size budget. Returns
|
|
100
|
+
* `undefined` for a non-renderable format (e.g. raw PCM) or oversize audio; callers fall back to the
|
|
101
|
+
* transcript as the message content in that case.
|
|
102
|
+
*
|
|
103
|
+
* @param {Buffer} audioBytes
|
|
104
|
+
* @param {string} mimeType
|
|
105
|
+
* @param {number} [maxBytes]
|
|
106
|
+
* @returns {AudioPart | undefined}
|
|
107
|
+
*/
|
|
108
|
+
function formatAudioPartWithGuard (audioBytes, mimeType, maxBytes = LLMOBS_AUDIO_INLINE_MAX_BYTES) {
|
|
109
|
+
if (!audioBytes?.length || !isRenderableAudioMime(mimeType)) return
|
|
110
|
+
if (!fitsInlineAudioBudget(audioBytes.length, maxBytes)) return
|
|
111
|
+
|
|
112
|
+
return formatAudioPart(audioBytes, mimeType)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = {
|
|
116
|
+
audioMimeTypeFromFormat,
|
|
117
|
+
fitsInlineAudioBudget,
|
|
118
|
+
formatAudioPart,
|
|
119
|
+
formatAudioPartWithGuard,
|
|
120
|
+
isRenderableAudioMime,
|
|
121
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
// Surfaced as a message's content when audio was captured but couldn't be turned into a playable
|
|
5
|
+
// part (unsupported format, or over the size budget) and there is no transcript to show instead.
|
|
6
|
+
AUDIO_FALLBACK: '[audio]',
|
|
7
|
+
|
|
8
|
+
// G.711 telephony audio is always 8 kHz mono.
|
|
9
|
+
G711_SAMPLE_RATE: 8000,
|
|
10
|
+
|
|
11
|
+
// Budget for inline audio, measured on the *base64-encoded* size, since that is what actually
|
|
12
|
+
// rides the span event. Kept below the 5 MB per-span-event limit with headroom for the rest of the
|
|
13
|
+
// event, whose whole I/O is dropped backend-side when oversize. 4 MiB encoded is ~3 MiB of audio.
|
|
14
|
+
//
|
|
15
|
+
// Per *event*, not per audio part. An event carrying audio on more than one message — a realtime
|
|
16
|
+
// turn has both the user's and the agent's — has to divide this between them, or two individually
|
|
17
|
+
// accepted clips sum past the limit and cost the event all of its I/O.
|
|
18
|
+
LLMOBS_AUDIO_INLINE_MAX_BYTES: 4 * 1024 * 1024,
|
|
19
|
+
|
|
20
|
+
// Cap on the raw audio buffered per side of a realtime turn: the point at which base64 encoding
|
|
21
|
+
// would put a 1:1 format over `LLMOBS_AUDIO_INLINE_MAX_BYTES` anyway (4 chars per 3 bytes).
|
|
22
|
+
// Beyond this the size guard would drop the audio at tag time, so we stop retaining it rather
|
|
23
|
+
// than hold megabytes in memory only to discard them. A memory bound, not a correctness one — the
|
|
24
|
+
// guard still decides.
|
|
25
|
+
//
|
|
26
|
+
// A format that expands on the way to a playable part inlines less than this: G.711 decodes to
|
|
27
|
+
// PCM16 at 2 bytes per sample, so only about half of it can ever ride the span event. Callers
|
|
28
|
+
// check the *converted* size against the budget before converting (`fitsInlineAudioBudget`), so
|
|
29
|
+
// the excess is never paid for in allocations — it is only retained and then dropped.
|
|
30
|
+
LLMOBS_AUDIO_ACCUMULATE_MAX_BYTES: 3 * 1024 * 1024,
|
|
31
|
+
|
|
32
|
+
PCM16_BYTES_PER_SAMPLE: 2,
|
|
33
|
+
|
|
34
|
+
WAV_HEADER_BYTES: 44,
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
ERROR_NAMES: {
|
|
5
|
+
API: 'PromptAPIError',
|
|
6
|
+
AUTH: 'PromptAuthError',
|
|
7
|
+
CONFLICT: 'PromptConflictError',
|
|
8
|
+
NOT_FOUND: 'PromptNotFoundError',
|
|
9
|
+
SERVER: 'PromptServerError',
|
|
10
|
+
VALIDATION: 'PromptValidationError',
|
|
11
|
+
},
|
|
12
|
+
PROMPTS_PATH: '/api/unstable/llm-obs/v1/prompts',
|
|
13
|
+
SOURCE_CACHE: 'cache',
|
|
14
|
+
}
|
|
@@ -69,6 +69,23 @@ module.exports = {
|
|
|
69
69
|
INSTRUMENTATION_METHOD_ANNOTATED: 'annotated',
|
|
70
70
|
INSTRUMENTATION_METHOD_UNKNOWN: 'unknown',
|
|
71
71
|
|
|
72
|
+
GEN_AI_OPERATION_NAME: 'gen_ai.operation.name',
|
|
73
|
+
GEN_AI_REQUEST_MODEL: 'gen_ai.request.model',
|
|
74
|
+
GEN_AI_PROVIDER_NAME: 'gen_ai.provider.name',
|
|
75
|
+
GEN_AI_APPLICATION_NAME: 'gen_ai.application.name',
|
|
76
|
+
GEN_AI_CONVERSATION_ID: 'gen_ai.conversation.id',
|
|
77
|
+
|
|
78
|
+
GEN_AI_USAGE_INPUT_TOKENS_METRIC_KEY: 'gen_ai.usage.input_tokens',
|
|
79
|
+
GEN_AI_USAGE_OUTPUT_TOKENS_METRIC_KEY: 'gen_ai.usage.output_tokens',
|
|
80
|
+
GEN_AI_USAGE_TOTAL_TOKENS_METRIC_KEY: 'gen_ai.usage.total_tokens',
|
|
81
|
+
GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS_METRIC_KEY: 'gen_ai.usage.cache_read_input_tokens',
|
|
82
|
+
GEN_AI_USAGE_CACHE_WRITE_INPUT_TOKENS_METRIC_KEY: 'gen_ai.usage.cache_write_input_tokens',
|
|
83
|
+
GEN_AI_USAGE_REASONING_OUTPUT_TOKENS_METRIC_KEY: 'gen_ai.usage.reasoning_output_tokens',
|
|
84
|
+
|
|
85
|
+
// Marks the `gen_ai.*` tags on an APM span as tracer-emitted. Without it the backend reads them
|
|
86
|
+
// as user-set and builds a duplicate LLMObs span out of the APM span.
|
|
87
|
+
ARTIFICIAL_GEN_AI_TAGS: '_dd.llmobs.artificial_gen_ai_tags',
|
|
88
|
+
|
|
72
89
|
ROUTING_API_KEY: '_dd.llmobs.routing.api_key',
|
|
73
90
|
ROUTING_SITE: '_dd.llmobs.routing.site',
|
|
74
91
|
}
|
|
@@ -61,7 +61,6 @@ const TERMS = {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* @param {string[]} metricTypes
|
|
64
|
-
* @returns {string} the quoted list, e.g. `"categorical", "score" or "json"`
|
|
65
64
|
*/
|
|
66
65
|
function formatMetricTypes (metricTypes) {
|
|
67
66
|
const quoted = metricTypes.map(metricType => `"${metricType}"`)
|
|
@@ -99,7 +98,6 @@ function invalidTagsError (kind) {
|
|
|
99
98
|
/**
|
|
100
99
|
* @param {unknown} timestampMs
|
|
101
100
|
* @param {MetricEventKind} kind
|
|
102
|
-
* @returns {void}
|
|
103
101
|
*/
|
|
104
102
|
function validateTimestamp (timestampMs, kind) {
|
|
105
103
|
if (typeof timestampMs !== 'number' || timestampMs < 0) {
|
|
@@ -137,7 +135,6 @@ function validateLabel (label, kind) {
|
|
|
137
135
|
/**
|
|
138
136
|
* @param {string | undefined} metricType - Already lower-cased metric type.
|
|
139
137
|
* @param {MetricEventKind} kind
|
|
140
|
-
* @returns {void}
|
|
141
138
|
*/
|
|
142
139
|
function validateMetricType (metricType, kind) {
|
|
143
140
|
if (!metricType || !METRIC_TYPES[kind].includes(metricType)) {
|
|
@@ -148,7 +145,6 @@ function validateMetricType (metricType, kind) {
|
|
|
148
145
|
/**
|
|
149
146
|
* @param {string | undefined} metricType - Metric type already validated for the submitted kind.
|
|
150
147
|
* @param {unknown} value
|
|
151
|
-
* @returns {void}
|
|
152
148
|
*/
|
|
153
149
|
function validateMetricValue (metricType, value) {
|
|
154
150
|
if (metricType === 'categorical' && typeof value !== 'string') {
|
|
@@ -170,7 +166,6 @@ function validateMetricValue (metricType, value) {
|
|
|
170
166
|
|
|
171
167
|
/**
|
|
172
168
|
* @param {unknown} assessment
|
|
173
|
-
* @returns {void}
|
|
174
169
|
*/
|
|
175
170
|
function validateAssessment (assessment) {
|
|
176
171
|
if (assessment != null && assessment !== 'pass' && assessment !== 'fail') {
|
|
@@ -180,7 +175,6 @@ function validateAssessment (assessment) {
|
|
|
180
175
|
|
|
181
176
|
/**
|
|
182
177
|
* @param {unknown} reasoning
|
|
183
|
-
* @returns {void}
|
|
184
178
|
*/
|
|
185
179
|
function validateReasoning (reasoning) {
|
|
186
180
|
if (reasoning != null && typeof reasoning !== 'string') {
|
|
@@ -330,7 +330,6 @@ class Dataset {
|
|
|
330
330
|
* @param {string} recordId Dataset record id.
|
|
331
331
|
* @param {'add' | 'remove' | 'replace'} operation Tag operation to queue.
|
|
332
332
|
* @param {string[]} tags Tags in key:value format.
|
|
333
|
-
* @returns {void}
|
|
334
333
|
*/
|
|
335
334
|
#queueTagOperation (recordId, operation, tags) {
|
|
336
335
|
if (operation !== 'replace' && tags.length === 0) return
|
|
@@ -503,7 +502,6 @@ class Dataset {
|
|
|
503
502
|
* Detach tag changes sent by this batch so edits made while the request is in flight
|
|
504
503
|
* are queued relative to the response that this batch will commit.
|
|
505
504
|
* @param {PendingBatch} pending
|
|
506
|
-
* @returns {void}
|
|
507
505
|
*/
|
|
508
506
|
#detachCommittedTagOperations (pending) {
|
|
509
507
|
pending.inFlightTagOperations = new Map()
|
|
@@ -527,7 +525,6 @@ class Dataset {
|
|
|
527
525
|
/**
|
|
528
526
|
* Restore tag changes when a batch request fails, including edits made while it was in flight.
|
|
529
527
|
* @param {PendingBatch} pending
|
|
530
|
-
* @returns {void}
|
|
531
528
|
*/
|
|
532
529
|
#restoreFailedTagOperations (pending) {
|
|
533
530
|
if (!pending.inFlightTagOperations) return
|
|
@@ -549,7 +546,6 @@ class Dataset {
|
|
|
549
546
|
/**
|
|
550
547
|
* Clear the changes represented by a completed batch while retaining concurrent local edits.
|
|
551
548
|
* @param {PendingBatch} pending
|
|
552
|
-
* @returns {void}
|
|
553
549
|
*/
|
|
554
550
|
#clearCommittedChanges (pending) {
|
|
555
551
|
for (const [recordId, payload] of pending.insertPayloads) {
|
|
@@ -35,8 +35,8 @@ class Experiments {
|
|
|
35
35
|
|
|
36
36
|
constructor (config, llmobs) {
|
|
37
37
|
this.#config = config
|
|
38
|
-
this.#llmobs = config.llmobs?.
|
|
39
|
-
this.#projectName = config.llmobs?.
|
|
38
|
+
this.#llmobs = config.llmobs?.DD_LLMOBS_ML_APP || config.service ? llmobs : undefined
|
|
39
|
+
this.#projectName = config.llmobs?.DD_LLMOBS_PROJECT_NAME || DEFAULT_PROJECT_NAME
|
|
40
40
|
this.#client = this.#clientForProject(this.#projectName)
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -179,9 +179,9 @@ class Experiments {
|
|
|
179
179
|
const projectName = options?.projectName ?? datasetProjectName
|
|
180
180
|
const client = this.#clientForOperation(projectName)
|
|
181
181
|
const usesDatasetOverride = datasetProjectName !== undefined && datasetProjectName !== this.#projectName
|
|
182
|
-
const resolvedProjectName = projectName ?? this.#config.llmobs?.
|
|
182
|
+
const resolvedProjectName = projectName ?? this.#config.llmobs?.DD_LLMOBS_PROJECT_NAME
|
|
183
183
|
const experimentOptions = options?.projectName === undefined &&
|
|
184
|
-
(usesDatasetOverride || this.#config.llmobs?.
|
|
184
|
+
(usesDatasetOverride || this.#config.llmobs?.DD_LLMOBS_PROJECT_NAME !== undefined) &&
|
|
185
185
|
resolvedProjectName !== undefined
|
|
186
186
|
? { ...options, projectName: resolvedProjectName }
|
|
187
187
|
: options
|
|
@@ -198,8 +198,9 @@ class Experiments {
|
|
|
198
198
|
*/
|
|
199
199
|
startExperiment (options) {
|
|
200
200
|
const client = this.#clientForOperation(options?.projectName)
|
|
201
|
-
const experimentOptions = options?.projectName === undefined &&
|
|
202
|
-
|
|
201
|
+
const experimentOptions = options?.projectName === undefined &&
|
|
202
|
+
this.#config.llmobs?.DD_LLMOBS_PROJECT_NAME !== undefined
|
|
203
|
+
? { ...options, projectName: this.#config.llmobs.DD_LLMOBS_PROJECT_NAME }
|
|
203
204
|
: options
|
|
204
205
|
return new Experiment(client, { ...experimentOptions, external: true }).start()
|
|
205
206
|
.then(experiment => new ExternalExperiment(experiment))
|
|
@@ -14,7 +14,6 @@ const EVALUATOR_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @param {object | null | undefined} value
|
|
17
|
-
* @returns {boolean}
|
|
18
17
|
*/
|
|
19
18
|
function hasEntries (value) {
|
|
20
19
|
if (!value) return false
|
|
@@ -47,16 +46,12 @@ function tagOperationsAreEmpty (operations) {
|
|
|
47
46
|
/**
|
|
48
47
|
* @param {unknown} value
|
|
49
48
|
* @param {string} name
|
|
50
|
-
* @returns {number}
|
|
51
49
|
*/
|
|
52
50
|
function normalizePositiveInteger (value, name) {
|
|
53
51
|
if (!Number.isInteger(value) || value < 1) throw new Error(`${name} must be a positive integer`)
|
|
54
|
-
return value
|
|
52
|
+
return /** @type {number} */ (value)
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
/**
|
|
58
|
-
* @returns {string}
|
|
59
|
-
*/
|
|
60
55
|
function generateRunId () {
|
|
61
56
|
return randomUUID()
|
|
62
57
|
}
|
|
@@ -77,7 +72,6 @@ function validateEvaluatorName (name) {
|
|
|
77
72
|
/**
|
|
78
73
|
* @param {(...args: unknown[]) => unknown} fn
|
|
79
74
|
* @param {string} fallback
|
|
80
|
-
* @returns {string}
|
|
81
75
|
*/
|
|
82
76
|
function functionName (fn, fallback) {
|
|
83
77
|
return typeof fn.name === 'string' && fn.name.length > 0 ? fn.name : fallback
|
|
@@ -124,7 +118,6 @@ function normalizeEvaluators (evaluators, kind) {
|
|
|
124
118
|
|
|
125
119
|
/**
|
|
126
120
|
* @param {unknown} value
|
|
127
|
-
* @returns {string}
|
|
128
121
|
*/
|
|
129
122
|
function inferMetricType (value) {
|
|
130
123
|
if (typeof value === 'boolean') return 'boolean'
|
|
@@ -184,7 +177,6 @@ function normalizeJsonMetricValue (value) {
|
|
|
184
177
|
|
|
185
178
|
/**
|
|
186
179
|
* @param {unknown} value
|
|
187
|
-
* @returns {string}
|
|
188
180
|
*/
|
|
189
181
|
function stringify (value) {
|
|
190
182
|
if (value == null) return ''
|
|
@@ -270,7 +262,6 @@ function sleep (ms) {
|
|
|
270
262
|
/**
|
|
271
263
|
* @param {unknown} value
|
|
272
264
|
* @param {number} fallback
|
|
273
|
-
* @returns {number}
|
|
274
265
|
*/
|
|
275
266
|
function timestampMs (value, fallback = Date.now()) {
|
|
276
267
|
if (value === null || value === undefined) return fallback
|
|
@@ -286,7 +277,6 @@ function timestampMs (value, fallback = Date.now()) {
|
|
|
286
277
|
/**
|
|
287
278
|
* @param {{ durationMs?: unknown, completedAt?: unknown }} row
|
|
288
279
|
* @param {number} startMs
|
|
289
|
-
* @returns {number}
|
|
290
280
|
*/
|
|
291
281
|
function durationNs (row, startMs) {
|
|
292
282
|
if (typeof row.durationMs === 'number' && Number.isFinite(row.durationMs)) {
|
|
@@ -152,7 +152,6 @@ function disable () {
|
|
|
152
152
|
* Keeps retired writers reachable until their destroy-triggered deliveries complete.
|
|
153
153
|
* @param {LLMObsSpanWriter | null} retiredSpanWriter
|
|
154
154
|
* @param {LLMObsEvalMetricsWriter | null} retiredEvalWriter
|
|
155
|
-
* @returns {void}
|
|
156
155
|
*/
|
|
157
156
|
function retireWriters (retiredSpanWriter, retiredEvalWriter) {
|
|
158
157
|
const retiredWriters = [retiredSpanWriter, retiredEvalWriter].filter(Boolean)
|
|
@@ -183,7 +182,7 @@ function handleLLMObsInjection (injection) {
|
|
|
183
182
|
const mlApp =
|
|
184
183
|
mlObsSpanTags?.[ML_APP] ||
|
|
185
184
|
parentContext?._trace?.tags?.[PROPAGATED_ML_APP_KEY] ||
|
|
186
|
-
globalTracerConfig.llmobs.
|
|
185
|
+
globalTracerConfig.llmobs.DD_LLMOBS_ML_APP
|
|
187
186
|
|
|
188
187
|
const sampleRate =
|
|
189
188
|
mlObsSpanTags?.[SAMPLE_RATE] ?? parentContext?._trace?.tags?.[PROPAGATED_SAMPLE_RATE_KEY]
|
|
@@ -239,7 +238,6 @@ function handleLLMObsInjection (injection) {
|
|
|
239
238
|
* @param {Function} [done]
|
|
240
239
|
* @param {LLMObsSpanWriter | null} [currentSpanWriter]
|
|
241
240
|
* @param {LLMObsEvalMetricsWriter | null} [currentEvalWriter]
|
|
242
|
-
* @returns {boolean} `true` when a writer throws synchronously.
|
|
243
241
|
*/
|
|
244
242
|
function flushWriters (done, currentSpanWriter = spanWriter, currentEvalWriter = evalWriter) {
|
|
245
243
|
let failed = false
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const NoopPrompts = require('./prompts/noop')
|
|
4
|
+
|
|
3
5
|
let NoopExperiments
|
|
4
6
|
|
|
5
7
|
class NoopLLMObs {
|
|
@@ -16,6 +18,14 @@ class NoopLLMObs {
|
|
|
16
18
|
return new NoopExperiments('LLM Observability is not enabled')
|
|
17
19
|
}
|
|
18
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Prompt Management API.
|
|
23
|
+
* @returns {import('../../../../index').llmobs.Prompts}
|
|
24
|
+
*/
|
|
25
|
+
get prompts () {
|
|
26
|
+
return new NoopPrompts()
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
enable (options) {}
|
|
20
30
|
|
|
21
31
|
disable () {}
|
|
@@ -337,7 +337,6 @@ function getToolNameFromTags (tags) {
|
|
|
337
337
|
|
|
338
338
|
/**
|
|
339
339
|
* @param {unknown} value
|
|
340
|
-
* @returns {string}
|
|
341
340
|
*/
|
|
342
341
|
function stringifyToolCallResult (value) {
|
|
343
342
|
return JSON.stringify(value) ?? UNPARSABLE_TOOL_RESULT
|
|
@@ -345,7 +344,6 @@ function stringifyToolCallResult (value) {
|
|
|
345
344
|
|
|
346
345
|
/**
|
|
347
346
|
* @param {ToolCallContentPart[]} value
|
|
348
|
-
* @returns {string}
|
|
349
347
|
*/
|
|
350
348
|
function formatToolCallContent (value) {
|
|
351
349
|
if (!Array.isArray(value)) return UNPARSABLE_TOOL_RESULT
|
|
@@ -388,7 +386,6 @@ function formatToolCallContent (value) {
|
|
|
388
386
|
|
|
389
387
|
/**
|
|
390
388
|
* @param {ToolCallResultContent | null | undefined} content
|
|
391
|
-
* @returns {string}
|
|
392
389
|
*/
|
|
393
390
|
function getToolCallResultContent (content) {
|
|
394
391
|
try {
|
|
@@ -426,7 +423,6 @@ function getToolCallResultContent (content) {
|
|
|
426
423
|
* Computes the LLM Observability `ai` span name
|
|
427
424
|
* @param {string} operation
|
|
428
425
|
* @param {string} functionId
|
|
429
|
-
* @returns {string}
|
|
430
426
|
*/
|
|
431
427
|
function getLlmObsSpanName (operation, functionId) {
|
|
432
428
|
return functionId ? `${functionId}.${operation}` : operation
|
|
@@ -62,7 +62,6 @@ function formatAnthropicToolResultContent (content) {
|
|
|
62
62
|
*
|
|
63
63
|
* @param {AnthropicLlmObsMessage[]} messages
|
|
64
64
|
* @param {{ role: string, content: string | Array<TextBlock | ImageBlock | ToolUseBlock | ToolResultBlock> }} message
|
|
65
|
-
* @returns {void}
|
|
66
65
|
*/
|
|
67
66
|
function appendMessage (messages, { role, content }) {
|
|
68
67
|
if (typeof content === 'string') {
|
|
@@ -55,7 +55,6 @@ function groupPartsByRole (parts) {
|
|
|
55
55
|
/**
|
|
56
56
|
* Check if parts contain thought/reasoning content
|
|
57
57
|
* @param {Array<{thought?: boolean}>} parts
|
|
58
|
-
* @returns {boolean}
|
|
59
58
|
*/
|
|
60
59
|
function hasThoughtParts (parts) {
|
|
61
60
|
return parts.some(part => part.thought === true)
|
|
@@ -65,7 +64,6 @@ function hasThoughtParts (parts) {
|
|
|
65
64
|
* Determine the role from a candidate and its parts
|
|
66
65
|
* @param {object} candidate
|
|
67
66
|
* @param {Array<{thought?: boolean}>} parts
|
|
68
|
-
* @returns {string}
|
|
69
67
|
*/
|
|
70
68
|
function determineRole (candidate, parts = []) {
|
|
71
69
|
// Check parts for thought indicators
|
|
@@ -84,7 +82,6 @@ function determineRole (candidate, parts = []) {
|
|
|
84
82
|
/**
|
|
85
83
|
* Normalize role to standard values
|
|
86
84
|
* @param {string} role
|
|
87
|
-
* @returns {string}
|
|
88
85
|
*/
|
|
89
86
|
function normalizeRole (role) {
|
|
90
87
|
if (role === ROLES.MODEL) return ROLES.ASSISTANT
|
|
@@ -520,7 +517,6 @@ function formatOutputMessages (response, isStreaming = false) {
|
|
|
520
517
|
/**
|
|
521
518
|
* Format embedding output from response
|
|
522
519
|
* @param {object} response
|
|
523
|
-
* @returns {string}
|
|
524
520
|
*/
|
|
525
521
|
function formatEmbeddingOutput (response) {
|
|
526
522
|
if (!response?.embeddings?.length) {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Formats tool call input as a JSON string.
|
|
5
5
|
* @param {string} toolName - The name of the tool being called
|
|
6
6
|
* @param {object} toolArguments - The arguments passed to the tool
|
|
7
|
-
* @returns {string} Formatted input string
|
|
8
7
|
*/
|
|
9
8
|
function formatInput (toolName, toolArguments) {
|
|
10
9
|
if (!toolName && !toolArguments) return ''
|
|
@@ -25,7 +24,6 @@ function formatInput (toolName, toolArguments) {
|
|
|
25
24
|
* MCP tool results contain a `content` array with items like:
|
|
26
25
|
* `[{ type: 'text', text: '...' }, { type: 'image', data: '...', mimeType: '...' }]`
|
|
27
26
|
* @param {object} result - The MCP CallToolResult
|
|
28
|
-
* @returns {string} JSON string of `{ content: Array<{type, text, annotations, meta}>, isError: boolean }`
|
|
29
27
|
*/
|
|
30
28
|
function formatOutput (result) {
|
|
31
29
|
if (!result) return ''
|
|
@@ -6,7 +6,6 @@ const INPUT_TYPE_TEXT = 'input_text'
|
|
|
6
6
|
|
|
7
7
|
const IMAGE_FALLBACK = '[image]'
|
|
8
8
|
const FILE_FALLBACK = '[file]'
|
|
9
|
-
const AUDIO_FALLBACK = '[audio]'
|
|
10
9
|
|
|
11
10
|
// OpenAI audio `format` values that don't map cleanly to `audio/<format>`.
|
|
12
11
|
const AUDIO_MIME_TYPES = {
|
|
@@ -19,6 +18,5 @@ module.exports = {
|
|
|
19
18
|
INPUT_TYPE_TEXT,
|
|
20
19
|
IMAGE_FALLBACK,
|
|
21
20
|
FILE_FALLBACK,
|
|
22
|
-
AUDIO_FALLBACK,
|
|
23
21
|
AUDIO_MIME_TYPES,
|
|
24
22
|
}
|
|
@@ -6,7 +6,8 @@ const {
|
|
|
6
6
|
PROMPT_MULTIMODAL,
|
|
7
7
|
INSTRUMENTATION_METHOD_AUTO,
|
|
8
8
|
} = require('../../constants/tags')
|
|
9
|
-
const { audioMimeTypeFromFormat, formatAudioPart
|
|
9
|
+
const { audioMimeTypeFromFormat, formatAudioPart } = require('../../audio-utils')
|
|
10
|
+
const { safeJsonParse } = require('../../util')
|
|
10
11
|
const { AUDIO_MIME_TYPES } = require('./constants')
|
|
11
12
|
const {
|
|
12
13
|
extractChatTemplateFromInstructions,
|
|
@@ -14,7 +15,7 @@ const {
|
|
|
14
15
|
extractTextFromContentItem,
|
|
15
16
|
extractContentParts,
|
|
16
17
|
hasMultimodalInputs,
|
|
17
|
-
|
|
18
|
+
getModelProviderAndClient,
|
|
18
19
|
} = require('./utils')
|
|
19
20
|
|
|
20
21
|
const allowedParamKeys = new Set([
|
|
@@ -108,10 +109,7 @@ class OpenAiLLMObsPlugin extends LLMObsPlugin {
|
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
_getModelProviderAndClient (baseUrl = '') {
|
|
111
|
-
|
|
112
|
-
if (modelProvider === 'azure_openai') return { modelProvider, client: 'AzureOpenAI' }
|
|
113
|
-
if (modelProvider === 'deepseek') return { modelProvider, client: 'DeepSeek' }
|
|
114
|
-
return { modelProvider, client: 'OpenAI' }
|
|
112
|
+
return getModelProviderAndClient(baseUrl)
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
_extractMetrics (response) {
|