dd-trace 5.81.0 → 5.83.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/LICENSE-3rdparty.csv +78 -79
- package/ci/init.js +6 -6
- package/index.d.ts +159 -3
- package/loader-hook.mjs +8 -3
- package/package.json +64 -66
- package/packages/datadog-core/src/storage.js +7 -7
- package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
- package/packages/datadog-esbuild/index.js +14 -7
- package/packages/datadog-esbuild/src/utils.js +14 -2
- package/packages/datadog-instrumentations/src/aerospike.js +3 -2
- package/packages/datadog-instrumentations/src/ai.js +9 -5
- package/packages/datadog-instrumentations/src/amqp10.js +1 -1
- package/packages/datadog-instrumentations/src/amqplib.js +4 -4
- package/packages/datadog-instrumentations/src/anthropic.js +2 -2
- package/packages/datadog-instrumentations/src/apollo-server-core.js +2 -2
- package/packages/datadog-instrumentations/src/apollo-server.js +1 -1
- package/packages/datadog-instrumentations/src/apollo.js +3 -2
- package/packages/datadog-instrumentations/src/avsc.js +1 -1
- package/packages/datadog-instrumentations/src/aws-sdk.js +1 -1
- package/packages/datadog-instrumentations/src/azure-event-hubs.js +4 -3
- package/packages/datadog-instrumentations/src/azure-functions.js +2 -2
- package/packages/datadog-instrumentations/src/azure-service-bus.js +3 -4
- package/packages/datadog-instrumentations/src/bluebird.js +1 -1
- package/packages/datadog-instrumentations/src/bullmq.js +11 -0
- package/packages/datadog-instrumentations/src/bunyan.js +1 -1
- package/packages/datadog-instrumentations/src/cassandra-driver.js +1 -1
- package/packages/datadog-instrumentations/src/child_process.js +3 -3
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +3 -3
- package/packages/datadog-instrumentations/src/couchbase.js +1 -1
- package/packages/datadog-instrumentations/src/crypto.js +1 -1
- package/packages/datadog-instrumentations/src/cucumber.js +13 -14
- package/packages/datadog-instrumentations/src/cypress.js +1 -1
- package/packages/datadog-instrumentations/src/dns.js +1 -1
- package/packages/datadog-instrumentations/src/elasticsearch.js +1 -1
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +1 -1
- package/packages/datadog-instrumentations/src/express.js +1 -1
- package/packages/datadog-instrumentations/src/fs.js +1 -1
- package/packages/datadog-instrumentations/src/generic-pool.js +1 -1
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +137 -15
- package/packages/datadog-instrumentations/src/google-cloud-vertexai.js +2 -3
- package/packages/datadog-instrumentations/src/google-genai.js +3 -3
- package/packages/datadog-instrumentations/src/graphql.js +2 -2
- package/packages/datadog-instrumentations/src/grpc/client.js +1 -1
- package/packages/datadog-instrumentations/src/grpc/server.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/instrumentations.js +4 -3
- package/packages/datadog-instrumentations/src/helpers/register.js +9 -11
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/bullmq.json +106 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/shared-utils.js +9 -0
- package/packages/datadog-instrumentations/src/hono.js +55 -10
- package/packages/datadog-instrumentations/src/http/client.js +2 -2
- package/packages/datadog-instrumentations/src/ioredis.js +1 -1
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +37 -16
- package/packages/datadog-instrumentations/src/kafkajs.js +3 -3
- package/packages/datadog-instrumentations/src/knex.js +1 -1
- package/packages/datadog-instrumentations/src/koa.js +2 -1
- package/packages/datadog-instrumentations/src/ldapjs.js +1 -1
- package/packages/datadog-instrumentations/src/light-my-request.js +93 -0
- package/packages/datadog-instrumentations/src/limitd-client.js +1 -1
- package/packages/datadog-instrumentations/src/lodash.js +1 -2
- package/packages/datadog-instrumentations/src/mariadb.js +1 -2
- package/packages/datadog-instrumentations/src/memcached.js +1 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/mocha.js +1 -1
- package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
- package/packages/datadog-instrumentations/src/mongodb.js +1 -1
- package/packages/datadog-instrumentations/src/mongoose.js +1 -1
- package/packages/datadog-instrumentations/src/mquery.js +1 -1
- package/packages/datadog-instrumentations/src/mysql.js +2 -2
- package/packages/datadog-instrumentations/src/mysql2.js +3 -3
- package/packages/datadog-instrumentations/src/net.js +14 -6
- package/packages/datadog-instrumentations/src/next.js +1 -1
- package/packages/datadog-instrumentations/src/nyc.js +2 -2
- package/packages/datadog-instrumentations/src/openai.js +2 -2
- package/packages/datadog-instrumentations/src/opensearch.js +1 -1
- package/packages/datadog-instrumentations/src/oracledb.js +1 -1
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +5 -5
- package/packages/datadog-instrumentations/src/pg.js +7 -5
- package/packages/datadog-instrumentations/src/pino.js +1 -1
- package/packages/datadog-instrumentations/src/playwright.js +4 -4
- package/packages/datadog-instrumentations/src/prisma.js +52 -37
- package/packages/datadog-instrumentations/src/process.js +1 -1
- package/packages/datadog-instrumentations/src/promise-js.js +1 -1
- package/packages/datadog-instrumentations/src/promise.js +1 -1
- package/packages/datadog-instrumentations/src/protobufjs.js +1 -1
- package/packages/datadog-instrumentations/src/q.js +1 -1
- package/packages/datadog-instrumentations/src/redis.js +1 -1
- package/packages/datadog-instrumentations/src/rhea.js +1 -1
- package/packages/datadog-instrumentations/src/selenium.js +3 -3
- package/packages/datadog-instrumentations/src/sequelize.js +1 -2
- package/packages/datadog-instrumentations/src/sharedb.js +1 -1
- package/packages/datadog-instrumentations/src/tedious.js +1 -1
- package/packages/datadog-instrumentations/src/undici.js +15 -4
- package/packages/datadog-instrumentations/src/url.js +1 -1
- package/packages/datadog-instrumentations/src/vitest.js +1 -1
- package/packages/datadog-instrumentations/src/vm.js +1 -1
- package/packages/datadog-instrumentations/src/when.js +1 -1
- package/packages/datadog-instrumentations/src/winston.js +1 -1
- package/packages/datadog-instrumentations/src/ws.js +3 -2
- package/packages/datadog-plugin-amqp10/src/index.js +1 -1
- package/packages/datadog-plugin-amqplib/src/index.js +1 -1
- package/packages/datadog-plugin-anthropic/src/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/base.js +4 -4
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +4 -4
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/util.js +3 -3
- package/packages/datadog-plugin-azure-event-hubs/src/index.js +1 -1
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +21 -7
- package/packages/datadog-plugin-azure-service-bus/src/index.js +1 -1
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +6 -2
- package/packages/datadog-plugin-bullmq/src/consumer.js +60 -0
- package/packages/datadog-plugin-bullmq/src/index.js +18 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +178 -0
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +1 -1
- package/packages/datadog-plugin-cucumber/src/index.js +2 -2
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +2 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +1 -1
- package/packages/datadog-plugin-dd-trace-api/src/index.js +2 -2
- package/packages/datadog-plugin-express/src/code_origin.js +21 -15
- package/packages/datadog-plugin-express/src/index.js +1 -1
- package/packages/datadog-plugin-fastify/src/code_origin.js +17 -4
- package/packages/datadog-plugin-fastify/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +13 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +171 -12
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +160 -13
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +217 -0
- package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +1 -1
- package/packages/datadog-plugin-google-genai/src/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
- package/packages/datadog-plugin-grpc/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/client.js +2 -1
- package/packages/datadog-plugin-http/src/index.js +25 -5
- package/packages/datadog-plugin-http2/src/client.js +2 -2
- package/packages/datadog-plugin-http2/src/index.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +2 -2
- package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
- package/packages/datadog-plugin-langchain/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +2 -2
- package/packages/datadog-plugin-moleculer/src/index.js +1 -1
- package/packages/datadog-plugin-mongodb-core/src/index.js +8 -4
- package/packages/datadog-plugin-openai/src/index.js +1 -1
- package/packages/datadog-plugin-openai/src/stream-helpers.js +30 -10
- package/packages/datadog-plugin-openai/src/tracing.js +2 -2
- package/packages/datadog-plugin-playwright/src/index.js +3 -3
- package/packages/datadog-plugin-rhea/src/index.js +1 -1
- package/packages/datadog-plugin-undici/src/index.js +305 -2
- package/packages/datadog-plugin-vitest/src/index.js +5 -5
- package/packages/datadog-plugin-ws/src/close.js +56 -3
- package/packages/datadog-plugin-ws/src/index.js +4 -0
- package/packages/datadog-plugin-ws/src/producer.js +39 -4
- package/packages/datadog-plugin-ws/src/receiver.js +39 -3
- package/packages/datadog-plugin-ws/src/server.js +13 -1
- package/packages/datadog-plugin-ws/src/util.js +107 -0
- package/packages/datadog-shimmer/src/shimmer.js +2 -2
- package/packages/dd-trace/index.js +19 -0
- package/packages/dd-trace/src/aiguard/sdk.js +3 -3
- package/packages/dd-trace/src/appsec/graphql.js +2 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/code-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/command-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/ldap-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +3 -3
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/untrusted-deserialization-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/unvalidated-redirect-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-cipher-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-hash-analyzer.js +3 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-randomness-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
- package/packages/dd-trace/src/appsec/iast/index.js +5 -5
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +1 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.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 +11 -15
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
- package/packages/dd-trace/src/appsec/index.js +8 -8
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +1 -1
- package/packages/dd-trace/src/appsec/rasp/index.js +3 -5
- package/packages/dd-trace/src/appsec/rasp/lfi.js +1 -1
- package/packages/dd-trace/src/appsec/rc-products.js +10 -0
- package/packages/dd-trace/src/appsec/recommended.json +230 -3
- package/packages/dd-trace/src/appsec/remote_config.js +177 -0
- package/packages/dd-trace/src/appsec/reporter.js +3 -3
- package/packages/dd-trace/src/appsec/rule_manager.js +37 -20
- package/packages/dd-trace/src/appsec/sdk/index.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +2 -2
- package/packages/dd-trace/src/appsec/user_tracking.js +2 -2
- package/packages/dd-trace/src/appsec/waf/index.js +17 -3
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +11 -0
- package/packages/dd-trace/src/azure_metadata.js +15 -4
- package/packages/dd-trace/src/baggage.js +36 -11
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +5 -1
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +6 -0
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -3
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -3
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +5 -5
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +1 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -2
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -4
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +4 -4
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +2 -2
- package/packages/dd-trace/src/{config_defaults.js → config/defaults.js} +5 -4
- package/packages/dd-trace/src/{config-helper.js → config/helper.js} +88 -15
- package/packages/dd-trace/src/{config.js → config/index.js} +115 -67
- package/packages/dd-trace/src/config/remote_config.js +202 -0
- package/packages/dd-trace/src/{config_stable.js → config/stable.js} +20 -32
- package/packages/dd-trace/src/{supported-configurations.json → config/supported-configurations.json} +5 -0
- package/packages/dd-trace/src/constants.js +5 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +11 -2
- package/packages/dd-trace/src/datastreams/checkpointer.js +2 -2
- package/packages/dd-trace/src/datastreams/index.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +7 -7
- package/packages/dd-trace/src/datastreams/processor.js +3 -3
- package/packages/dd-trace/src/datastreams/writer.js +3 -3
- package/packages/dd-trace/src/debugger/config.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/config.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/index.js +7 -2
- package/packages/dd-trace/src/debugger/devtools_client/send.js +6 -6
- package/packages/dd-trace/src/debugger/devtools_client/session.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +5 -5
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/constants.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/state.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/status.js +2 -2
- package/packages/dd-trace/src/debugger/index.js +84 -16
- package/packages/dd-trace/src/dogstatsd.js +5 -4
- package/packages/dd-trace/src/encode/0.4.js +3 -3
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +2 -2
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
- package/packages/dd-trace/src/encode/span-stats.js +6 -1
- package/packages/dd-trace/src/exporter.js +2 -2
- package/packages/dd-trace/src/exporters/agent/index.js +2 -4
- package/packages/dd-trace/src/exporters/agent/writer.js +9 -14
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -2
- package/packages/dd-trace/src/exporters/common/docker.js +2 -2
- package/packages/dd-trace/src/exporters/common/request.js +3 -3
- package/packages/dd-trace/src/exporters/common/util.js +2 -2
- package/packages/dd-trace/src/exporters/common/writer.js +1 -1
- package/packages/dd-trace/src/exporters/span-stats/index.js +1 -1
- package/packages/dd-trace/src/external-logger/src/index.js +1 -2
- package/packages/dd-trace/src/flare/index.js +2 -2
- package/packages/dd-trace/src/guardrails/index.js +6 -3
- package/packages/dd-trace/src/guardrails/telemetry.js +1 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/index.js +4 -4
- package/packages/dd-trace/src/lambda/handler.js +5 -5
- package/packages/dd-trace/src/lambda/index.js +2 -2
- package/packages/dd-trace/src/lambda/runtime/patch.js +6 -6
- package/packages/dd-trace/src/lambda/runtime/ritm.js +3 -3
- package/packages/dd-trace/src/llmobs/constants/tags.js +14 -1
- package/packages/dd-trace/src/llmobs/index.js +10 -11
- package/packages/dd-trace/src/llmobs/noop.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +38 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +30 -9
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +3 -3
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +2 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/llm.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +16 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +19 -5
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +22 -10
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +46 -26
- package/packages/dd-trace/src/llmobs/span_processor.js +26 -20
- package/packages/dd-trace/src/llmobs/tagger.js +175 -1
- package/packages/dd-trace/src/llmobs/telemetry.js +3 -4
- package/packages/dd-trace/src/llmobs/writers/base.js +117 -38
- package/packages/dd-trace/src/llmobs/writers/spans.js +5 -5
- package/packages/dd-trace/src/log/index.js +5 -5
- package/packages/dd-trace/src/noop/proxy.js +5 -5
- package/packages/dd-trace/src/noop/span.js +1 -1
- package/packages/dd-trace/src/openfeature/index.js +2 -2
- package/packages/dd-trace/src/openfeature/noop.js +14 -14
- package/packages/dd-trace/src/openfeature/remote_config.js +31 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +12 -13
- package/packages/dd-trace/src/openfeature/writers/exposures.js +9 -9
- package/packages/dd-trace/src/opentelemetry/context_manager.js +2 -2
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +1 -1
- package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +4 -4
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +9 -8
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +3 -3
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +2 -2
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +4 -4
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +36 -11
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +11 -10
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +1 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +51 -9
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +68 -28
- package/packages/dd-trace/src/opentracing/span.js +7 -7
- package/packages/dd-trace/src/opentracing/tracer.js +5 -5
- package/packages/dd-trace/src/payload-tagging/index.js +6 -2
- package/packages/dd-trace/src/plugin_manager.js +8 -6
- package/packages/dd-trace/src/plugins/apollo.js +1 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +27 -27
- package/packages/dd-trace/src/plugins/database.js +1 -1
- package/packages/dd-trace/src/plugins/index.js +5 -1
- package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
- package/packages/dd-trace/src/plugins/outbound.js +1 -1
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +5 -8
- package/packages/dd-trace/src/plugins/util/git-cache.js +3 -3
- package/packages/dd-trace/src/plugins/util/git.js +8 -8
- package/packages/dd-trace/src/plugins/util/stacktrace.js +1 -1
- package/packages/dd-trace/src/plugins/util/test.js +25 -25
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +41 -43
- package/packages/dd-trace/src/plugins/util/web.js +8 -5
- package/packages/dd-trace/src/priority_sampler.js +15 -16
- package/packages/dd-trace/src/process-tags/index.js +31 -29
- package/packages/dd-trace/src/profiler.js +4 -39
- package/packages/dd-trace/src/profiling/config.js +104 -50
- package/packages/dd-trace/src/profiling/exporter_cli.js +8 -8
- package/packages/dd-trace/src/profiling/exporters/agent.js +6 -6
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +9 -2
- package/packages/dd-trace/src/profiling/index.js +1 -1
- package/packages/dd-trace/src/profiling/libuv-size.js +1 -1
- package/packages/dd-trace/src/profiling/profiler.js +61 -7
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +2 -2
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/proxy.js +43 -20
- package/packages/dd-trace/src/remote_config/capabilities.js +3 -0
- package/packages/dd-trace/src/remote_config/index.js +541 -137
- package/packages/dd-trace/src/require-package-json.js +1 -1
- package/packages/dd-trace/src/ritm.js +58 -31
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +3 -3
- package/packages/dd-trace/src/serverless.js +17 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +8 -0
- package/packages/dd-trace/src/span_format.js +1 -1
- package/packages/dd-trace/src/span_processor.js +4 -4
- package/packages/dd-trace/src/span_stats.js +6 -4
- package/packages/dd-trace/src/standalone/index.js +1 -1
- package/packages/dd-trace/src/startup-log.js +7 -16
- package/packages/dd-trace/src/telemetry/dependencies.js +3 -3
- package/packages/dd-trace/src/telemetry/endpoints.js +75 -13
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/send-data.js +103 -4
- package/packages/dd-trace/src/telemetry/telemetry.js +238 -114
- package/packages/dd-trace/src/tracer.js +3 -3
- package/packages/dd-trace/src/tracer_metadata.js +19 -15
- package/packages/dd-trace/src/remote_config/manager.js +0 -368
- /package/packages/dd-trace/src/{git_properties.js → config/git_properties.js} +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { channel } = require('dc-polyfill')
|
|
3
4
|
const BaseLLMObsPlugin = require('../base')
|
|
4
5
|
const { getModelProvider } = require('../../../../../datadog-plugin-ai/src/utils')
|
|
5
6
|
|
|
6
|
-
const { channel } = require('dc-polyfill')
|
|
7
|
-
|
|
8
7
|
const toolCreationCh = channel('dd-trace:vercel-ai:tool')
|
|
9
8
|
const setAttributesCh = channel('dd-trace:vercel-ai:span:setAttributes')
|
|
10
9
|
|
|
@@ -21,6 +20,38 @@ const {
|
|
|
21
20
|
getLlmObsSpanName
|
|
22
21
|
} = require('./util')
|
|
23
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {Record<string, unknown> & { description?: string, id?: string }} AvailableToolArgs
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {string | number | boolean | null | undefined | string[] | number[] | boolean[]} TagValue
|
|
29
|
+
* @typedef {Record<string, TagValue>} SpanTags
|
|
30
|
+
*
|
|
31
|
+
* @typedef {{ name?: string, description?: string }} ToolForModel
|
|
32
|
+
*
|
|
33
|
+
* @typedef {{ type: 'text' | 'reasoning' | 'redacted-reasoning', text?: string, data?: string }} TextPart
|
|
34
|
+
* @typedef {{ type: 'tool-call', toolName: string, toolCallId: string, args?: unknown, input?: unknown }} ToolCallPart
|
|
35
|
+
* @typedef {(
|
|
36
|
+
* { type: 'tool-result', toolCallId: string, output?: { type: string, value?: unknown }, result?: unknown } &
|
|
37
|
+
* Record<string, unknown>
|
|
38
|
+
* )} ToolResultPart
|
|
39
|
+
*
|
|
40
|
+
* @typedef {{
|
|
41
|
+
* role: 'system',
|
|
42
|
+
* content: string
|
|
43
|
+
* } | {
|
|
44
|
+
* role: 'user',
|
|
45
|
+
* content: TextPart[]
|
|
46
|
+
* } | {
|
|
47
|
+
* role: 'assistant',
|
|
48
|
+
* content: Array<TextPart | ToolCallPart>
|
|
49
|
+
* } | {
|
|
50
|
+
* role: 'tool',
|
|
51
|
+
* content: ToolResultPart[]
|
|
52
|
+
* }} AiSdkMessage
|
|
53
|
+
*/
|
|
54
|
+
|
|
24
55
|
const SPAN_NAME_TO_KIND_MAPPING = {
|
|
25
56
|
// embeddings
|
|
26
57
|
embed: 'workflow',
|
|
@@ -47,7 +78,7 @@ class VercelAILLMObsPlugin extends BaseLLMObsPlugin {
|
|
|
47
78
|
/**
|
|
48
79
|
* The available tools within the runtime scope of this integration.
|
|
49
80
|
* This essentially acts as a global registry for all tools made through the Vercel AI SDK.
|
|
50
|
-
* @type {Set<
|
|
81
|
+
* @type {Set<AvailableToolArgs>}
|
|
51
82
|
*/
|
|
52
83
|
#availableTools
|
|
53
84
|
|
|
@@ -80,7 +111,7 @@ class VercelAILLMObsPlugin extends BaseLLMObsPlugin {
|
|
|
80
111
|
* We use the tool description as the next best identifier for a tool.
|
|
81
112
|
*
|
|
82
113
|
* @param {string} toolName
|
|
83
|
-
* @param {string} toolDescription
|
|
114
|
+
* @param {string | undefined} toolDescription
|
|
84
115
|
* @returns {string | undefined}
|
|
85
116
|
*/
|
|
86
117
|
findToolName (toolName, toolDescription) {
|
|
@@ -223,7 +254,7 @@ class VercelAILLMObsPlugin extends BaseLLMObsPlugin {
|
|
|
223
254
|
|
|
224
255
|
/**
|
|
225
256
|
* @param {import('../../../opentracing/span')} span
|
|
226
|
-
* @param {
|
|
257
|
+
* @param {SpanTags} tags
|
|
227
258
|
*/
|
|
228
259
|
setLLMOperationTags (span, tags) {
|
|
229
260
|
const toolsForModel = tags['ai.prompt.tools']?.map(getJsonStringValue)
|
|
@@ -290,8 +321,8 @@ class VercelAILLMObsPlugin extends BaseLLMObsPlugin {
|
|
|
290
321
|
* it is possible to have multiple tool call results in a single message that we
|
|
291
322
|
* need to split into multiple messages.
|
|
292
323
|
*
|
|
293
|
-
* @param {
|
|
294
|
-
* @param {
|
|
324
|
+
* @param {AiSdkMessage} message
|
|
325
|
+
* @param {ToolForModel[] | null | undefined} toolsForModel
|
|
295
326
|
* @returns {Array<{role: string, content: string, toolId?: string,
|
|
296
327
|
* toolCalls?: Array<{arguments: string, name: string, toolId: string, type: string}>}>}
|
|
297
328
|
*/
|
|
@@ -10,16 +10,35 @@ const MODEL_METADATA_KEYS = new Set([
|
|
|
10
10
|
'stop_sequences'
|
|
11
11
|
])
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {import('../../../opentracing/span')} Span
|
|
15
|
+
*
|
|
16
|
+
* @typedef {string | number | boolean | null | undefined | string[] | number[] | boolean[]} TagValue
|
|
17
|
+
* @typedef {Record<string, TagValue>} SpanTags
|
|
18
|
+
*
|
|
19
|
+
* @typedef {{ span?: Span }} CurrentStore
|
|
20
|
+
* @typedef {{ currentStore?: CurrentStore, attributes?: SpanTags }} AiPluginContext
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {{
|
|
25
|
+
* type: string,
|
|
26
|
+
* value?: unknown
|
|
27
|
+
* }} ToolCallOutput
|
|
28
|
+
*
|
|
29
|
+
* @typedef {{ output?: ToolCallOutput, result?: unknown } & Record<string, unknown>} ToolCallResultContent
|
|
30
|
+
*/
|
|
31
|
+
|
|
13
32
|
/**
|
|
14
33
|
* Get the span tags from the context (either the attributes or the span tags).
|
|
15
34
|
*
|
|
16
|
-
* @param {
|
|
17
|
-
* @returns {
|
|
35
|
+
* @param {AiPluginContext} ctx
|
|
36
|
+
* @returns {SpanTags}
|
|
18
37
|
*/
|
|
19
38
|
function getSpanTags (ctx) {
|
|
20
39
|
const span = ctx.currentStore?.span
|
|
21
40
|
const carrier = ctx.attributes ?? span?.context()._tags ?? {}
|
|
22
|
-
return carrier
|
|
41
|
+
return /** @type {SpanTags} */ (carrier)
|
|
23
42
|
}
|
|
24
43
|
|
|
25
44
|
/**
|
|
@@ -88,10 +107,11 @@ function getJsonStringValue (str, defaultValue) {
|
|
|
88
107
|
|
|
89
108
|
/**
|
|
90
109
|
* Get the model metadata from the span tags (top_p, top_k, temperature, etc.)
|
|
91
|
-
* @param {
|
|
92
|
-
* @returns {Record<string,
|
|
110
|
+
* @param {SpanTags} tags
|
|
111
|
+
* @returns {Record<string, unknown> | null}
|
|
93
112
|
*/
|
|
94
113
|
function getModelMetadata (tags) {
|
|
114
|
+
/** @type {Record<string, unknown>} */
|
|
95
115
|
const modelMetadata = {}
|
|
96
116
|
for (const metadata of MODEL_METADATA_KEYS) {
|
|
97
117
|
const metadataTagKey = `gen_ai.request.${metadata}`
|
|
@@ -106,10 +126,11 @@ function getModelMetadata (tags) {
|
|
|
106
126
|
|
|
107
127
|
/**
|
|
108
128
|
* Get the generation metadata from the span tags (maxSteps, maxRetries, etc.)
|
|
109
|
-
* @param {
|
|
110
|
-
* @returns {Record<string,
|
|
129
|
+
* @param {SpanTags} tags
|
|
130
|
+
* @returns {Record<string, unknown> | null}
|
|
111
131
|
*/
|
|
112
132
|
function getGenerationMetadata (tags) {
|
|
133
|
+
/** @type {Record<string, unknown>} */
|
|
113
134
|
const metadata = {}
|
|
114
135
|
|
|
115
136
|
for (const tag of Object.keys(tags)) {
|
|
@@ -131,7 +152,7 @@ function getGenerationMetadata (tags) {
|
|
|
131
152
|
* If the tool name is a parsable number, or is not found, null is returned.
|
|
132
153
|
* Older versions of the ai sdk would tag the tool name as its index in the tools array.
|
|
133
154
|
*
|
|
134
|
-
* @param {
|
|
155
|
+
* @param {SpanTags} tags
|
|
135
156
|
* @returns {string | null}
|
|
136
157
|
*/
|
|
137
158
|
function getToolNameFromTags (tags) {
|
|
@@ -147,7 +168,7 @@ function getToolNameFromTags (tags) {
|
|
|
147
168
|
/**
|
|
148
169
|
* Get the content of a tool call result.
|
|
149
170
|
* Version 5 of the ai sdk sets this tag as `content.output`, with a `
|
|
150
|
-
* @param {
|
|
171
|
+
* @param {{ output?: { type: string, value: unknown }, result?: unknown }} content
|
|
151
172
|
* @returns {string}
|
|
152
173
|
*/
|
|
153
174
|
function getToolCallResultContent (content) {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const BaseLLMObsPlugin = require('./base')
|
|
4
3
|
const { storage } = require('../../../../datadog-core')
|
|
5
|
-
const llmobsStore = storage('llmobs')
|
|
6
4
|
const telemetry = require('../telemetry')
|
|
7
|
-
|
|
8
5
|
const {
|
|
9
6
|
extractRequestParams,
|
|
10
7
|
extractTextAndResponseReason,
|
|
11
8
|
parseModelId,
|
|
12
9
|
extractTextAndResponseReasonFromStream
|
|
13
10
|
} = require('../../../../datadog-plugin-aws-sdk/src/services/bedrockruntime/utils')
|
|
11
|
+
const BaseLLMObsPlugin = require('./base')
|
|
12
|
+
|
|
13
|
+
const llmobsStore = storage('llmobs')
|
|
14
14
|
|
|
15
15
|
const ENABLED_OPERATIONS = new Set(['invokeModel', 'invokeModelWithResponseStream'])
|
|
16
16
|
|
|
@@ -258,7 +258,7 @@ function formatContentObject (content) {
|
|
|
258
258
|
|
|
259
259
|
/**
|
|
260
260
|
* Format input messages from contents
|
|
261
|
-
* @param {
|
|
261
|
+
* @param {[string|{text: string}|{parts: Array<string|{text: string}>}]} [contents]
|
|
262
262
|
* @returns {Array}
|
|
263
263
|
*/
|
|
264
264
|
function formatInputMessages (contents) {
|
|
@@ -285,7 +285,7 @@ function formatInputMessages (contents) {
|
|
|
285
285
|
|
|
286
286
|
/**
|
|
287
287
|
* Format embedding input from contents
|
|
288
|
-
* @param {
|
|
288
|
+
* @param {[string|{text: string}|{parts: Array<string|{text: string}>}]} [contents]
|
|
289
289
|
* @returns {Array}
|
|
290
290
|
*/
|
|
291
291
|
function formatEmbeddingInput (contents) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const LangChainLLMObsHandler = require('.')
|
|
4
3
|
const { spanHasError } = require('../../../util')
|
|
4
|
+
const LangChainLLMObsHandler = require('.')
|
|
5
5
|
|
|
6
6
|
class LangChainLLMObsChainHandler extends LangChainLLMObsHandler {
|
|
7
7
|
setMetaTags ({ span, inputs, results }) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const LangChainLLMObsHandler = require('.')
|
|
4
3
|
const LLMObsTagger = require('../../../tagger')
|
|
5
4
|
const { spanHasError } = require('../../../util')
|
|
5
|
+
const LangChainLLMObsHandler = require('.')
|
|
6
6
|
|
|
7
7
|
class LangChainLLMObsEmbeddingHandler extends LangChainLLMObsHandler {
|
|
8
8
|
setMetaTags ({ span, inputs, results }) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const LangChainLLMObsHandler = require('.')
|
|
4
3
|
const LLMObsTagger = require('../../../tagger')
|
|
5
4
|
const { spanHasError } = require('../../../util')
|
|
5
|
+
const LangChainLLMObsHandler = require('.')
|
|
6
6
|
|
|
7
7
|
class LangChainLLMObsLlmHandler extends LangChainLLMObsHandler {
|
|
8
8
|
setMetaTags ({ span, inputs, results }) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const LangChainLLMObsHandler = require('.')
|
|
4
3
|
const { spanHasError } = require('../../../util')
|
|
4
|
+
const LangChainLLMObsHandler = require('.')
|
|
5
5
|
|
|
6
6
|
class LangChainLLMObsVectorStoreHandler extends LangChainLLMObsHandler {
|
|
7
7
|
setMetaTags ({ span, inputs, results }) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const INPUT_TYPE_IMAGE = 'input_image'
|
|
4
|
+
const INPUT_TYPE_FILE = 'input_file'
|
|
5
|
+
const INPUT_TYPE_TEXT = 'input_text'
|
|
6
|
+
|
|
7
|
+
const IMAGE_FALLBACK = '[image]'
|
|
8
|
+
const FILE_FALLBACK = '[file]'
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
INPUT_TYPE_IMAGE,
|
|
12
|
+
INPUT_TYPE_FILE,
|
|
13
|
+
INPUT_TYPE_TEXT,
|
|
14
|
+
IMAGE_FALLBACK,
|
|
15
|
+
FILE_FALLBACK
|
|
16
|
+
}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const LLMObsPlugin = require('../base')
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
PROMPT_TRACKING_INSTRUMENTATION_METHOD,
|
|
6
|
+
PROMPT_MULTIMODAL,
|
|
7
|
+
INSTRUMENTATION_METHOD_AUTO
|
|
8
|
+
} = require('../../constants/tags')
|
|
9
|
+
const {
|
|
10
|
+
extractChatTemplateFromInstructions,
|
|
11
|
+
normalizePromptVariables,
|
|
12
|
+
extractTextFromContentItem,
|
|
13
|
+
hasMultimodalInputs
|
|
14
|
+
} = require('./utils')
|
|
5
15
|
|
|
6
16
|
const allowedParamKeys = new Set([
|
|
7
17
|
'max_output_tokens',
|
|
@@ -412,16 +422,20 @@ class OpenAiLLMObsPlugin extends LLMObsPlugin {
|
|
|
412
422
|
// Handle prompt tracking for reusable prompts
|
|
413
423
|
if (inputs.prompt && response?.prompt) {
|
|
414
424
|
const { id, version } = response.prompt // ResponsePrompt
|
|
415
|
-
// TODO: Add proper tagger API for prompt metadata
|
|
416
425
|
if (id && version) {
|
|
417
426
|
const normalizedVariables = normalizePromptVariables(inputs.prompt.variables)
|
|
418
427
|
const chatTemplate = extractChatTemplateFromInstructions(response.instructions, normalizedVariables)
|
|
419
|
-
this._tagger.
|
|
428
|
+
this._tagger.tagPrompt(span, {
|
|
420
429
|
id,
|
|
421
430
|
version,
|
|
422
431
|
variables: normalizedVariables,
|
|
423
|
-
|
|
424
|
-
})
|
|
432
|
+
template: chatTemplate
|
|
433
|
+
}, true)
|
|
434
|
+
const tags = { [PROMPT_TRACKING_INSTRUMENTATION_METHOD]: INSTRUMENTATION_METHOD_AUTO }
|
|
435
|
+
if (hasMultimodalInputs(inputs.prompt.variables)) {
|
|
436
|
+
tags[PROMPT_MULTIMODAL] = 'true'
|
|
437
|
+
}
|
|
438
|
+
this._tagger.tagSpanTags(span, tags)
|
|
425
439
|
}
|
|
426
440
|
}
|
|
427
441
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const {
|
|
4
|
+
INPUT_TYPE_IMAGE,
|
|
5
|
+
INPUT_TYPE_FILE,
|
|
6
|
+
IMAGE_FALLBACK,
|
|
7
|
+
FILE_FALLBACK
|
|
8
|
+
} = require('./constants')
|
|
5
9
|
|
|
6
10
|
const REGEX_SPECIAL_CHARS = /[.*+?^${}()|[\]\\]/g
|
|
7
11
|
|
|
@@ -11,8 +15,8 @@ const REGEX_SPECIAL_CHARS = /[.*+?^${}()|[\]\\]/g
|
|
|
11
15
|
* Performs reverse templating: reconstructs the template by replacing actual values with {{variable_name}}.
|
|
12
16
|
* For images/files: uses {{variable_name}} when values are available, falls back to [image]/[file] when stripped.
|
|
13
17
|
*
|
|
14
|
-
* @param {Array<
|
|
15
|
-
* @param {
|
|
18
|
+
* @param {Array<object>} instructions - From Response.instructions (array of ResponseInputMessageItem)
|
|
19
|
+
* @param {Record<string, string>} variables - Normalized variables (output of normalizePromptVariables)
|
|
16
20
|
* @returns {Array<{role: string, content: string}>} Chat template with placeholders
|
|
17
21
|
*/
|
|
18
22
|
function extractChatTemplateFromInstructions (instructions, variables) {
|
|
@@ -66,7 +70,7 @@ function extractChatTemplateFromInstructions (instructions, variables) {
|
|
|
66
70
|
* Used for both input messages and chat template extraction. Falls back to [image]/[file] markers
|
|
67
71
|
* when the actual values are stripped (e.g., by OpenAI's default URL stripping behavior).
|
|
68
72
|
*
|
|
69
|
-
* @param {
|
|
73
|
+
* @param {object} contentItem - Content item from Response.instructions[].content (ResponseInputContentItem)
|
|
70
74
|
* @returns {string|null} Text content, URL/file reference, or [image]/[file] fallback marker
|
|
71
75
|
*/
|
|
72
76
|
function extractTextFromContentItem (contentItem) {
|
|
@@ -77,11 +81,11 @@ function extractTextFromContentItem (contentItem) {
|
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
// For image/file items, extract the actual reference value
|
|
80
|
-
if (contentItem.type ===
|
|
84
|
+
if (contentItem.type === INPUT_TYPE_IMAGE) {
|
|
81
85
|
return contentItem.image_url || contentItem.file_id || IMAGE_FALLBACK
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
if (contentItem.type ===
|
|
88
|
+
if (contentItem.type === INPUT_TYPE_FILE) {
|
|
85
89
|
return contentItem.file_id || contentItem.file_url || contentItem.filename || FILE_FALLBACK
|
|
86
90
|
}
|
|
87
91
|
|
|
@@ -93,8 +97,8 @@ function extractTextFromContentItem (contentItem) {
|
|
|
93
97
|
*
|
|
94
98
|
* Converts ResponseInputText, ResponseInputImage, and ResponseInputFile objects to simple string values.
|
|
95
99
|
*
|
|
96
|
-
* @param {
|
|
97
|
-
* @returns {
|
|
100
|
+
* @param {Record<string, string | object>} variables - From ResponsePrompt.variables
|
|
101
|
+
* @returns {Record<string, string>} Normalized variables with simple string values
|
|
98
102
|
*/
|
|
99
103
|
function normalizePromptVariables (variables) {
|
|
100
104
|
if (!variables) return {}
|
|
@@ -107,8 +111,16 @@ function normalizePromptVariables (variables) {
|
|
|
107
111
|
)
|
|
108
112
|
}
|
|
109
113
|
|
|
114
|
+
function hasMultimodalInputs (variables) {
|
|
115
|
+
if (!variables) return false
|
|
116
|
+
return Object.values(variables).some(value =>
|
|
117
|
+
value?.type === INPUT_TYPE_IMAGE || value?.type === INPUT_TYPE_FILE
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
110
121
|
module.exports = {
|
|
111
122
|
extractChatTemplateFromInstructions,
|
|
112
123
|
normalizePromptVariables,
|
|
113
|
-
extractTextFromContentItem
|
|
124
|
+
extractTextFromContentItem,
|
|
125
|
+
hasMultimodalInputs
|
|
114
126
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const LLMObsPlugin = require('./base')
|
|
4
3
|
const {
|
|
5
4
|
extractModel,
|
|
6
5
|
extractSystemInstructions
|
|
7
6
|
} = require('../../../../datadog-plugin-google-cloud-vertexai/src/utils')
|
|
7
|
+
const LLMObsPlugin = require('./base')
|
|
8
8
|
|
|
9
9
|
class VertexAILLMObsPlugin extends LLMObsPlugin {
|
|
10
10
|
static integration = 'vertexai' // used for llmobs telemetry
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { channel } = require('dc-polyfill')
|
|
4
4
|
|
|
5
|
+
const { isTrue, isError } = require('../util')
|
|
6
|
+
const tracerVersion = require('../../../../package.json').version
|
|
7
|
+
const logger = require('../log')
|
|
8
|
+
const { getValueFromEnvSources } = require('../config/helper')
|
|
9
|
+
const Span = require('../opentracing/span')
|
|
10
|
+
const { SPAN_KIND, OUTPUT_VALUE, INPUT_VALUE } = require('./constants/tags')
|
|
5
11
|
const {
|
|
6
12
|
getFunctionArguments,
|
|
7
13
|
validateKind
|
|
8
14
|
} = require('./util')
|
|
9
|
-
const { isTrue, isError } = require('../util')
|
|
10
|
-
|
|
11
15
|
const { storage } = require('./storage')
|
|
12
|
-
|
|
13
|
-
const Span = require('../opentracing/span')
|
|
14
|
-
|
|
15
|
-
const tracerVersion = require('../../../../package.json').version
|
|
16
|
-
const logger = require('../log')
|
|
17
|
-
const { getEnvironmentVariable } = require('../config-helper')
|
|
18
16
|
const telemetry = require('./telemetry')
|
|
19
|
-
|
|
20
17
|
const LLMObsTagger = require('./tagger')
|
|
21
18
|
|
|
22
19
|
// communicating with writer
|
|
23
|
-
const { channel } = require('dc-polyfill')
|
|
24
20
|
const evalMetricAppendCh = channel('llmobs:eval-metric:append')
|
|
25
21
|
const flushCh = channel('llmobs:writers:flush')
|
|
26
22
|
const registerUserSpanProcessorCh = channel('llmobs:register-processor')
|
|
@@ -53,23 +49,20 @@ class LLMObs extends NoopLLMObs {
|
|
|
53
49
|
|
|
54
50
|
logger.debug('Enabling LLMObs')
|
|
55
51
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const DD_LLMOBS_ENABLED = getEnvironmentVariable('DD_LLMOBS_ENABLED')
|
|
52
|
+
const DD_LLMOBS_ENABLED = getValueFromEnvSources('DD_LLMOBS_ENABLED')
|
|
59
53
|
|
|
60
|
-
|
|
61
|
-
mlApp,
|
|
62
|
-
agentlessEnabled
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const enabled = DD_LLMOBS_ENABLED == null || isTrue(DD_LLMOBS_ENABLED)
|
|
66
|
-
if (!enabled) {
|
|
54
|
+
if (DD_LLMOBS_ENABLED != null && !isTrue(DD_LLMOBS_ENABLED)) {
|
|
67
55
|
logger.debug('LLMObs.enable() called when DD_LLMOBS_ENABLED is false. No action taken.')
|
|
68
56
|
return
|
|
69
57
|
}
|
|
70
58
|
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
const llmobs = {
|
|
60
|
+
mlApp: options.mlApp,
|
|
61
|
+
agentlessEnabled: options.agentlessEnabled
|
|
62
|
+
}
|
|
63
|
+
// TODO: This will update config telemetry with the origin 'code', which is not ideal when `enable()` is called
|
|
64
|
+
// based on `APM_TRACING` RC product updates.
|
|
65
|
+
this._config.updateOptions({ llmobs })
|
|
73
66
|
|
|
74
67
|
// configure writers and channel subscribers
|
|
75
68
|
this._llmobsModule.enable(this._config)
|
|
@@ -248,7 +241,7 @@ class LLMObs extends NoopLLMObs {
|
|
|
248
241
|
throw new Error('LLMObs span must have a span kind specified')
|
|
249
242
|
}
|
|
250
243
|
|
|
251
|
-
const { inputData, outputData, metadata, metrics, tags } = options
|
|
244
|
+
const { inputData, outputData, metadata, metrics, tags, prompt } = options
|
|
252
245
|
|
|
253
246
|
if (inputData || outputData) {
|
|
254
247
|
if (spanKind === 'llm') {
|
|
@@ -271,6 +264,9 @@ class LLMObs extends NoopLLMObs {
|
|
|
271
264
|
if (tags) {
|
|
272
265
|
this._tagger.tagSpanTags(span, tags)
|
|
273
266
|
}
|
|
267
|
+
if (prompt) {
|
|
268
|
+
this._tagger.tagPrompt(span, prompt)
|
|
269
|
+
}
|
|
274
270
|
} catch (e) {
|
|
275
271
|
if (e.ddErrorTag) {
|
|
276
272
|
err = e.ddErrorTag
|
|
@@ -411,7 +407,7 @@ class LLMObs extends NoopLLMObs {
|
|
|
411
407
|
}
|
|
412
408
|
|
|
413
409
|
// When OTel tracing is enabled, add source:otel tag to allow backend to wait for OTel span conversion
|
|
414
|
-
if (isTrue(
|
|
410
|
+
if (isTrue(getValueFromEnvSources('DD_TRACE_OTEL_ENABLED'))) {
|
|
415
411
|
evaluationTags.source = 'otel'
|
|
416
412
|
}
|
|
417
413
|
|
|
@@ -425,7 +421,9 @@ class LLMObs extends NoopLLMObs {
|
|
|
425
421
|
timestamp_ms: timestampMs,
|
|
426
422
|
tags: Object.entries(evaluationTags).map(([key, value]) => `${key}:${value}`)
|
|
427
423
|
}
|
|
428
|
-
|
|
424
|
+
const currentStore = storage.getStore()
|
|
425
|
+
const routing = currentStore?.routingContext
|
|
426
|
+
evalMetricAppendCh.publish({ payload, routing })
|
|
429
427
|
} finally {
|
|
430
428
|
telemetry.recordSubmitEvaluation(options, err)
|
|
431
429
|
}
|
|
@@ -447,6 +445,28 @@ class LLMObs extends NoopLLMObs {
|
|
|
447
445
|
return storage.run(store, fn)
|
|
448
446
|
}
|
|
449
447
|
|
|
448
|
+
routingContext (options, fn) {
|
|
449
|
+
if (!this.enabled) return fn()
|
|
450
|
+
if (!options?.ddApiKey) {
|
|
451
|
+
throw new Error('ddApiKey is required for routing context')
|
|
452
|
+
}
|
|
453
|
+
const currentStore = storage.getStore()
|
|
454
|
+
if (currentStore?.routingContext) {
|
|
455
|
+
logger.warn(
|
|
456
|
+
'[LLM Observability] Nested routing context detected. Inner context will override outer context. ' +
|
|
457
|
+
'Spans created in the inner context will only be sent to the inner context.'
|
|
458
|
+
)
|
|
459
|
+
}
|
|
460
|
+
const store = {
|
|
461
|
+
...currentStore,
|
|
462
|
+
routingContext: {
|
|
463
|
+
apiKey: options.ddApiKey,
|
|
464
|
+
site: options.ddSite
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return storage.run(store, fn)
|
|
468
|
+
}
|
|
469
|
+
|
|
450
470
|
flush () {
|
|
451
471
|
if (!this.enabled) return
|
|
452
472
|
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const util = require('node:util')
|
|
4
|
+
|
|
5
|
+
const tracerVersion = require('../../../../package.json').version
|
|
6
|
+
const logger = require('../log')
|
|
7
|
+
const {
|
|
8
|
+
ERROR_MESSAGE,
|
|
9
|
+
ERROR_TYPE,
|
|
10
|
+
ERROR_STACK
|
|
11
|
+
} = require('../constants')
|
|
3
12
|
const {
|
|
4
13
|
SPAN_KIND,
|
|
5
14
|
MODEL_NAME,
|
|
@@ -17,25 +26,15 @@ const {
|
|
|
17
26
|
TAGS,
|
|
18
27
|
PARENT_ID_KEY,
|
|
19
28
|
SESSION_ID,
|
|
20
|
-
NAME
|
|
29
|
+
NAME,
|
|
30
|
+
INPUT_PROMPT,
|
|
31
|
+
ROUTING_API_KEY,
|
|
32
|
+
ROUTING_SITE
|
|
21
33
|
} = require('./constants/tags')
|
|
22
34
|
const { UNSERIALIZABLE_VALUE_TEXT } = require('./constants/text')
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
ERROR_MESSAGE,
|
|
26
|
-
ERROR_TYPE,
|
|
27
|
-
ERROR_STACK
|
|
28
|
-
} = require('../constants')
|
|
29
|
-
|
|
30
35
|
const telemetry = require('./telemetry')
|
|
31
|
-
|
|
32
36
|
const LLMObsTagger = require('./tagger')
|
|
33
37
|
|
|
34
|
-
const tracerVersion = require('../../../../package.json').version
|
|
35
|
-
const logger = require('../log')
|
|
36
|
-
|
|
37
|
-
const util = require('node:util')
|
|
38
|
-
|
|
39
38
|
class LLMObservabilitySpan {
|
|
40
39
|
constructor () {
|
|
41
40
|
this.input = []
|
|
@@ -82,7 +81,13 @@ class LLMObsSpanProcessor {
|
|
|
82
81
|
telemetry.incrementLLMObsSpanFinishedCount(span)
|
|
83
82
|
if (formattedEvent == null) return
|
|
84
83
|
|
|
85
|
-
|
|
84
|
+
const mlObsTags = LLMObsTagger.tagMap.get(span)
|
|
85
|
+
const routing = {
|
|
86
|
+
apiKey: mlObsTags[ROUTING_API_KEY],
|
|
87
|
+
site: mlObsTags[ROUTING_SITE]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this.#writer.append(formattedEvent, routing)
|
|
86
91
|
} catch (e) {
|
|
87
92
|
// this should be a rare case
|
|
88
93
|
// we protect against unserializable properties in the format function, and in
|
|
@@ -126,11 +131,6 @@ class LLMObsSpanProcessor {
|
|
|
126
131
|
inputType = 'value'
|
|
127
132
|
}
|
|
128
133
|
|
|
129
|
-
// Handle prompt metadata for reusable prompts
|
|
130
|
-
if (mlObsTags['_ml_obs.meta.input.prompt']) {
|
|
131
|
-
input.prompt = mlObsTags['_ml_obs.meta.input.prompt']
|
|
132
|
-
}
|
|
133
|
-
|
|
134
134
|
if (spanKind === 'llm' && mlObsTags[OUTPUT_MESSAGES]) {
|
|
135
135
|
llmObsSpan.output = mlObsTags[OUTPUT_MESSAGES]
|
|
136
136
|
outputType = 'messages'
|
|
@@ -181,6 +181,12 @@ class LLMObsSpanProcessor {
|
|
|
181
181
|
if (input) meta.input = input
|
|
182
182
|
if (output) meta.output = output
|
|
183
183
|
|
|
184
|
+
const prompt = mlObsTags[INPUT_PROMPT]
|
|
185
|
+
if (prompt && spanKind === 'llm') {
|
|
186
|
+
// by this point, we should have logged a warning if the span kind was not llm
|
|
187
|
+
meta.input.prompt = prompt
|
|
188
|
+
}
|
|
189
|
+
|
|
184
190
|
const llmObsSpanEvent = {
|
|
185
191
|
trace_id: span.context().toTraceId(true),
|
|
186
192
|
span_id: span.context().toSpanId(),
|