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
|
@@ -28,7 +28,15 @@ const {
|
|
|
28
28
|
REASONING_OUTPUT_TOKENS_METRIC_KEY,
|
|
29
29
|
INTEGRATION,
|
|
30
30
|
DECORATOR,
|
|
31
|
-
PROPAGATED_ML_APP_KEY
|
|
31
|
+
PROPAGATED_ML_APP_KEY,
|
|
32
|
+
DEFAULT_PROMPT_NAME,
|
|
33
|
+
INTERNAL_CONTEXT_VARIABLE_KEYS,
|
|
34
|
+
INTERNAL_QUERY_VARIABLE_KEYS,
|
|
35
|
+
INPUT_PROMPT,
|
|
36
|
+
ROUTING_API_KEY,
|
|
37
|
+
ROUTING_SITE,
|
|
38
|
+
PROMPT_TRACKING_INSTRUMENTATION_METHOD,
|
|
39
|
+
INSTRUMENTATION_METHOD_ANNOTATED
|
|
32
40
|
} = require('./constants/tags')
|
|
33
41
|
const { storage } = require('./storage')
|
|
34
42
|
|
|
@@ -110,6 +118,18 @@ class LLMObsTagger {
|
|
|
110
118
|
// apply annotation context name
|
|
111
119
|
const annotationContextName = annotationContext?.name
|
|
112
120
|
if (annotationContextName) this._setTag(span, NAME, annotationContextName)
|
|
121
|
+
|
|
122
|
+
// apply annotation context prompt
|
|
123
|
+
const annotationContextPrompt = annotationContext?.prompt
|
|
124
|
+
if (annotationContextPrompt) this.tagPrompt(span, annotationContextPrompt)
|
|
125
|
+
|
|
126
|
+
const routing = storage.getStore()?.routingContext
|
|
127
|
+
if (routing) {
|
|
128
|
+
this._setTag(span, ROUTING_API_KEY, routing.apiKey)
|
|
129
|
+
if (routing.site) {
|
|
130
|
+
this._setTag(span, ROUTING_SITE, routing.site)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
113
133
|
}
|
|
114
134
|
|
|
115
135
|
// TODO: similarly for the following `tag` methods,
|
|
@@ -194,6 +214,160 @@ class LLMObsTagger {
|
|
|
194
214
|
}
|
|
195
215
|
}
|
|
196
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Tags a prompt on an LLMObs span.
|
|
219
|
+
* @param {import('../opentracing/span')} span
|
|
220
|
+
* @param {string | Record<string, unknown>} prompt
|
|
221
|
+
* @param {boolean?} strictValidation
|
|
222
|
+
* whether to validate the prompt against the strict schema, used for auto-instrumentation
|
|
223
|
+
*/
|
|
224
|
+
tagPrompt (span, prompt, strictValidation = false) {
|
|
225
|
+
const spanKind = registry.get(span)?.[SPAN_KIND]
|
|
226
|
+
if (spanKind !== 'llm') {
|
|
227
|
+
log.warn('Dropping prompt on non-LLM span kind, annotating prompts is only supported for LLM span kinds.')
|
|
228
|
+
return
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (!prompt || typeof prompt !== 'object') {
|
|
232
|
+
this.#handleFailure('Prompt must be an object.', 'invalid_prompt')
|
|
233
|
+
return
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const mlApp = registry.get(span)?.[ML_APP] // this should be defined at this point
|
|
237
|
+
const {
|
|
238
|
+
id,
|
|
239
|
+
version,
|
|
240
|
+
tags,
|
|
241
|
+
variables,
|
|
242
|
+
template,
|
|
243
|
+
contextVariables,
|
|
244
|
+
queryVariables,
|
|
245
|
+
} = prompt
|
|
246
|
+
|
|
247
|
+
if (strictValidation) {
|
|
248
|
+
if (id == null) {
|
|
249
|
+
this.#handleFailure('Prompt ID is required.', 'invalid_prompt')
|
|
250
|
+
return
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (template == null) {
|
|
254
|
+
this.#handleFailure('Prompt template is required.', 'invalid_prompt')
|
|
255
|
+
return
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const finalPromptId = id ?? `${mlApp}_${DEFAULT_PROMPT_NAME}`
|
|
260
|
+
const finalCtxVariablesKeys = contextVariables ?? ['context']
|
|
261
|
+
const finalQueryVariablesKeys = queryVariables ?? ['question']
|
|
262
|
+
|
|
263
|
+
// validate prompt id
|
|
264
|
+
if (typeof finalPromptId !== 'string') {
|
|
265
|
+
this.#handleFailure('Prompt ID must be a string.', 'invalid_prompt')
|
|
266
|
+
return
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// validate prompt context variables keys
|
|
270
|
+
if (Array.isArray(finalCtxVariablesKeys)) {
|
|
271
|
+
for (const key of finalCtxVariablesKeys) {
|
|
272
|
+
if (typeof key !== 'string') {
|
|
273
|
+
this.#handleFailure('Prompt context variables keys must be an array of strings.', 'invalid_prompt')
|
|
274
|
+
return
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
} else if (finalCtxVariablesKeys) {
|
|
278
|
+
this.#handleFailure('Prompt context variables keys must be an array.', 'invalid_prompt')
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// validate prompt query variables keys
|
|
283
|
+
if (Array.isArray(finalQueryVariablesKeys)) {
|
|
284
|
+
for (const key of finalQueryVariablesKeys) {
|
|
285
|
+
if (typeof key !== 'string') {
|
|
286
|
+
this.#handleFailure('Prompt query variables keys must be an array of strings.', 'invalid_prompt')
|
|
287
|
+
return
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
} else if (finalQueryVariablesKeys) {
|
|
291
|
+
this.#handleFailure('Prompt query variables keys must be an array.', 'invalid_prompt')
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// validate prompt version
|
|
296
|
+
if (version && typeof version !== 'string') {
|
|
297
|
+
this.#handleFailure('Prompt version must be a string.', 'invalid_prompt')
|
|
298
|
+
return
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// validate prompt tags
|
|
302
|
+
if (tags && (typeof tags !== 'object' || tags instanceof Map)) {
|
|
303
|
+
this.#handleFailure('Prompt tags must be an non-Map object.', 'invalid_prompt')
|
|
304
|
+
return
|
|
305
|
+
} else if (tags) {
|
|
306
|
+
for (const [key, value] of Object.entries(tags)) {
|
|
307
|
+
if (typeof key !== 'string' || typeof value !== 'string') {
|
|
308
|
+
this.#handleFailure('Prompt tags must be an object of string key-value pairs.', 'invalid_prompt')
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// validate prompt template is either string or list of messages
|
|
315
|
+
if (template && !(typeof template === 'string' || Array.isArray(template))) {
|
|
316
|
+
this.#handleFailure('Prompt template must be a string or an array of messages.', 'invalid_prompt')
|
|
317
|
+
return
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (Array.isArray(template)) {
|
|
321
|
+
for (const message of template) {
|
|
322
|
+
if (typeof message !== 'object' || !message.role || !message.content) {
|
|
323
|
+
this.#handleFailure(
|
|
324
|
+
'Prompt chat template must be an array of objects with role and content properties.', 'invalid_prompt'
|
|
325
|
+
)
|
|
326
|
+
return
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// validate variables are a string-string mapping
|
|
332
|
+
if (variables && (typeof variables !== 'object' || variables instanceof Map)) {
|
|
333
|
+
this.#handleFailure('Prompt variables must be an non-Map object.', 'invalid_prompt')
|
|
334
|
+
return
|
|
335
|
+
} else if (variables) {
|
|
336
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
337
|
+
if (typeof key !== 'string' || typeof value !== 'string') {
|
|
338
|
+
this.#handleFailure('Prompt variables must be an object of string key-value pairs.', 'invalid_prompt')
|
|
339
|
+
return
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
let finalTemplate, finalChatTemplate
|
|
345
|
+
if (typeof template === 'string') {
|
|
346
|
+
finalTemplate = template
|
|
347
|
+
} else if (Array.isArray(template)) {
|
|
348
|
+
finalChatTemplate = template.map(message => ({ role: message.role, content: message.content }))
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const validatedPrompt = {}
|
|
352
|
+
if (finalPromptId) validatedPrompt.id = finalPromptId
|
|
353
|
+
if (version) validatedPrompt.version = version
|
|
354
|
+
if (variables) validatedPrompt.variables = variables
|
|
355
|
+
if (finalTemplate) validatedPrompt.template = finalTemplate
|
|
356
|
+
if (finalChatTemplate?.length) validatedPrompt.chat_template = finalChatTemplate
|
|
357
|
+
if (tags) validatedPrompt.tags = tags
|
|
358
|
+
if (finalCtxVariablesKeys) validatedPrompt[INTERNAL_CONTEXT_VARIABLE_KEYS] = finalCtxVariablesKeys
|
|
359
|
+
if (finalQueryVariablesKeys) validatedPrompt[INTERNAL_QUERY_VARIABLE_KEYS] = finalQueryVariablesKeys
|
|
360
|
+
|
|
361
|
+
const currentPrompt = registry.get(span)?.[INPUT_PROMPT]
|
|
362
|
+
if (currentPrompt) {
|
|
363
|
+
Object.assign(currentPrompt, validatedPrompt)
|
|
364
|
+
} else {
|
|
365
|
+
this._setTag(span, INPUT_PROMPT, validatedPrompt)
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
this.tagSpanTags(span, { [PROMPT_TRACKING_INSTRUMENTATION_METHOD]: INSTRUMENTATION_METHOD_ANNOTATED })
|
|
369
|
+
}
|
|
370
|
+
|
|
197
371
|
changeKind (span, newKind) {
|
|
198
372
|
this._setTag(span, SPAN_KIND, newKind)
|
|
199
373
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const ERROR_TYPE = require('../constants')
|
|
4
|
+
|
|
5
|
+
const telemetryMetrics = require('../telemetry/metrics')
|
|
3
6
|
const {
|
|
4
7
|
SPAN_KIND,
|
|
5
8
|
MODEL_PROVIDER,
|
|
@@ -10,10 +13,6 @@ const {
|
|
|
10
13
|
DECORATOR
|
|
11
14
|
} = require('./constants/tags')
|
|
12
15
|
|
|
13
|
-
const ERROR_TYPE = require('../constants')
|
|
14
|
-
|
|
15
|
-
const telemetryMetrics = require('../telemetry/metrics')
|
|
16
|
-
|
|
17
16
|
const LLMObsTagger = require('./tagger')
|
|
18
17
|
|
|
19
18
|
const llmobsMetrics = telemetryMetrics.manager.namespace('mlobs')
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const request = require('../../exporters/common/request')
|
|
4
|
-
const { getEnvironmentVariable } = require('../../config-helper')
|
|
5
3
|
const { URL, format } = require('node:url')
|
|
6
4
|
const path = require('node:path')
|
|
5
|
+
const request = require('../../exporters/common/request')
|
|
6
|
+
const { getEnvironmentVariable } = require('../../config/helper')
|
|
7
7
|
|
|
8
8
|
const logger = require('../../log')
|
|
9
9
|
|
|
@@ -16,85 +16,163 @@ const {
|
|
|
16
16
|
} = require('../constants/writers')
|
|
17
17
|
const { parseResponseAndLog } = require('./util')
|
|
18
18
|
|
|
19
|
+
class LLMObsBuffer {
|
|
20
|
+
constructor ({ events, size, routing = {}, isDefault = false, limit = 1000 }) {
|
|
21
|
+
this.events = events
|
|
22
|
+
this.size = size
|
|
23
|
+
this.routing = routing
|
|
24
|
+
this.isDefault = isDefault
|
|
25
|
+
this.limit = limit
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
clear () {
|
|
29
|
+
this.events = []
|
|
30
|
+
this.size = 0
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
19
34
|
class BaseLLMObsWriter {
|
|
35
|
+
#destroyer
|
|
36
|
+
/** @type {Map<string, LLMObsBuffer>} */
|
|
37
|
+
#multiTenantBuffers = new Map()
|
|
38
|
+
|
|
20
39
|
constructor ({ interval, timeout, eventType, config, endpoint, intake }) {
|
|
21
40
|
this._interval = interval ?? getEnvironmentVariable('_DD_LLMOBS_FLUSH_INTERVAL') ?? 1000 // 1s
|
|
22
41
|
this._timeout = timeout ?? getEnvironmentVariable('_DD_LLMOBS_TIMEOUT') ?? 5000 // 5s
|
|
23
42
|
this._eventType = eventType
|
|
24
43
|
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
this._bufferSize = 0
|
|
44
|
+
/** @type {LLMObsBuffer} */
|
|
45
|
+
this._buffer = new LLMObsBuffer({ events: [], size: 0, isDefault: true })
|
|
28
46
|
|
|
29
47
|
this._config = config
|
|
30
48
|
this._endpoint = endpoint
|
|
49
|
+
this._baseEndpoint = endpoint // should not be unset
|
|
31
50
|
this._intake = intake
|
|
32
51
|
|
|
33
52
|
this._periodic = setInterval(() => {
|
|
34
53
|
this.flush()
|
|
35
54
|
}, this._interval).unref()
|
|
36
55
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
process.once('beforeExit', this._beforeExitHandler)
|
|
56
|
+
const destroyer = this.destroy.bind(this)
|
|
57
|
+
globalThis[Symbol.for('dd-trace')].beforeExitHandlers.add(destroyer)
|
|
41
58
|
|
|
42
|
-
this
|
|
59
|
+
this.#destroyer = destroyer
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Split on protocol separator to preserve it
|
|
63
|
+
// path.join will remove some slashes unnecessarily
|
|
64
|
+
#buildUrl (baseUrl, endpoint) {
|
|
65
|
+
const [protocol, rest] = baseUrl.split('://')
|
|
66
|
+
return protocol + '://' + path.join(rest, endpoint)
|
|
43
67
|
}
|
|
44
68
|
|
|
45
69
|
get url () {
|
|
46
70
|
if (this._agentless == null) return null
|
|
71
|
+
return this.#buildUrl(this._baseUrl.href, this._endpoint)
|
|
72
|
+
}
|
|
47
73
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
74
|
+
_getBuffer (routing) {
|
|
75
|
+
if (!routing?.apiKey) {
|
|
76
|
+
return this._buffer
|
|
77
|
+
}
|
|
78
|
+
const apiKey = routing.apiKey
|
|
79
|
+
let buffer = this.#multiTenantBuffers.get(apiKey)
|
|
80
|
+
if (!buffer) {
|
|
81
|
+
buffer = new LLMObsBuffer({ events: [], size: 0, routing })
|
|
82
|
+
this.#multiTenantBuffers.set(apiKey, buffer)
|
|
83
|
+
}
|
|
84
|
+
return buffer
|
|
55
85
|
}
|
|
56
86
|
|
|
57
|
-
append (event, byteLength) {
|
|
58
|
-
|
|
59
|
-
|
|
87
|
+
append (event, routing, byteLength) {
|
|
88
|
+
const buffer = this._getBuffer(routing)
|
|
89
|
+
|
|
90
|
+
if (buffer.events.length >= buffer.limit) {
|
|
91
|
+
logger.warn(`${this.constructor.name} event buffer full (limit is ${buffer.limit}), dropping event`)
|
|
60
92
|
telemetry.recordDroppedPayload(1, this._eventType, 'buffer_full')
|
|
61
93
|
return
|
|
62
94
|
}
|
|
63
95
|
|
|
64
|
-
|
|
65
|
-
|
|
96
|
+
const eventSize = byteLength || Buffer.byteLength(JSON.stringify(event))
|
|
97
|
+
|
|
98
|
+
buffer.size += eventSize
|
|
99
|
+
buffer.events.push(event)
|
|
66
100
|
}
|
|
67
101
|
|
|
68
102
|
flush () {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (this._buffer.length === 0 || noAgentStrategy) {
|
|
103
|
+
if (this._agentless == null) {
|
|
72
104
|
return
|
|
73
105
|
}
|
|
74
106
|
|
|
75
|
-
|
|
76
|
-
this._buffer
|
|
77
|
-
|
|
78
|
-
|
|
107
|
+
// Flush default buffer
|
|
108
|
+
if (this._buffer.events.length > 0) {
|
|
109
|
+
const events = this._buffer.events
|
|
110
|
+
this._buffer.clear()
|
|
111
|
+
|
|
112
|
+
const payload = this._encode(this.makePayload(events))
|
|
113
|
+
|
|
114
|
+
log.debug('Encoded LLMObs payload: %s', payload)
|
|
115
|
+
|
|
116
|
+
const options = this._getOptions()
|
|
117
|
+
|
|
118
|
+
request(payload, options, (err, resp, code) => {
|
|
119
|
+
parseResponseAndLog(err, code, events.length, this.url, this._eventType)
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Flush multi-tenant buffers
|
|
124
|
+
for (const [apiKey, buffer] of this.#multiTenantBuffers) {
|
|
125
|
+
if (buffer.events.length === 0) continue
|
|
126
|
+
|
|
127
|
+
const events = buffer.events
|
|
128
|
+
buffer.clear()
|
|
129
|
+
|
|
130
|
+
const payload = this._encode(this.makePayload(events))
|
|
131
|
+
const site = buffer.routing.site || this._config.site
|
|
132
|
+
const options = {
|
|
133
|
+
headers: {
|
|
134
|
+
'Content-Type': 'application/json',
|
|
135
|
+
'DD-API-KEY': apiKey
|
|
136
|
+
},
|
|
137
|
+
method: 'POST',
|
|
138
|
+
timeout: this._timeout,
|
|
139
|
+
url: new URL(format({
|
|
140
|
+
protocol: 'https:',
|
|
141
|
+
hostname: `${this._intake}.${site}`
|
|
142
|
+
})),
|
|
143
|
+
path: this._baseEndpoint
|
|
144
|
+
}
|
|
145
|
+
const url = this.#buildUrl(options.url.href, options.path)
|
|
146
|
+
const maskedApiKey = apiKey ? `****${apiKey.slice(-4)}` : ''
|
|
79
147
|
|
|
80
|
-
|
|
148
|
+
log.debug('Encoding and flushing multi-tenant buffer for %s', maskedApiKey)
|
|
149
|
+
log.debug('Encoded LLMObs payload: %s', payload)
|
|
81
150
|
|
|
82
|
-
|
|
151
|
+
request(payload, options, (err, resp, code) => {
|
|
152
|
+
parseResponseAndLog(err, code, events.length, url, this._eventType)
|
|
153
|
+
})
|
|
154
|
+
}
|
|
83
155
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
156
|
+
this.#cleanupEmptyBuffers()
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
#cleanupEmptyBuffers () {
|
|
160
|
+
for (const [key, buffer] of this.#multiTenantBuffers) {
|
|
161
|
+
if (buffer.events.length === 0) {
|
|
162
|
+
this.#multiTenantBuffers.delete(key)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
87
165
|
}
|
|
88
166
|
|
|
89
167
|
makePayload (events) {}
|
|
90
168
|
|
|
91
169
|
destroy () {
|
|
92
|
-
if (
|
|
170
|
+
if (this.#destroyer) {
|
|
93
171
|
logger.debug(`Stopping ${this.constructor.name}`)
|
|
94
172
|
clearInterval(this._periodic)
|
|
95
|
-
|
|
173
|
+
globalThis[Symbol.for('dd-trace')].beforeExitHandlers.delete(this.#destroyer)
|
|
96
174
|
this.flush()
|
|
97
|
-
this
|
|
175
|
+
this.#destroyer = undefined
|
|
98
176
|
}
|
|
99
177
|
}
|
|
100
178
|
|
|
@@ -110,10 +188,11 @@ class BaseLLMObsWriter {
|
|
|
110
188
|
|
|
111
189
|
_getUrlAndPath () {
|
|
112
190
|
if (this._agentless) {
|
|
191
|
+
const site = this._config.site
|
|
113
192
|
return {
|
|
114
193
|
url: new URL(format({
|
|
115
194
|
protocol: 'https:',
|
|
116
|
-
hostname: `${this._intake}.${
|
|
195
|
+
hostname: `${this._intake}.${site}`
|
|
117
196
|
})),
|
|
118
197
|
endpoint: this._endpoint
|
|
119
198
|
}
|
|
@@ -9,11 +9,10 @@ const {
|
|
|
9
9
|
} = require('../constants/writers')
|
|
10
10
|
const { DROPPED_VALUE_TEXT } = require('../constants/text')
|
|
11
11
|
const { DROPPED_IO_COLLECTION_ERROR } = require('../constants/tags')
|
|
12
|
-
const BaseWriter = require('./base')
|
|
13
12
|
const telemetry = require('../telemetry')
|
|
14
13
|
const logger = require('../../log')
|
|
15
|
-
|
|
16
14
|
const tracerVersion = require('../../../../../package.json').version
|
|
15
|
+
const BaseWriter = require('./base')
|
|
17
16
|
|
|
18
17
|
class LLMObsSpanWriter extends BaseWriter {
|
|
19
18
|
constructor (config) {
|
|
@@ -25,7 +24,7 @@ class LLMObsSpanWriter extends BaseWriter {
|
|
|
25
24
|
})
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
append (event) {
|
|
27
|
+
append (event, routing) {
|
|
29
28
|
const eventSizeBytes = Buffer.byteLength(JSON.stringify(event))
|
|
30
29
|
telemetry.recordLLMObsRawSpanSize(event, eventSizeBytes)
|
|
31
30
|
|
|
@@ -40,12 +39,13 @@ class LLMObsSpanWriter extends BaseWriter {
|
|
|
40
39
|
|
|
41
40
|
telemetry.recordLLMObsSpanSize(event, processedEventSizeBytes, shouldTruncate)
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
const buffer = this._getBuffer(routing)
|
|
43
|
+
if (buffer.size + processedEventSizeBytes > EVP_PAYLOAD_SIZE_LIMIT) {
|
|
44
44
|
logger.debug('Flushing queue because queuing next event will exceed EvP payload limit')
|
|
45
45
|
this.flush()
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
super.append(event, processedEventSizeBytes)
|
|
48
|
+
super.append(event, routing, processedEventSizeBytes)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
makePayload (events) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const { inspect } = require('util')
|
|
3
3
|
const { isTrue } = require('../util')
|
|
4
|
+
const { getValueFromEnvSources } = require('../config/helper')
|
|
4
5
|
const { traceChannel, debugChannel, infoChannel, warnChannel, errorChannel } = require('./channels')
|
|
5
6
|
const logWriter = require('./writer')
|
|
6
7
|
const { Log, LogConfig, NoTransmitError } = require('./log')
|
|
7
8
|
const { memoize } = require('./utils')
|
|
8
|
-
const { getEnvironmentVariable } = require('../config-helper')
|
|
9
9
|
|
|
10
10
|
const config = {
|
|
11
11
|
enabled: false,
|
|
@@ -112,8 +112,8 @@ const log = {
|
|
|
112
112
|
isEnabled (fleetStableConfigValue, localStableConfigValue) {
|
|
113
113
|
return isTrue(
|
|
114
114
|
fleetStableConfigValue ??
|
|
115
|
-
|
|
116
|
-
(
|
|
115
|
+
getValueFromEnvSources('DD_TRACE_DEBUG') ??
|
|
116
|
+
(getValueFromEnvSources('OTEL_LOG_LEVEL') === 'debug' || undefined) ??
|
|
117
117
|
localStableConfigValue ??
|
|
118
118
|
config.enabled
|
|
119
119
|
)
|
|
@@ -126,8 +126,8 @@ const log = {
|
|
|
126
126
|
) {
|
|
127
127
|
return optionsValue ??
|
|
128
128
|
fleetStableConfigValue ??
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
getValueFromEnvSources('DD_TRACE_LOG_LEVEL') ??
|
|
130
|
+
getValueFromEnvSources('OTEL_LOG_LEVEL') ??
|
|
131
131
|
localStableConfigValue ??
|
|
132
132
|
config.logLevel
|
|
133
133
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const NoopTracer = require('./tracer')
|
|
4
3
|
const NoopAppsecSdk = require('../appsec/sdk/noop')
|
|
5
|
-
const NoopDogStatsDClient = require('./dogstatsd')
|
|
6
4
|
const NoopLLMObsSDK = require('../llmobs/noop')
|
|
7
5
|
const NoopFlaggingProvider = require('../openfeature/noop')
|
|
8
6
|
const NoopAIGuardSDK = require('../aiguard/noop')
|
|
7
|
+
const NoopDogStatsDClient = require('./dogstatsd')
|
|
8
|
+
const NoopTracer = require('./tracer')
|
|
9
9
|
|
|
10
10
|
const noop = new NoopTracer()
|
|
11
11
|
const noopAppsec = new NoopAppsecSdk()
|
|
@@ -23,10 +23,10 @@ class NoopProxy {
|
|
|
23
23
|
this.llmobs = noopLLMObs
|
|
24
24
|
this.openfeature = noopOpenFeatureProvider
|
|
25
25
|
this.aiguard = noopAIGuard
|
|
26
|
-
this.setBaggageItem = () => {}
|
|
27
|
-
this.getBaggageItem = () => {}
|
|
26
|
+
this.setBaggageItem = (key, value) => {}
|
|
27
|
+
this.getBaggageItem = (key) => {}
|
|
28
28
|
this.getAllBaggageItems = () => {}
|
|
29
|
-
this.removeBaggageItem = () => {}
|
|
29
|
+
this.removeBaggageItem = (keyToRemove) => {}
|
|
30
30
|
this.removeAllBaggageItems = () => {}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const NoopSpanContext = require('./span_context')
|
|
4
3
|
const id = require('../id')
|
|
5
4
|
const { storage } = require('../../../datadog-core') // TODO: noop storage?
|
|
5
|
+
const NoopSpanContext = require('./span_context')
|
|
6
6
|
|
|
7
7
|
class NoopSpan {
|
|
8
8
|
constructor (tracer, parent) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { channel } = require('dc-polyfill')
|
|
3
4
|
const log = require('../log')
|
|
4
5
|
const ExposuresWriter = require('./writers/exposures')
|
|
5
6
|
const { setAgentStrategy } = require('./writers/util')
|
|
6
|
-
const { channel } = require('dc-polyfill')
|
|
7
7
|
|
|
8
8
|
const exposureSubmitCh = channel('ffe:exposure:submit')
|
|
9
9
|
const flushCh = channel('ffe:writers:flush')
|
|
@@ -12,7 +12,7 @@ let exposuresWriter = null
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @private
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {object | Array<object>} exposureEvents - Exposure events channel subscriber
|
|
16
16
|
* @returns {void}
|
|
17
17
|
*/
|
|
18
18
|
function _handleExposureSubmit (exposureEvents) {
|
|
@@ -9,7 +9,7 @@ const { NOOP_REASON } = require('./constants/constants')
|
|
|
9
9
|
*/
|
|
10
10
|
class NoopFlaggingProvider {
|
|
11
11
|
/**
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {object} [noopTracer] - Optional noop tracer instance
|
|
13
13
|
*/
|
|
14
14
|
constructor (noopTracer) {
|
|
15
15
|
this._tracer = noopTracer
|
|
@@ -22,8 +22,8 @@ class NoopFlaggingProvider {
|
|
|
22
22
|
/**
|
|
23
23
|
* @param {string} flagKey - Flag key
|
|
24
24
|
* @param {boolean} defaultValue - Default value to return
|
|
25
|
-
* @param {
|
|
26
|
-
* @param {
|
|
25
|
+
* @param {object} context - Evaluation context
|
|
26
|
+
* @param {object} logger - Logger instance
|
|
27
27
|
* @returns {Promise<{value: boolean, reason: string}>} Resolution details
|
|
28
28
|
*/
|
|
29
29
|
resolveBooleanEvaluation (flagKey, defaultValue, context, logger) {
|
|
@@ -36,8 +36,8 @@ class NoopFlaggingProvider {
|
|
|
36
36
|
/**
|
|
37
37
|
* @param {string} flagKey - Flag key
|
|
38
38
|
* @param {string} defaultValue - Default value to return
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {
|
|
39
|
+
* @param {object} context - Evaluation context
|
|
40
|
+
* @param {object} logger - Logger instance
|
|
41
41
|
* @returns {Promise<{value: string, reason: string}>} Resolution details
|
|
42
42
|
*/
|
|
43
43
|
resolveStringEvaluation (flagKey, defaultValue, context, logger) {
|
|
@@ -50,8 +50,8 @@ class NoopFlaggingProvider {
|
|
|
50
50
|
/**
|
|
51
51
|
* @param {string} flagKey - Flag key
|
|
52
52
|
* @param {number} defaultValue - Default value to return
|
|
53
|
-
* @param {
|
|
54
|
-
* @param {
|
|
53
|
+
* @param {object} context - Evaluation context
|
|
54
|
+
* @param {object} logger - Logger instance
|
|
55
55
|
* @returns {Promise<{value: number, reason: string}>} Resolution details
|
|
56
56
|
*/
|
|
57
57
|
resolveNumberEvaluation (flagKey, defaultValue, context, logger) {
|
|
@@ -63,10 +63,10 @@ class NoopFlaggingProvider {
|
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* @param {string} flagKey - Flag key
|
|
66
|
-
* @param {
|
|
67
|
-
* @param {
|
|
68
|
-
* @param {
|
|
69
|
-
* @returns {Promise<{value:
|
|
66
|
+
* @param {object} defaultValue - Default value to return
|
|
67
|
+
* @param {object} context - Evaluation context
|
|
68
|
+
* @param {object} logger - Logger instance
|
|
69
|
+
* @returns {Promise<{value: object, reason: string}>} Resolution details
|
|
70
70
|
*/
|
|
71
71
|
resolveObjectEvaluation (flagKey, defaultValue, context, logger) {
|
|
72
72
|
return Promise.resolve({
|
|
@@ -76,14 +76,14 @@ class NoopFlaggingProvider {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* @returns {
|
|
79
|
+
* @returns {object} Current configuration
|
|
80
80
|
*/
|
|
81
81
|
getConfiguration () {
|
|
82
82
|
return this._config
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* @param {
|
|
86
|
+
* @param {object} config - Configuration to set
|
|
87
87
|
*/
|
|
88
88
|
setConfiguration (config) {
|
|
89
89
|
this._config = config
|
|
@@ -91,7 +91,7 @@ class NoopFlaggingProvider {
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* @internal
|
|
94
|
-
* @param {
|
|
94
|
+
* @param {object} ufc - Universal Flag Configuration object
|
|
95
95
|
*/
|
|
96
96
|
_setConfiguration (ufc) {
|
|
97
97
|
this.setConfiguration(ufc)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const RemoteConfigCapabilities = require('../remote_config/capabilities')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configures remote config handlers for openfeature feature flagging
|
|
7
|
+
*
|
|
8
|
+
* @param {object} rc - RemoteConfig instance
|
|
9
|
+
* @param {object} config - Tracer config
|
|
10
|
+
* @param {Function} getOpenfeatureProxy - Function that returns the OpenFeature proxy from tracer
|
|
11
|
+
*/
|
|
12
|
+
function enable (rc, config, getOpenfeatureProxy) {
|
|
13
|
+
// Always enable capability for feature flag configuration
|
|
14
|
+
// This indicates the library supports this capability via remote config
|
|
15
|
+
rc.updateCapabilities(RemoteConfigCapabilities.FFE_FLAG_CONFIGURATION_RULES, true)
|
|
16
|
+
|
|
17
|
+
// Only register product handler if the experimental feature is enabled
|
|
18
|
+
if (!config.experimental.flaggingProvider.enabled) return
|
|
19
|
+
|
|
20
|
+
// Set product handler for FFE_FLAGS
|
|
21
|
+
rc.setProductHandler('FFE_FLAGS', (action, conf) => {
|
|
22
|
+
// Feed UFC config directly to OpenFeature provider
|
|
23
|
+
if (action === 'apply' || action === 'modify') {
|
|
24
|
+
getOpenfeatureProxy()._setConfiguration(conf)
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
enable
|
|
31
|
+
}
|