dd-trace 5.80.0 → 5.82.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 +79 -88
- package/ext/tags.d.ts +1 -0
- package/ext/tags.js +1 -0
- package/index.d.ts +42 -35
- package/loader-hook.mjs +16 -4
- package/package.json +33 -56
- package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
- package/packages/datadog-esbuild/index.js +44 -26
- package/packages/datadog-esbuild/src/utils.js +14 -2
- package/packages/datadog-instrumentations/index.js +1 -0
- package/packages/datadog-instrumentations/src/aerospike.js +3 -2
- package/packages/datadog-instrumentations/src/ai.js +2 -2
- 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 +14 -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 +6 -2
- 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 +2 -2
- 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 +12 -13
- 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/find-my-way.js +6 -5
- 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 +120 -0
- package/packages/datadog-instrumentations/src/graphql.js +21 -1
- 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 +5 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +11 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +12 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +27 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +152 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/bullmq.json +106 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +6 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langchain.js +237 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +11 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +139 -0
- 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/ioredis.js +1 -1
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +2 -2
- package/packages/datadog-instrumentations/src/kafkajs.js +3 -3
- package/packages/datadog-instrumentations/src/knex.js +1 -1
- package/packages/datadog-instrumentations/src/langchain.js +3 -109
- 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 +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 +1 -1
- package/packages/datadog-instrumentations/src/mysql2.js +2 -2
- package/packages/datadog-instrumentations/src/net.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +1 -1
- package/packages/datadog-instrumentations/src/nyc.js +1 -1
- 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 +1 -1
- package/packages/datadog-instrumentations/src/pg.js +3 -3
- package/packages/datadog-instrumentations/src/pino.js +1 -1
- package/packages/datadog-instrumentations/src/playwright.js +46 -17
- 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/router.js +1 -1
- package/packages/datadog-instrumentations/src/selenium.js +4 -2
- 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 +4 -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 +38 -19
- 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/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 +19 -5
- package/packages/datadog-plugin-azure-service-bus/src/index.js +1 -1
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +4 -0
- 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-child_process/src/scrub-cmd-params.js +1 -1
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +23 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +2 -2
- package/packages/datadog-plugin-cypress/src/support.js +73 -31
- package/packages/datadog-plugin-express/src/index.js +1 -1
- 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 +17 -0
- package/packages/datadog-plugin-google-genai/src/tracing.js +41 -0
- package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +5 -4
- 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/util.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
- package/packages/datadog-plugin-langchain/src/index.js +1 -1
- package/packages/datadog-plugin-langchain/src/tracing.js +7 -3
- package/packages/datadog-plugin-moleculer/src/index.js +1 -1
- package/packages/datadog-plugin-mongodb-core/src/index.js +6 -2
- package/packages/datadog-plugin-next/src/index.js +11 -3
- 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-rhea/src/index.js +1 -1
- 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/src/aiguard/sdk.js +21 -13
- package/packages/dd-trace/src/appsec/api_security_sampler.js +1 -1
- 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/overhead-controller.js +1 -1
- 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-esm.mjs +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +11 -16
- 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 +4 -4
- 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 +1 -1
- 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 -7
- 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 +8 -2
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +8 -6
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +4 -2
- package/packages/dd-trace/src/config/remote_config.js +34 -0
- package/packages/dd-trace/src/config.js +109 -34
- package/packages/dd-trace/src/config_defaults.js +16 -3
- package/packages/dd-trace/src/constants.js +5 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +10 -1
- package/packages/dd-trace/src/datastreams/checkpointer.js +2 -2
- package/packages/dd-trace/src/datastreams/encoding.js +23 -6
- package/packages/dd-trace/src/datastreams/index.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +41 -2
- package/packages/dd-trace/src/datastreams/processor.js +3 -3
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -1
- package/packages/dd-trace/src/datastreams/writer.js +2 -2
- package/packages/dd-trace/src/debugger/config.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +15 -5
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/index.js +37 -17
- package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +24 -18
- package/packages/dd-trace/src/debugger/devtools_client/send.js +21 -11
- package/packages/dd-trace/src/debugger/devtools_client/session.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +103 -15
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/constants.js +25 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +56 -25
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +64 -23
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +404 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +8 -3
- package/packages/dd-trace/src/debugger/devtools_client/status.js +3 -3
- package/packages/dd-trace/src/debugger/index.js +2 -2
- package/packages/dd-trace/src/dogstatsd.js +3 -2
- package/packages/dd-trace/src/encode/0.4.js +1 -1
- 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 +13 -2
- package/packages/dd-trace/src/exporter.js +2 -2
- package/packages/dd-trace/src/exporters/agent/index.js +1 -1
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +1 -1
- package/packages/dd-trace/src/exporters/common/request.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 +1 -1
- package/packages/dd-trace/src/guardrails/index.js +6 -3
- package/packages/dd-trace/src/histogram.js +1 -1
- package/packages/dd-trace/src/id.js +60 -0
- package/packages/dd-trace/src/index.js +1 -1
- package/packages/dd-trace/src/lambda/handler.js +4 -4
- package/packages/dd-trace/src/lambda/index.js +1 -1
- package/packages/dd-trace/src/lambda/runtime/patch.js +4 -4
- package/packages/dd-trace/src/lambda/runtime/ritm.js +2 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +8 -1
- package/packages/dd-trace/src/llmobs/index.js +8 -9
- 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/index.js +104 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +486 -0
- 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/langchain/index.js +2 -2
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +16 -0
- package/packages/dd-trace/src/llmobs/plugins/{openai.js → openai/index.js} +63 -6
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +126 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +20 -22
- package/packages/dd-trace/src/llmobs/span_processor.js +15 -14
- package/packages/dd-trace/src/llmobs/tagger.js +4 -0
- package/packages/dd-trace/src/llmobs/telemetry.js +3 -4
- package/packages/dd-trace/src/llmobs/writers/base.js +2 -2
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -2
- package/packages/dd-trace/src/log/index.js +1 -1
- package/packages/dd-trace/src/noop/proxy.js +2 -2
- 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 +5 -5
- 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/index.js +2 -2
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +3 -2
- package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +4 -4
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +5 -3
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +17 -16
- package/packages/dd-trace/src/opentelemetry/metrics/constants.js +34 -0
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +81 -0
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +225 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +171 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +54 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +62 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +251 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +557 -0
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +10 -18
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +47 -32
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +1 -1
- package/packages/dd-trace/src/opentelemetry/span.js +3 -3
- package/packages/dd-trace/src/opentelemetry/tracer.js +4 -4
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +1 -1
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +24 -8
- package/packages/dd-trace/src/opentracing/span.js +3 -3
- package/packages/dd-trace/src/opentracing/tracer.js +5 -5
- package/packages/dd-trace/src/payload-tagging/index.js +8 -4
- package/packages/dd-trace/src/plugin_manager.js +5 -3
- 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 +6 -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 +1 -1
- 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 +27 -27
- package/packages/dd-trace/src/plugins/util/url.js +119 -1
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +1 -1
- package/packages/dd-trace/src/plugins/util/web.js +18 -46
- package/packages/dd-trace/src/priority_sampler.js +15 -16
- package/packages/dd-trace/src/process-tags/index.js +83 -0
- package/packages/dd-trace/src/profiling/config.js +33 -22
- package/packages/dd-trace/src/profiling/exporter_cli.js +4 -4
- package/packages/dd-trace/src/profiling/exporters/agent.js +5 -5
- 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 +4 -5
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +11 -2
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/proxy.js +17 -18
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- 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 +50 -27
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +1 -1
- package/packages/dd-trace/src/serverless.js +16 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +4 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +4 -0
- package/packages/dd-trace/src/span_format.js +10 -5
- package/packages/dd-trace/src/span_processor.js +8 -3
- package/packages/dd-trace/src/span_stats.js +21 -8
- package/packages/dd-trace/src/spanleak.js +1 -1
- package/packages/dd-trace/src/standalone/index.js +1 -1
- package/packages/dd-trace/src/startup-log.js +3 -3
- package/packages/dd-trace/src/supported-configurations.json +16 -0
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -4
- package/packages/dd-trace/src/telemetry/endpoints.js +8 -8
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +22 -8
- package/packages/dd-trace/src/tracer.js +3 -3
- package/packages/dd-trace/src/tracer_metadata.js +19 -15
- package/vendor/dist/@datadog/sketches-js/LICENSE +39 -0
- package/vendor/dist/@datadog/sketches-js/index.js +1 -0
- package/vendor/dist/@datadog/source-map/LICENSE +28 -0
- package/vendor/dist/@datadog/source-map/index.js +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +55 -0
- package/vendor/dist/@isaacs/ttlcache/index.js +1 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/core/index.js +1 -0
- package/vendor/dist/@opentelemetry/resources/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/resources/index.js +1 -0
- package/vendor/dist/astring/LICENSE +19 -0
- package/vendor/dist/astring/index.js +1 -0
- package/vendor/dist/crypto-randomuuid/index.js +1 -0
- package/vendor/dist/escape-string-regexp/LICENSE +9 -0
- package/vendor/dist/escape-string-regexp/index.js +1 -0
- package/vendor/dist/esquery/LICENSE +24 -0
- package/vendor/dist/esquery/index.js +1 -0
- package/vendor/dist/ignore/LICENSE +21 -0
- package/vendor/dist/ignore/index.js +1 -0
- package/vendor/dist/istanbul-lib-coverage/LICENSE +24 -0
- package/vendor/dist/istanbul-lib-coverage/index.js +1 -0
- package/vendor/dist/jest-docblock/LICENSE +21 -0
- package/vendor/dist/jest-docblock/index.js +1 -0
- package/vendor/dist/jsonpath-plus/LICENSE +22 -0
- package/vendor/dist/jsonpath-plus/index.js +1 -0
- package/vendor/dist/limiter/LICENSE +19 -0
- package/vendor/dist/limiter/index.js +1 -0
- package/vendor/dist/lodash.sortby/LICENSE +47 -0
- package/vendor/dist/lodash.sortby/index.js +1 -0
- package/vendor/dist/lru-cache/LICENSE +15 -0
- package/vendor/dist/lru-cache/index.js +1 -0
- package/vendor/dist/meriyah/LICENSE +7 -0
- package/vendor/dist/meriyah/index.js +1 -0
- package/vendor/dist/module-details-from-path/LICENSE +21 -0
- package/vendor/dist/module-details-from-path/index.js +1 -0
- package/vendor/dist/mutexify/promise/LICENSE +21 -0
- package/vendor/dist/mutexify/promise/index.js +1 -0
- package/vendor/dist/opentracing/LICENSE +201 -0
- package/vendor/dist/opentracing/binary_carrier.d.ts +11 -0
- package/vendor/dist/opentracing/constants.d.ts +61 -0
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +2 -0
- package/vendor/dist/opentracing/ext/tags.d.ts +90 -0
- package/vendor/dist/opentracing/functions.d.ts +20 -0
- package/vendor/dist/opentracing/global_tracer.d.ts +14 -0
- package/vendor/dist/opentracing/index.d.ts +12 -0
- package/vendor/dist/opentracing/index.js +1 -0
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +5 -0
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +13 -0
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +16 -0
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +50 -0
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +26 -0
- package/vendor/dist/opentracing/noop.d.ts +8 -0
- package/vendor/dist/opentracing/reference.d.ts +33 -0
- package/vendor/dist/opentracing/span.d.ts +147 -0
- package/vendor/dist/opentracing/span_context.d.ts +26 -0
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +16 -0
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +3 -0
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +4 -0
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +3 -0
- package/vendor/dist/opentracing/test/unittest.d.ts +2 -0
- package/vendor/dist/opentracing/tracer.d.ts +127 -0
- package/vendor/dist/path-to-regexp/LICENSE +21 -0
- package/vendor/dist/path-to-regexp/index.js +1 -0
- package/vendor/dist/pprof-format/LICENSE +8 -0
- package/vendor/dist/pprof-format/index.js +1 -0
- package/vendor/dist/protobufjs/LICENSE +39 -0
- package/vendor/dist/protobufjs/index.js +1 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +39 -0
- package/vendor/dist/protobufjs/minimal/index.js +1 -0
- package/vendor/dist/retry/LICENSE +21 -0
- package/vendor/dist/retry/index.js +1 -0
- package/vendor/dist/rfdc/LICENSE +15 -0
- package/vendor/dist/rfdc/index.js +1 -0
- package/vendor/dist/semifies/LICENSE +201 -0
- package/vendor/dist/semifies/index.js +1 -0
- package/vendor/dist/shell-quote/LICENSE +24 -0
- package/vendor/dist/shell-quote/index.js +1 -0
- package/vendor/dist/source-map/LICENSE +28 -0
- package/vendor/dist/source-map/index.js +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +28 -0
- package/vendor/dist/source-map/lib/util/index.js +1 -0
- package/vendor/dist/source-map/mappings.wasm +0 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +21 -0
- package/vendor/dist/tlhunter-sorted-set/index.js +1 -0
- package/vendor/dist/ttl-set/LICENSE +21 -0
- package/vendor/dist/ttl-set/index.js +1 -0
- package/packages/dd-trace/src/remote_config/manager.js +0 -368
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
|
|
4
|
+
const SpanContext = require('../../dd-trace/src/opentracing/span_context')
|
|
5
|
+
const id = require('../../dd-trace/src/id')
|
|
6
|
+
const log = require('../../dd-trace/src/log')
|
|
7
|
+
|
|
8
|
+
// WeakMap to track push receive spans by request
|
|
9
|
+
const pushReceiveSpans = new WeakMap()
|
|
10
|
+
|
|
11
|
+
class GoogleCloudPubsubPushSubscriptionPlugin extends TracingPlugin {
|
|
12
|
+
static get id () { return 'google-cloud-pubsub-push-subscription' }
|
|
13
|
+
|
|
14
|
+
constructor (...args) {
|
|
15
|
+
super(...args)
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* PUSH SUBSCRIPTION: GCP sends HTTP POST requests to our service with message data in headers.
|
|
19
|
+
* We intercept these requests to create a pubsub.push.receive span that wraps the HTTP request.
|
|
20
|
+
*
|
|
21
|
+
* Flow: Detect push request -> Extract trace context -> Create receive span -> Activate it
|
|
22
|
+
* Hierarchy: pubsub.push.receive (parent) -> http.request (child) -> express.middleware...
|
|
23
|
+
*
|
|
24
|
+
* Plugin load order (http/index.js) ensures we subscribe before HttpServerPlugin.
|
|
25
|
+
*/
|
|
26
|
+
this.addSub('apm:http:server:request:start', (ctx) => {
|
|
27
|
+
this.#handlePubSubRequest(ctx)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
this.addSub('apm:http:server:request:finish', ({ req }) => {
|
|
31
|
+
this.#finishPushReceiveSpan(req)
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#finishPushReceiveSpan (req) {
|
|
36
|
+
const pushReceiveSpan = pushReceiveSpans.get(req)
|
|
37
|
+
if (pushReceiveSpan && !pushReceiveSpan._duration) {
|
|
38
|
+
pushReceiveSpan.finish()
|
|
39
|
+
pushReceiveSpans.delete(req)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#handlePubSubRequest (ctx) {
|
|
44
|
+
const { req } = ctx
|
|
45
|
+
const userAgent = req.headers['user-agent'] || ''
|
|
46
|
+
if (req.method !== 'POST' || !userAgent.includes('APIs-Google')) {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (req.headers['x-goog-pubsub-message-id']) {
|
|
51
|
+
this.#createPushReceiveSpanAndActivate(ctx)
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
log.warn(
|
|
56
|
+
'[PubSub] No x-goog-pubsub-* headers detected. pubsub.push.receive spans will not be created. ' +
|
|
57
|
+
'Add --push-no-wrapper-write-metadata to your subscription.'
|
|
58
|
+
)
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#createPushReceiveSpanAndActivate (ctx) {
|
|
63
|
+
const { req, res } = ctx
|
|
64
|
+
const messageData = this.#parseMessage(req)
|
|
65
|
+
if (!messageData) {
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const originalContext = this.#extractContext(messageData)
|
|
70
|
+
const pubsubRequestContext = this.#reconstructPubSubContext(messageData.attrs) || originalContext
|
|
71
|
+
const isSameTrace = pubsubRequestContext &&
|
|
72
|
+
originalContext?.toTraceId() === pubsubRequestContext.toTraceId()
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Create receive span, choosing parent context:
|
|
76
|
+
* - Same trace: use batch context (message is part of the batch trace)
|
|
77
|
+
* - Different trace: use message context as parent, link to batch for observability
|
|
78
|
+
*
|
|
79
|
+
* this.enter() activates the span so the HTTP request span becomes its child.
|
|
80
|
+
*/
|
|
81
|
+
const pushReceiveSpan = this.#createPushReceiveSpan(
|
|
82
|
+
messageData,
|
|
83
|
+
isSameTrace ? pubsubRequestContext : originalContext,
|
|
84
|
+
isSameTrace ? null : pubsubRequestContext
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if (!pushReceiveSpan) {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.enter(pushReceiveSpan, { req, res })
|
|
92
|
+
pushReceiveSpans.set(req, pushReceiveSpan)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#parseMessage (req) {
|
|
96
|
+
const subscription = req.headers['x-goog-pubsub-subscription-name']
|
|
97
|
+
const message = {
|
|
98
|
+
messageId: req.headers['x-goog-pubsub-message-id'],
|
|
99
|
+
publishTime: req.headers['x-goog-pubsub-publish-time']
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const topicName = req.headers['pubsub.topic'] || 'push-subscription-topic'
|
|
103
|
+
return { message, subscription, attrs: req.headers, topicName }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#extractContext (messageData) {
|
|
107
|
+
return this.tracer.extract('text_map', messageData.attrs)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
#reconstructPubSubContext (attrs) {
|
|
111
|
+
/**
|
|
112
|
+
* Reconstruct the batch publish span context from message attributes.
|
|
113
|
+
*
|
|
114
|
+
* When a batch is published, the producer injects:
|
|
115
|
+
* - _dd.pubsub_request.trace_id: lower 64 bits of the batch span's trace ID (hex)
|
|
116
|
+
* - _dd.pubsub_request.span_id: the batch span's span ID (hex)
|
|
117
|
+
* - _dd.pubsub_request.p.tid: upper 64 bits of trace ID (hex, optional for 128-bit traces)
|
|
118
|
+
*
|
|
119
|
+
* This context represents the "pubsub.request" span on the producer side.
|
|
120
|
+
* We use it to create span links, connecting each pubsub.push.receive span back to the original batch.
|
|
121
|
+
*/
|
|
122
|
+
const traceIdLower = attrs['_dd.pubsub_request.trace_id']
|
|
123
|
+
const spanId = attrs['_dd.pubsub_request.span_id']
|
|
124
|
+
const traceIdUpper = attrs['_dd.pubsub_request.p.tid']
|
|
125
|
+
|
|
126
|
+
if (!traceIdLower || !spanId) return null
|
|
127
|
+
|
|
128
|
+
// Reconstruct full 128-bit trace ID (or pad 64-bit to 128-bit)
|
|
129
|
+
const traceId128 = traceIdUpper ? traceIdUpper + traceIdLower : traceIdLower.padStart(32, '0')
|
|
130
|
+
const traceId = id(traceId128, 16)
|
|
131
|
+
const parentId = id(spanId, 16)
|
|
132
|
+
|
|
133
|
+
const tags = {}
|
|
134
|
+
if (traceIdUpper) tags['_dd.p.tid'] = traceIdUpper
|
|
135
|
+
|
|
136
|
+
return new SpanContext({
|
|
137
|
+
traceId,
|
|
138
|
+
spanId: parentId,
|
|
139
|
+
tags
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#createPushReceiveSpan (messageData, parentContext, linkContext) {
|
|
144
|
+
const { message, subscription, topicName, attrs } = messageData
|
|
145
|
+
const subscriptionName = subscription?.slice(subscription.lastIndexOf('/') + 1) ?? subscription
|
|
146
|
+
const publishStartTime = attrs['x-dd-publish-start-time']
|
|
147
|
+
const startTime = publishStartTime ? Number.parseInt(publishStartTime, 10) : undefined
|
|
148
|
+
|
|
149
|
+
// Get the base service name and construct the pubsub service override
|
|
150
|
+
const baseService = this.tracer._service
|
|
151
|
+
const serviceOverride = this.config.service ?? `${baseService}-pubsub`
|
|
152
|
+
|
|
153
|
+
// Use this.startSpan() which automatically activates the span
|
|
154
|
+
const span = this.startSpan('pubsub.push.receive', {
|
|
155
|
+
childOf: parentContext,
|
|
156
|
+
startTime,
|
|
157
|
+
kind: 'consumer',
|
|
158
|
+
service: serviceOverride,
|
|
159
|
+
meta: {
|
|
160
|
+
component: 'google-cloud-pubsub',
|
|
161
|
+
'pubsub.method': 'receive',
|
|
162
|
+
'pubsub.subscription': subscription,
|
|
163
|
+
'pubsub.message_id': message.messageId,
|
|
164
|
+
'pubsub.subscription_type': 'push',
|
|
165
|
+
'pubsub.topic': topicName,
|
|
166
|
+
'_dd.base_service': baseService,
|
|
167
|
+
'_dd.serviceoverride.type': 'integration',
|
|
168
|
+
'resource.name': `Push Subscription ${subscriptionName}`
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
if (!span) {
|
|
173
|
+
return null
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
span._integrationName = 'google-cloud-pubsub'
|
|
177
|
+
// Calculate delivery latency (queue time from publish to delivery)
|
|
178
|
+
if (publishStartTime) {
|
|
179
|
+
const deliveryDuration = Date.now() - Number(publishStartTime)
|
|
180
|
+
span.setTag('pubsub.delivery_duration_ms', deliveryDuration)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
this.#addBatchMetadata(span, attrs)
|
|
184
|
+
|
|
185
|
+
if (linkContext) {
|
|
186
|
+
if (span.addLink) {
|
|
187
|
+
span.addLink(linkContext, {})
|
|
188
|
+
} else {
|
|
189
|
+
span._links ??= []
|
|
190
|
+
span._links.push({ context: linkContext, attributes: {} })
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return span
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
#addBatchMetadata (span, attrs) {
|
|
198
|
+
const batchSizeStr = attrs['_dd.batch.size']
|
|
199
|
+
const batchIndexStr = attrs['_dd.batch.index']
|
|
200
|
+
|
|
201
|
+
if (!batchSizeStr || batchIndexStr === undefined) return
|
|
202
|
+
|
|
203
|
+
const size = Number(batchSizeStr)
|
|
204
|
+
const index = Number(batchIndexStr)
|
|
205
|
+
|
|
206
|
+
span.setTag('pubsub.batch.message_count', size)
|
|
207
|
+
span.setTag('pubsub.batch.message_index', index)
|
|
208
|
+
span.setTag('pubsub.batch.description', `Message ${index + 1} of ${size}`)
|
|
209
|
+
|
|
210
|
+
const requestTraceId = attrs['_dd.pubsub_request.trace_id']
|
|
211
|
+
if (requestTraceId) {
|
|
212
|
+
span.setTag('pubsub.batch.request_trace_id', requestTraceId)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
module.exports = GoogleCloudPubsubPushSubscriptionPlugin
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
4
|
-
const GoogleVertexAITracingPlugin = require('./tracing')
|
|
5
4
|
const VertexAILLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/vertexai')
|
|
5
|
+
const GoogleVertexAITracingPlugin = require('./tracing')
|
|
6
6
|
|
|
7
7
|
class GoogleCloudVertexAIPlugin extends CompositePlugin {
|
|
8
8
|
static id = 'google-cloud-vertexai'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
4
|
+
const GenAiLLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/genai')
|
|
5
|
+
const GenAiTracingPlugin = require('./tracing')
|
|
6
|
+
|
|
7
|
+
class GenAiPlugin extends CompositePlugin {
|
|
8
|
+
static id = 'google-genai'
|
|
9
|
+
static get plugins () {
|
|
10
|
+
return {
|
|
11
|
+
llmobs: GenAiLLMObsPlugin,
|
|
12
|
+
tracing: GenAiTracingPlugin
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = GenAiPlugin
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const TracingPlugin = require('../../dd-trace/src/plugins/tracing.js')
|
|
4
|
+
|
|
5
|
+
class GenAiTracingPlugin extends TracingPlugin {
|
|
6
|
+
static id = 'google-genai'
|
|
7
|
+
static operation = 'request'
|
|
8
|
+
static prefix = 'tracing:apm:google:genai:request'
|
|
9
|
+
|
|
10
|
+
static get type () { return 'web' }
|
|
11
|
+
static get kind () { return 'client' }
|
|
12
|
+
|
|
13
|
+
bindStart (ctx) {
|
|
14
|
+
const { args, methodName } = ctx
|
|
15
|
+
|
|
16
|
+
const inputs = args[0]
|
|
17
|
+
const model = inputs?.model || 'unknown'
|
|
18
|
+
|
|
19
|
+
this.startSpan('google_genai.request', {
|
|
20
|
+
meta: {
|
|
21
|
+
'resource.name': methodName,
|
|
22
|
+
'google_genai.request.model': model,
|
|
23
|
+
'google_genai.request.provider': 'google'
|
|
24
|
+
}
|
|
25
|
+
}, ctx)
|
|
26
|
+
|
|
27
|
+
return ctx.currentStore
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
asyncEnd (ctx) {
|
|
31
|
+
const { span } = ctx.currentStore
|
|
32
|
+
if (!span) return
|
|
33
|
+
|
|
34
|
+
if (ctx.result) {
|
|
35
|
+
span.setTag('google_genai.response.model', ctx.result.modelVersion || ctx.inputs?.model)
|
|
36
|
+
}
|
|
37
|
+
span.finish()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = GenAiTracingPlugin
|
|
@@ -5,10 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
8
|
+
const ddGlobal = globalThis[Symbol.for('dd-trace')];
|
|
9
|
+
const visitor_1 = ddGlobal.graphql_visitor;
|
|
10
|
+
const printer_1 = ddGlobal.graphql_printer;
|
|
11
|
+
const utilities_1 = ddGlobal.graphql_utilities;
|
|
12
|
+
const lodash_sortby_1 = __importDefault(require("../../../../vendor/dist/lodash.sortby"));
|
|
12
13
|
function hideLiterals(ast) {
|
|
13
14
|
return visitor_1.visit(ast, {
|
|
14
15
|
IntValue(node) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
3
4
|
const GrpcServerPlugin = require('./server')
|
|
4
5
|
const GrpcClientPlugin = require('./client')
|
|
5
|
-
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
6
6
|
|
|
7
7
|
class GrpcPlugin extends CompositePlugin {
|
|
8
8
|
static id = 'grpc'
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { URL } = require('url')
|
|
4
|
+
|
|
3
5
|
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
6
|
const { storage } = require('../../datadog-core')
|
|
5
7
|
const tags = require('../../../ext/tags')
|
|
@@ -9,7 +11,6 @@ const HTTP_HEADERS = formats.HTTP_HEADERS
|
|
|
9
11
|
const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
|
|
10
12
|
const log = require('../../dd-trace/src/log')
|
|
11
13
|
const { CLIENT_PORT_KEY, COMPONENT, ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
|
|
12
|
-
const { URL } = require('url')
|
|
13
14
|
|
|
14
15
|
const HTTP_STATUS_CODE = tags.HTTP_STATUS_CODE
|
|
15
16
|
const HTTP_REQUEST_HEADERS = tags.HTTP_REQUEST_HEADERS
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const HttpClientPlugin = require('./client')
|
|
3
|
+
const PushSubscriptionPlugin = require('../../datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription')
|
|
5
4
|
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
5
|
+
const { enableGCPPubSubPushSubscription } = require('../../dd-trace/src/serverless')
|
|
6
|
+
const log = require('../../dd-trace/src/log')
|
|
7
|
+
const HttpClientPlugin = require('./client')
|
|
8
|
+
const HttpServerPlugin = require('./server')
|
|
6
9
|
|
|
10
|
+
/**
|
|
11
|
+
* HTTP Plugin loads server/client plugins with optional GCP Pub/Sub Push support.
|
|
12
|
+
* Plugin order is critical: PushSubscriptionPlugin must load FIRST to intercept
|
|
13
|
+
* Pub/Sub push requests and activate delivery spans before HTTP spans are created.
|
|
14
|
+
*/
|
|
7
15
|
class HttpPlugin extends CompositePlugin {
|
|
8
16
|
static id = 'http'
|
|
9
17
|
static get plugins () {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
const plugins = {}
|
|
19
|
+
|
|
20
|
+
// Load push subscription plugin first (if enabled) for GCP Cloud Run
|
|
21
|
+
if (enableGCPPubSubPushSubscription()) {
|
|
22
|
+
try {
|
|
23
|
+
plugins['pubsub-push-subscription'] = PushSubscriptionPlugin
|
|
24
|
+
log.debug('Loaded GCP Pub/Sub Push Subscription plugin for HTTP requests')
|
|
25
|
+
} catch (e) {
|
|
26
|
+
log.debug(`Failed to load GCP Pub/Sub Push Subscription plugin: ${e.message}`)
|
|
27
|
+
}
|
|
13
28
|
}
|
|
29
|
+
|
|
30
|
+
plugins.server = HttpServerPlugin
|
|
31
|
+
plugins.client = HttpClientPlugin
|
|
32
|
+
|
|
33
|
+
return plugins
|
|
14
34
|
}
|
|
15
35
|
}
|
|
16
36
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const URL = require('url').URL
|
|
4
|
+
|
|
3
5
|
const { storage } = require('../../datadog-core')
|
|
4
6
|
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
5
|
-
|
|
6
|
-
const URL = require('url').URL
|
|
7
7
|
const log = require('../../dd-trace/src/log')
|
|
8
8
|
const tags = require('../../../ext/tags')
|
|
9
9
|
const kinds = require('../../../ext/kinds')
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
3
4
|
const Http2ServerPlugin = require('./server')
|
|
4
5
|
const Http2ClientPlugin = require('./client')
|
|
5
|
-
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
6
6
|
|
|
7
7
|
class Http2Plugin extends CompositePlugin {
|
|
8
8
|
static id = 'http2'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { readFileSync } = require('fs')
|
|
4
|
-
const { parse } = require('jest-docblock')
|
|
4
|
+
const { parse } = require('../../../vendor/dist/jest-docblock')
|
|
5
5
|
|
|
6
6
|
const { getTestSuitePath } = require('../../dd-trace/src/plugins/util/test')
|
|
7
7
|
const log = require('../../dd-trace/src/log')
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
3
4
|
const ProducerPlugin = require('./producer')
|
|
4
5
|
const ConsumerPlugin = require('./consumer')
|
|
5
6
|
const BatchConsumerPlugin = require('./batch-consumer')
|
|
6
|
-
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
7
7
|
|
|
8
8
|
class KafkajsPlugin extends CompositePlugin {
|
|
9
9
|
static id = 'kafkajs'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const langChainTracingPlugins = require('./tracing')
|
|
4
3
|
const langChainLLMObsPlugins = require('../../dd-trace/src/llmobs/plugins/langchain')
|
|
5
4
|
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
5
|
+
const langChainTracingPlugins = require('./tracing')
|
|
6
6
|
|
|
7
7
|
const plugins = {}
|
|
8
8
|
|
|
@@ -12,6 +12,8 @@ const LangChainHandler = require('./handlers/default')
|
|
|
12
12
|
const LangChainLanguageModelHandler = require('./handlers/language_models')
|
|
13
13
|
const LangChainEmbeddingHandler = require('./handlers/embedding')
|
|
14
14
|
|
|
15
|
+
const defaultNs = ['langchain', 'embeddings']
|
|
16
|
+
|
|
15
17
|
class BaseLangChainTracingPlugin extends TracingPlugin {
|
|
16
18
|
static id = 'langchain'
|
|
17
19
|
static operation = 'invoke'
|
|
@@ -36,7 +38,9 @@ class BaseLangChainTracingPlugin extends TracingPlugin {
|
|
|
36
38
|
const type = ctx.type = this.constructor.lcType
|
|
37
39
|
|
|
38
40
|
// Runnable interfaces have an `lc_namespace` property
|
|
39
|
-
const ns = ctx.self.lc_namespace ||
|
|
41
|
+
const ns = ctx.self.lc_namespace || (
|
|
42
|
+
ctx.self.constructor.name === 'OpenAIEmbeddings' ? [...defaultNs, 'openai'] : defaultNs
|
|
43
|
+
)
|
|
40
44
|
|
|
41
45
|
const resourceParts = [...ns, ctx.self.constructor.name]
|
|
42
46
|
if (type === 'tool') {
|
|
@@ -111,13 +115,13 @@ class BaseLLMGeneratePlugin extends BaseLangChainTracingPlugin {
|
|
|
111
115
|
class EmbeddingsEmbedQueryPlugin extends BaseLangChainTracingPlugin {
|
|
112
116
|
static id = 'langchain_embeddings_embed_query'
|
|
113
117
|
static lcType = 'embedding'
|
|
114
|
-
static prefix = 'tracing:
|
|
118
|
+
static prefix = 'tracing:orchestrion:@langchain/core:Embeddings_embedQuery'
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
class EmbeddingsEmbedDocumentsPlugin extends BaseLangChainTracingPlugin {
|
|
118
122
|
static id = 'langchain_embeddings_embed_documents'
|
|
119
123
|
static lcType = 'embedding'
|
|
120
|
-
static prefix = 'tracing:
|
|
124
|
+
static prefix = 'tracing:orchestrion:@langchain/core:Embeddings_embedDocuments'
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
class ToolInvokePlugin extends BaseLangChainTracingPlugin {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
// TODO: support https://moleculer.services/docs/0.13/actions.html#Streaming
|
|
4
4
|
|
|
5
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
5
6
|
const MoleculerServerPlugin = require('./server')
|
|
6
7
|
const MoleculerClientPlugin = require('./client')
|
|
7
|
-
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
8
8
|
|
|
9
9
|
class MoleculerPlugin extends CompositePlugin {
|
|
10
10
|
static id = 'moleculer'
|
|
@@ -204,8 +204,12 @@ function isBinary (val) {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
function isHeartbeat (ops, config) {
|
|
207
|
-
// Check if it's a heartbeat command
|
|
208
|
-
return
|
|
207
|
+
// Check if it's a heartbeat command https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.md
|
|
208
|
+
return (
|
|
209
|
+
ops &&
|
|
210
|
+
typeof ops === 'object' &&
|
|
211
|
+
(ops.hello === 1 || ops.helloOk === true || ops.ismaster === 1 || ops.isMaster === 1)
|
|
212
|
+
)
|
|
209
213
|
}
|
|
210
214
|
|
|
211
215
|
module.exports = MongodbCorePlugin
|
|
@@ -10,10 +10,10 @@ const errorPages = new Set(['/404', '/500', '/_error', '/_not-found', '/_not-fou
|
|
|
10
10
|
|
|
11
11
|
class NextPlugin extends ServerPlugin {
|
|
12
12
|
static id = 'next'
|
|
13
|
+
#requestsBySpanId = new WeakMap()
|
|
13
14
|
|
|
14
15
|
constructor (...args) {
|
|
15
16
|
super(...args)
|
|
16
|
-
this._requests = new WeakMap()
|
|
17
17
|
this.addSub('apm:next:page:load', message => this.pageLoad(message))
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -35,7 +35,9 @@ class NextPlugin extends ServerPlugin {
|
|
|
35
35
|
|
|
36
36
|
analyticsSampler.sample(span, this.config.measured, true)
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
// Store request by span ID to handle cases where child spans are activated
|
|
39
|
+
const spanId = span.context()._spanId
|
|
40
|
+
this.#requestsBySpanId.set(spanId, req)
|
|
39
41
|
|
|
40
42
|
return { ...store, span }
|
|
41
43
|
}
|
|
@@ -89,7 +91,13 @@ class NextPlugin extends ServerPlugin {
|
|
|
89
91
|
if (!store) return
|
|
90
92
|
|
|
91
93
|
const span = store.span
|
|
92
|
-
|
|
94
|
+
|
|
95
|
+
const spanId = span.context()._spanId
|
|
96
|
+
const parentSpanId = span.context()._parentId
|
|
97
|
+
|
|
98
|
+
// Try current span first, then parent span.
|
|
99
|
+
// This handles cases where pageLoad runs in a child span context
|
|
100
|
+
const req = this.#requestsBySpanId.get(spanId) ?? this.#requestsBySpanId.get(parentSpanId)
|
|
93
101
|
|
|
94
102
|
// safeguard against missing req in complicated timeout scenarios
|
|
95
103
|
if (!req) return
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
4
|
-
const OpenAiTracingPlugin = require('./tracing')
|
|
5
4
|
const OpenAiLLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/openai')
|
|
5
|
+
const OpenAiTracingPlugin = require('./tracing')
|
|
6
6
|
|
|
7
7
|
class OpenAiPlugin extends CompositePlugin {
|
|
8
8
|
static id = 'openai'
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Record<string, unknown>} JsonObject
|
|
5
|
+
*
|
|
6
|
+
* @typedef {{ function: { arguments: string } }} ToolCall
|
|
7
|
+
* @typedef {{ content?: string, tool_calls?: ToolCall[] }} ChatDelta
|
|
8
|
+
*
|
|
9
|
+
* @typedef {{
|
|
10
|
+
* index: number,
|
|
11
|
+
* finish_reason?: string | null,
|
|
12
|
+
* text?: string,
|
|
13
|
+
* delta?: ChatDelta
|
|
14
|
+
* }} StreamChoice
|
|
15
|
+
*
|
|
16
|
+
* @typedef {JsonObject & { choices: StreamChoice[], usage?: unknown }} StreamChunk
|
|
17
|
+
* @typedef {JsonObject & { choices: Array<StreamChoice | undefined>, usage?: unknown }} StreamResponseBody
|
|
18
|
+
*
|
|
19
|
+
* @typedef {JsonObject & { status?: string }} ResponsesApiResponse
|
|
20
|
+
* @typedef {JsonObject & { response?: ResponsesApiResponse }} ResponsesApiChunk
|
|
21
|
+
*/
|
|
22
|
+
|
|
3
23
|
/**
|
|
4
24
|
* Combines legacy OpenAI streamed chunks into a single object.
|
|
5
25
|
* These legacy chunks are returned as buffers instead of individual objects.
|
|
6
26
|
* @param {readonly Uint8Array[]} chunks
|
|
7
|
-
* @returns {
|
|
27
|
+
* @returns {JsonObject[]}
|
|
8
28
|
*/
|
|
9
29
|
function convertBuffersToObjects (chunks) {
|
|
10
30
|
return Buffer
|
|
@@ -21,10 +41,10 @@ function convertBuffersToObjects (chunks) {
|
|
|
21
41
|
* The shared logic will add a new choice index entry if it doesn't exist, and otherwise
|
|
22
42
|
* hand off to a onChoice handler to add that choice to the previously stored choice.
|
|
23
43
|
*
|
|
24
|
-
* @param {
|
|
44
|
+
* @param {StreamChunk[]} chunks
|
|
25
45
|
* @param {number} n
|
|
26
|
-
* @param {
|
|
27
|
-
* @returns {
|
|
46
|
+
* @param {(newChoice: StreamChoice, existingChoice: StreamChoice) => void} onChoice
|
|
47
|
+
* @returns {StreamResponseBody}
|
|
28
48
|
*/
|
|
29
49
|
function constructResponseFromStreamedChunks (chunks, n, onChoice) {
|
|
30
50
|
const body = { ...chunks[0], choices: Array.from({ length: n }) }
|
|
@@ -54,9 +74,9 @@ function constructResponseFromStreamedChunks (chunks, n, onChoice) {
|
|
|
54
74
|
/**
|
|
55
75
|
* Constructs the entire response from a stream of OpenAI completion chunks,
|
|
56
76
|
* mainly combining the text choices of each chunk into a single string per choice.
|
|
57
|
-
* @param {
|
|
77
|
+
* @param {StreamChunk[]} chunks
|
|
58
78
|
* @param {number} n the number of choices to expect in the response
|
|
59
|
-
* @returns {
|
|
79
|
+
* @returns {StreamResponseBody}
|
|
60
80
|
*/
|
|
61
81
|
function constructCompletionResponseFromStreamedChunks (chunks, n) {
|
|
62
82
|
return constructResponseFromStreamedChunks(chunks, n, (choice, oldChoice) => {
|
|
@@ -74,9 +94,9 @@ function constructCompletionResponseFromStreamedChunks (chunks, n) {
|
|
|
74
94
|
/**
|
|
75
95
|
* Constructs the entire response from a stream of OpenAI chat completion chunks,
|
|
76
96
|
* mainly combining the text choices of each chunk into a single string per choice.
|
|
77
|
-
* @param {
|
|
97
|
+
* @param {StreamChunk[]} chunks
|
|
78
98
|
* @param {number} n the number of choices to expect in the response
|
|
79
|
-
* @returns {
|
|
99
|
+
* @returns {StreamResponseBody}
|
|
80
100
|
*/
|
|
81
101
|
function constructChatCompletionResponseFromStreamedChunks (chunks, n) {
|
|
82
102
|
return constructResponseFromStreamedChunks(chunks, n, (choice, oldChoice) => {
|
|
@@ -110,8 +130,8 @@ function constructChatCompletionResponseFromStreamedChunks (chunks, n) {
|
|
|
110
130
|
/**
|
|
111
131
|
* Constructs the entire response from a stream of OpenAI responses chunks.
|
|
112
132
|
* The responses API uses event-based streaming with delta chunks.
|
|
113
|
-
* @param {
|
|
114
|
-
* @returns {
|
|
133
|
+
* @param {ResponsesApiChunk[]} chunks
|
|
134
|
+
* @returns {ResponsesApiResponse|undefined}
|
|
115
135
|
*/
|
|
116
136
|
function constructResponseResponseFromStreamedChunks (chunks) {
|
|
117
137
|
// The responses API streams events with different types:
|
|
@@ -4,10 +4,10 @@ const path = require('path')
|
|
|
4
4
|
|
|
5
5
|
const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
|
|
6
6
|
const { storage } = require('../../datadog-core')
|
|
7
|
-
const services = require('./services')
|
|
8
7
|
const Sampler = require('../../dd-trace/src/sampler')
|
|
9
8
|
const { MEASURED } = require('../../../ext/tags')
|
|
10
9
|
|
|
10
|
+
const { DD_MAJOR } = require('../../../version')
|
|
11
11
|
const {
|
|
12
12
|
convertBuffersToObjects,
|
|
13
13
|
constructCompletionResponseFromStreamedChunks,
|
|
@@ -15,7 +15,7 @@ const {
|
|
|
15
15
|
constructResponseResponseFromStreamedChunks
|
|
16
16
|
} = require('./stream-helpers')
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const services = require('./services')
|
|
19
19
|
|
|
20
20
|
class OpenAiTracingPlugin extends TracingPlugin {
|
|
21
21
|
static id = 'openai'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
3
4
|
const ProducerPlugin = require('./producer')
|
|
4
5
|
const ConsumerPlugin = require('./consumer')
|
|
5
|
-
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
6
6
|
|
|
7
7
|
class RheaPlugin extends CompositePlugin {
|
|
8
8
|
static id = 'rhea'
|