dd-trace 5.81.0 → 5.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +78 -79
- package/ci/init.js +6 -6
- package/index.d.ts +159 -3
- package/loader-hook.mjs +8 -3
- package/package.json +64 -66
- package/packages/datadog-core/src/storage.js +7 -7
- package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
- package/packages/datadog-esbuild/index.js +14 -7
- package/packages/datadog-esbuild/src/utils.js +14 -2
- package/packages/datadog-instrumentations/src/aerospike.js +3 -2
- package/packages/datadog-instrumentations/src/ai.js +9 -5
- package/packages/datadog-instrumentations/src/amqp10.js +1 -1
- package/packages/datadog-instrumentations/src/amqplib.js +4 -4
- package/packages/datadog-instrumentations/src/anthropic.js +2 -2
- package/packages/datadog-instrumentations/src/apollo-server-core.js +2 -2
- package/packages/datadog-instrumentations/src/apollo-server.js +1 -1
- package/packages/datadog-instrumentations/src/apollo.js +3 -2
- package/packages/datadog-instrumentations/src/avsc.js +1 -1
- package/packages/datadog-instrumentations/src/aws-sdk.js +1 -1
- package/packages/datadog-instrumentations/src/azure-event-hubs.js +4 -3
- package/packages/datadog-instrumentations/src/azure-functions.js +2 -2
- package/packages/datadog-instrumentations/src/azure-service-bus.js +3 -4
- package/packages/datadog-instrumentations/src/bluebird.js +1 -1
- package/packages/datadog-instrumentations/src/bullmq.js +11 -0
- package/packages/datadog-instrumentations/src/bunyan.js +1 -1
- package/packages/datadog-instrumentations/src/cassandra-driver.js +1 -1
- package/packages/datadog-instrumentations/src/child_process.js +3 -3
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +3 -3
- package/packages/datadog-instrumentations/src/couchbase.js +1 -1
- package/packages/datadog-instrumentations/src/crypto.js +1 -1
- package/packages/datadog-instrumentations/src/cucumber.js +13 -14
- package/packages/datadog-instrumentations/src/cypress.js +1 -1
- package/packages/datadog-instrumentations/src/dns.js +1 -1
- package/packages/datadog-instrumentations/src/elasticsearch.js +1 -1
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +1 -1
- package/packages/datadog-instrumentations/src/express.js +1 -1
- package/packages/datadog-instrumentations/src/fs.js +1 -1
- package/packages/datadog-instrumentations/src/generic-pool.js +1 -1
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +137 -15
- package/packages/datadog-instrumentations/src/google-cloud-vertexai.js +2 -3
- package/packages/datadog-instrumentations/src/google-genai.js +3 -3
- package/packages/datadog-instrumentations/src/graphql.js +2 -2
- package/packages/datadog-instrumentations/src/grpc/client.js +1 -1
- package/packages/datadog-instrumentations/src/grpc/server.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/instrumentations.js +4 -3
- package/packages/datadog-instrumentations/src/helpers/register.js +9 -11
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/bullmq.json +106 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/shared-utils.js +9 -0
- package/packages/datadog-instrumentations/src/hono.js +55 -10
- package/packages/datadog-instrumentations/src/http/client.js +2 -2
- package/packages/datadog-instrumentations/src/ioredis.js +1 -1
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +37 -16
- package/packages/datadog-instrumentations/src/kafkajs.js +3 -3
- package/packages/datadog-instrumentations/src/knex.js +1 -1
- package/packages/datadog-instrumentations/src/koa.js +2 -1
- package/packages/datadog-instrumentations/src/ldapjs.js +1 -1
- package/packages/datadog-instrumentations/src/light-my-request.js +93 -0
- package/packages/datadog-instrumentations/src/limitd-client.js +1 -1
- package/packages/datadog-instrumentations/src/lodash.js +1 -2
- package/packages/datadog-instrumentations/src/mariadb.js +1 -2
- package/packages/datadog-instrumentations/src/memcached.js +1 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/mocha.js +1 -1
- package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
- package/packages/datadog-instrumentations/src/mongodb.js +1 -1
- package/packages/datadog-instrumentations/src/mongoose.js +1 -1
- package/packages/datadog-instrumentations/src/mquery.js +1 -1
- package/packages/datadog-instrumentations/src/mysql.js +2 -2
- package/packages/datadog-instrumentations/src/mysql2.js +3 -3
- package/packages/datadog-instrumentations/src/net.js +14 -6
- package/packages/datadog-instrumentations/src/next.js +1 -1
- package/packages/datadog-instrumentations/src/nyc.js +2 -2
- package/packages/datadog-instrumentations/src/openai.js +2 -2
- package/packages/datadog-instrumentations/src/opensearch.js +1 -1
- package/packages/datadog-instrumentations/src/oracledb.js +1 -1
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +5 -5
- package/packages/datadog-instrumentations/src/pg.js +7 -5
- package/packages/datadog-instrumentations/src/pino.js +1 -1
- package/packages/datadog-instrumentations/src/playwright.js +4 -4
- package/packages/datadog-instrumentations/src/prisma.js +52 -37
- package/packages/datadog-instrumentations/src/process.js +1 -1
- package/packages/datadog-instrumentations/src/promise-js.js +1 -1
- package/packages/datadog-instrumentations/src/promise.js +1 -1
- package/packages/datadog-instrumentations/src/protobufjs.js +1 -1
- package/packages/datadog-instrumentations/src/q.js +1 -1
- package/packages/datadog-instrumentations/src/redis.js +1 -1
- package/packages/datadog-instrumentations/src/rhea.js +1 -1
- package/packages/datadog-instrumentations/src/selenium.js +3 -3
- package/packages/datadog-instrumentations/src/sequelize.js +1 -2
- package/packages/datadog-instrumentations/src/sharedb.js +1 -1
- package/packages/datadog-instrumentations/src/tedious.js +1 -1
- package/packages/datadog-instrumentations/src/undici.js +15 -4
- package/packages/datadog-instrumentations/src/url.js +1 -1
- package/packages/datadog-instrumentations/src/vitest.js +1 -1
- package/packages/datadog-instrumentations/src/vm.js +1 -1
- package/packages/datadog-instrumentations/src/when.js +1 -1
- package/packages/datadog-instrumentations/src/winston.js +1 -1
- package/packages/datadog-instrumentations/src/ws.js +3 -2
- package/packages/datadog-plugin-amqp10/src/index.js +1 -1
- package/packages/datadog-plugin-amqplib/src/index.js +1 -1
- package/packages/datadog-plugin-anthropic/src/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/base.js +4 -4
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +4 -4
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/util.js +3 -3
- package/packages/datadog-plugin-azure-event-hubs/src/index.js +1 -1
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +21 -7
- package/packages/datadog-plugin-azure-service-bus/src/index.js +1 -1
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +6 -2
- package/packages/datadog-plugin-bullmq/src/consumer.js +60 -0
- package/packages/datadog-plugin-bullmq/src/index.js +18 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +178 -0
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +1 -1
- package/packages/datadog-plugin-cucumber/src/index.js +2 -2
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +2 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +1 -1
- package/packages/datadog-plugin-dd-trace-api/src/index.js +2 -2
- package/packages/datadog-plugin-express/src/code_origin.js +21 -15
- package/packages/datadog-plugin-express/src/index.js +1 -1
- package/packages/datadog-plugin-fastify/src/code_origin.js +17 -4
- package/packages/datadog-plugin-fastify/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +13 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +171 -12
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +160 -13
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +217 -0
- package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +1 -1
- package/packages/datadog-plugin-google-genai/src/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
- package/packages/datadog-plugin-grpc/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/client.js +2 -1
- package/packages/datadog-plugin-http/src/index.js +25 -5
- package/packages/datadog-plugin-http2/src/client.js +2 -2
- package/packages/datadog-plugin-http2/src/index.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +2 -2
- package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
- package/packages/datadog-plugin-langchain/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +2 -2
- package/packages/datadog-plugin-moleculer/src/index.js +1 -1
- package/packages/datadog-plugin-mongodb-core/src/index.js +8 -4
- package/packages/datadog-plugin-openai/src/index.js +1 -1
- package/packages/datadog-plugin-openai/src/stream-helpers.js +30 -10
- package/packages/datadog-plugin-openai/src/tracing.js +2 -2
- package/packages/datadog-plugin-playwright/src/index.js +3 -3
- package/packages/datadog-plugin-rhea/src/index.js +1 -1
- package/packages/datadog-plugin-undici/src/index.js +305 -2
- package/packages/datadog-plugin-vitest/src/index.js +5 -5
- package/packages/datadog-plugin-ws/src/close.js +56 -3
- package/packages/datadog-plugin-ws/src/index.js +4 -0
- package/packages/datadog-plugin-ws/src/producer.js +39 -4
- package/packages/datadog-plugin-ws/src/receiver.js +39 -3
- package/packages/datadog-plugin-ws/src/server.js +13 -1
- package/packages/datadog-plugin-ws/src/util.js +107 -0
- package/packages/datadog-shimmer/src/shimmer.js +2 -2
- package/packages/dd-trace/index.js +19 -0
- package/packages/dd-trace/src/aiguard/sdk.js +3 -3
- package/packages/dd-trace/src/appsec/graphql.js +2 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/code-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/command-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/ldap-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +3 -3
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/untrusted-deserialization-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/unvalidated-redirect-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-cipher-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-hash-analyzer.js +3 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-randomness-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
- package/packages/dd-trace/src/appsec/iast/index.js +5 -5
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +1 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +11 -15
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
- package/packages/dd-trace/src/appsec/index.js +8 -8
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +1 -1
- package/packages/dd-trace/src/appsec/rasp/index.js +3 -5
- package/packages/dd-trace/src/appsec/rasp/lfi.js +1 -1
- package/packages/dd-trace/src/appsec/rc-products.js +10 -0
- package/packages/dd-trace/src/appsec/recommended.json +230 -3
- package/packages/dd-trace/src/appsec/remote_config.js +177 -0
- package/packages/dd-trace/src/appsec/reporter.js +3 -3
- package/packages/dd-trace/src/appsec/rule_manager.js +37 -20
- package/packages/dd-trace/src/appsec/sdk/index.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +2 -2
- package/packages/dd-trace/src/appsec/user_tracking.js +2 -2
- package/packages/dd-trace/src/appsec/waf/index.js +17 -3
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +11 -0
- package/packages/dd-trace/src/azure_metadata.js +15 -4
- package/packages/dd-trace/src/baggage.js +36 -11
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +5 -1
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +6 -0
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +4 -3
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -3
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +5 -5
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +1 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -2
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -4
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +4 -4
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +2 -2
- package/packages/dd-trace/src/{config_defaults.js → config/defaults.js} +5 -4
- package/packages/dd-trace/src/{config-helper.js → config/helper.js} +88 -15
- package/packages/dd-trace/src/{config.js → config/index.js} +115 -67
- package/packages/dd-trace/src/config/remote_config.js +202 -0
- package/packages/dd-trace/src/{config_stable.js → config/stable.js} +20 -32
- package/packages/dd-trace/src/{supported-configurations.json → config/supported-configurations.json} +5 -0
- package/packages/dd-trace/src/constants.js +5 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +11 -2
- package/packages/dd-trace/src/datastreams/checkpointer.js +2 -2
- package/packages/dd-trace/src/datastreams/index.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +7 -7
- package/packages/dd-trace/src/datastreams/processor.js +3 -3
- package/packages/dd-trace/src/datastreams/writer.js +3 -3
- package/packages/dd-trace/src/debugger/config.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/config.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/index.js +7 -2
- package/packages/dd-trace/src/debugger/devtools_client/send.js +6 -6
- package/packages/dd-trace/src/debugger/devtools_client/session.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +5 -5
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/constants.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/state.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/status.js +2 -2
- package/packages/dd-trace/src/debugger/index.js +84 -16
- package/packages/dd-trace/src/dogstatsd.js +5 -4
- package/packages/dd-trace/src/encode/0.4.js +3 -3
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +2 -2
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
- package/packages/dd-trace/src/encode/span-stats.js +6 -1
- package/packages/dd-trace/src/exporter.js +2 -2
- package/packages/dd-trace/src/exporters/agent/index.js +2 -4
- package/packages/dd-trace/src/exporters/agent/writer.js +9 -14
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -2
- package/packages/dd-trace/src/exporters/common/docker.js +2 -2
- package/packages/dd-trace/src/exporters/common/request.js +3 -3
- package/packages/dd-trace/src/exporters/common/util.js +2 -2
- package/packages/dd-trace/src/exporters/common/writer.js +1 -1
- package/packages/dd-trace/src/exporters/span-stats/index.js +1 -1
- package/packages/dd-trace/src/external-logger/src/index.js +1 -2
- package/packages/dd-trace/src/flare/index.js +2 -2
- package/packages/dd-trace/src/guardrails/index.js +6 -3
- package/packages/dd-trace/src/guardrails/telemetry.js +1 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/index.js +4 -4
- package/packages/dd-trace/src/lambda/handler.js +5 -5
- package/packages/dd-trace/src/lambda/index.js +2 -2
- package/packages/dd-trace/src/lambda/runtime/patch.js +6 -6
- package/packages/dd-trace/src/lambda/runtime/ritm.js +3 -3
- package/packages/dd-trace/src/llmobs/constants/tags.js +14 -1
- package/packages/dd-trace/src/llmobs/index.js +10 -11
- package/packages/dd-trace/src/llmobs/noop.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +38 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +30 -9
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +3 -3
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +2 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/llm.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +16 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +19 -5
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +22 -10
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +46 -26
- package/packages/dd-trace/src/llmobs/span_processor.js +26 -20
- package/packages/dd-trace/src/llmobs/tagger.js +175 -1
- package/packages/dd-trace/src/llmobs/telemetry.js +3 -4
- package/packages/dd-trace/src/llmobs/writers/base.js +117 -38
- package/packages/dd-trace/src/llmobs/writers/spans.js +5 -5
- package/packages/dd-trace/src/log/index.js +5 -5
- package/packages/dd-trace/src/noop/proxy.js +5 -5
- package/packages/dd-trace/src/noop/span.js +1 -1
- package/packages/dd-trace/src/openfeature/index.js +2 -2
- package/packages/dd-trace/src/openfeature/noop.js +14 -14
- package/packages/dd-trace/src/openfeature/remote_config.js +31 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +12 -13
- package/packages/dd-trace/src/openfeature/writers/exposures.js +9 -9
- package/packages/dd-trace/src/opentelemetry/context_manager.js +2 -2
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +1 -1
- package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +4 -4
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +9 -8
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +3 -3
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +2 -2
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +4 -4
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +36 -11
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +11 -10
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +1 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +51 -9
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +68 -28
- package/packages/dd-trace/src/opentracing/span.js +7 -7
- package/packages/dd-trace/src/opentracing/tracer.js +5 -5
- package/packages/dd-trace/src/payload-tagging/index.js +6 -2
- package/packages/dd-trace/src/plugin_manager.js +8 -6
- package/packages/dd-trace/src/plugins/apollo.js +1 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +27 -27
- package/packages/dd-trace/src/plugins/database.js +1 -1
- package/packages/dd-trace/src/plugins/index.js +5 -1
- package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
- package/packages/dd-trace/src/plugins/outbound.js +1 -1
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +5 -8
- package/packages/dd-trace/src/plugins/util/git-cache.js +3 -3
- package/packages/dd-trace/src/plugins/util/git.js +8 -8
- package/packages/dd-trace/src/plugins/util/stacktrace.js +1 -1
- package/packages/dd-trace/src/plugins/util/test.js +25 -25
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +41 -43
- package/packages/dd-trace/src/plugins/util/web.js +8 -5
- package/packages/dd-trace/src/priority_sampler.js +15 -16
- package/packages/dd-trace/src/process-tags/index.js +31 -29
- package/packages/dd-trace/src/profiler.js +4 -39
- package/packages/dd-trace/src/profiling/config.js +104 -50
- package/packages/dd-trace/src/profiling/exporter_cli.js +8 -8
- package/packages/dd-trace/src/profiling/exporters/agent.js +6 -6
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +9 -2
- package/packages/dd-trace/src/profiling/index.js +1 -1
- package/packages/dd-trace/src/profiling/libuv-size.js +1 -1
- package/packages/dd-trace/src/profiling/profiler.js +61 -7
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +2 -2
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/proxy.js +43 -20
- package/packages/dd-trace/src/remote_config/capabilities.js +3 -0
- package/packages/dd-trace/src/remote_config/index.js +541 -137
- package/packages/dd-trace/src/require-package-json.js +1 -1
- package/packages/dd-trace/src/ritm.js +58 -31
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +3 -3
- package/packages/dd-trace/src/serverless.js +17 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +8 -0
- package/packages/dd-trace/src/span_format.js +1 -1
- package/packages/dd-trace/src/span_processor.js +4 -4
- package/packages/dd-trace/src/span_stats.js +6 -4
- package/packages/dd-trace/src/standalone/index.js +1 -1
- package/packages/dd-trace/src/startup-log.js +7 -16
- package/packages/dd-trace/src/telemetry/dependencies.js +3 -3
- package/packages/dd-trace/src/telemetry/endpoints.js +75 -13
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/send-data.js +103 -4
- package/packages/dd-trace/src/telemetry/telemetry.js +238 -114
- package/packages/dd-trace/src/tracer.js +3 -3
- package/packages/dd-trace/src/tracer_metadata.js +19 -15
- package/packages/dd-trace/src/remote_config/manager.js +0 -368
- /package/packages/dd-trace/src/{git_properties.js → config/git_properties.js} +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { URL, format } = require('node:url')
|
|
3
4
|
const request = require('../../exporters/common/request')
|
|
4
5
|
const { safeJSONStringify } = require('../../exporters/common/util')
|
|
5
|
-
const { URL, format } = require('node:url')
|
|
6
6
|
|
|
7
7
|
const log = require('../../log')
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @typedef {
|
|
10
|
+
* @typedef {object} BaseFFEWriterOptions
|
|
11
11
|
* @property {number} [interval] - Flush interval in milliseconds
|
|
12
12
|
* @property {number} [timeout] - Request timeout in milliseconds
|
|
13
|
-
* @property {
|
|
13
|
+
* @property {object} config - Tracer configuration object
|
|
14
14
|
* @property {string} endpoint - API endpoint path
|
|
15
15
|
* @property {URL} [agentUrl] - Base URL for the agent
|
|
16
16
|
* @property {number} [payloadSizeLimit] - Maximum payload size in bytes
|
|
17
17
|
* @property {number} [eventSizeLimit] - Maximum individual event size in bytes
|
|
18
|
-
* @property {
|
|
18
|
+
* @property {object} [headers] - Additional HTTP headers
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -23,6 +23,7 @@ const log = require('../../log')
|
|
|
23
23
|
* @class BaseFFEWriter
|
|
24
24
|
*/
|
|
25
25
|
class BaseFFEWriter {
|
|
26
|
+
#destroyer
|
|
26
27
|
/**
|
|
27
28
|
* @param {BaseFFEWriterOptions} options - Writer configuration options
|
|
28
29
|
*/
|
|
@@ -56,18 +57,16 @@ class BaseFFEWriter {
|
|
|
56
57
|
this.flush()
|
|
57
58
|
}, this._interval).unref()
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
process.once('beforeExit', this._beforeExitHandler)
|
|
60
|
+
const destroyer = this.destroy.bind(this)
|
|
61
|
+
globalThis[Symbol.for('dd-trace')].beforeExitHandlers.add(destroyer)
|
|
63
62
|
|
|
64
|
-
this
|
|
63
|
+
this.#destroyer = destroyer
|
|
65
64
|
this._droppedEvents = 0
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
/**
|
|
69
68
|
* Appends an event array to the buffer
|
|
70
|
-
* @param {Array|
|
|
69
|
+
* @param {Array | object} events - Event object(s) to append to buffer
|
|
71
70
|
*/
|
|
72
71
|
append (events) {
|
|
73
72
|
const eventArray = Array.isArray(events) ? events : [events]
|
|
@@ -141,12 +140,12 @@ class BaseFFEWriter {
|
|
|
141
140
|
* Cleans up resources and flushes remaining events
|
|
142
141
|
*/
|
|
143
142
|
destroy () {
|
|
144
|
-
if (
|
|
143
|
+
if (this.#destroyer) {
|
|
145
144
|
log.debug(() => `Stopping ${this.constructor.name}`)
|
|
146
145
|
clearInterval(this._periodic)
|
|
147
|
-
process.removeListener('beforeExit', this._beforeExitHandler)
|
|
148
146
|
this.flush()
|
|
149
|
-
this
|
|
147
|
+
globalThis[Symbol.for('dd-trace')].beforeExitHandlers.delete(this.#destroyer)
|
|
148
|
+
this.#destroyer = undefined
|
|
150
149
|
|
|
151
150
|
if (this._droppedEvents > 0) {
|
|
152
151
|
log.warn(`${this.constructor.name} dropped ${this._droppedEvents} events due to buffer overflow`)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const BaseFFEWriter = require('./base')
|
|
4
3
|
const {
|
|
5
4
|
EXPOSURES_ENDPOINT,
|
|
6
5
|
EVP_PROXY_AGENT_BASE_PATH,
|
|
@@ -9,31 +8,32 @@ const {
|
|
|
9
8
|
EVP_PAYLOAD_SIZE_LIMIT,
|
|
10
9
|
EVP_EVENT_SIZE_LIMIT
|
|
11
10
|
} = require('../constants/constants')
|
|
11
|
+
const BaseFFEWriter = require('./base')
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* @typedef {
|
|
14
|
+
* @typedef {object} ExposureEvent
|
|
15
15
|
* @property {number} timestamp - Unix timestamp in milliseconds
|
|
16
|
-
* @property {
|
|
16
|
+
* @property {object} allocation - Allocation information
|
|
17
17
|
* @property {string} allocation.key - Allocation key
|
|
18
|
-
* @property {
|
|
18
|
+
* @property {object} flag - Flag information
|
|
19
19
|
* @property {string} flag.key - Flag key
|
|
20
|
-
* @property {
|
|
20
|
+
* @property {object} variant - Variant information
|
|
21
21
|
* @property {string} variant.key - Variant key
|
|
22
|
-
* @property {
|
|
22
|
+
* @property {object} subject - Subject (user/entity) information
|
|
23
23
|
* @property {string} subject.id - Subject identifier
|
|
24
24
|
* @property {string} [subject.type] - Subject type
|
|
25
|
-
* @property {
|
|
25
|
+
* @property {object} [subject.attributes] - Additional subject attributes
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @typedef {
|
|
29
|
+
* @typedef {object} ExposureContext
|
|
30
30
|
* @property {string} service - Service name
|
|
31
31
|
* @property {string} [version] - Service version
|
|
32
32
|
* @property {string} [env] - Service environment
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* @typedef {
|
|
36
|
+
* @typedef {object} ExposureEventPayload
|
|
37
37
|
* @property {ExposureContext} context - Service context metadata
|
|
38
38
|
* @property {ExposureEvent[]} exposures - Formatted exposure events
|
|
39
39
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { storage } = require('../../../datadog-core')
|
|
4
3
|
const { trace, ROOT_CONTEXT, propagation } = require('@opentelemetry/api')
|
|
4
|
+
const { storage } = require('../../../datadog-core')
|
|
5
5
|
const DataDogSpanContext = require('../opentracing/span_context')
|
|
6
6
|
|
|
7
|
-
const SpanContext = require('./span_context')
|
|
8
7
|
const tracer = require('../../')
|
|
8
|
+
const SpanContext = require('./span_context')
|
|
9
9
|
|
|
10
10
|
class ContextManager {
|
|
11
11
|
constructor () {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { sanitizeAttributes } = require('../../../../../vendor/dist/@opentelemetry/core')
|
|
4
3
|
const { context } = require('@opentelemetry/api')
|
|
4
|
+
const { sanitizeAttributes } = require('../../../../../vendor/dist/@opentelemetry/core')
|
|
5
5
|
const { VERSION: packageVersion } = require('../../../../../version')
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const { logs } = require('@opentelemetry/api-logs')
|
|
3
3
|
const { context } = require('@opentelemetry/api')
|
|
4
|
-
const Logger = require('./logger')
|
|
5
4
|
const log = require('../../log')
|
|
6
5
|
const ContextManager = require('../context_manager')
|
|
6
|
+
const Logger = require('./logger')
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {import('@opentelemetry/api-logs').Logger} Logger
|
|
@@ -26,7 +26,7 @@ class LoggerProvider {
|
|
|
26
26
|
/**
|
|
27
27
|
* Creates a new LoggerProvider instance with a single processor for Datadog Agent export.
|
|
28
28
|
*
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {object} [options] - LoggerProvider options
|
|
30
30
|
* @param {BatchLogRecordProcessor} [options.processor] - Single LogRecordProcessor instance for
|
|
31
31
|
* exporting logs to Datadog Agent
|
|
32
32
|
*/
|
|
@@ -40,9 +40,9 @@ class LoggerProvider {
|
|
|
40
40
|
/**
|
|
41
41
|
* Gets or creates a logger instance.
|
|
42
42
|
*
|
|
43
|
-
* @param {string|
|
|
43
|
+
* @param {string | object} nameOrOptions - Logger name or options object
|
|
44
44
|
* @param {string} [version] - Logger version (when nameOrOptions is a string)
|
|
45
|
-
* @param {
|
|
45
|
+
* @param {object} [options] - Additional options (when nameOrOptions is a string)
|
|
46
46
|
* @returns {Logger} Logger instance
|
|
47
47
|
*/
|
|
48
48
|
getLogger (nameOrOptions, version, options = {}) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const OtlpTransformerBase = require('../otlp/otlp_transformer_base')
|
|
4
3
|
const { SeverityNumber } = require('@opentelemetry/api-logs')
|
|
5
|
-
const { getProtobufTypes } = require('../otlp/protobuf_loader')
|
|
6
4
|
const { trace } = require('@opentelemetry/api')
|
|
7
5
|
|
|
6
|
+
const OtlpTransformerBase = require('../otlp/otlp_transformer_base')
|
|
7
|
+
const { getProtobufTypes } = require('../otlp/protobuf_loader')
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* @typedef {import('@opentelemetry/api-logs').LogRecord} LogRecord
|
|
10
11
|
*/
|
|
@@ -105,7 +106,7 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
105
106
|
/**
|
|
106
107
|
* Creates scope logs grouped by instrumentation library.
|
|
107
108
|
* @param {LogRecord[]} logRecords - Array of log records to transform
|
|
108
|
-
* @returns {
|
|
109
|
+
* @returns {object[]} Array of scope log objects
|
|
109
110
|
*/
|
|
110
111
|
#transformScope (logRecords) {
|
|
111
112
|
const groupedRecords = this.groupByInstrumentationScope(logRecords)
|
|
@@ -131,7 +132,7 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
131
132
|
/**
|
|
132
133
|
* Transforms a single log record to OTLP format.
|
|
133
134
|
* @param {LogRecord} logRecord - Log record to transform
|
|
134
|
-
* @returns {
|
|
135
|
+
* @returns {object} OTLP log record object
|
|
135
136
|
*/
|
|
136
137
|
#transformLogRecord (logRecord) {
|
|
137
138
|
const spanContext = this.#extractSpanContext(logRecord.context)
|
|
@@ -176,8 +177,8 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
176
177
|
|
|
177
178
|
/**
|
|
178
179
|
* Extracts span context from the log record's context.
|
|
179
|
-
* @param {
|
|
180
|
-
* @returns {
|
|
180
|
+
* @param {object} logContext - The log record's context
|
|
181
|
+
* @returns {object | null} Span context or null if not available
|
|
181
182
|
*/
|
|
182
183
|
#extractSpanContext (logContext) {
|
|
183
184
|
if (!logContext) return null
|
|
@@ -214,8 +215,8 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
214
215
|
|
|
215
216
|
/**
|
|
216
217
|
* Transforms log body to OTLP AnyValue format.
|
|
217
|
-
* @param {
|
|
218
|
-
* @returns {
|
|
218
|
+
* @param {import('@opentelemetry/api-logs').LogBody} body - Log body to transform
|
|
219
|
+
* @returns {object} OTLP AnyValue object
|
|
219
220
|
*/
|
|
220
221
|
#transformBody (body) {
|
|
221
222
|
if (typeof body === 'string') {
|
|
@@ -9,7 +9,7 @@ const { METRIC_TYPES } = require('./constants')
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @typedef {
|
|
12
|
+
* @typedef {object} Measurement
|
|
13
13
|
* @property {string} name - Instrument name
|
|
14
14
|
* @property {string} description - Instrument description
|
|
15
15
|
* @property {string} unit - Measurement unit
|
|
@@ -30,11 +30,11 @@ class Instrument {
|
|
|
30
30
|
* Creates a new instrument instance.
|
|
31
31
|
*
|
|
32
32
|
* @param {string} name - Instrument name (e.g., 'http.request.duration')
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {object} options - Instrument configuration options
|
|
34
34
|
* @param {string} [options.description] - Human-readable description of the instrument
|
|
35
35
|
* @param {string} [options.unit] - Unit of measurement (e.g., 'ms', 'bytes', '1')
|
|
36
36
|
* @param {InstrumentationScope} instrumentationScope - Instrumentation scope for this instrument
|
|
37
|
-
* @param {
|
|
37
|
+
* @param {object} reader - Metric reader for recording measurements
|
|
38
38
|
*/
|
|
39
39
|
constructor (name, options, instrumentationScope, reader) {
|
|
40
40
|
this.name = name
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { VERSION: packageVersion } = require('../../../../../version')
|
|
4
|
+
const log = require('../../log')
|
|
4
5
|
const {
|
|
5
6
|
Counter, UpDownCounter, Histogram, Gauge, ObservableGauge, ObservableCounter, ObservableUpDownCounter
|
|
6
7
|
} = require('./instruments')
|
|
7
|
-
const log = require('../../log')
|
|
8
8
|
const { METRIC_TYPES } = require('./constants')
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -31,7 +31,7 @@ class Meter {
|
|
|
31
31
|
* @param {string} [instrumentationScope.name] - Meter name (defaults to 'dd-trace-js')
|
|
32
32
|
* @param {string} [instrumentationScope.version] - Meter version (defaults to tracer version)
|
|
33
33
|
* @param {string} [instrumentationScope.schemaUrl] - Schema URL
|
|
34
|
-
* @param {
|
|
34
|
+
* @param {object} [instrumentationScope.attributes] - Attributes for the instrumentation scope
|
|
35
35
|
*/
|
|
36
36
|
constructor (
|
|
37
37
|
meterProvider,
|
|
@@ -85,7 +85,7 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
85
85
|
* Creates scope metrics grouped by instrumentation scope.
|
|
86
86
|
* @param {Iterable<AggregatedMetric>} metrics - Iterable of metrics to transform
|
|
87
87
|
* @param {boolean} isJson - Whether to format for JSON output
|
|
88
|
-
* @returns {Array<
|
|
88
|
+
* @returns {Array<object>} Array of scope metric objects
|
|
89
89
|
*
|
|
90
90
|
*/
|
|
91
91
|
#transformScope (metrics, isJson = false) {
|
|
@@ -125,7 +125,7 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
125
125
|
*
|
|
126
126
|
* @param {AggregatedMetric} metric - The metric to transform
|
|
127
127
|
* @param {boolean} isJson - Whether to output JSON format (vs protobuf)
|
|
128
|
-
* @returns {
|
|
128
|
+
* @returns {object} - The metric transformed to OTLP protobuf or JSON format
|
|
129
129
|
*/
|
|
130
130
|
#transformMetric (metric, isJson = false) {
|
|
131
131
|
const result = {
|
|
@@ -176,7 +176,7 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
176
176
|
*
|
|
177
177
|
* @param {HistogramDataPoint} dp - The histogram data point to transform
|
|
178
178
|
* @param {boolean} isJson - Whether to output JSON format (vs protobuf)
|
|
179
|
-
* @returns {
|
|
179
|
+
* @returns {object} The histogram data point transformed to OTLP protobuf format
|
|
180
180
|
*/
|
|
181
181
|
#transformHistogramDataPoint (dp, isJson) {
|
|
182
182
|
const attributes = isJson
|
|
@@ -209,7 +209,7 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
209
209
|
*
|
|
210
210
|
* @param {NumberDataPoint} dataPoint - The number data point to transform
|
|
211
211
|
* @param {boolean} isJson - Whether to output JSON format (vs protobuf)
|
|
212
|
-
* @returns {
|
|
212
|
+
* @returns {object} The number data point transformed to OTLP protobuf format
|
|
213
213
|
*/
|
|
214
214
|
#transformNumberDataPoint (dataPoint, isJson) {
|
|
215
215
|
const attributes = isJson
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const log = require('../../log')
|
|
4
|
+
const { stableStringify } = require('../otlp/otlp_transformer_base')
|
|
3
5
|
const {
|
|
4
6
|
METRIC_TYPES, TEMPORALITY, DEFAULT_HISTOGRAM_BUCKETS, DEFAULT_MAX_MEASUREMENT_QUEUE_SIZE
|
|
5
7
|
} = require('./constants')
|
|
6
|
-
const log = require('../../log')
|
|
7
|
-
const { stableStringify } = require('../otlp/otlp_transformer_base')
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {import('@opentelemetry/api').Attributes} Attributes
|
|
@@ -13,7 +13,32 @@ const { stableStringify } = require('../otlp/otlp_transformer_base')
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @typedef {
|
|
16
|
+
* @typedef {{ value: number, startTime: number }} SumCumulativeState
|
|
17
|
+
*
|
|
18
|
+
* @typedef {{
|
|
19
|
+
* count: number,
|
|
20
|
+
* sum: number,
|
|
21
|
+
* min: number,
|
|
22
|
+
* max: number,
|
|
23
|
+
* bucketCounts: number[],
|
|
24
|
+
* startTime: number
|
|
25
|
+
* }} HistogramCumulativeState
|
|
26
|
+
*
|
|
27
|
+
* @typedef {SumCumulativeState | HistogramCumulativeState} CumulativeStateValue
|
|
28
|
+
*
|
|
29
|
+
* @typedef {{
|
|
30
|
+
* count: number,
|
|
31
|
+
* sum: number,
|
|
32
|
+
* min?: number,
|
|
33
|
+
* max?: number,
|
|
34
|
+
* bucketCounts: number[]
|
|
35
|
+
* }} HistogramLastExportedState
|
|
36
|
+
*
|
|
37
|
+
* @typedef {number | HistogramLastExportedState} LastExportedStateValue
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @typedef {object} NumberDataPoint
|
|
17
42
|
* @property {Attributes} attributes - Number data point metric attributes
|
|
18
43
|
* @property {string} attrKey - Stable stringified key for attributes
|
|
19
44
|
* @property {number} timeUnixNano - Timestamp in nanoseconds
|
|
@@ -22,7 +47,7 @@ const { stableStringify } = require('../otlp/otlp_transformer_base')
|
|
|
22
47
|
*/
|
|
23
48
|
|
|
24
49
|
/**
|
|
25
|
-
* @typedef {
|
|
50
|
+
* @typedef {object} HistogramDataPoint
|
|
26
51
|
* @property {Attributes} attributes - Histogram data point metric attributes
|
|
27
52
|
* @property {string} attrKey - Stable stringified key for attributes
|
|
28
53
|
* @property {number} timeUnixNano - Timestamp in nanoseconds
|
|
@@ -36,7 +61,7 @@ const { stableStringify } = require('../otlp/otlp_transformer_base')
|
|
|
36
61
|
*/
|
|
37
62
|
|
|
38
63
|
/**
|
|
39
|
-
* @typedef {
|
|
64
|
+
* @typedef {object} AggregatedMetricDataPoint
|
|
40
65
|
* @property {Attributes} attributes - Aggregated metric data point metric attributes
|
|
41
66
|
* @property {string} attrKey - Stable stringified key for attributes
|
|
42
67
|
* @property {number} timeUnixNano - Timestamp in nanoseconds
|
|
@@ -50,7 +75,7 @@ const { stableStringify } = require('../otlp/otlp_transformer_base')
|
|
|
50
75
|
*/
|
|
51
76
|
|
|
52
77
|
/**
|
|
53
|
-
* @typedef {
|
|
78
|
+
* @typedef {object} AggregatedMetric
|
|
54
79
|
* @property {string} name - Metric name
|
|
55
80
|
* @property {string} description - Metric description
|
|
56
81
|
* @property {string} unit - Metric unit
|
|
@@ -255,8 +280,8 @@ class MetricAggregator {
|
|
|
255
280
|
* Aggregates measurements into metrics.
|
|
256
281
|
*
|
|
257
282
|
* @param {Measurement[]} measurements - The measurements to aggregate
|
|
258
|
-
* @param {Map<string,
|
|
259
|
-
* @param {Map<string,
|
|
283
|
+
* @param {Map<string, CumulativeStateValue>} cumulativeState - The cumulative state of the metrics
|
|
284
|
+
* @param {Map<string, LastExportedStateValue>} lastExportedState - The last exported state of the metrics
|
|
260
285
|
* @returns {Iterable<AggregatedMetric>} The aggregated metrics
|
|
261
286
|
*/
|
|
262
287
|
aggregate (measurements, cumulativeState, lastExportedState) {
|
|
@@ -353,7 +378,7 @@ class MetricAggregator {
|
|
|
353
378
|
* Applies delta temporality to the metrics.
|
|
354
379
|
*
|
|
355
380
|
* @param {Iterable<AggregatedMetric>} metrics - The metrics to apply delta temporality to
|
|
356
|
-
* @param {Map<string,
|
|
381
|
+
* @param {Map<string, LastExportedStateValue>} lastExportedState - The last exported state of the metrics
|
|
357
382
|
* @returns {void}
|
|
358
383
|
*/
|
|
359
384
|
#applyDeltaTemporality (metrics, lastExportedState) {
|
|
@@ -424,7 +449,7 @@ class MetricAggregator {
|
|
|
424
449
|
* @param {string} attrKey - The attribute key
|
|
425
450
|
* @param {number} timestamp - The timestamp of the measurement
|
|
426
451
|
* @param {string} stateKey - The state key
|
|
427
|
-
* @param {Map<string,
|
|
452
|
+
* @param {Map<string, CumulativeStateValue>} cumulativeState - The cumulative state of the metrics
|
|
428
453
|
*/
|
|
429
454
|
#aggregateSum (metric, value, attributes, attrKey, timestamp, stateKey, cumulativeState) {
|
|
430
455
|
if (!cumulativeState.has(stateKey)) {
|
|
@@ -478,7 +503,7 @@ class MetricAggregator {
|
|
|
478
503
|
* @param {string} attrKey - The attribute key
|
|
479
504
|
* @param {number} timestamp - The timestamp of the measurement
|
|
480
505
|
* @param {string} stateKey - The state key
|
|
481
|
-
* @param {Map<string,
|
|
506
|
+
* @param {Map<string, CumulativeStateValue>} cumulativeState - The cumulative state of the metrics
|
|
482
507
|
* @returns {void}
|
|
483
508
|
*/
|
|
484
509
|
#aggregateHistogram (metric, value, attributes, attrKey, timestamp, stateKey, cumulativeState) {
|
|
@@ -90,7 +90,7 @@ class OtlpHttpExporterBase {
|
|
|
90
90
|
data += chunk
|
|
91
91
|
})
|
|
92
92
|
|
|
93
|
-
res.
|
|
93
|
+
res.once('end', () => {
|
|
94
94
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
95
95
|
resultCallback({ code: 0 })
|
|
96
96
|
} else {
|
|
@@ -105,7 +105,7 @@ class OtlpHttpExporterBase {
|
|
|
105
105
|
resultCallback({ code: 1, error })
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
-
req.
|
|
108
|
+
req.once('timeout', () => {
|
|
109
109
|
req.destroy()
|
|
110
110
|
const error = new Error('Request timeout')
|
|
111
111
|
resultCallback({ code: 1, error })
|
|
@@ -4,6 +4,7 @@ const log = require('../../log')
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {import('@opentelemetry/api').Attributes} Attributes
|
|
7
|
+
* @typedef {import('@opentelemetry/api').AttributeValue} AttributeValue
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -61,7 +62,7 @@ class OtlpTransformerBase {
|
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
64
|
* Transforms resource attributes to OTLP resource format.
|
|
64
|
-
* @returns {
|
|
65
|
+
* @returns {object} OTLP resource object
|
|
65
66
|
* @protected
|
|
66
67
|
*/
|
|
67
68
|
transformResource () {
|
|
@@ -73,8 +74,8 @@ class OtlpTransformerBase {
|
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* Transforms attributes to OTLP KeyValue format.
|
|
76
|
-
* @param {
|
|
77
|
-
* @returns {
|
|
77
|
+
* @param {Attributes} attributes - Attributes to transform
|
|
78
|
+
* @returns {object[]} Array of OTLP KeyValue objects
|
|
78
79
|
* @protected
|
|
79
80
|
*/
|
|
80
81
|
transformAttributes (attributes) {
|
|
@@ -86,8 +87,8 @@ class OtlpTransformerBase {
|
|
|
86
87
|
|
|
87
88
|
/**
|
|
88
89
|
* Transforms attributes to JSON format (simplified).
|
|
89
|
-
* @param {
|
|
90
|
-
* @returns {
|
|
90
|
+
* @param {object} attributes - Attributes to transform
|
|
91
|
+
* @returns {object[]} Array of OTLP KeyValue objects with string values
|
|
91
92
|
* @protected
|
|
92
93
|
*/
|
|
93
94
|
attributesToJson (attributes) {
|
|
@@ -103,8 +104,8 @@ class OtlpTransformerBase {
|
|
|
103
104
|
* Transforms any value to OTLP AnyValue format.
|
|
104
105
|
* Supports: strings, numbers (int/double), booleans, arrays.
|
|
105
106
|
* Objects are filtered out by sanitizeAttributes before reaching this method.
|
|
106
|
-
* @param {
|
|
107
|
-
* @returns {
|
|
107
|
+
* @param {AttributeValue | null | undefined} value - Value to transform
|
|
108
|
+
* @returns {object} OTLP AnyValue object
|
|
108
109
|
* @protected
|
|
109
110
|
*/
|
|
110
111
|
transformAnyValue (value) {
|
|
@@ -130,8 +131,8 @@ class OtlpTransformerBase {
|
|
|
130
131
|
|
|
131
132
|
/**
|
|
132
133
|
* Serializes data to protobuf format.
|
|
133
|
-
* @param {
|
|
134
|
-
* @param {
|
|
134
|
+
* @param {object} protoType - Protobuf type from protobuf_loader
|
|
135
|
+
* @param {object} data - Data to serialize
|
|
135
136
|
* @returns {Buffer} Protobuf-encoded data
|
|
136
137
|
* @protected
|
|
137
138
|
*/
|
|
@@ -143,7 +144,7 @@ class OtlpTransformerBase {
|
|
|
143
144
|
|
|
144
145
|
/**
|
|
145
146
|
* Serializes data to JSON format.
|
|
146
|
-
* @param {
|
|
147
|
+
* @param {object} data - Data to serialize
|
|
147
148
|
* @returns {Buffer} JSON-encoded data
|
|
148
149
|
* @protected
|
|
149
150
|
*/
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* - https://github.com/open-telemetry/opentelemetry-proto (v1.7.0)
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
const protobuf = require('../../../../../vendor/dist/protobufjs')
|
|
18
17
|
const path = require('path')
|
|
18
|
+
const protobuf = require('../../../../../vendor/dist/protobufjs')
|
|
19
19
|
|
|
20
20
|
let _root = null
|
|
21
21
|
let protoLogsService = null
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { performance } = require('perf_hooks')
|
|
3
4
|
const api = require('@opentelemetry/api')
|
|
4
5
|
|
|
5
|
-
const { performance } = require('perf_hooks')
|
|
6
6
|
const { timeOrigin } = performance
|
|
7
7
|
|
|
8
8
|
const { timeInputToHrTime } = require('../../../../vendor/dist/@opentelemetry/core')
|
|
@@ -13,8 +13,8 @@ const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK, IGNORE_OTEL_ERROR } = require('.
|
|
|
13
13
|
const { SERVICE_NAME, RESOURCE_NAME, SPAN_KIND } = require('../../../../ext/tags')
|
|
14
14
|
const kinds = require('../../../../ext/kinds')
|
|
15
15
|
|
|
16
|
-
const SpanContext = require('./span_context')
|
|
17
16
|
const id = require('../id')
|
|
17
|
+
const SpanContext = require('./span_context')
|
|
18
18
|
|
|
19
19
|
// The one built into OTel rounds so we lose sub-millisecond precision.
|
|
20
20
|
function hrTimeToMilliseconds (time) {
|
|
@@ -3,13 +3,49 @@
|
|
|
3
3
|
const api = require('@opentelemetry/api')
|
|
4
4
|
const { sanitizeAttributes } = require('../../../../vendor/dist/@opentelemetry/core')
|
|
5
5
|
|
|
6
|
-
const Sampler = require('./sampler')
|
|
7
|
-
const Span = require('./span')
|
|
8
6
|
const id = require('../id')
|
|
9
7
|
const log = require('../log')
|
|
10
|
-
const
|
|
8
|
+
const DatadogSpanContext = require('../opentracing/span_context')
|
|
11
9
|
const TextMapPropagator = require('../opentracing/propagation/text_map')
|
|
12
10
|
const TraceState = require('../opentracing/propagation/tracestate')
|
|
11
|
+
const SpanContext = require('./span_context')
|
|
12
|
+
const Span = require('./span')
|
|
13
|
+
const Sampler = require('./sampler')
|
|
14
|
+
|
|
15
|
+
function normalizeLinkContext (context) {
|
|
16
|
+
if (!context) return
|
|
17
|
+
|
|
18
|
+
// OTel API bridge SpanContext wrapper
|
|
19
|
+
if (context._ddContext) return context._ddContext
|
|
20
|
+
|
|
21
|
+
// Datadog span context
|
|
22
|
+
if (typeof context.toTraceId === 'function' && typeof context.toSpanId === 'function') {
|
|
23
|
+
return context
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Standard OTel SpanContext (traceId/spanId)
|
|
27
|
+
if (typeof context.traceId !== 'string' || typeof context.spanId !== 'string') {
|
|
28
|
+
// Invalid
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let sampling
|
|
33
|
+
if (typeof context.traceFlags === 'number') {
|
|
34
|
+
sampling = { priority: context.traceFlags & 1 }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let tracestate
|
|
38
|
+
if (context.traceState?.serialize) {
|
|
39
|
+
tracestate = TraceState.fromString(context.traceState.serialize())
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return new DatadogSpanContext({
|
|
43
|
+
traceId: id(context.traceId, 16),
|
|
44
|
+
spanId: id(context.spanId, 16),
|
|
45
|
+
sampling,
|
|
46
|
+
tracestate
|
|
47
|
+
})
|
|
48
|
+
}
|
|
13
49
|
|
|
14
50
|
class Tracer {
|
|
15
51
|
constructor (library, config, tracerProvider) {
|
|
@@ -96,7 +132,7 @@ class Tracer {
|
|
|
96
132
|
context = api.trace.deleteSpan(context)
|
|
97
133
|
}
|
|
98
134
|
const parentSpan = api.trace.getSpan(context)
|
|
99
|
-
const parentSpanContext = parentSpan
|
|
135
|
+
const parentSpanContext = parentSpan?.spanContext()
|
|
100
136
|
let spanContext
|
|
101
137
|
if (parentSpanContext && api.trace.isSpanContextValid(parentSpanContext)) {
|
|
102
138
|
spanContext = parentSpanContext._ddContext
|
|
@@ -107,12 +143,18 @@ class Tracer {
|
|
|
107
143
|
}
|
|
108
144
|
|
|
109
145
|
const spanKind = options.kind || api.SpanKind.INTERNAL
|
|
110
|
-
const links =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
146
|
+
const links = []
|
|
147
|
+
if (options.links?.length) {
|
|
148
|
+
for (const link of options.links) {
|
|
149
|
+
const ddContext = normalizeLinkContext(link?.context)
|
|
150
|
+
if (!ddContext) continue
|
|
151
|
+
|
|
152
|
+
links.push({
|
|
153
|
+
context: ddContext,
|
|
154
|
+
attributes: sanitizeAttributes(link.attributes)
|
|
155
|
+
})
|
|
114
156
|
}
|
|
115
|
-
}
|
|
157
|
+
}
|
|
116
158
|
const attributes = sanitizeAttributes(options.attributes)
|
|
117
159
|
|
|
118
160
|
// TODO: sampling API is not yet supported
|