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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const shimmer = require('../../datadog-shimmer')
|
|
3
4
|
const {
|
|
4
5
|
channel,
|
|
5
6
|
addHook
|
|
6
7
|
} = require('./helpers/instrument')
|
|
7
|
-
const shimmer = require('../../datadog-shimmer')
|
|
8
8
|
|
|
9
9
|
const requestStartCh = channel('apm:google-cloud-pubsub:request:start')
|
|
10
10
|
const requestFinishCh = channel('apm:google-cloud-pubsub:request:finish')
|
|
@@ -14,6 +14,21 @@ const receiveStartCh = channel('apm:google-cloud-pubsub:receive:start')
|
|
|
14
14
|
const receiveFinishCh = channel('apm:google-cloud-pubsub:receive:finish')
|
|
15
15
|
const receiveErrorCh = channel('apm:google-cloud-pubsub:receive:error')
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Message-level channels for trace context injection and async context propagation:
|
|
19
|
+
* - messagePublishCh: Inject trace context when Topic.publish() is called
|
|
20
|
+
* - messageAckStoreCh: Store async context when message.ack() is called (PULL)
|
|
21
|
+
* - messageAckRetrieveCh: Retrieve stored context when acknowledge() API is called (PULL)
|
|
22
|
+
* - messageStoreCh: Propagate context when Subscription emits 'message' event (PULL)
|
|
23
|
+
*/
|
|
24
|
+
const messagePublishCh = channel('apm:google-cloud-pubsub:message:publish')
|
|
25
|
+
const messageAckStoreCh = channel('apm:google-cloud-pubsub:message:ack-store')
|
|
26
|
+
const messageAckRetrieveCh = channel('apm:google-cloud-pubsub:message:ack-retrieve')
|
|
27
|
+
const messageStoreCh = channel('apm:google-cloud-pubsub:message:store')
|
|
28
|
+
|
|
29
|
+
// WeakMap for passing context between LeaseManager._dispense and LeaseManager.remove
|
|
30
|
+
const messageContexts = new WeakMap()
|
|
31
|
+
|
|
17
32
|
const publisherMethods = [
|
|
18
33
|
'createTopic',
|
|
19
34
|
'updateTopic',
|
|
@@ -65,6 +80,21 @@ function wrapMethod (method) {
|
|
|
65
80
|
if (!requestStartCh.hasSubscribers) return method.apply(this, arguments)
|
|
66
81
|
|
|
67
82
|
const ctx = { request, api, projectId: this.auth._cachedProjectId }
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* For acknowledge/modifyAckDeadline: retrieve stored context from consumer plugin.
|
|
86
|
+
* These APIs only have ackIds (no Message objects), so async context is lost.
|
|
87
|
+
* Plugin sets ctx.storedContext, which client.js uses to link the acknowledge span.
|
|
88
|
+
*/
|
|
89
|
+
const isAckOperation = api === 'acknowledge' || api === 'modifyAckDeadline'
|
|
90
|
+
if (isAckOperation && request?.ackIds?.length > 0) {
|
|
91
|
+
messageAckRetrieveCh.publish({
|
|
92
|
+
ackIds: request.ackIds,
|
|
93
|
+
api,
|
|
94
|
+
ctx
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
68
98
|
return requestStartCh.runStores(ctx, () => {
|
|
69
99
|
const cb = arguments[arguments.length - 1]
|
|
70
100
|
|
|
@@ -74,12 +104,11 @@ function wrapMethod (method) {
|
|
|
74
104
|
ctx.error = error
|
|
75
105
|
requestErrorCh.publish(ctx)
|
|
76
106
|
}
|
|
77
|
-
|
|
78
107
|
return requestFinishCh.runStores(ctx, cb, this, ...arguments)
|
|
79
108
|
})
|
|
80
|
-
|
|
81
109
|
return method.apply(this, arguments)
|
|
82
110
|
}
|
|
111
|
+
|
|
83
112
|
return method.apply(this, arguments)
|
|
84
113
|
.then(
|
|
85
114
|
response => {
|
|
@@ -108,12 +137,16 @@ function massWrap (obj, methods, wrapper) {
|
|
|
108
137
|
addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'] }, (obj) => {
|
|
109
138
|
const Subscription = obj.Subscription
|
|
110
139
|
|
|
140
|
+
/**
|
|
141
|
+
* PULL: Intercept 'message' events and propagate async context via runStores.
|
|
142
|
+
* This ensures the consumer plugin creates spans in the correct context.
|
|
143
|
+
*/
|
|
111
144
|
shimmer.wrap(Subscription.prototype, 'emit', emit => function (eventName, message) {
|
|
112
145
|
if (eventName !== 'message' || !message) return emit.apply(this, arguments)
|
|
113
146
|
|
|
114
|
-
const ctx = {}
|
|
147
|
+
const ctx = { message }
|
|
115
148
|
try {
|
|
116
|
-
return
|
|
149
|
+
return messageStoreCh.runStores(ctx, emit, this, ...arguments)
|
|
117
150
|
} catch (err) {
|
|
118
151
|
ctx.error = err
|
|
119
152
|
receiveErrorCh.publish(ctx)
|
|
@@ -124,26 +157,70 @@ addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'] }, (obj) => {
|
|
|
124
157
|
return obj
|
|
125
158
|
})
|
|
126
159
|
|
|
160
|
+
addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'], file: 'build/src/subscriber.js' }, (obj) => {
|
|
161
|
+
const Message = obj.Message
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* PULL: Capture async context when message.ack() is called.
|
|
165
|
+
* This is our last chance before context is lost. The acknowledge() API call happens
|
|
166
|
+
* later (often batched), and we'll retrieve this stored context to link spans.
|
|
167
|
+
* Flow: message.ack() -> store context -> acknowledge() API -> retrieve context
|
|
168
|
+
*/
|
|
169
|
+
if (Message?.prototype?.ack) {
|
|
170
|
+
shimmer.wrap(Message.prototype, 'ack', originalAck => function () {
|
|
171
|
+
if (this.ackId) {
|
|
172
|
+
const ctx = {
|
|
173
|
+
message: this,
|
|
174
|
+
ackId: this.ackId
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return messageAckStoreCh.runStores(ctx, originalAck, this, ...arguments)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return originalAck.apply(this, arguments)
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return obj
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* PULL: Hook LeaseManager to track message lifecycle (dispense/remove/clear).
|
|
189
|
+
* _dispense: Message given to handler -> create span
|
|
190
|
+
* remove: Message removed from lease (ack/nack/timeout) -> finish span
|
|
191
|
+
* clear: Subscription closed -> finish all remaining spans
|
|
192
|
+
*/
|
|
127
193
|
addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'], file: 'build/src/lease-manager.js' }, (obj) => {
|
|
128
194
|
const LeaseManager = obj.LeaseManager
|
|
129
|
-
|
|
195
|
+
if (!LeaseManager) {
|
|
196
|
+
return obj
|
|
197
|
+
}
|
|
130
198
|
|
|
131
199
|
shimmer.wrap(LeaseManager.prototype, '_dispense', dispense => function (message) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return dispense.apply(this, arguments)
|
|
200
|
+
const ctx = { message }
|
|
201
|
+
messageContexts.set(message, ctx)
|
|
202
|
+
|
|
203
|
+
return receiveStartCh.runStores(ctx, dispense, this, ...arguments)
|
|
137
204
|
})
|
|
138
205
|
|
|
139
206
|
shimmer.wrap(LeaseManager.prototype, 'remove', remove => function (message) {
|
|
140
|
-
|
|
207
|
+
const ctx = messageContexts.get(message)
|
|
208
|
+
if (ctx) {
|
|
209
|
+
messageContexts.delete(message)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return receiveFinishCh.runStores(ctx || { message }, remove, this, ...arguments)
|
|
141
213
|
})
|
|
142
214
|
|
|
143
215
|
shimmer.wrap(LeaseManager.prototype, 'clear', clear => function () {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
216
|
+
if (this._messages) {
|
|
217
|
+
for (const message of this._messages.values()) {
|
|
218
|
+
const ctx = messageContexts.get(message)
|
|
219
|
+
if (ctx) {
|
|
220
|
+
receiveFinishCh.publish(ctx)
|
|
221
|
+
messageContexts.delete(message)
|
|
222
|
+
}
|
|
223
|
+
}
|
|
147
224
|
}
|
|
148
225
|
return clear.apply(this, arguments)
|
|
149
226
|
})
|
|
@@ -151,6 +228,51 @@ addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'], file: 'build/src/le
|
|
|
151
228
|
return obj
|
|
152
229
|
})
|
|
153
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Inject trace context into individual messages via Topic.publish()/publishMessage().
|
|
233
|
+
* Flow: User calls topic.publish() -> inject context (here) -> SDK batches messages ->
|
|
234
|
+
* publish() API called -> producer plugin creates batch span + metadata
|
|
235
|
+
*/
|
|
236
|
+
addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'] }, (obj) => {
|
|
237
|
+
if (!obj.Topic?.prototype) return obj
|
|
238
|
+
|
|
239
|
+
if (typeof obj.Topic.prototype.publishMessage === 'function') {
|
|
240
|
+
shimmer.wrap(obj.Topic.prototype, 'publishMessage', publishMessage => {
|
|
241
|
+
return function (data, attributesOrCallback, callback) {
|
|
242
|
+
if (data && typeof data === 'object') {
|
|
243
|
+
if (!data.attributes) data.attributes = {}
|
|
244
|
+
messagePublishCh.publish({
|
|
245
|
+
attributes: data.attributes,
|
|
246
|
+
pubsub: this.pubsub,
|
|
247
|
+
topicName: this.name
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
return publishMessage.apply(this, arguments)
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (typeof obj.Topic.prototype.publish === 'function') {
|
|
256
|
+
shimmer.wrap(obj.Topic.prototype, 'publish', publish => function (buffer, attributesOrCallback, callback) {
|
|
257
|
+
if (typeof attributesOrCallback === 'function' || !attributesOrCallback) {
|
|
258
|
+
arguments[1] = {}
|
|
259
|
+
arguments[2] = attributesOrCallback
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
messagePublishCh.publish({
|
|
263
|
+
attributes: arguments[1],
|
|
264
|
+
pubsub: this.pubsub,
|
|
265
|
+
topicName: this.name,
|
|
266
|
+
buffer
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
return publish.apply(this, arguments)
|
|
270
|
+
})
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return obj
|
|
274
|
+
})
|
|
275
|
+
|
|
154
276
|
addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'] }, (obj) => {
|
|
155
277
|
const { PublisherClient, SchemaServiceClient, SubscriberClient } = obj.v1
|
|
156
278
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { addHook } = require('./helpers/instrument')
|
|
4
|
-
const shimmer = require('../../datadog-shimmer')
|
|
5
|
-
|
|
6
3
|
const vertexaiTracingChannel = require('dc-polyfill').tracingChannel('apm:vertexai:request')
|
|
4
|
+
const shimmer = require('../../datadog-shimmer')
|
|
5
|
+
const { addHook } = require('./helpers/instrument')
|
|
7
6
|
|
|
8
7
|
function wrapGenerate (generate) {
|
|
9
8
|
return function (request) {
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { channel, tracingChannel } = require('dc-polyfill')
|
|
4
|
+
|
|
5
|
+
const shimmer = require('../../datadog-shimmer')
|
|
6
|
+
const { addHook } = require('./helpers/instrument')
|
|
7
|
+
|
|
8
|
+
const genaiTracingChannel = tracingChannel('apm:google:genai:request')
|
|
9
|
+
const onStreamedChunkCh = channel('apm:google:genai:request:chunk')
|
|
10
|
+
|
|
11
|
+
function wrapGenerateContent (method) {
|
|
12
|
+
return function wrappedGenerateContent (original) {
|
|
13
|
+
return function (...args) {
|
|
14
|
+
if (!genaiTracingChannel.start.hasSubscribers) {
|
|
15
|
+
return original.apply(this, args)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const normalizedName = normalizeMethodName(method)
|
|
19
|
+
|
|
20
|
+
const ctx = { args, methodName: normalizedName }
|
|
21
|
+
|
|
22
|
+
return genaiTracingChannel.start.runStores(ctx, () => {
|
|
23
|
+
let result
|
|
24
|
+
try {
|
|
25
|
+
result = original.apply(this, arguments)
|
|
26
|
+
} catch (error) {
|
|
27
|
+
finish(ctx, null, error)
|
|
28
|
+
throw error
|
|
29
|
+
} finally {
|
|
30
|
+
genaiTracingChannel.end.publish(ctx)
|
|
31
|
+
}
|
|
32
|
+
return result.then(response => {
|
|
33
|
+
if (response[Symbol.asyncIterator]) {
|
|
34
|
+
shimmer.wrap(response, Symbol.asyncIterator, iterator => wrapStreamIterator(iterator, ctx))
|
|
35
|
+
} else {
|
|
36
|
+
finish(ctx, response, null)
|
|
37
|
+
}
|
|
38
|
+
return response
|
|
39
|
+
}).catch(error => {
|
|
40
|
+
finish(ctx, null, error)
|
|
41
|
+
throw error
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function wrapStreamIterator (iterator, ctx) {
|
|
49
|
+
return function () {
|
|
50
|
+
const itr = iterator.apply(this, arguments)
|
|
51
|
+
shimmer.wrap(itr, 'next', next => function () {
|
|
52
|
+
return next.apply(this, arguments)
|
|
53
|
+
.then(res => {
|
|
54
|
+
const { done, value: chunk } = res
|
|
55
|
+
onStreamedChunkCh.publish({ ctx, chunk, done })
|
|
56
|
+
|
|
57
|
+
if (done) {
|
|
58
|
+
finish(ctx)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return res
|
|
62
|
+
})
|
|
63
|
+
.catch(error => {
|
|
64
|
+
finish(ctx, null, error)
|
|
65
|
+
throw error
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return itr
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function finish (ctx, result, error) {
|
|
73
|
+
if (error) {
|
|
74
|
+
ctx.error = error
|
|
75
|
+
genaiTracingChannel.error.publish(ctx)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// streamed responses are handled and set separately
|
|
79
|
+
ctx.result ??= result
|
|
80
|
+
|
|
81
|
+
genaiTracingChannel.asyncEnd.publish(ctx)
|
|
82
|
+
}
|
|
83
|
+
// Hook the main package entry point
|
|
84
|
+
addHook({
|
|
85
|
+
name: '@google/genai',
|
|
86
|
+
versions: ['>=1.19.0']
|
|
87
|
+
}, exports => {
|
|
88
|
+
// Wrap GoogleGenAI to intercept when it creates Models instances
|
|
89
|
+
if (!exports.GoogleGenAI) return exports
|
|
90
|
+
|
|
91
|
+
shimmer.wrap(exports, 'GoogleGenAI', GoogleGenAI => {
|
|
92
|
+
return class extends GoogleGenAI {
|
|
93
|
+
constructor (...args) {
|
|
94
|
+
super(...args)
|
|
95
|
+
|
|
96
|
+
// We are patching the instance instead of the prototype because when it is compiled from
|
|
97
|
+
// typescript, the models property is not available on the prototype.
|
|
98
|
+
if (this.models) {
|
|
99
|
+
if (this.models.generateContent) {
|
|
100
|
+
shimmer.wrap(this.models, 'generateContent', wrapGenerateContent('generateContent'))
|
|
101
|
+
}
|
|
102
|
+
if (this.models.generateContentStream) {
|
|
103
|
+
shimmer.wrap(this.models, 'generateContentStream', wrapGenerateContent('generateContentStream'))
|
|
104
|
+
}
|
|
105
|
+
if (this.models.embedContent) {
|
|
106
|
+
shimmer.wrap(this.models, 'embedContent', wrapGenerateContent('embedContent'))
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
return exports
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
function normalizeMethodName (methodName) {
|
|
116
|
+
// Convert camelCase to snake_case and add Models prefix
|
|
117
|
+
return 'Models.' + methodName
|
|
118
|
+
.replaceAll(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
119
|
+
.toLowerCase()
|
|
120
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const shimmer = require('../../datadog-shimmer')
|
|
3
4
|
const {
|
|
4
5
|
addHook,
|
|
5
6
|
channel
|
|
6
7
|
} = require('./helpers/instrument')
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
const ddGlobal = globalThis[Symbol.for('dd-trace')] ??= {}
|
|
8
10
|
|
|
9
11
|
/** cached objects */
|
|
10
12
|
|
|
@@ -360,3 +362,21 @@ addHook({ name: 'graphql', file: 'validation/validate.js', versions: ['>=0.10']
|
|
|
360
362
|
|
|
361
363
|
return validate
|
|
362
364
|
})
|
|
365
|
+
|
|
366
|
+
addHook({ name: 'graphql', file: 'language/printer.js', versions: ['>=0.10'] }, printer => {
|
|
367
|
+
// HACK: It's possible `graphql` is loaded before `@apollo/gateway` so we
|
|
368
|
+
// can't use a channel as the latter plugin would load after the publish
|
|
369
|
+
// happened. Not sure how to handle this so for now use a global.
|
|
370
|
+
ddGlobal.graphql_printer = printer
|
|
371
|
+
return printer
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
addHook({ name: 'graphql', file: 'language/visitor.js', versions: ['>=0.10'] }, visitor => {
|
|
375
|
+
ddGlobal.graphql_visitor = visitor
|
|
376
|
+
return visitor
|
|
377
|
+
})
|
|
378
|
+
|
|
379
|
+
addHook({ name: 'graphql', file: 'utilities/index.js', versions: ['>=0.10'] }, utilities => {
|
|
380
|
+
ddGlobal.graphql_utilities = utilities
|
|
381
|
+
return utilities
|
|
382
|
+
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const types = require('./types')
|
|
4
3
|
const { addHook, channel } = require('../helpers/instrument')
|
|
5
4
|
const shimmer = require('../../../datadog-shimmer')
|
|
5
|
+
const types = require('./types')
|
|
6
6
|
|
|
7
7
|
const patched = new WeakSet()
|
|
8
8
|
const instances = new WeakMap()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const types = require('./types')
|
|
4
3
|
const { channel, addHook } = require('../helpers/instrument')
|
|
5
4
|
const shimmer = require('../../../datadog-shimmer')
|
|
5
|
+
const types = require('./types')
|
|
6
6
|
|
|
7
7
|
const startChannel = channel('apm:grpc:server:request:start')
|
|
8
8
|
const asyncStartChannel = channel('apm:grpc:server:request:asyncStart')
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const dc = require('dc-polyfill')
|
|
4
4
|
|
|
5
|
+
const log = require('../../../dd-trace/src/log')
|
|
5
6
|
const {
|
|
6
7
|
filename,
|
|
7
8
|
loadChannel,
|
|
@@ -9,7 +10,6 @@ const {
|
|
|
9
10
|
} = require('./register.js')
|
|
10
11
|
const hooks = require('./hooks')
|
|
11
12
|
const instrumentations = require('./instrumentations')
|
|
12
|
-
const log = require('../../../dd-trace/src/log')
|
|
13
13
|
|
|
14
14
|
const CHANNEL = 'dd-trace:bundler:load'
|
|
15
15
|
|
|
@@ -13,6 +13,7 @@ module.exports = {
|
|
|
13
13
|
'@playwright/test': () => require('../playwright'),
|
|
14
14
|
'@elastic/elasticsearch': () => require('../elasticsearch'),
|
|
15
15
|
'@elastic/transport': () => require('../elasticsearch'),
|
|
16
|
+
'@google/genai': () => require('../google-genai'),
|
|
16
17
|
'@google-cloud/pubsub': () => require('../google-cloud-pubsub'),
|
|
17
18
|
'@google-cloud/vertexai': () => require('../google-cloud-vertexai'),
|
|
18
19
|
'@graphql-tools/executor': () => require('../graphql'),
|
|
@@ -28,7 +29,8 @@ module.exports = {
|
|
|
28
29
|
'@node-redis/client': () => require('../redis'),
|
|
29
30
|
'@opensearch-project/opensearch': () => require('../opensearch'),
|
|
30
31
|
'@opentelemetry/sdk-trace-node': () => require('../otel-sdk-trace'),
|
|
31
|
-
'@prisma/client': () => require('../prisma'),
|
|
32
|
+
'@prisma/client': { esmFirst: true, fn: () => require('../prisma') },
|
|
33
|
+
'./runtime/library.js': () => require('../prisma'),
|
|
32
34
|
'@redis/client': () => require('../redis'),
|
|
33
35
|
'@smithy/smithy-client': () => require('../aws-sdk'),
|
|
34
36
|
'@vitest/runner': { esmFirst: true, fn: () => require('../vitest') },
|
|
@@ -40,6 +42,7 @@ module.exports = {
|
|
|
40
42
|
'aws-sdk': () => require('../aws-sdk'),
|
|
41
43
|
bluebird: () => require('../bluebird'),
|
|
42
44
|
'body-parser': () => require('../body-parser'),
|
|
45
|
+
bullmq: () => require('../bullmq'),
|
|
43
46
|
bunyan: () => require('../bunyan'),
|
|
44
47
|
'cassandra-driver': () => require('../cassandra-driver'),
|
|
45
48
|
child_process: () => require('../child_process'),
|
|
@@ -82,6 +85,7 @@ module.exports = {
|
|
|
82
85
|
kafkajs: () => require('../kafkajs'),
|
|
83
86
|
langchain: () => require('../langchain'),
|
|
84
87
|
ldapjs: () => require('../ldapjs'),
|
|
88
|
+
'light-my-request': () => require('../light-my-request'),
|
|
85
89
|
'limitd-client': () => require('../limitd-client'),
|
|
86
90
|
lodash: () => require('../lodash'),
|
|
87
91
|
mariadb: () => require('../mariadb'),
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { AsyncResource } = require('async_hooks')
|
|
3
4
|
const dc = require('dc-polyfill')
|
|
4
5
|
const instrumentations = require('./instrumentations')
|
|
5
|
-
const
|
|
6
|
+
const rewriterInstrumentations = require('./rewriter/instrumentations')
|
|
6
7
|
|
|
7
8
|
const channelMap = {}
|
|
8
9
|
exports.channel = function (name) {
|
|
@@ -22,6 +23,15 @@ exports.tracingChannel = function (name) {
|
|
|
22
23
|
return tc
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
exports.getHooks = function getHooks (names) {
|
|
27
|
+
names = [names].flat()
|
|
28
|
+
|
|
29
|
+
return rewriterInstrumentations
|
|
30
|
+
.map(inst => inst.module)
|
|
31
|
+
.filter(({ name }) => names.includes(name))
|
|
32
|
+
.map(({ name, versionRange, filePath }) => ({ name, versions: [versionRange], file: filePath }))
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
/**
|
|
26
36
|
* @param {object} args
|
|
27
37
|
* @param {string|string[]} args.name module name
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { channel } = require('dc-polyfill')
|
|
4
3
|
const path = require('path')
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const { channel } = require('dc-polyfill')
|
|
5
|
+
const satisfies = require('../../../../vendor/dist/semifies')
|
|
7
6
|
const requirePackageJson = require('../../../dd-trace/src/require-package-json')
|
|
8
7
|
const log = require('../../../dd-trace/src/log')
|
|
9
|
-
const checkRequireCache = require('./check-require-cache')
|
|
10
8
|
const telemetry = require('../../../dd-trace/src/guardrails/telemetry')
|
|
11
9
|
const { isInServerlessEnvironment } = require('../../../dd-trace/src/serverless')
|
|
12
10
|
const { getEnvironmentVariables } = require('../../../dd-trace/src/config-helper')
|
|
11
|
+
const checkRequireCache = require('./check-require-cache')
|
|
12
|
+
const Hook = require('./hook')
|
|
13
|
+
const { isRelativeRequire } = require('./shared-utils')
|
|
14
|
+
const rewriter = require('./rewriter')
|
|
13
15
|
|
|
14
16
|
const envs = getEnvironmentVariables()
|
|
15
17
|
|
|
@@ -48,6 +50,10 @@ if (DD_TRACE_DEBUG && DD_TRACE_DEBUG.toLowerCase() !== 'false') {
|
|
|
48
50
|
const seenCombo = new Set()
|
|
49
51
|
const allInstrumentations = {}
|
|
50
52
|
|
|
53
|
+
for (const inst of disabledInstrumentations) {
|
|
54
|
+
rewriter.disable(inst)
|
|
55
|
+
}
|
|
56
|
+
|
|
51
57
|
// TODO: make this more efficient
|
|
52
58
|
for (const packageName of names) {
|
|
53
59
|
if (disabledInstrumentations.has(packageName)) continue
|
|
@@ -99,6 +105,8 @@ for (const packageName of names) {
|
|
|
99
105
|
hook[HOOK_SYMBOL] ??= new WeakSet()
|
|
100
106
|
let matchesFile = moduleName === fullFilename
|
|
101
107
|
|
|
108
|
+
if (!matchesFile && isRelativeRequire(name)) matchesFile = true
|
|
109
|
+
|
|
102
110
|
if (fullFilePattern) {
|
|
103
111
|
// Some libraries include a hash in their filenames when installed,
|
|
104
112
|
// so our instrumentation has to include a '.*' to match them for more than a single version.
|
|
@@ -214,7 +222,6 @@ function parseHookInstrumentationFileName (packageName) {
|
|
|
214
222
|
hook = hook.fn
|
|
215
223
|
}
|
|
216
224
|
const hookString = hook.toString()
|
|
217
|
-
|
|
218
225
|
const regex = /require\('([^']*)'\)/
|
|
219
226
|
const match = hookString.match(regex)
|
|
220
227
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
let meriyah
|
|
4
|
+
let astring
|
|
5
|
+
let esquery
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
parse: (...args) => {
|
|
9
|
+
meriyah ??= require('../../../../../vendor/dist/meriyah')
|
|
10
|
+
|
|
11
|
+
return meriyah.parse(...args)
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
generate: (...args) => {
|
|
15
|
+
astring ??= require('../../../../../vendor/dist/astring')
|
|
16
|
+
|
|
17
|
+
return astring.generate(...args)
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
traverse: (ast, query, visitor) => {
|
|
21
|
+
esquery ??= require('../../../../../vendor/dist/esquery').default
|
|
22
|
+
|
|
23
|
+
const selector = esquery.parse(query)
|
|
24
|
+
|
|
25
|
+
return esquery.traverse(ast, selector, visitor)
|
|
26
|
+
},
|
|
27
|
+
}
|