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
|
@@ -3,10 +3,93 @@
|
|
|
3
3
|
const request = require('../exporters/common/request')
|
|
4
4
|
const log = require('../log')
|
|
5
5
|
const { isTrue } = require('../util')
|
|
6
|
-
const {
|
|
6
|
+
const { getValueFromEnvSources } = require('../config/helper')
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Record<string, unknown>} TelemetryPayloadObject
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Telemetry "request_type" values sent by this library.
|
|
13
|
+
*
|
|
14
|
+
* @typedef {'app-started'
|
|
15
|
+
* | 'app-integrations-change'
|
|
16
|
+
* | 'app-heartbeat'
|
|
17
|
+
* | 'app-extended-heartbeat'
|
|
18
|
+
* | 'app-client-configuration-change'
|
|
19
|
+
* | 'app-closing'
|
|
20
|
+
* | 'app-dependencies-loaded'
|
|
21
|
+
* | 'app-endpoints'
|
|
22
|
+
* | 'generate-metrics'
|
|
23
|
+
* | 'distributions'
|
|
24
|
+
* | 'logs'
|
|
25
|
+
* | 'message-batch'} TelemetryRequestType
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {{ request_type: string, payload: TelemetryPayloadObject }} MessageBatchItem
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {MessageBatchItem[]} MessageBatchPayload
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Telemetry payloads are usually single objects, but some request types (e.g. `message-batch`)
|
|
35
|
+
* send arrays.
|
|
36
|
+
*
|
|
37
|
+
* @typedef {TelemetryPayloadObject | MessageBatchPayload} TelemetryPayload
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {{language_name: string, tracer_version: string} & Record<string, unknown>} TelemetryApplication
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Exclude<TelemetryRequestType, 'message-batch'>} NonBatchTelemetryRequestType
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {{
|
|
47
|
+
* payload: TelemetryPayloadObject,
|
|
48
|
+
* reqType: NonBatchTelemetryRequestType
|
|
49
|
+
* } | {
|
|
50
|
+
* payload: MessageBatchPayload,
|
|
51
|
+
* reqType: 'message-batch'
|
|
52
|
+
* }} SendDataRetryObject
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* @typedef {{
|
|
56
|
+
* hostname: string,
|
|
57
|
+
* os: string,
|
|
58
|
+
* architecture: string,
|
|
59
|
+
* os_version?: string,
|
|
60
|
+
* kernel_version?: string,
|
|
61
|
+
* kernel_release?: string,
|
|
62
|
+
* kernel_name?: string
|
|
63
|
+
* } & Record<string, unknown>} TelemetryHost
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* @typedef {{
|
|
67
|
+
* hostname?: string,
|
|
68
|
+
* port?: string | number,
|
|
69
|
+
* url?: string | URL,
|
|
70
|
+
* site?: string,
|
|
71
|
+
* apiKey?: string,
|
|
72
|
+
* isCiVisibility?: boolean,
|
|
73
|
+
* spanAttributeSchema?: string,
|
|
74
|
+
* tags: Record<string, string>,
|
|
75
|
+
* telemetry?: { debug?: boolean }
|
|
76
|
+
* }} TelemetryConfig
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* @callback SendDataCallback
|
|
80
|
+
* @param {Error | null | undefined} error
|
|
81
|
+
* @param {SendDataRetryObject} retryObj
|
|
82
|
+
* @returns {void}
|
|
83
|
+
*/
|
|
7
84
|
|
|
8
85
|
let agentTelemetry = true
|
|
9
86
|
|
|
87
|
+
/**
|
|
88
|
+
* @param {TelemetryConfig} config
|
|
89
|
+
* @param {TelemetryApplication} application
|
|
90
|
+
* @param {TelemetryRequestType} reqType
|
|
91
|
+
* @returns {Record<string, string>}
|
|
92
|
+
*/
|
|
10
93
|
function getHeaders (config, application, reqType) {
|
|
11
94
|
const headers = {
|
|
12
95
|
'content-type': 'application/json',
|
|
@@ -25,6 +108,9 @@ function getHeaders (config, application, reqType) {
|
|
|
25
108
|
return headers
|
|
26
109
|
}
|
|
27
110
|
|
|
111
|
+
/**
|
|
112
|
+
* @param {string | undefined} site
|
|
113
|
+
*/
|
|
28
114
|
function getAgentlessTelemetryEndpoint (site) {
|
|
29
115
|
if (site === 'datad0g.com') { // staging
|
|
30
116
|
return 'https://all-http-intake.logs.datad0g.com'
|
|
@@ -34,6 +120,10 @@ function getAgentlessTelemetryEndpoint (site) {
|
|
|
34
120
|
|
|
35
121
|
let seqId = 0
|
|
36
122
|
|
|
123
|
+
/**
|
|
124
|
+
* @param {TelemetryPayload} payload
|
|
125
|
+
* @returns {TelemetryPayload}
|
|
126
|
+
*/
|
|
37
127
|
function getPayload (payload) {
|
|
38
128
|
// Some telemetry endpoints payloads accept collections of elements such as the 'logs' endpoint.
|
|
39
129
|
// 'logs' request type payload is meant to send library logs to Datadog’s backend.
|
|
@@ -44,6 +134,15 @@ function getPayload (payload) {
|
|
|
44
134
|
return trimmedPayload
|
|
45
135
|
}
|
|
46
136
|
|
|
137
|
+
// TODO(BridgeAR): Simplify this code. A lot does not need to be recalculated on every call.
|
|
138
|
+
/**
|
|
139
|
+
* @param {TelemetryConfig} config
|
|
140
|
+
* @param {TelemetryApplication} application
|
|
141
|
+
* @param {TelemetryHost} host
|
|
142
|
+
* @param {TelemetryRequestType} reqType
|
|
143
|
+
* @param {TelemetryPayload} [payload]
|
|
144
|
+
* @param {SendDataCallback} [cb]
|
|
145
|
+
*/
|
|
47
146
|
function sendData (config, application, host, reqType, payload = {}, cb = () => {}) {
|
|
48
147
|
const {
|
|
49
148
|
hostname,
|
|
@@ -54,7 +153,7 @@ function sendData (config, application, host, reqType, payload = {}, cb = () =>
|
|
|
54
153
|
let url = config.url
|
|
55
154
|
|
|
56
155
|
const isCiVisibilityAgentlessMode = isCiVisibility &&
|
|
57
|
-
isTrue(
|
|
156
|
+
isTrue(getValueFromEnvSources('DD_CIVISIBILITY_AGENTLESS_ENABLED'))
|
|
58
157
|
|
|
59
158
|
if (isCiVisibilityAgentlessMode) {
|
|
60
159
|
try {
|
|
@@ -88,14 +187,14 @@ function sendData (config, application, host, reqType, payload = {}, cb = () =>
|
|
|
88
187
|
})
|
|
89
188
|
|
|
90
189
|
request(data, options, (error) => {
|
|
91
|
-
if (error &&
|
|
190
|
+
if (error && getValueFromEnvSources('DD_API_KEY') && config.site) {
|
|
92
191
|
if (agentTelemetry) {
|
|
93
192
|
log.warn('Agent telemetry failed, started agentless telemetry')
|
|
94
193
|
agentTelemetry = false
|
|
95
194
|
}
|
|
96
195
|
// figure out which data center to send to
|
|
97
196
|
const backendUrl = getAgentlessTelemetryEndpoint(config.site)
|
|
98
|
-
const backendHeader = { ...options.headers, 'DD-API-KEY':
|
|
197
|
+
const backendHeader = { ...options.headers, 'DD-API-KEY': getValueFromEnvSources('DD_API_KEY') }
|
|
99
198
|
const backendOptions = {
|
|
100
199
|
...options,
|
|
101
200
|
url: backendUrl,
|
|
@@ -1,31 +1,131 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
|
|
3
|
-
const dc = require('dc-polyfill')
|
|
2
|
+
|
|
4
3
|
const os = require('os')
|
|
4
|
+
const dc = require('dc-polyfill')
|
|
5
|
+
|
|
6
|
+
const tracerVersion = require('../../../../package.json').version
|
|
7
|
+
const { errors } = require('../startup-log')
|
|
8
|
+
const logger = require('../log')
|
|
9
|
+
const processTags = require('../process-tags')
|
|
5
10
|
const dependencies = require('./dependencies')
|
|
6
11
|
const endpoints = require('./endpoints')
|
|
7
12
|
const { sendData } = require('./send-data')
|
|
8
|
-
const { errors } = require('../startup-log')
|
|
9
13
|
const { manager: metricsManager } = require('./metrics')
|
|
10
14
|
const telemetryLogger = require('./logs')
|
|
11
|
-
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Record<string, unknown>} TelemetryPayloadObject
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {string | number | boolean | null | undefined | URL | Record<string, unknown> | unknown[]} ConfigValue
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {{
|
|
24
|
+
* name: string,
|
|
25
|
+
* enabled: boolean,
|
|
26
|
+
* auto_enabled: boolean,
|
|
27
|
+
* process_tags: typeof processTags.tagsObject
|
|
28
|
+
* }} Integration
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {{ _enabled: boolean }} Plugin
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {{ _pluginsByName: Record<string, Plugin> }} PluginManager
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {{
|
|
38
|
+
* service_name: string | undefined,
|
|
39
|
+
* env: string | undefined,
|
|
40
|
+
* service_version: string | undefined,
|
|
41
|
+
* tracer_version: string,
|
|
42
|
+
* language_name: 'nodejs',
|
|
43
|
+
* language_version: string
|
|
44
|
+
* process_tags: typeof processTags.tagsObject
|
|
45
|
+
* }} TelemetryApplication
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {{
|
|
49
|
+
* hostname: string,
|
|
50
|
+
* os: string,
|
|
51
|
+
* architecture: string,
|
|
52
|
+
* os_version?: string,
|
|
53
|
+
* kernel_version?: string,
|
|
54
|
+
* kernel_release?: string,
|
|
55
|
+
* kernel_name?: string
|
|
56
|
+
* }} TelemetryHost
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* @typedef {{
|
|
60
|
+
* telemetry: {
|
|
61
|
+
* enabled: boolean,
|
|
62
|
+
* heartbeatInterval: number,
|
|
63
|
+
* debug?: boolean,
|
|
64
|
+
* dependencyCollection?: boolean,
|
|
65
|
+
* logCollection?: boolean
|
|
66
|
+
* },
|
|
67
|
+
* service: string | undefined,
|
|
68
|
+
* env: string | undefined,
|
|
69
|
+
* version: string | undefined,
|
|
70
|
+
* tags: Record<string, string>,
|
|
71
|
+
* url?: string | URL,
|
|
72
|
+
* hostname?: string,
|
|
73
|
+
* port?: string | number,
|
|
74
|
+
* site?: string,
|
|
75
|
+
* apiKey?: string,
|
|
76
|
+
* isCiVisibility?: boolean,
|
|
77
|
+
* spanAttributeSchema?: string,
|
|
78
|
+
* installSignature?: { id?: string, time?: string, type?: string },
|
|
79
|
+
* sca?: { enabled?: boolean },
|
|
80
|
+
* appsec: { enabled: boolean, apiSecurity?: {
|
|
81
|
+
* endpointCollectionEnabled?: boolean,
|
|
82
|
+
* endpointCollectionMessageLimit?: number
|
|
83
|
+
* } },
|
|
84
|
+
* profiling: { enabled: boolean | 'true' | 'false' | 'auto' }
|
|
85
|
+
* }} TelemetryConfig
|
|
86
|
+
*/
|
|
12
87
|
|
|
13
88
|
const telemetryStartChannel = dc.channel('datadog:telemetry:start')
|
|
14
89
|
const telemetryStopChannel = dc.channel('datadog:telemetry:stop')
|
|
15
90
|
const telemetryAppClosingChannel = dc.channel('datadog:telemetry:app-closing')
|
|
16
91
|
|
|
92
|
+
/** @type {TelemetryConfig | undefined} */
|
|
17
93
|
let config
|
|
94
|
+
|
|
95
|
+
/** @type {PluginManager} */
|
|
18
96
|
let pluginManager
|
|
19
97
|
|
|
98
|
+
/** @type {TelemetryApplication} */
|
|
20
99
|
let application
|
|
21
|
-
|
|
22
|
-
|
|
100
|
+
|
|
101
|
+
/** @type {TelemetryHost} */
|
|
102
|
+
const host = createHostObject()
|
|
103
|
+
|
|
104
|
+
/** @type {ReturnType<typeof setInterval> | undefined} */
|
|
23
105
|
let heartbeatInterval
|
|
106
|
+
|
|
107
|
+
/** @type {ReturnType<typeof setInterval> | undefined} */
|
|
24
108
|
let extendedInterval
|
|
109
|
+
|
|
110
|
+
/** @type {Integration[]} */
|
|
25
111
|
let integrations
|
|
112
|
+
|
|
113
|
+
/** @type {Map<string, { name: string, value: ConfigValue, origin: string, seq_id: number }>} */
|
|
26
114
|
const configWithOrigin = new Map()
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Retry information that `telemetry.js` keeps in-memory to be merged into the next payload.
|
|
118
|
+
*
|
|
119
|
+
* @typedef {{ payload: TelemetryPayloadObject, reqType: string }} RetryData
|
|
120
|
+
*/
|
|
121
|
+
/** @type {{ payload: TelemetryPayloadObject, reqType: string } | null} */
|
|
27
122
|
let retryData = null
|
|
28
|
-
|
|
123
|
+
|
|
124
|
+
/** @type {TelemetryPayloadObject[]} */
|
|
125
|
+
let heartbeatFailedIntegrations = []
|
|
126
|
+
|
|
127
|
+
/** @type {TelemetryPayloadObject[]} */
|
|
128
|
+
let heartbeatFailedDependencies = []
|
|
29
129
|
|
|
30
130
|
const sentIntegrations = new Set()
|
|
31
131
|
|
|
@@ -35,58 +135,58 @@ function getRetryData () {
|
|
|
35
135
|
return retryData
|
|
36
136
|
}
|
|
37
137
|
|
|
138
|
+
/**
|
|
139
|
+
* @param {Error | null | undefined} error
|
|
140
|
+
* @param {import('./send-data').SendDataRetryObject} retryObj
|
|
141
|
+
*/
|
|
38
142
|
function updateRetryData (error, retryObj) {
|
|
39
|
-
if (error) {
|
|
40
|
-
if (retryObj.reqType === 'message-batch') {
|
|
41
|
-
const payload = retryObj.payload[0].payload
|
|
42
|
-
const reqType = retryObj.payload[0].request_type
|
|
43
|
-
retryData = { payload, reqType }
|
|
44
|
-
|
|
45
|
-
// Since this payload failed twice it now gets save in to the extended heartbeat
|
|
46
|
-
const failedPayload = retryObj.payload[1].payload
|
|
47
|
-
const failedReqType = retryObj.payload[1].request_type
|
|
48
|
-
|
|
49
|
-
// save away the dependencies and integration request for extended heartbeat.
|
|
50
|
-
if (failedReqType === 'app-integrations-change') {
|
|
51
|
-
if (extendedHeartbeatPayload.integrations) {
|
|
52
|
-
extendedHeartbeatPayload.integrations.push(failedPayload)
|
|
53
|
-
} else {
|
|
54
|
-
extendedHeartbeatPayload.integrations = [failedPayload]
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (failedReqType === 'app-dependencies-loaded') {
|
|
58
|
-
if (extendedHeartbeatPayload.dependencies) {
|
|
59
|
-
extendedHeartbeatPayload.dependencies.push(failedPayload)
|
|
60
|
-
} else {
|
|
61
|
-
extendedHeartbeatPayload.dependencies = [failedPayload]
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
retryData = retryObj
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
143
|
+
if (!error) {
|
|
68
144
|
retryData = null
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
if (retryObj.reqType !== 'message-batch') {
|
|
148
|
+
retryData = retryObj
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
retryData = {
|
|
153
|
+
payload: retryObj.payload[0].payload,
|
|
154
|
+
reqType: retryObj.payload[0].request_type,
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Since this payload failed twice it now gets save in to the extended heartbeat
|
|
158
|
+
const failedPayload = retryObj.payload[1].payload
|
|
159
|
+
const failedReqType = retryObj.payload[1].request_type
|
|
160
|
+
|
|
161
|
+
// save away the dependencies and integration request for extended heartbeat.
|
|
162
|
+
if (failedReqType === 'app-integrations-change') {
|
|
163
|
+
heartbeatFailedIntegrations.push(failedPayload)
|
|
164
|
+
} else if (failedReqType === 'app-dependencies-loaded') {
|
|
165
|
+
heartbeatFailedDependencies.push(failedPayload)
|
|
69
166
|
}
|
|
70
167
|
}
|
|
71
168
|
|
|
72
169
|
function getIntegrations () {
|
|
73
|
-
const newIntegrations = []
|
|
74
|
-
for (const pluginName
|
|
75
|
-
if (sentIntegrations.has(pluginName)) {
|
|
76
|
-
|
|
170
|
+
const newIntegrations = /** @type {Integration[]} */ ([])
|
|
171
|
+
for (const pluginName of Object.keys(pluginManager._pluginsByName ?? {})) {
|
|
172
|
+
if (!sentIntegrations.has(pluginName)) {
|
|
173
|
+
newIntegrations.push({
|
|
174
|
+
name: pluginName,
|
|
175
|
+
enabled: pluginManager._pluginsByName[pluginName]._enabled,
|
|
176
|
+
auto_enabled: true,
|
|
177
|
+
[processTags.TELEMETRY_FIELD_NAME]: processTags.tagsObject
|
|
178
|
+
})
|
|
179
|
+
sentIntegrations.add(pluginName)
|
|
77
180
|
}
|
|
78
|
-
newIntegrations.push({
|
|
79
|
-
name: pluginName,
|
|
80
|
-
enabled: pluginManager._pluginsByName[pluginName]._enabled,
|
|
81
|
-
auto_enabled: true
|
|
82
|
-
})
|
|
83
|
-
sentIntegrations.add(pluginName)
|
|
84
181
|
}
|
|
85
182
|
return newIntegrations
|
|
86
183
|
}
|
|
87
184
|
|
|
185
|
+
/**
|
|
186
|
+
* @param {TelemetryConfig} config
|
|
187
|
+
*/
|
|
88
188
|
function getProducts (config) {
|
|
89
|
-
|
|
189
|
+
return {
|
|
90
190
|
appsec: {
|
|
91
191
|
enabled: config.appsec.enabled
|
|
92
192
|
},
|
|
@@ -95,13 +195,11 @@ function getProducts (config) {
|
|
|
95
195
|
enabled: profilingEnabledToBoolean(config.profiling.enabled)
|
|
96
196
|
}
|
|
97
197
|
}
|
|
98
|
-
if (errors.profilingError) {
|
|
99
|
-
products.profiler.error = errors.profilingError
|
|
100
|
-
errors.profilingError = {}
|
|
101
|
-
}
|
|
102
|
-
return products
|
|
103
198
|
}
|
|
104
199
|
|
|
200
|
+
/**
|
|
201
|
+
* @param {TelemetryConfig} config
|
|
202
|
+
*/
|
|
105
203
|
function getInstallSignature (config) {
|
|
106
204
|
const { installSignature: sig } = config
|
|
107
205
|
if (sig && (sig.id || sig.time || sig.type)) {
|
|
@@ -113,6 +211,9 @@ function getInstallSignature (config) {
|
|
|
113
211
|
}
|
|
114
212
|
}
|
|
115
213
|
|
|
214
|
+
/**
|
|
215
|
+
* @param {TelemetryConfig} config
|
|
216
|
+
*/
|
|
116
217
|
function appStarted (config) {
|
|
117
218
|
const app = {
|
|
118
219
|
products: getProducts(config),
|
|
@@ -122,11 +223,10 @@ function appStarted (config) {
|
|
|
122
223
|
if (installSignature) {
|
|
123
224
|
app.install_signature = installSignature
|
|
124
225
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// }
|
|
226
|
+
if (errors.agentError) {
|
|
227
|
+
app.error = errors.agentError
|
|
228
|
+
errors.agentError = undefined
|
|
229
|
+
}
|
|
130
230
|
return app
|
|
131
231
|
}
|
|
132
232
|
|
|
@@ -143,11 +243,10 @@ function appClosing () {
|
|
|
143
243
|
telemetryLogger.send(config, application, host)
|
|
144
244
|
}
|
|
145
245
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
246
|
+
/**
|
|
247
|
+
* @param {TelemetryConfig} config
|
|
248
|
+
* @returns {TelemetryApplication}
|
|
249
|
+
*/
|
|
151
250
|
function createAppObject (config) {
|
|
152
251
|
return {
|
|
153
252
|
service_name: config.service,
|
|
@@ -155,54 +254,60 @@ function createAppObject (config) {
|
|
|
155
254
|
service_version: config.version,
|
|
156
255
|
tracer_version: tracerVersion,
|
|
157
256
|
language_name: 'nodejs',
|
|
158
|
-
language_version: process.versions.node
|
|
257
|
+
language_version: process.versions.node,
|
|
258
|
+
process_tags: processTags.tagsObject
|
|
159
259
|
}
|
|
160
260
|
}
|
|
161
261
|
|
|
262
|
+
/**
|
|
263
|
+
* @returns {TelemetryHost}
|
|
264
|
+
*/
|
|
162
265
|
function createHostObject () {
|
|
163
266
|
const osName = os.type()
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
os: osName,
|
|
169
|
-
architecture: os.arch(),
|
|
170
|
-
kernel_version: os.version(),
|
|
171
|
-
kernel_release: os.release(),
|
|
172
|
-
kernel_name: osName
|
|
173
|
-
}
|
|
267
|
+
const base = {
|
|
268
|
+
hostname: os.hostname(),
|
|
269
|
+
os: osName,
|
|
270
|
+
architecture: os.arch(),
|
|
174
271
|
}
|
|
175
272
|
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
273
|
+
if (os.platform() === 'win32') {
|
|
274
|
+
base.os_version = os.version() // Optional
|
|
275
|
+
} else {
|
|
276
|
+
base.kernel_version = os.version()
|
|
277
|
+
base.kernel_release = os.release()
|
|
278
|
+
base.kernel_name = osName
|
|
183
279
|
}
|
|
184
280
|
|
|
185
|
-
return
|
|
186
|
-
hostname: os.hostname(), // TODO is this enough?
|
|
187
|
-
os: osName
|
|
188
|
-
}
|
|
281
|
+
return base
|
|
189
282
|
}
|
|
190
283
|
|
|
191
284
|
function getTelemetryData () {
|
|
192
|
-
return { config, application, host, heartbeatInterval }
|
|
285
|
+
return { config, application, host, heartbeatInterval: config?.telemetry.heartbeatInterval }
|
|
193
286
|
}
|
|
194
287
|
|
|
288
|
+
/**
|
|
289
|
+
* @param {{ reqType: string, payload: TelemetryPayloadObject }[]} payload
|
|
290
|
+
*/
|
|
195
291
|
function createBatchPayload (payload) {
|
|
196
|
-
|
|
292
|
+
return payload.map(item => {
|
|
197
293
|
return {
|
|
198
294
|
request_type: item.reqType,
|
|
199
295
|
payload: item.payload
|
|
200
296
|
}
|
|
201
297
|
})
|
|
202
|
-
|
|
203
|
-
return batchPayload
|
|
204
298
|
}
|
|
205
299
|
|
|
300
|
+
/**
|
|
301
|
+
* @param {import('./send-data').NonBatchTelemetryRequestType} currReqType
|
|
302
|
+
* @param {TelemetryPayloadObject} [currPayload]
|
|
303
|
+
* @returns {{
|
|
304
|
+
* reqType: 'message-batch',
|
|
305
|
+
* payload: import('./send-data').MessageBatchPayload
|
|
306
|
+
* } | {
|
|
307
|
+
* reqType: import('./send-data').NonBatchTelemetryRequestType,
|
|
308
|
+
* payload: TelemetryPayloadObject
|
|
309
|
+
* }}
|
|
310
|
+
*/
|
|
206
311
|
function createPayload (currReqType, currPayload = {}) {
|
|
207
312
|
if (getRetryData()) {
|
|
208
313
|
const payload = { reqType: currReqType, payload: currPayload }
|
|
@@ -213,31 +318,42 @@ function createPayload (currReqType, currPayload = {}) {
|
|
|
213
318
|
return { reqType: currReqType, payload: currPayload }
|
|
214
319
|
}
|
|
215
320
|
|
|
216
|
-
|
|
217
|
-
|
|
321
|
+
/**
|
|
322
|
+
* @param {TelemetryConfig} config
|
|
323
|
+
* @param {TelemetryApplication} application
|
|
324
|
+
*/
|
|
325
|
+
function heartbeat (config, application) {
|
|
326
|
+
heartbeatInterval = setInterval(() => {
|
|
218
327
|
metricsManager.send(config, application, host)
|
|
219
328
|
telemetryLogger.send(config, application, host)
|
|
220
329
|
|
|
221
330
|
const { reqType, payload } = createPayload('app-heartbeat')
|
|
222
331
|
sendData(config, application, host, reqType, payload, updateRetryData)
|
|
223
|
-
|
|
224
|
-
}, heartbeatInterval).unref()
|
|
225
|
-
return heartbeatTimeout
|
|
332
|
+
}, config.telemetry.heartbeatInterval).unref()
|
|
226
333
|
}
|
|
227
334
|
|
|
335
|
+
/**
|
|
336
|
+
* @param {TelemetryConfig} config
|
|
337
|
+
*/
|
|
228
338
|
function extendedHeartbeat (config) {
|
|
229
339
|
extendedInterval = setInterval(() => {
|
|
230
340
|
const appPayload = appStarted(config)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
341
|
+
if (heartbeatFailedIntegrations.length > 0) {
|
|
342
|
+
appPayload.integrations = heartbeatFailedIntegrations
|
|
343
|
+
heartbeatFailedIntegrations = []
|
|
344
|
+
}
|
|
345
|
+
if (heartbeatFailedDependencies.length > 0) {
|
|
346
|
+
appPayload.dependencies = heartbeatFailedDependencies
|
|
347
|
+
heartbeatFailedDependencies = []
|
|
234
348
|
}
|
|
235
|
-
sendData(config, application, host, 'app-extended-heartbeat',
|
|
236
|
-
Object.keys(extendedHeartbeatPayload).forEach(key => delete extendedHeartbeatPayload[key])
|
|
349
|
+
sendData(config, application, host, 'app-extended-heartbeat', appPayload)
|
|
237
350
|
}, 1000 * 60 * 60 * 24).unref()
|
|
238
|
-
return extendedInterval
|
|
239
351
|
}
|
|
240
352
|
|
|
353
|
+
/**
|
|
354
|
+
* @param {TelemetryConfig} aConfig
|
|
355
|
+
* @param {PluginManager} thePluginManager
|
|
356
|
+
*/
|
|
241
357
|
function start (aConfig, thePluginManager) {
|
|
242
358
|
if (!aConfig.telemetry.enabled) {
|
|
243
359
|
if (aConfig.sca?.enabled) {
|
|
@@ -249,8 +365,6 @@ function start (aConfig, thePluginManager) {
|
|
|
249
365
|
config = aConfig
|
|
250
366
|
pluginManager = thePluginManager
|
|
251
367
|
application = createAppObject(config)
|
|
252
|
-
host = createHostObject()
|
|
253
|
-
heartbeatInterval = config.telemetry.heartbeatInterval
|
|
254
368
|
integrations = getIntegrations()
|
|
255
369
|
|
|
256
370
|
dependencies.start(config, application, host, getRetryData, updateRetryData)
|
|
@@ -264,11 +378,11 @@ function start (aConfig, thePluginManager) {
|
|
|
264
378
|
{ integrations }, updateRetryData)
|
|
265
379
|
}
|
|
266
380
|
|
|
267
|
-
heartbeat(config, application
|
|
381
|
+
heartbeat(config, application)
|
|
268
382
|
|
|
269
383
|
extendedHeartbeat(config)
|
|
270
384
|
|
|
271
|
-
|
|
385
|
+
globalThis[Symbol.for('dd-trace')].beforeExitHandlers.add(appClosing)
|
|
272
386
|
telemetryStartChannel.publish(getTelemetryData())
|
|
273
387
|
}
|
|
274
388
|
|
|
@@ -277,8 +391,8 @@ function stop () {
|
|
|
277
391
|
return
|
|
278
392
|
}
|
|
279
393
|
clearInterval(extendedInterval)
|
|
280
|
-
|
|
281
|
-
|
|
394
|
+
clearInterval(heartbeatInterval)
|
|
395
|
+
globalThis[Symbol.for('dd-trace')].beforeExitHandlers.delete(appClosing)
|
|
282
396
|
|
|
283
397
|
telemetryStopChannel.publish(getTelemetryData())
|
|
284
398
|
|
|
@@ -300,6 +414,9 @@ function updateIntegrations () {
|
|
|
300
414
|
sendData(config, application, host, reqType, payload, updateRetryData)
|
|
301
415
|
}
|
|
302
416
|
|
|
417
|
+
/**
|
|
418
|
+
* @param {Record<string, string | number | boolean> | null | undefined} map
|
|
419
|
+
*/
|
|
303
420
|
function formatMapForTelemetry (map) {
|
|
304
421
|
// format from an object to a string map in order for
|
|
305
422
|
// telemetry intake to accept the configuration
|
|
@@ -354,6 +471,10 @@ const nameMapping = {
|
|
|
354
471
|
|
|
355
472
|
const namesNeedFormatting = new Set(['DD_TAGS', 'peerServiceMapping', 'serviceMapping'])
|
|
356
473
|
|
|
474
|
+
/**
|
|
475
|
+
* @param {{ name: string, value: ConfigValue, origin: string }[]} changes
|
|
476
|
+
* @param {TelemetryConfig} config
|
|
477
|
+
*/
|
|
357
478
|
function updateConfig (changes, config) {
|
|
358
479
|
if (!config.telemetry.enabled) return
|
|
359
480
|
if (changes.length === 0) return
|
|
@@ -361,7 +482,6 @@ function updateConfig (changes, config) {
|
|
|
361
482
|
logger.trace(changes)
|
|
362
483
|
|
|
363
484
|
const application = createAppObject(config)
|
|
364
|
-
const host = createHostObject()
|
|
365
485
|
|
|
366
486
|
const changed = configWithOrigin.size > 0
|
|
367
487
|
|
|
@@ -370,15 +490,16 @@ function updateConfig (changes, config) {
|
|
|
370
490
|
const { origin, value } = change
|
|
371
491
|
const entry = { name, value, origin, seq_id: seqId++ }
|
|
372
492
|
|
|
373
|
-
if (namesNeedFormatting.has(
|
|
374
|
-
entry.value
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
493
|
+
if (namesNeedFormatting.has(name)) {
|
|
494
|
+
// @ts-expect-error entry.value is known to be a map for these config names
|
|
495
|
+
entry.value = formatMapForTelemetry(value)
|
|
496
|
+
} else if (name === 'url') {
|
|
497
|
+
if (value) {
|
|
498
|
+
entry.value = value.toString()
|
|
378
499
|
}
|
|
379
|
-
} else if (
|
|
380
|
-
entry.value = JSON.stringify(
|
|
381
|
-
} else if (Array.isArray(
|
|
500
|
+
} else if (name === 'DD_TRACE_SAMPLING_RULES') {
|
|
501
|
+
entry.value = JSON.stringify(value)
|
|
502
|
+
} else if (Array.isArray(value)) {
|
|
382
503
|
entry.value = value.join(',')
|
|
383
504
|
}
|
|
384
505
|
|
|
@@ -395,6 +516,9 @@ function updateConfig (changes, config) {
|
|
|
395
516
|
}
|
|
396
517
|
}
|
|
397
518
|
|
|
519
|
+
/**
|
|
520
|
+
* @param {TelemetryConfig['profiling']['enabled']} profilingEnabled
|
|
521
|
+
*/
|
|
398
522
|
function profilingEnabledToBoolean (profilingEnabled) {
|
|
399
523
|
if (typeof profilingEnabled === 'boolean') {
|
|
400
524
|
return profilingEnabled
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const Tracer = require('./opentracing/tracer')
|
|
4
3
|
const tags = require('../../../ext/tags')
|
|
4
|
+
const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
|
|
5
|
+
const { flushStartupLogs } = require('../../datadog-instrumentations/src/helpers/check-require-cache')
|
|
6
|
+
const Tracer = require('./opentracing/tracer')
|
|
5
7
|
const Scope = require('./scope')
|
|
6
8
|
const { isError } = require('./util')
|
|
7
9
|
const { setStartupLogConfig } = require('./startup-log')
|
|
8
|
-
const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
|
|
9
10
|
const { DataStreamsCheckpointer, DataStreamsManager, DataStreamsProcessor } = require('./datastreams')
|
|
10
|
-
const { flushStartupLogs } = require('../../datadog-instrumentations/src/helpers/check-require-cache')
|
|
11
11
|
const log = require('./log/writer')
|
|
12
12
|
|
|
13
13
|
const SPAN_TYPE = tags.SPAN_TYPE
|