dd-trace 5.80.0 → 5.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +79 -88
- package/ext/tags.d.ts +1 -0
- package/ext/tags.js +1 -0
- package/index.d.ts +42 -35
- package/loader-hook.mjs +16 -4
- package/package.json +33 -56
- package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
- package/packages/datadog-esbuild/index.js +44 -26
- package/packages/datadog-esbuild/src/utils.js +14 -2
- package/packages/datadog-instrumentations/index.js +1 -0
- package/packages/datadog-instrumentations/src/aerospike.js +3 -2
- package/packages/datadog-instrumentations/src/ai.js +2 -2
- package/packages/datadog-instrumentations/src/amqp10.js +1 -1
- package/packages/datadog-instrumentations/src/amqplib.js +4 -4
- package/packages/datadog-instrumentations/src/anthropic.js +14 -2
- package/packages/datadog-instrumentations/src/apollo-server-core.js +2 -2
- package/packages/datadog-instrumentations/src/apollo-server.js +1 -1
- package/packages/datadog-instrumentations/src/apollo.js +3 -2
- package/packages/datadog-instrumentations/src/avsc.js +1 -1
- package/packages/datadog-instrumentations/src/aws-sdk.js +6 -2
- package/packages/datadog-instrumentations/src/azure-event-hubs.js +4 -3
- package/packages/datadog-instrumentations/src/azure-functions.js +2 -2
- package/packages/datadog-instrumentations/src/azure-service-bus.js +3 -4
- package/packages/datadog-instrumentations/src/bluebird.js +1 -1
- package/packages/datadog-instrumentations/src/bullmq.js +11 -0
- package/packages/datadog-instrumentations/src/bunyan.js +1 -1
- package/packages/datadog-instrumentations/src/cassandra-driver.js +1 -1
- package/packages/datadog-instrumentations/src/child_process.js +2 -2
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +3 -3
- package/packages/datadog-instrumentations/src/couchbase.js +1 -1
- package/packages/datadog-instrumentations/src/crypto.js +1 -1
- package/packages/datadog-instrumentations/src/cucumber.js +12 -13
- package/packages/datadog-instrumentations/src/cypress.js +1 -1
- package/packages/datadog-instrumentations/src/dns.js +1 -1
- package/packages/datadog-instrumentations/src/elasticsearch.js +1 -1
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +1 -1
- package/packages/datadog-instrumentations/src/express.js +1 -1
- package/packages/datadog-instrumentations/src/find-my-way.js +6 -5
- package/packages/datadog-instrumentations/src/fs.js +1 -1
- package/packages/datadog-instrumentations/src/generic-pool.js +1 -1
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +137 -15
- package/packages/datadog-instrumentations/src/google-cloud-vertexai.js +2 -3
- package/packages/datadog-instrumentations/src/google-genai.js +120 -0
- package/packages/datadog-instrumentations/src/graphql.js +21 -1
- package/packages/datadog-instrumentations/src/grpc/client.js +1 -1
- package/packages/datadog-instrumentations/src/grpc/server.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +11 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +12 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +27 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +152 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/bullmq.json +106 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +6 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langchain.js +237 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +11 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +139 -0
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/shared-utils.js +9 -0
- package/packages/datadog-instrumentations/src/hono.js +55 -10
- package/packages/datadog-instrumentations/src/ioredis.js +1 -1
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +2 -2
- package/packages/datadog-instrumentations/src/kafkajs.js +3 -3
- package/packages/datadog-instrumentations/src/knex.js +1 -1
- package/packages/datadog-instrumentations/src/langchain.js +3 -109
- package/packages/datadog-instrumentations/src/ldapjs.js +1 -1
- package/packages/datadog-instrumentations/src/light-my-request.js +93 -0
- package/packages/datadog-instrumentations/src/limitd-client.js +1 -1
- package/packages/datadog-instrumentations/src/lodash.js +1 -2
- package/packages/datadog-instrumentations/src/mariadb.js +1 -2
- package/packages/datadog-instrumentations/src/memcached.js +1 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +1 -1
- package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
- package/packages/datadog-instrumentations/src/mongodb.js +1 -1
- package/packages/datadog-instrumentations/src/mongoose.js +1 -1
- package/packages/datadog-instrumentations/src/mquery.js +1 -1
- package/packages/datadog-instrumentations/src/mysql.js +1 -1
- package/packages/datadog-instrumentations/src/mysql2.js +2 -2
- package/packages/datadog-instrumentations/src/net.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +1 -1
- package/packages/datadog-instrumentations/src/nyc.js +1 -1
- package/packages/datadog-instrumentations/src/openai.js +2 -2
- package/packages/datadog-instrumentations/src/opensearch.js +1 -1
- package/packages/datadog-instrumentations/src/oracledb.js +1 -1
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +1 -1
- package/packages/datadog-instrumentations/src/pg.js +3 -3
- package/packages/datadog-instrumentations/src/pino.js +1 -1
- package/packages/datadog-instrumentations/src/playwright.js +46 -17
- package/packages/datadog-instrumentations/src/prisma.js +52 -37
- package/packages/datadog-instrumentations/src/process.js +1 -1
- package/packages/datadog-instrumentations/src/promise-js.js +1 -1
- package/packages/datadog-instrumentations/src/promise.js +1 -1
- package/packages/datadog-instrumentations/src/protobufjs.js +1 -1
- package/packages/datadog-instrumentations/src/q.js +1 -1
- package/packages/datadog-instrumentations/src/redis.js +1 -1
- package/packages/datadog-instrumentations/src/rhea.js +1 -1
- package/packages/datadog-instrumentations/src/router.js +1 -1
- package/packages/datadog-instrumentations/src/selenium.js +4 -2
- package/packages/datadog-instrumentations/src/sequelize.js +1 -2
- package/packages/datadog-instrumentations/src/sharedb.js +1 -1
- package/packages/datadog-instrumentations/src/tedious.js +1 -1
- package/packages/datadog-instrumentations/src/undici.js +4 -4
- package/packages/datadog-instrumentations/src/url.js +1 -1
- package/packages/datadog-instrumentations/src/vitest.js +1 -1
- package/packages/datadog-instrumentations/src/vm.js +1 -1
- package/packages/datadog-instrumentations/src/when.js +1 -1
- package/packages/datadog-instrumentations/src/winston.js +1 -1
- package/packages/datadog-instrumentations/src/ws.js +38 -19
- package/packages/datadog-plugin-amqp10/src/index.js +1 -1
- package/packages/datadog-plugin-amqplib/src/index.js +1 -1
- package/packages/datadog-plugin-anthropic/src/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +4 -4
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/util.js +3 -3
- package/packages/datadog-plugin-azure-event-hubs/src/index.js +1 -1
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +19 -5
- package/packages/datadog-plugin-azure-service-bus/src/index.js +1 -1
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +4 -0
- package/packages/datadog-plugin-bullmq/src/consumer.js +60 -0
- package/packages/datadog-plugin-bullmq/src/index.js +18 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +178 -0
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +23 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +2 -2
- package/packages/datadog-plugin-cypress/src/support.js +73 -31
- package/packages/datadog-plugin-express/src/index.js +1 -1
- package/packages/datadog-plugin-fastify/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +13 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +171 -12
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +160 -13
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +217 -0
- package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +1 -1
- package/packages/datadog-plugin-google-genai/src/index.js +17 -0
- package/packages/datadog-plugin-google-genai/src/tracing.js +41 -0
- package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +5 -4
- package/packages/datadog-plugin-grpc/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/client.js +2 -1
- package/packages/datadog-plugin-http/src/index.js +25 -5
- package/packages/datadog-plugin-http2/src/client.js +2 -2
- package/packages/datadog-plugin-http2/src/index.js +1 -1
- package/packages/datadog-plugin-jest/src/util.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
- package/packages/datadog-plugin-langchain/src/index.js +1 -1
- package/packages/datadog-plugin-langchain/src/tracing.js +7 -3
- package/packages/datadog-plugin-moleculer/src/index.js +1 -1
- package/packages/datadog-plugin-mongodb-core/src/index.js +6 -2
- package/packages/datadog-plugin-next/src/index.js +11 -3
- package/packages/datadog-plugin-openai/src/index.js +1 -1
- package/packages/datadog-plugin-openai/src/stream-helpers.js +30 -10
- package/packages/datadog-plugin-openai/src/tracing.js +2 -2
- package/packages/datadog-plugin-rhea/src/index.js +1 -1
- package/packages/datadog-plugin-ws/src/close.js +56 -3
- package/packages/datadog-plugin-ws/src/index.js +4 -0
- package/packages/datadog-plugin-ws/src/producer.js +39 -4
- package/packages/datadog-plugin-ws/src/receiver.js +39 -3
- package/packages/datadog-plugin-ws/src/server.js +13 -1
- package/packages/datadog-plugin-ws/src/util.js +107 -0
- package/packages/datadog-shimmer/src/shimmer.js +2 -2
- package/packages/dd-trace/src/aiguard/sdk.js +21 -13
- package/packages/dd-trace/src/appsec/api_security_sampler.js +1 -1
- package/packages/dd-trace/src/appsec/graphql.js +2 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/code-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/command-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/ldap-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +3 -3
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/untrusted-deserialization-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/unvalidated-redirect-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-cipher-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-hash-analyzer.js +3 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-randomness-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
- package/packages/dd-trace/src/appsec/iast/index.js +5 -5
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +1 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +11 -16
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +4 -4
- package/packages/dd-trace/src/appsec/index.js +8 -8
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +1 -1
- package/packages/dd-trace/src/appsec/rasp/index.js +1 -1
- package/packages/dd-trace/src/appsec/rasp/lfi.js +1 -1
- package/packages/dd-trace/src/appsec/rc-products.js +10 -0
- package/packages/dd-trace/src/appsec/recommended.json +230 -3
- package/packages/dd-trace/src/appsec/remote_config.js +177 -0
- package/packages/dd-trace/src/appsec/reporter.js +3 -7
- package/packages/dd-trace/src/appsec/rule_manager.js +37 -20
- package/packages/dd-trace/src/appsec/sdk/index.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +2 -2
- package/packages/dd-trace/src/appsec/user_tracking.js +2 -2
- package/packages/dd-trace/src/appsec/waf/index.js +17 -3
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +11 -0
- package/packages/dd-trace/src/azure_metadata.js +8 -2
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +8 -6
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +4 -2
- package/packages/dd-trace/src/config/remote_config.js +34 -0
- package/packages/dd-trace/src/config.js +109 -34
- package/packages/dd-trace/src/config_defaults.js +16 -3
- package/packages/dd-trace/src/constants.js +5 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +10 -1
- package/packages/dd-trace/src/datastreams/checkpointer.js +2 -2
- package/packages/dd-trace/src/datastreams/encoding.js +23 -6
- package/packages/dd-trace/src/datastreams/index.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +41 -2
- package/packages/dd-trace/src/datastreams/processor.js +3 -3
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -1
- package/packages/dd-trace/src/datastreams/writer.js +2 -2
- package/packages/dd-trace/src/debugger/config.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +15 -5
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/index.js +37 -17
- package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +24 -18
- package/packages/dd-trace/src/debugger/devtools_client/send.js +21 -11
- package/packages/dd-trace/src/debugger/devtools_client/session.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +103 -15
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/constants.js +25 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +56 -25
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +64 -23
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +404 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +8 -3
- package/packages/dd-trace/src/debugger/devtools_client/status.js +3 -3
- package/packages/dd-trace/src/debugger/index.js +2 -2
- package/packages/dd-trace/src/dogstatsd.js +3 -2
- package/packages/dd-trace/src/encode/0.4.js +1 -1
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +2 -2
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
- package/packages/dd-trace/src/encode/span-stats.js +13 -2
- package/packages/dd-trace/src/exporter.js +2 -2
- package/packages/dd-trace/src/exporters/agent/index.js +1 -1
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +1 -1
- package/packages/dd-trace/src/exporters/common/request.js +2 -2
- package/packages/dd-trace/src/exporters/common/writer.js +1 -1
- package/packages/dd-trace/src/exporters/span-stats/index.js +1 -1
- package/packages/dd-trace/src/external-logger/src/index.js +1 -2
- package/packages/dd-trace/src/flare/index.js +1 -1
- package/packages/dd-trace/src/guardrails/index.js +6 -3
- package/packages/dd-trace/src/histogram.js +1 -1
- package/packages/dd-trace/src/id.js +60 -0
- package/packages/dd-trace/src/index.js +1 -1
- package/packages/dd-trace/src/lambda/handler.js +4 -4
- package/packages/dd-trace/src/lambda/index.js +1 -1
- package/packages/dd-trace/src/lambda/runtime/patch.js +4 -4
- package/packages/dd-trace/src/lambda/runtime/ritm.js +2 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +8 -1
- package/packages/dd-trace/src/llmobs/index.js +8 -9
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +38 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +30 -9
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +3 -3
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +104 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +486 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/llm.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +2 -2
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +16 -0
- package/packages/dd-trace/src/llmobs/plugins/{openai.js → openai/index.js} +63 -6
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +126 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +20 -22
- package/packages/dd-trace/src/llmobs/span_processor.js +15 -14
- package/packages/dd-trace/src/llmobs/tagger.js +4 -0
- package/packages/dd-trace/src/llmobs/telemetry.js +3 -4
- package/packages/dd-trace/src/llmobs/writers/base.js +2 -2
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -2
- package/packages/dd-trace/src/log/index.js +1 -1
- package/packages/dd-trace/src/noop/proxy.js +2 -2
- package/packages/dd-trace/src/noop/span.js +1 -1
- package/packages/dd-trace/src/openfeature/index.js +2 -2
- package/packages/dd-trace/src/openfeature/noop.js +14 -14
- package/packages/dd-trace/src/openfeature/remote_config.js +31 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +5 -5
- package/packages/dd-trace/src/openfeature/writers/exposures.js +9 -9
- package/packages/dd-trace/src/opentelemetry/context_manager.js +2 -2
- package/packages/dd-trace/src/opentelemetry/logs/index.js +2 -2
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +3 -2
- package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +4 -4
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +5 -3
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +17 -16
- package/packages/dd-trace/src/opentelemetry/metrics/constants.js +34 -0
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +81 -0
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +225 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +171 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +54 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +62 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +251 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +557 -0
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +10 -18
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +47 -32
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +1 -1
- package/packages/dd-trace/src/opentelemetry/span.js +3 -3
- package/packages/dd-trace/src/opentelemetry/tracer.js +4 -4
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +1 -1
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +24 -8
- package/packages/dd-trace/src/opentracing/span.js +3 -3
- package/packages/dd-trace/src/opentracing/tracer.js +5 -5
- package/packages/dd-trace/src/payload-tagging/index.js +8 -4
- package/packages/dd-trace/src/plugin_manager.js +5 -3
- package/packages/dd-trace/src/plugins/apollo.js +1 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +27 -27
- package/packages/dd-trace/src/plugins/database.js +1 -1
- package/packages/dd-trace/src/plugins/index.js +6 -1
- package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
- package/packages/dd-trace/src/plugins/outbound.js +1 -1
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +1 -1
- package/packages/dd-trace/src/plugins/util/git.js +8 -8
- package/packages/dd-trace/src/plugins/util/stacktrace.js +1 -1
- package/packages/dd-trace/src/plugins/util/test.js +27 -27
- package/packages/dd-trace/src/plugins/util/url.js +119 -1
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +1 -1
- package/packages/dd-trace/src/plugins/util/web.js +18 -46
- package/packages/dd-trace/src/priority_sampler.js +15 -16
- package/packages/dd-trace/src/process-tags/index.js +83 -0
- package/packages/dd-trace/src/profiling/config.js +33 -22
- package/packages/dd-trace/src/profiling/exporter_cli.js +4 -4
- package/packages/dd-trace/src/profiling/exporters/agent.js +5 -5
- package/packages/dd-trace/src/profiling/index.js +1 -1
- package/packages/dd-trace/src/profiling/libuv-size.js +1 -1
- package/packages/dd-trace/src/profiling/profiler.js +4 -5
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +11 -2
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/proxy.js +17 -18
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/index.js +541 -137
- package/packages/dd-trace/src/require-package-json.js +1 -1
- package/packages/dd-trace/src/ritm.js +50 -27
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +1 -1
- package/packages/dd-trace/src/serverless.js +16 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +4 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +4 -0
- package/packages/dd-trace/src/span_format.js +10 -5
- package/packages/dd-trace/src/span_processor.js +8 -3
- package/packages/dd-trace/src/span_stats.js +21 -8
- package/packages/dd-trace/src/spanleak.js +1 -1
- package/packages/dd-trace/src/standalone/index.js +1 -1
- package/packages/dd-trace/src/startup-log.js +3 -3
- package/packages/dd-trace/src/supported-configurations.json +16 -0
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -4
- package/packages/dd-trace/src/telemetry/endpoints.js +8 -8
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +22 -8
- package/packages/dd-trace/src/tracer.js +3 -3
- package/packages/dd-trace/src/tracer_metadata.js +19 -15
- package/vendor/dist/@datadog/sketches-js/LICENSE +39 -0
- package/vendor/dist/@datadog/sketches-js/index.js +1 -0
- package/vendor/dist/@datadog/source-map/LICENSE +28 -0
- package/vendor/dist/@datadog/source-map/index.js +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +55 -0
- package/vendor/dist/@isaacs/ttlcache/index.js +1 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/core/index.js +1 -0
- package/vendor/dist/@opentelemetry/resources/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/resources/index.js +1 -0
- package/vendor/dist/astring/LICENSE +19 -0
- package/vendor/dist/astring/index.js +1 -0
- package/vendor/dist/crypto-randomuuid/index.js +1 -0
- package/vendor/dist/escape-string-regexp/LICENSE +9 -0
- package/vendor/dist/escape-string-regexp/index.js +1 -0
- package/vendor/dist/esquery/LICENSE +24 -0
- package/vendor/dist/esquery/index.js +1 -0
- package/vendor/dist/ignore/LICENSE +21 -0
- package/vendor/dist/ignore/index.js +1 -0
- package/vendor/dist/istanbul-lib-coverage/LICENSE +24 -0
- package/vendor/dist/istanbul-lib-coverage/index.js +1 -0
- package/vendor/dist/jest-docblock/LICENSE +21 -0
- package/vendor/dist/jest-docblock/index.js +1 -0
- package/vendor/dist/jsonpath-plus/LICENSE +22 -0
- package/vendor/dist/jsonpath-plus/index.js +1 -0
- package/vendor/dist/limiter/LICENSE +19 -0
- package/vendor/dist/limiter/index.js +1 -0
- package/vendor/dist/lodash.sortby/LICENSE +47 -0
- package/vendor/dist/lodash.sortby/index.js +1 -0
- package/vendor/dist/lru-cache/LICENSE +15 -0
- package/vendor/dist/lru-cache/index.js +1 -0
- package/vendor/dist/meriyah/LICENSE +7 -0
- package/vendor/dist/meriyah/index.js +1 -0
- package/vendor/dist/module-details-from-path/LICENSE +21 -0
- package/vendor/dist/module-details-from-path/index.js +1 -0
- package/vendor/dist/mutexify/promise/LICENSE +21 -0
- package/vendor/dist/mutexify/promise/index.js +1 -0
- package/vendor/dist/opentracing/LICENSE +201 -0
- package/vendor/dist/opentracing/binary_carrier.d.ts +11 -0
- package/vendor/dist/opentracing/constants.d.ts +61 -0
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +2 -0
- package/vendor/dist/opentracing/ext/tags.d.ts +90 -0
- package/vendor/dist/opentracing/functions.d.ts +20 -0
- package/vendor/dist/opentracing/global_tracer.d.ts +14 -0
- package/vendor/dist/opentracing/index.d.ts +12 -0
- package/vendor/dist/opentracing/index.js +1 -0
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +5 -0
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +13 -0
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +16 -0
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +50 -0
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +26 -0
- package/vendor/dist/opentracing/noop.d.ts +8 -0
- package/vendor/dist/opentracing/reference.d.ts +33 -0
- package/vendor/dist/opentracing/span.d.ts +147 -0
- package/vendor/dist/opentracing/span_context.d.ts +26 -0
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +16 -0
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +3 -0
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +4 -0
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +3 -0
- package/vendor/dist/opentracing/test/unittest.d.ts +2 -0
- package/vendor/dist/opentracing/tracer.d.ts +127 -0
- package/vendor/dist/path-to-regexp/LICENSE +21 -0
- package/vendor/dist/path-to-regexp/index.js +1 -0
- package/vendor/dist/pprof-format/LICENSE +8 -0
- package/vendor/dist/pprof-format/index.js +1 -0
- package/vendor/dist/protobufjs/LICENSE +39 -0
- package/vendor/dist/protobufjs/index.js +1 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +39 -0
- package/vendor/dist/protobufjs/minimal/index.js +1 -0
- package/vendor/dist/retry/LICENSE +21 -0
- package/vendor/dist/retry/index.js +1 -0
- package/vendor/dist/rfdc/LICENSE +15 -0
- package/vendor/dist/rfdc/index.js +1 -0
- package/vendor/dist/semifies/LICENSE +201 -0
- package/vendor/dist/semifies/index.js +1 -0
- package/vendor/dist/shell-quote/LICENSE +24 -0
- package/vendor/dist/shell-quote/index.js +1 -0
- package/vendor/dist/source-map/LICENSE +28 -0
- package/vendor/dist/source-map/index.js +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +28 -0
- package/vendor/dist/source-map/lib/util/index.js +1 -0
- package/vendor/dist/source-map/mappings.wasm +0 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +21 -0
- package/vendor/dist/tlhunter-sorted-set/index.js +1 -0
- package/vendor/dist/ttl-set/LICENSE +21 -0
- package/vendor/dist/ttl-set/index.js +1 -0
- package/packages/dd-trace/src/remote_config/manager.js +0 -368
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const RemoteConfigCapabilities = require('../remote_config/capabilities')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configures remote config handlers for openfeature feature flagging
|
|
7
|
+
*
|
|
8
|
+
* @param {object} rc - RemoteConfig instance
|
|
9
|
+
* @param {object} config - Tracer config
|
|
10
|
+
* @param {Function} getOpenfeatureProxy - Function that returns the OpenFeature proxy from tracer
|
|
11
|
+
*/
|
|
12
|
+
function enable (rc, config, getOpenfeatureProxy) {
|
|
13
|
+
// Always enable capability for feature flag configuration
|
|
14
|
+
// This indicates the library supports this capability via remote config
|
|
15
|
+
rc.updateCapabilities(RemoteConfigCapabilities.FFE_FLAG_CONFIGURATION_RULES, true)
|
|
16
|
+
|
|
17
|
+
// Only register product handler if the experimental feature is enabled
|
|
18
|
+
if (!config.experimental.flaggingProvider.enabled) return
|
|
19
|
+
|
|
20
|
+
// Set product handler for FFE_FLAGS
|
|
21
|
+
rc.setProductHandler('FFE_FLAGS', (action, conf) => {
|
|
22
|
+
// Feed UFC config directly to OpenFeature provider
|
|
23
|
+
if (action === 'apply' || action === 'modify') {
|
|
24
|
+
getOpenfeatureProxy()._setConfiguration(conf)
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
enable
|
|
31
|
+
}
|
|
@@ -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
|
/**
|
|
@@ -67,7 +67,7 @@ class BaseFFEWriter {
|
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Appends an event array to the buffer
|
|
70
|
-
* @param {Array|
|
|
70
|
+
* @param {Array | object} events - Event object(s) to append to buffer
|
|
71
71
|
*/
|
|
72
72
|
append (events) {
|
|
73
73
|
const eventArray = Array.isArray(events) ? events : [events]
|
|
@@ -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 () {
|
|
@@ -70,8 +70,8 @@ function initializeOpenTelemetryLogs (config) {
|
|
|
70
70
|
// Create batch processor for exporting logs to Datadog Agent
|
|
71
71
|
const processor = new BatchLogRecordProcessor(
|
|
72
72
|
exporter,
|
|
73
|
-
config.
|
|
74
|
-
config.
|
|
73
|
+
config.otelBatchTimeout,
|
|
74
|
+
config.otelMaxExportBatchSize
|
|
75
75
|
)
|
|
76
76
|
|
|
77
77
|
// Create logger provider with processor for Datadog Agent export
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { sanitizeAttributes } = require('@opentelemetry/core')
|
|
4
3
|
const { context } = require('@opentelemetry/api')
|
|
5
|
-
const
|
|
4
|
+
const { sanitizeAttributes } = require('../../../../../vendor/dist/@opentelemetry/core')
|
|
5
|
+
const { VERSION: packageVersion } = require('../../../../../version')
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* @typedef {import('@opentelemetry/api-logs').LogRecord} LogRecord
|
|
8
9
|
* @typedef {import('@opentelemetry/api-logs').LoggerProvider} LoggerProvider
|
|
@@ -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 = {}) {
|
|
@@ -11,7 +11,7 @@ const OtlpTransformer = require('./otlp_transformer')
|
|
|
11
11
|
/**
|
|
12
12
|
* OtlpHttpLogExporter exports log records via OTLP over HTTP.
|
|
13
13
|
*
|
|
14
|
-
* This implementation follows the OTLP HTTP specification:
|
|
14
|
+
* This implementation follows the OTLP HTTP v1.7.0 specification:
|
|
15
15
|
* https://opentelemetry.io/docs/specs/otlp/#otlphttp
|
|
16
16
|
*
|
|
17
17
|
* @class OtlpHttpLogExporter
|
|
@@ -37,6 +37,8 @@ class OtlpHttpLogExporter extends OtlpHttpExporterBase {
|
|
|
37
37
|
*
|
|
38
38
|
* @param {LogRecord[]} logRecords - Array of enriched log records to export
|
|
39
39
|
* @param {Function} resultCallback - Callback function for export result
|
|
40
|
+
*
|
|
41
|
+
* @returns {void}
|
|
40
42
|
*/
|
|
41
43
|
export (logRecords, resultCallback) {
|
|
42
44
|
if (logRecords.length === 0) {
|
|
@@ -45,8 +47,8 @@ class OtlpHttpLogExporter extends OtlpHttpExporterBase {
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
const payload = this.transformer.transformLogRecords(logRecords)
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
50
|
+
this.sendPayload(payload, resultCallback)
|
|
51
|
+
this.recordTelemetry('otel.log_records', logRecords.length)
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -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
|
*/
|
|
@@ -40,7 +41,7 @@ const SEVERITY_MAP = {
|
|
|
40
41
|
/**
|
|
41
42
|
* OtlpTransformer transforms log records to OTLP format.
|
|
42
43
|
*
|
|
43
|
-
* This implementation follows the OTLP Logs Data Model specification:
|
|
44
|
+
* This implementation follows the OTLP Logs v1.7.0 Data Model specification:
|
|
44
45
|
* https://opentelemetry.io/docs/specs/otlp/#log-data-model
|
|
45
46
|
*
|
|
46
47
|
* @class OtlpTransformer
|
|
@@ -79,12 +80,12 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
79
80
|
|
|
80
81
|
const logsData = {
|
|
81
82
|
resourceLogs: [{
|
|
82
|
-
resource: this.
|
|
83
|
+
resource: this.transformResource(),
|
|
83
84
|
scopeLogs: this.#transformScope(logRecords),
|
|
84
85
|
}]
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
return this.
|
|
88
|
+
return this.serializeToProtobuf(protoLogsService, logsData)
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
/**
|
|
@@ -95,20 +96,20 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
95
96
|
#transformToJson (logRecords) {
|
|
96
97
|
const logsData = {
|
|
97
98
|
resourceLogs: [{
|
|
98
|
-
resource: this.
|
|
99
|
+
resource: this.transformResource(),
|
|
99
100
|
scopeLogs: this.#transformScope(logRecords)
|
|
100
101
|
}]
|
|
101
102
|
}
|
|
102
|
-
return this.
|
|
103
|
+
return this.serializeToJson(logsData)
|
|
103
104
|
}
|
|
104
105
|
|
|
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
|
-
const groupedRecords = this.
|
|
112
|
+
const groupedRecords = this.groupByInstrumentationScope(logRecords)
|
|
112
113
|
const scopeLogs = []
|
|
113
114
|
|
|
114
115
|
for (const records of groupedRecords.values()) {
|
|
@@ -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)
|
|
@@ -155,7 +156,7 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
if (logRecord.attributes) {
|
|
158
|
-
result.attributes = this.
|
|
159
|
+
result.attributes = this.transformAttributes(logRecord.attributes)
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
if (spanContext?.traceFlags !== undefined) {
|
|
@@ -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') {
|
|
@@ -232,7 +233,7 @@ class OtlpTransformer extends OtlpTransformerBase {
|
|
|
232
233
|
kvlistValue: {
|
|
233
234
|
values: Object.entries(body).map(([key, value]) => ({
|
|
234
235
|
key,
|
|
235
|
-
value: this.
|
|
236
|
+
value: this.transformAnyValue(value)
|
|
236
237
|
}))
|
|
237
238
|
}
|
|
238
239
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Metric type constants
|
|
4
|
+
const METRIC_TYPES = {
|
|
5
|
+
HISTOGRAM: 'histogram',
|
|
6
|
+
COUNTER: 'counter',
|
|
7
|
+
UPDOWNCOUNTER: 'updowncounter',
|
|
8
|
+
OBSERVABLECOUNTER: 'observable-counter',
|
|
9
|
+
OBSERVABLEUPDOWNCOUNTER: 'observable-updowncounter',
|
|
10
|
+
GAUGE: 'gauge'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Temporality constants
|
|
14
|
+
const TEMPORALITY = {
|
|
15
|
+
DELTA: 'DELTA',
|
|
16
|
+
CUMULATIVE: 'CUMULATIVE',
|
|
17
|
+
GAUGE: 'GAUGE',
|
|
18
|
+
LOWMEMORY: 'LOWMEMORY'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Default histogram bucket boundaries (in milliseconds for latency metrics)
|
|
22
|
+
const DEFAULT_HISTOGRAM_BUCKETS = [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10_000]
|
|
23
|
+
|
|
24
|
+
// Maximum number of measurements to queue before dropping
|
|
25
|
+
// This limit corresponds to the maximum number of items
|
|
26
|
+
// that be reliably added to a single Array.
|
|
27
|
+
const DEFAULT_MAX_MEASUREMENT_QUEUE_SIZE = 65_536
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
METRIC_TYPES,
|
|
31
|
+
TEMPORALITY,
|
|
32
|
+
DEFAULT_HISTOGRAM_BUCKETS,
|
|
33
|
+
DEFAULT_MAX_MEASUREMENT_QUEUE_SIZE
|
|
34
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const os = require('os')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {import('../../config')} Config
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @file OpenTelemetry Metrics Implementation for dd-trace-js
|
|
11
|
+
*
|
|
12
|
+
* This package provides a custom OpenTelemetry Metrics implementation that integrates
|
|
13
|
+
* with the Datadog tracing library. It includes all necessary components for
|
|
14
|
+
* creating instruments, recording measurements, and exporting metrics via OTLP.
|
|
15
|
+
*
|
|
16
|
+
* Key Components:
|
|
17
|
+
* - MeterProvider: Main entry point for creating meters
|
|
18
|
+
* - Meter: Provides methods to create metric instruments
|
|
19
|
+
* - Instruments: Gauge, Counter, UpDownCounter, ObservableGauge, ObservableCounter, ObservableUpDownCounter, Histogram
|
|
20
|
+
* - PeriodicMetricReader: Collects and exports instruments (metrics) at regular intervals
|
|
21
|
+
* - OtlpHttpMetricExporter: Exports instruments (metrics) via OTLP over HTTP
|
|
22
|
+
* - OtlpTransformer: Transforms instruments (metrics) to OTLP format
|
|
23
|
+
*
|
|
24
|
+
* This is a custom implementation to avoid pulling in the full OpenTelemetry SDK,
|
|
25
|
+
* based on OTLP Protocol v1.7.0. It supports both protobuf and JSON serialization
|
|
26
|
+
* formats and integrates with Datadog's configuration system.
|
|
27
|
+
*
|
|
28
|
+
* @package
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const { metrics } = require('@opentelemetry/api')
|
|
32
|
+
const MeterProvider = require('./meter_provider')
|
|
33
|
+
const PeriodicMetricReader = require('./periodic_metric_reader')
|
|
34
|
+
const OtlpHttpMetricExporter = require('./otlp_http_metric_exporter')
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Initializes OpenTelemetry Metrics support
|
|
38
|
+
* @param {Config} config - Tracer configuration instance
|
|
39
|
+
*/
|
|
40
|
+
function initializeOpenTelemetryMetrics (config) {
|
|
41
|
+
const resourceAttributes = {
|
|
42
|
+
'service.name': config.service,
|
|
43
|
+
'service.version': config.version,
|
|
44
|
+
'deployment.environment': config.env
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (config.tags) {
|
|
48
|
+
const filteredTags = { ...config.tags }
|
|
49
|
+
delete filteredTags.service
|
|
50
|
+
delete filteredTags.version
|
|
51
|
+
delete filteredTags.env
|
|
52
|
+
Object.assign(resourceAttributes, filteredTags)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (config.reportHostname) {
|
|
56
|
+
resourceAttributes['host.name'] = os.hostname()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const exporter = new OtlpHttpMetricExporter(
|
|
60
|
+
config.otelMetricsUrl,
|
|
61
|
+
config.otelMetricsHeaders,
|
|
62
|
+
config.otelMetricsTimeout,
|
|
63
|
+
config.otelMetricsProtocol,
|
|
64
|
+
resourceAttributes
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
const reader = new PeriodicMetricReader(
|
|
68
|
+
exporter,
|
|
69
|
+
config.otelMetricsExportInterval,
|
|
70
|
+
config.otelMetricsTemporalityPreference,
|
|
71
|
+
config.otelMaxQueueSize
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const meterProvider = new MeterProvider({ reader })
|
|
75
|
+
metrics.setGlobalMeterProvider(meterProvider)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = {
|
|
79
|
+
MeterProvider,
|
|
80
|
+
initializeOpenTelemetryMetrics
|
|
81
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { sanitizeAttributes } = require('../../../../../vendor/dist/@opentelemetry/core')
|
|
4
|
+
const { METRIC_TYPES } = require('./constants')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import('@opentelemetry/api').Attributes} Attributes
|
|
8
|
+
* @typedef {import('@opentelemetry/core').InstrumentationScope} InstrumentationScope
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {object} Measurement
|
|
13
|
+
* @property {string} name - Instrument name
|
|
14
|
+
* @property {string} description - Instrument description
|
|
15
|
+
* @property {string} unit - Measurement unit
|
|
16
|
+
* @property {InstrumentationScope} instrumentationScope - Instrumentation scope
|
|
17
|
+
* @property {string} type - Metric type from METRIC_TYPES
|
|
18
|
+
* @property {number} value - Measured value
|
|
19
|
+
* @property {Attributes} attributes - Sanitized metric attributes
|
|
20
|
+
* @property {number} timestamp - Timestamp in nanoseconds
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Base class for all metric instruments.
|
|
25
|
+
*
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
class Instrument {
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new instrument instance.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} name - Instrument name (e.g., 'http.request.duration')
|
|
33
|
+
* @param {object} options - Instrument configuration options
|
|
34
|
+
* @param {string} [options.description] - Human-readable description of the instrument
|
|
35
|
+
* @param {string} [options.unit] - Unit of measurement (e.g., 'ms', 'bytes', '1')
|
|
36
|
+
* @param {InstrumentationScope} instrumentationScope - Instrumentation scope for this instrument
|
|
37
|
+
* @param {object} reader - Metric reader for recording measurements
|
|
38
|
+
*/
|
|
39
|
+
constructor (name, options, instrumentationScope, reader) {
|
|
40
|
+
this.name = name
|
|
41
|
+
this.description = options.description ?? ''
|
|
42
|
+
this.unit = options.unit ?? ''
|
|
43
|
+
this.valueType = options.valueType // currently ignored, TODO: add support for ValueType
|
|
44
|
+
this.advice = options.advice // currently ignored, TODO: add support for MetricAdvice
|
|
45
|
+
this.instrumentationScope = instrumentationScope
|
|
46
|
+
this.reader = reader
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a measurement object for recording metric values.
|
|
51
|
+
* @param {string} type - Metric type from METRIC_TYPES
|
|
52
|
+
* @param {number} value - Numeric value to record
|
|
53
|
+
* @param {Attributes} attributes - Key-value pairs for metric dimensions
|
|
54
|
+
* @returns {Measurement} Measurement object with metadata and timestamp
|
|
55
|
+
*/
|
|
56
|
+
createMeasurement (type, value, attributes) {
|
|
57
|
+
return {
|
|
58
|
+
name: this.name,
|
|
59
|
+
description: this.description,
|
|
60
|
+
unit: this.unit,
|
|
61
|
+
instrumentationScope: this.instrumentationScope,
|
|
62
|
+
type,
|
|
63
|
+
value,
|
|
64
|
+
attributes: sanitizeAttributes(attributes),
|
|
65
|
+
timestamp: Number(process.hrtime.bigint())
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Implementation of the OpenTelemetry Counter interface:
|
|
72
|
+
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api._opentelemetry_api.Counter.html
|
|
73
|
+
* @class Counter
|
|
74
|
+
*/
|
|
75
|
+
class Counter extends Instrument {
|
|
76
|
+
add (value, attributes = {}) {
|
|
77
|
+
if (value < 0) return
|
|
78
|
+
this.reader?.record(this.createMeasurement(METRIC_TYPES.COUNTER, value, attributes))
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Implementation of the OpenTelemetry UpDownCounter interface:
|
|
84
|
+
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api._opentelemetry_api.UpDownCounter.html
|
|
85
|
+
* @class UpDownCounter
|
|
86
|
+
*/
|
|
87
|
+
class UpDownCounter extends Instrument {
|
|
88
|
+
add (value, attributes = {}) {
|
|
89
|
+
this.reader?.record(this.createMeasurement(METRIC_TYPES.UPDOWNCOUNTER, value, attributes))
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Implementation of the OpenTelemetry Histogram interface:
|
|
95
|
+
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api._opentelemetry_api.Histogram.html
|
|
96
|
+
* @class Histogram
|
|
97
|
+
*/
|
|
98
|
+
class Histogram extends Instrument {
|
|
99
|
+
record (value, attributes = {}) {
|
|
100
|
+
if (value < 0) return
|
|
101
|
+
this.reader?.record(this.createMeasurement(METRIC_TYPES.HISTOGRAM, value, attributes))
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Implementation of the OpenTelemetry Gauge interface:
|
|
107
|
+
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api._opentelemetry_api.Gauge.html
|
|
108
|
+
* @class Gauge
|
|
109
|
+
*/
|
|
110
|
+
class Gauge extends Instrument {
|
|
111
|
+
record (value, attributes = {}) {
|
|
112
|
+
this.reader?.record(this.createMeasurement(METRIC_TYPES.GAUGE, value, attributes))
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Base class for observable (asynchronous) instruments.
|
|
118
|
+
* Implementation of the OpenTelemetry Observable interface:
|
|
119
|
+
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api._opentelemetry_api.Observable.html
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
class ObservableInstrument extends Instrument {
|
|
123
|
+
#callbacks = []
|
|
124
|
+
#type
|
|
125
|
+
|
|
126
|
+
constructor (name, options, instrumentationScope, reader, type) {
|
|
127
|
+
super(name, options, instrumentationScope, reader)
|
|
128
|
+
this.#type = type
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Adds a callback to invoke during metric collection.
|
|
133
|
+
*
|
|
134
|
+
* @param {Function} callback - Receives an ObservableResult to record observations
|
|
135
|
+
*/
|
|
136
|
+
addCallback (callback) {
|
|
137
|
+
if (typeof callback !== 'function') return
|
|
138
|
+
this.#callbacks.push(callback)
|
|
139
|
+
this.reader?.observableInstruments.add(this)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Removes a callback.
|
|
144
|
+
*
|
|
145
|
+
* @param {Function} callback - The callback to remove
|
|
146
|
+
*/
|
|
147
|
+
removeCallback (callback) {
|
|
148
|
+
const index = this.#callbacks.indexOf(callback)
|
|
149
|
+
if (index !== -1) {
|
|
150
|
+
this.#callbacks.splice(index, 1)
|
|
151
|
+
if (this.#callbacks.length === 0) {
|
|
152
|
+
// Remove instrument from collection when no callbacks remain
|
|
153
|
+
this.reader?.observableInstruments.delete(this)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Collects observations from all callbacks. Errors are silently ignored.
|
|
160
|
+
*
|
|
161
|
+
* @returns {Array<Measurement>} Array of measurements
|
|
162
|
+
*/
|
|
163
|
+
collect () {
|
|
164
|
+
const observations = []
|
|
165
|
+
const observableResult = {
|
|
166
|
+
observe: (value, attributes = {}) => {
|
|
167
|
+
observations.push(this.createMeasurement(this.#type, value, attributes))
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
for (const callback of this.#callbacks) {
|
|
172
|
+
try {
|
|
173
|
+
callback(observableResult)
|
|
174
|
+
} catch {
|
|
175
|
+
// Ignore callback errors per OpenTelemetry spec to prevent disruption
|
|
176
|
+
// Errors are swallowed as callbacks should not break metric collection
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return observations
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Implementation of the OpenTelemetry ObservableGauge interface:
|
|
186
|
+
* https://open-telemetry.github.io/opentelemetry-js/types/_opentelemetry_api._opentelemetry_api.ObservableGauge.html
|
|
187
|
+
* @class ObservableGauge
|
|
188
|
+
*/
|
|
189
|
+
class ObservableGauge extends ObservableInstrument {
|
|
190
|
+
constructor (name, options, instrumentationScope, reader) {
|
|
191
|
+
super(name, options, instrumentationScope, reader, METRIC_TYPES.GAUGE)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Implementation of the OpenTelemetry ObservableCounter interface:
|
|
197
|
+
* https://open-telemetry.github.io/opentelemetry-js/types/_opentelemetry_api._opentelemetry_api.ObservableCounter.html
|
|
198
|
+
* @class ObservableCounter
|
|
199
|
+
*/
|
|
200
|
+
class ObservableCounter extends ObservableInstrument {
|
|
201
|
+
constructor (name, options, instrumentationScope, reader) {
|
|
202
|
+
super(name, options, instrumentationScope, reader, METRIC_TYPES.OBSERVABLECOUNTER)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Implementation of the OpenTelemetry ObservableUpDownCounter interface:
|
|
208
|
+
* https://open-telemetry.github.io/opentelemetry-js/types/_opentelemetry_api._opentelemetry_api.ObservableUpDownCounter.html
|
|
209
|
+
* @class ObservableUpDownCounter
|
|
210
|
+
*/
|
|
211
|
+
class ObservableUpDownCounter extends ObservableInstrument {
|
|
212
|
+
constructor (name, options, instrumentationScope, reader) {
|
|
213
|
+
super(name, options, instrumentationScope, reader, METRIC_TYPES.OBSERVABLEUPDOWNCOUNTER)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
module.exports = {
|
|
218
|
+
Counter,
|
|
219
|
+
UpDownCounter,
|
|
220
|
+
Histogram,
|
|
221
|
+
Gauge,
|
|
222
|
+
ObservableGauge,
|
|
223
|
+
ObservableCounter,
|
|
224
|
+
ObservableUpDownCounter
|
|
225
|
+
}
|