dd-trace 5.80.0 → 5.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +79 -88
- package/ext/tags.d.ts +1 -0
- package/ext/tags.js +1 -0
- package/index.d.ts +42 -35
- package/loader-hook.mjs +16 -4
- package/package.json +33 -56
- package/packages/datadog-core/src/utils/src/parse-tags.js +1 -1
- package/packages/datadog-esbuild/index.js +44 -26
- package/packages/datadog-esbuild/src/utils.js +14 -2
- package/packages/datadog-instrumentations/index.js +1 -0
- package/packages/datadog-instrumentations/src/aerospike.js +3 -2
- package/packages/datadog-instrumentations/src/ai.js +2 -2
- package/packages/datadog-instrumentations/src/amqp10.js +1 -1
- package/packages/datadog-instrumentations/src/amqplib.js +4 -4
- package/packages/datadog-instrumentations/src/anthropic.js +14 -2
- package/packages/datadog-instrumentations/src/apollo-server-core.js +2 -2
- package/packages/datadog-instrumentations/src/apollo-server.js +1 -1
- package/packages/datadog-instrumentations/src/apollo.js +3 -2
- package/packages/datadog-instrumentations/src/avsc.js +1 -1
- package/packages/datadog-instrumentations/src/aws-sdk.js +6 -2
- package/packages/datadog-instrumentations/src/azure-event-hubs.js +4 -3
- package/packages/datadog-instrumentations/src/azure-functions.js +2 -2
- package/packages/datadog-instrumentations/src/azure-service-bus.js +3 -4
- package/packages/datadog-instrumentations/src/bluebird.js +1 -1
- package/packages/datadog-instrumentations/src/bullmq.js +11 -0
- package/packages/datadog-instrumentations/src/bunyan.js +1 -1
- package/packages/datadog-instrumentations/src/cassandra-driver.js +1 -1
- package/packages/datadog-instrumentations/src/child_process.js +2 -2
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +3 -3
- package/packages/datadog-instrumentations/src/couchbase.js +1 -1
- package/packages/datadog-instrumentations/src/crypto.js +1 -1
- package/packages/datadog-instrumentations/src/cucumber.js +12 -13
- package/packages/datadog-instrumentations/src/cypress.js +1 -1
- package/packages/datadog-instrumentations/src/dns.js +1 -1
- package/packages/datadog-instrumentations/src/elasticsearch.js +1 -1
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +1 -1
- package/packages/datadog-instrumentations/src/express.js +1 -1
- package/packages/datadog-instrumentations/src/find-my-way.js +6 -5
- package/packages/datadog-instrumentations/src/fs.js +1 -1
- package/packages/datadog-instrumentations/src/generic-pool.js +1 -1
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +137 -15
- package/packages/datadog-instrumentations/src/google-cloud-vertexai.js +2 -3
- package/packages/datadog-instrumentations/src/google-genai.js +120 -0
- package/packages/datadog-instrumentations/src/graphql.js +21 -1
- package/packages/datadog-instrumentations/src/grpc/client.js +1 -1
- package/packages/datadog-instrumentations/src/grpc/server.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/instrument.js +11 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +12 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +27 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +152 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/bullmq.json +106 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +6 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langchain.js +237 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +11 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +139 -0
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/shared-utils.js +9 -0
- package/packages/datadog-instrumentations/src/hono.js +55 -10
- package/packages/datadog-instrumentations/src/ioredis.js +1 -1
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +2 -2
- package/packages/datadog-instrumentations/src/kafkajs.js +3 -3
- package/packages/datadog-instrumentations/src/knex.js +1 -1
- package/packages/datadog-instrumentations/src/langchain.js +3 -109
- package/packages/datadog-instrumentations/src/ldapjs.js +1 -1
- package/packages/datadog-instrumentations/src/light-my-request.js +93 -0
- package/packages/datadog-instrumentations/src/limitd-client.js +1 -1
- package/packages/datadog-instrumentations/src/lodash.js +1 -2
- package/packages/datadog-instrumentations/src/mariadb.js +1 -2
- package/packages/datadog-instrumentations/src/memcached.js +1 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +1 -1
- package/packages/datadog-instrumentations/src/mongodb-core.js +1 -1
- package/packages/datadog-instrumentations/src/mongodb.js +1 -1
- package/packages/datadog-instrumentations/src/mongoose.js +1 -1
- package/packages/datadog-instrumentations/src/mquery.js +1 -1
- package/packages/datadog-instrumentations/src/mysql.js +1 -1
- package/packages/datadog-instrumentations/src/mysql2.js +2 -2
- package/packages/datadog-instrumentations/src/net.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +1 -1
- package/packages/datadog-instrumentations/src/nyc.js +1 -1
- package/packages/datadog-instrumentations/src/openai.js +2 -2
- package/packages/datadog-instrumentations/src/opensearch.js +1 -1
- package/packages/datadog-instrumentations/src/oracledb.js +1 -1
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +1 -1
- package/packages/datadog-instrumentations/src/pg.js +3 -3
- package/packages/datadog-instrumentations/src/pino.js +1 -1
- package/packages/datadog-instrumentations/src/playwright.js +46 -17
- package/packages/datadog-instrumentations/src/prisma.js +52 -37
- package/packages/datadog-instrumentations/src/process.js +1 -1
- package/packages/datadog-instrumentations/src/promise-js.js +1 -1
- package/packages/datadog-instrumentations/src/promise.js +1 -1
- package/packages/datadog-instrumentations/src/protobufjs.js +1 -1
- package/packages/datadog-instrumentations/src/q.js +1 -1
- package/packages/datadog-instrumentations/src/redis.js +1 -1
- package/packages/datadog-instrumentations/src/rhea.js +1 -1
- package/packages/datadog-instrumentations/src/router.js +1 -1
- package/packages/datadog-instrumentations/src/selenium.js +4 -2
- package/packages/datadog-instrumentations/src/sequelize.js +1 -2
- package/packages/datadog-instrumentations/src/sharedb.js +1 -1
- package/packages/datadog-instrumentations/src/tedious.js +1 -1
- package/packages/datadog-instrumentations/src/undici.js +4 -4
- package/packages/datadog-instrumentations/src/url.js +1 -1
- package/packages/datadog-instrumentations/src/vitest.js +1 -1
- package/packages/datadog-instrumentations/src/vm.js +1 -1
- package/packages/datadog-instrumentations/src/when.js +1 -1
- package/packages/datadog-instrumentations/src/winston.js +1 -1
- package/packages/datadog-instrumentations/src/ws.js +38 -19
- package/packages/datadog-plugin-amqp10/src/index.js +1 -1
- package/packages/datadog-plugin-amqplib/src/index.js +1 -1
- package/packages/datadog-plugin-anthropic/src/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +4 -4
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
- package/packages/datadog-plugin-aws-sdk/src/util.js +3 -3
- package/packages/datadog-plugin-azure-event-hubs/src/index.js +1 -1
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +19 -5
- package/packages/datadog-plugin-azure-service-bus/src/index.js +1 -1
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +4 -0
- package/packages/datadog-plugin-bullmq/src/consumer.js +60 -0
- package/packages/datadog-plugin-bullmq/src/index.js +18 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +178 -0
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
- package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +23 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +2 -2
- package/packages/datadog-plugin-cypress/src/support.js +73 -31
- package/packages/datadog-plugin-express/src/index.js +1 -1
- package/packages/datadog-plugin-fastify/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +13 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +171 -12
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +160 -13
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +217 -0
- package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +1 -1
- package/packages/datadog-plugin-google-genai/src/index.js +17 -0
- package/packages/datadog-plugin-google-genai/src/tracing.js +41 -0
- package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +5 -4
- package/packages/datadog-plugin-grpc/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/client.js +2 -1
- package/packages/datadog-plugin-http/src/index.js +25 -5
- package/packages/datadog-plugin-http2/src/client.js +2 -2
- package/packages/datadog-plugin-http2/src/index.js +1 -1
- package/packages/datadog-plugin-jest/src/util.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
- package/packages/datadog-plugin-langchain/src/index.js +1 -1
- package/packages/datadog-plugin-langchain/src/tracing.js +7 -3
- package/packages/datadog-plugin-moleculer/src/index.js +1 -1
- package/packages/datadog-plugin-mongodb-core/src/index.js +6 -2
- package/packages/datadog-plugin-next/src/index.js +11 -3
- package/packages/datadog-plugin-openai/src/index.js +1 -1
- package/packages/datadog-plugin-openai/src/stream-helpers.js +30 -10
- package/packages/datadog-plugin-openai/src/tracing.js +2 -2
- package/packages/datadog-plugin-rhea/src/index.js +1 -1
- package/packages/datadog-plugin-ws/src/close.js +56 -3
- package/packages/datadog-plugin-ws/src/index.js +4 -0
- package/packages/datadog-plugin-ws/src/producer.js +39 -4
- package/packages/datadog-plugin-ws/src/receiver.js +39 -3
- package/packages/datadog-plugin-ws/src/server.js +13 -1
- package/packages/datadog-plugin-ws/src/util.js +107 -0
- package/packages/datadog-shimmer/src/shimmer.js +2 -2
- package/packages/dd-trace/src/aiguard/sdk.js +21 -13
- package/packages/dd-trace/src/appsec/api_security_sampler.js +1 -1
- package/packages/dd-trace/src/appsec/graphql.js +2 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/code-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/command-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/ldap-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +3 -3
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/untrusted-deserialization-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/unvalidated-redirect-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-cipher-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-hash-analyzer.js +3 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/weak-randomness-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +3 -3
- package/packages/dd-trace/src/appsec/iast/index.js +5 -5
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +1 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +11 -16
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +4 -4
- package/packages/dd-trace/src/appsec/index.js +8 -8
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +1 -1
- package/packages/dd-trace/src/appsec/rasp/index.js +1 -1
- package/packages/dd-trace/src/appsec/rasp/lfi.js +1 -1
- package/packages/dd-trace/src/appsec/rc-products.js +10 -0
- package/packages/dd-trace/src/appsec/recommended.json +230 -3
- package/packages/dd-trace/src/appsec/remote_config.js +177 -0
- package/packages/dd-trace/src/appsec/reporter.js +3 -7
- package/packages/dd-trace/src/appsec/rule_manager.js +37 -20
- package/packages/dd-trace/src/appsec/sdk/index.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +2 -2
- package/packages/dd-trace/src/appsec/user_tracking.js +2 -2
- package/packages/dd-trace/src/appsec/waf/index.js +17 -3
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +11 -0
- package/packages/dd-trace/src/azure_metadata.js +8 -2
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +8 -6
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +4 -2
- package/packages/dd-trace/src/config/remote_config.js +34 -0
- package/packages/dd-trace/src/config.js +109 -34
- package/packages/dd-trace/src/config_defaults.js +16 -3
- package/packages/dd-trace/src/constants.js +5 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +10 -1
- package/packages/dd-trace/src/datastreams/checkpointer.js +2 -2
- package/packages/dd-trace/src/datastreams/encoding.js +23 -6
- package/packages/dd-trace/src/datastreams/index.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +41 -2
- package/packages/dd-trace/src/datastreams/processor.js +3 -3
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -1
- package/packages/dd-trace/src/datastreams/writer.js +2 -2
- package/packages/dd-trace/src/debugger/config.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +15 -5
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/index.js +37 -17
- package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +24 -18
- package/packages/dd-trace/src/debugger/devtools_client/send.js +21 -11
- package/packages/dd-trace/src/debugger/devtools_client/session.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +103 -15
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/constants.js +25 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +56 -25
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +64 -23
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +404 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +8 -3
- package/packages/dd-trace/src/debugger/devtools_client/status.js +3 -3
- package/packages/dd-trace/src/debugger/index.js +2 -2
- package/packages/dd-trace/src/dogstatsd.js +3 -2
- package/packages/dd-trace/src/encode/0.4.js +1 -1
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +2 -2
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
- package/packages/dd-trace/src/encode/span-stats.js +13 -2
- package/packages/dd-trace/src/exporter.js +2 -2
- package/packages/dd-trace/src/exporters/agent/index.js +1 -1
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +1 -1
- package/packages/dd-trace/src/exporters/common/request.js +2 -2
- package/packages/dd-trace/src/exporters/common/writer.js +1 -1
- package/packages/dd-trace/src/exporters/span-stats/index.js +1 -1
- package/packages/dd-trace/src/external-logger/src/index.js +1 -2
- package/packages/dd-trace/src/flare/index.js +1 -1
- package/packages/dd-trace/src/guardrails/index.js +6 -3
- package/packages/dd-trace/src/histogram.js +1 -1
- package/packages/dd-trace/src/id.js +60 -0
- package/packages/dd-trace/src/index.js +1 -1
- package/packages/dd-trace/src/lambda/handler.js +4 -4
- package/packages/dd-trace/src/lambda/index.js +1 -1
- package/packages/dd-trace/src/lambda/runtime/patch.js +4 -4
- package/packages/dd-trace/src/lambda/runtime/ritm.js +2 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +8 -1
- package/packages/dd-trace/src/llmobs/index.js +8 -9
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +38 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +30 -9
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +3 -3
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +104 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +486 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/llm.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +2 -2
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +16 -0
- package/packages/dd-trace/src/llmobs/plugins/{openai.js → openai/index.js} +63 -6
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +126 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +1 -1
- package/packages/dd-trace/src/llmobs/sdk.js +20 -22
- package/packages/dd-trace/src/llmobs/span_processor.js +15 -14
- package/packages/dd-trace/src/llmobs/tagger.js +4 -0
- package/packages/dd-trace/src/llmobs/telemetry.js +3 -4
- package/packages/dd-trace/src/llmobs/writers/base.js +2 -2
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -2
- package/packages/dd-trace/src/log/index.js +1 -1
- package/packages/dd-trace/src/noop/proxy.js +2 -2
- package/packages/dd-trace/src/noop/span.js +1 -1
- package/packages/dd-trace/src/openfeature/index.js +2 -2
- package/packages/dd-trace/src/openfeature/noop.js +14 -14
- package/packages/dd-trace/src/openfeature/remote_config.js +31 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +5 -5
- package/packages/dd-trace/src/openfeature/writers/exposures.js +9 -9
- package/packages/dd-trace/src/opentelemetry/context_manager.js +2 -2
- package/packages/dd-trace/src/opentelemetry/logs/index.js +2 -2
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +3 -2
- package/packages/dd-trace/src/opentelemetry/logs/logger_provider.js +4 -4
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +5 -3
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +17 -16
- package/packages/dd-trace/src/opentelemetry/metrics/constants.js +34 -0
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +81 -0
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +225 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +171 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +54 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +62 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +251 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +557 -0
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +10 -18
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +47 -32
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +1 -1
- package/packages/dd-trace/src/opentelemetry/span.js +3 -3
- package/packages/dd-trace/src/opentelemetry/tracer.js +4 -4
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +1 -1
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +24 -8
- package/packages/dd-trace/src/opentracing/span.js +3 -3
- package/packages/dd-trace/src/opentracing/tracer.js +5 -5
- package/packages/dd-trace/src/payload-tagging/index.js +8 -4
- package/packages/dd-trace/src/plugin_manager.js +5 -3
- package/packages/dd-trace/src/plugins/apollo.js +1 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +27 -27
- package/packages/dd-trace/src/plugins/database.js +1 -1
- package/packages/dd-trace/src/plugins/index.js +6 -1
- package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
- package/packages/dd-trace/src/plugins/outbound.js +1 -1
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +1 -1
- package/packages/dd-trace/src/plugins/util/git.js +8 -8
- package/packages/dd-trace/src/plugins/util/stacktrace.js +1 -1
- package/packages/dd-trace/src/plugins/util/test.js +27 -27
- package/packages/dd-trace/src/plugins/util/url.js +119 -1
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +1 -1
- package/packages/dd-trace/src/plugins/util/web.js +18 -46
- package/packages/dd-trace/src/priority_sampler.js +15 -16
- package/packages/dd-trace/src/process-tags/index.js +83 -0
- package/packages/dd-trace/src/profiling/config.js +33 -22
- package/packages/dd-trace/src/profiling/exporter_cli.js +4 -4
- package/packages/dd-trace/src/profiling/exporters/agent.js +5 -5
- package/packages/dd-trace/src/profiling/index.js +1 -1
- package/packages/dd-trace/src/profiling/libuv-size.js +1 -1
- package/packages/dd-trace/src/profiling/profiler.js +4 -5
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +11 -2
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/proxy.js +17 -18
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/index.js +541 -137
- package/packages/dd-trace/src/require-package-json.js +1 -1
- package/packages/dd-trace/src/ritm.js +50 -27
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +1 -1
- package/packages/dd-trace/src/serverless.js +16 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +4 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +4 -0
- package/packages/dd-trace/src/span_format.js +10 -5
- package/packages/dd-trace/src/span_processor.js +8 -3
- package/packages/dd-trace/src/span_stats.js +21 -8
- package/packages/dd-trace/src/spanleak.js +1 -1
- package/packages/dd-trace/src/standalone/index.js +1 -1
- package/packages/dd-trace/src/startup-log.js +3 -3
- package/packages/dd-trace/src/supported-configurations.json +16 -0
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -4
- package/packages/dd-trace/src/telemetry/endpoints.js +8 -8
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +22 -8
- package/packages/dd-trace/src/tracer.js +3 -3
- package/packages/dd-trace/src/tracer_metadata.js +19 -15
- package/vendor/dist/@datadog/sketches-js/LICENSE +39 -0
- package/vendor/dist/@datadog/sketches-js/index.js +1 -0
- package/vendor/dist/@datadog/source-map/LICENSE +28 -0
- package/vendor/dist/@datadog/source-map/index.js +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +55 -0
- package/vendor/dist/@isaacs/ttlcache/index.js +1 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/core/index.js +1 -0
- package/vendor/dist/@opentelemetry/resources/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/resources/index.js +1 -0
- package/vendor/dist/astring/LICENSE +19 -0
- package/vendor/dist/astring/index.js +1 -0
- package/vendor/dist/crypto-randomuuid/index.js +1 -0
- package/vendor/dist/escape-string-regexp/LICENSE +9 -0
- package/vendor/dist/escape-string-regexp/index.js +1 -0
- package/vendor/dist/esquery/LICENSE +24 -0
- package/vendor/dist/esquery/index.js +1 -0
- package/vendor/dist/ignore/LICENSE +21 -0
- package/vendor/dist/ignore/index.js +1 -0
- package/vendor/dist/istanbul-lib-coverage/LICENSE +24 -0
- package/vendor/dist/istanbul-lib-coverage/index.js +1 -0
- package/vendor/dist/jest-docblock/LICENSE +21 -0
- package/vendor/dist/jest-docblock/index.js +1 -0
- package/vendor/dist/jsonpath-plus/LICENSE +22 -0
- package/vendor/dist/jsonpath-plus/index.js +1 -0
- package/vendor/dist/limiter/LICENSE +19 -0
- package/vendor/dist/limiter/index.js +1 -0
- package/vendor/dist/lodash.sortby/LICENSE +47 -0
- package/vendor/dist/lodash.sortby/index.js +1 -0
- package/vendor/dist/lru-cache/LICENSE +15 -0
- package/vendor/dist/lru-cache/index.js +1 -0
- package/vendor/dist/meriyah/LICENSE +7 -0
- package/vendor/dist/meriyah/index.js +1 -0
- package/vendor/dist/module-details-from-path/LICENSE +21 -0
- package/vendor/dist/module-details-from-path/index.js +1 -0
- package/vendor/dist/mutexify/promise/LICENSE +21 -0
- package/vendor/dist/mutexify/promise/index.js +1 -0
- package/vendor/dist/opentracing/LICENSE +201 -0
- package/vendor/dist/opentracing/binary_carrier.d.ts +11 -0
- package/vendor/dist/opentracing/constants.d.ts +61 -0
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +2 -0
- package/vendor/dist/opentracing/ext/tags.d.ts +90 -0
- package/vendor/dist/opentracing/functions.d.ts +20 -0
- package/vendor/dist/opentracing/global_tracer.d.ts +14 -0
- package/vendor/dist/opentracing/index.d.ts +12 -0
- package/vendor/dist/opentracing/index.js +1 -0
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +5 -0
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +13 -0
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +16 -0
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +50 -0
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +26 -0
- package/vendor/dist/opentracing/noop.d.ts +8 -0
- package/vendor/dist/opentracing/reference.d.ts +33 -0
- package/vendor/dist/opentracing/span.d.ts +147 -0
- package/vendor/dist/opentracing/span_context.d.ts +26 -0
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +16 -0
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +3 -0
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +4 -0
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +3 -0
- package/vendor/dist/opentracing/test/unittest.d.ts +2 -0
- package/vendor/dist/opentracing/tracer.d.ts +127 -0
- package/vendor/dist/path-to-regexp/LICENSE +21 -0
- package/vendor/dist/path-to-regexp/index.js +1 -0
- package/vendor/dist/pprof-format/LICENSE +8 -0
- package/vendor/dist/pprof-format/index.js +1 -0
- package/vendor/dist/protobufjs/LICENSE +39 -0
- package/vendor/dist/protobufjs/index.js +1 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +39 -0
- package/vendor/dist/protobufjs/minimal/index.js +1 -0
- package/vendor/dist/retry/LICENSE +21 -0
- package/vendor/dist/retry/index.js +1 -0
- package/vendor/dist/rfdc/LICENSE +15 -0
- package/vendor/dist/rfdc/index.js +1 -0
- package/vendor/dist/semifies/LICENSE +201 -0
- package/vendor/dist/semifies/index.js +1 -0
- package/vendor/dist/shell-quote/LICENSE +24 -0
- package/vendor/dist/shell-quote/index.js +1 -0
- package/vendor/dist/source-map/LICENSE +28 -0
- package/vendor/dist/source-map/index.js +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +28 -0
- package/vendor/dist/source-map/lib/util/index.js +1 -0
- package/vendor/dist/source-map/mappings.wasm +0 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +21 -0
- package/vendor/dist/tlhunter-sorted-set/index.js +1 -0
- package/vendor/dist/ttl-set/LICENSE +21 -0
- package/vendor/dist/ttl-set/index.js +1 -0
- package/packages/dd-trace/src/remote_config/manager.js +0 -368
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const TracingPlugin = require('../../dd-trace/src/plugins/tracing.js')
|
|
4
|
+
const {
|
|
5
|
+
WEBSOCKET_PTR_KIND,
|
|
6
|
+
SPAN_POINTER_DIRECTION,
|
|
7
|
+
SPAN_POINTER_DIRECTION_NAME
|
|
8
|
+
} = require('../../dd-trace/src/constants')
|
|
9
|
+
const {
|
|
10
|
+
incrementWebSocketCounter,
|
|
11
|
+
buildWebSocketSpanPointerHash,
|
|
12
|
+
hasDistributedTracingContext
|
|
13
|
+
} = require('./util')
|
|
4
14
|
|
|
5
15
|
class WSClosePlugin extends TracingPlugin {
|
|
6
16
|
static get id () { return 'ws' }
|
|
@@ -10,11 +20,9 @@ class WSClosePlugin extends TracingPlugin {
|
|
|
10
20
|
|
|
11
21
|
bindStart (ctx) {
|
|
12
22
|
const {
|
|
13
|
-
traceWebsocketMessagesEnabled,
|
|
14
23
|
traceWebsocketMessagesInheritSampling,
|
|
15
24
|
traceWebsocketMessagesSeparateTraces
|
|
16
25
|
} = this.config
|
|
17
|
-
if (!traceWebsocketMessagesEnabled) return
|
|
18
26
|
|
|
19
27
|
const { code, data, socket, isPeerClose } = ctx
|
|
20
28
|
if (!socket?.spanContext) return
|
|
@@ -60,7 +68,52 @@ class WSClosePlugin extends TracingPlugin {
|
|
|
60
68
|
end (ctx) {
|
|
61
69
|
if (!Object.hasOwn(ctx, 'result') || !ctx.span) return
|
|
62
70
|
|
|
63
|
-
if (ctx.socket.spanContext)
|
|
71
|
+
if (ctx.socket.spanContext) {
|
|
72
|
+
const linkAttributes = {}
|
|
73
|
+
|
|
74
|
+
// Determine link kind based on whether this is peer close (incoming) or self close (outgoing)
|
|
75
|
+
const isIncoming = ctx.isPeerClose
|
|
76
|
+
linkAttributes['dd.kind'] = isIncoming ? 'executed_by' : 'resuming'
|
|
77
|
+
|
|
78
|
+
// Add span pointer for context propagation
|
|
79
|
+
if (this.config.traceWebsocketMessagesEnabled && ctx.socket.handshakeSpan) {
|
|
80
|
+
const handshakeSpan = ctx.socket.handshakeSpan
|
|
81
|
+
|
|
82
|
+
// Only add span pointers if distributed tracing is enabled and handshake has distributed context
|
|
83
|
+
if (hasDistributedTracingContext(handshakeSpan, ctx.socket)) {
|
|
84
|
+
const counterType = isIncoming ? 'receiveCounter' : 'sendCounter'
|
|
85
|
+
const counter = incrementWebSocketCounter(ctx.socket, counterType)
|
|
86
|
+
const handshakeContext = handshakeSpan.context()
|
|
87
|
+
|
|
88
|
+
const ptrHash = buildWebSocketSpanPointerHash(
|
|
89
|
+
handshakeContext._traceId,
|
|
90
|
+
handshakeContext._spanId,
|
|
91
|
+
counter,
|
|
92
|
+
true, // isServer
|
|
93
|
+
isIncoming
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
const directionName = isIncoming
|
|
97
|
+
? SPAN_POINTER_DIRECTION_NAME.UPSTREAM
|
|
98
|
+
: SPAN_POINTER_DIRECTION_NAME.DOWNSTREAM
|
|
99
|
+
const direction = isIncoming
|
|
100
|
+
? SPAN_POINTER_DIRECTION.UPSTREAM
|
|
101
|
+
: SPAN_POINTER_DIRECTION.DOWNSTREAM
|
|
102
|
+
|
|
103
|
+
// Add span pointer attributes to link
|
|
104
|
+
linkAttributes['link.name'] = directionName
|
|
105
|
+
linkAttributes['dd.kind'] = 'span-pointer'
|
|
106
|
+
linkAttributes['ptr.kind'] = WEBSOCKET_PTR_KIND
|
|
107
|
+
linkAttributes['ptr.dir'] = direction
|
|
108
|
+
linkAttributes['ptr.hash'] = ptrHash
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
ctx.span.addLink({
|
|
113
|
+
context: ctx.socket.spanContext,
|
|
114
|
+
attributes: linkAttributes
|
|
115
|
+
})
|
|
116
|
+
}
|
|
64
117
|
|
|
65
118
|
ctx.span.finish()
|
|
66
119
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const TracingPlugin = require('../../dd-trace/src/plugins/tracing.js')
|
|
4
|
+
const {
|
|
5
|
+
WEBSOCKET_PTR_KIND,
|
|
6
|
+
SPAN_POINTER_DIRECTION,
|
|
7
|
+
SPAN_POINTER_DIRECTION_NAME
|
|
8
|
+
} = require('../../dd-trace/src/constants')
|
|
9
|
+
const {
|
|
10
|
+
incrementWebSocketCounter,
|
|
11
|
+
buildWebSocketSpanPointerHash,
|
|
12
|
+
hasDistributedTracingContext
|
|
13
|
+
} = require('./util')
|
|
4
14
|
|
|
5
15
|
class WSProducerPlugin extends TracingPlugin {
|
|
6
16
|
static get id () { return 'ws' }
|
|
@@ -9,9 +19,6 @@ class WSProducerPlugin extends TracingPlugin {
|
|
|
9
19
|
static get kind () { return 'producer' }
|
|
10
20
|
|
|
11
21
|
bindStart (ctx) {
|
|
12
|
-
const messagesEnabled = this.config.traceWebsocketMessagesEnabled
|
|
13
|
-
if (!messagesEnabled) return
|
|
14
|
-
|
|
15
22
|
const { byteLength, socket, binary } = ctx
|
|
16
23
|
if (!socket.spanContext) return
|
|
17
24
|
|
|
@@ -51,9 +58,37 @@ class WSProducerPlugin extends TracingPlugin {
|
|
|
51
58
|
if (!Object.hasOwn(ctx, 'result') || !ctx.span) return
|
|
52
59
|
|
|
53
60
|
if (ctx.socket.spanContext) {
|
|
61
|
+
const linkAttributes = { 'dd.kind': 'resuming' }
|
|
62
|
+
|
|
63
|
+
// Add span pointer for context propagation
|
|
64
|
+
if (this.config.traceWebsocketMessagesEnabled && ctx.socket.handshakeSpan) {
|
|
65
|
+
const handshakeSpan = ctx.socket.handshakeSpan
|
|
66
|
+
|
|
67
|
+
// Only add span pointers if distributed tracing is enabled and handshake has distributed context
|
|
68
|
+
if (hasDistributedTracingContext(handshakeSpan, ctx.socket)) {
|
|
69
|
+
const counter = incrementWebSocketCounter(ctx.socket, 'sendCounter')
|
|
70
|
+
const handshakeContext = handshakeSpan.context()
|
|
71
|
+
|
|
72
|
+
const ptrHash = buildWebSocketSpanPointerHash(
|
|
73
|
+
handshakeContext._traceId,
|
|
74
|
+
handshakeContext._spanId,
|
|
75
|
+
counter,
|
|
76
|
+
true, // isServer
|
|
77
|
+
false // isIncoming (this is outgoing)
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
// Add span pointer attributes to link
|
|
81
|
+
linkAttributes['link.name'] = SPAN_POINTER_DIRECTION_NAME.DOWNSTREAM
|
|
82
|
+
linkAttributes['dd.kind'] = 'span-pointer'
|
|
83
|
+
linkAttributes['ptr.kind'] = WEBSOCKET_PTR_KIND
|
|
84
|
+
linkAttributes['ptr.dir'] = SPAN_POINTER_DIRECTION.DOWNSTREAM
|
|
85
|
+
linkAttributes['ptr.hash'] = ptrHash
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
54
89
|
ctx.span.addLink({
|
|
55
90
|
context: ctx.socket.spanContext,
|
|
56
|
-
attributes:
|
|
91
|
+
attributes: linkAttributes,
|
|
57
92
|
})
|
|
58
93
|
}
|
|
59
94
|
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const TracingPlugin = require('../../dd-trace/src/plugins/tracing.js')
|
|
4
|
+
const {
|
|
5
|
+
WEBSOCKET_PTR_KIND,
|
|
6
|
+
SPAN_POINTER_DIRECTION,
|
|
7
|
+
SPAN_POINTER_DIRECTION_NAME
|
|
8
|
+
} = require('../../dd-trace/src/constants')
|
|
9
|
+
const {
|
|
10
|
+
incrementWebSocketCounter,
|
|
11
|
+
buildWebSocketSpanPointerHash,
|
|
12
|
+
hasDistributedTracingContext
|
|
13
|
+
} = require('./util')
|
|
4
14
|
|
|
5
15
|
class WSReceiverPlugin extends TracingPlugin {
|
|
6
16
|
static get id () { return 'ws' }
|
|
@@ -10,11 +20,9 @@ class WSReceiverPlugin extends TracingPlugin {
|
|
|
10
20
|
|
|
11
21
|
bindStart (ctx) {
|
|
12
22
|
const {
|
|
13
|
-
traceWebsocketMessagesEnabled,
|
|
14
23
|
traceWebsocketMessagesInheritSampling,
|
|
15
24
|
traceWebsocketMessagesSeparateTraces
|
|
16
25
|
} = this.config
|
|
17
|
-
if (!traceWebsocketMessagesEnabled) return
|
|
18
26
|
|
|
19
27
|
const { byteLength, socket, binary } = ctx
|
|
20
28
|
if (!socket.spanContext) return
|
|
@@ -61,9 +69,37 @@ class WSReceiverPlugin extends TracingPlugin {
|
|
|
61
69
|
if (!Object.hasOwn(ctx, 'result') || !ctx.span) return
|
|
62
70
|
|
|
63
71
|
if (ctx.socket.spanContext) {
|
|
72
|
+
const linkAttributes = { 'dd.kind': 'executed_by' }
|
|
73
|
+
|
|
74
|
+
// Add span pointer for context propagation
|
|
75
|
+
if (this.config.traceWebsocketMessagesEnabled && ctx.socket.handshakeSpan) {
|
|
76
|
+
const handshakeSpan = ctx.socket.handshakeSpan
|
|
77
|
+
|
|
78
|
+
// Only add span pointers if distributed tracing is enabled and handshake has distributed context
|
|
79
|
+
if (hasDistributedTracingContext(handshakeSpan, ctx.socket)) {
|
|
80
|
+
const counter = incrementWebSocketCounter(ctx.socket, 'receiveCounter')
|
|
81
|
+
const handshakeContext = handshakeSpan.context()
|
|
82
|
+
|
|
83
|
+
const ptrHash = buildWebSocketSpanPointerHash(
|
|
84
|
+
handshakeContext._traceId,
|
|
85
|
+
handshakeContext._spanId,
|
|
86
|
+
counter,
|
|
87
|
+
true, // isServer
|
|
88
|
+
true // isIncoming
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
// Add span pointer attributes to link
|
|
92
|
+
linkAttributes['link.name'] = SPAN_POINTER_DIRECTION_NAME.UPSTREAM
|
|
93
|
+
linkAttributes['dd.kind'] = 'span-pointer'
|
|
94
|
+
linkAttributes['ptr.kind'] = WEBSOCKET_PTR_KIND
|
|
95
|
+
linkAttributes['ptr.dir'] = SPAN_POINTER_DIRECTION.UPSTREAM
|
|
96
|
+
linkAttributes['ptr.hash'] = ptrHash
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
64
100
|
ctx.span.addLink({
|
|
65
101
|
context: ctx.socket.spanContext,
|
|
66
|
-
attributes:
|
|
102
|
+
attributes: linkAttributes,
|
|
67
103
|
})
|
|
68
104
|
}
|
|
69
105
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const TracingPlugin = require('../../dd-trace/src/plugins/tracing.js')
|
|
4
4
|
const tags = require('../../../ext/tags.js')
|
|
5
|
+
const { FORMAT_HTTP_HEADERS } = require('../../../ext/formats')
|
|
6
|
+
const { initWebSocketMessageCounters } = require('./util')
|
|
5
7
|
|
|
6
8
|
const HTTP_STATUS_CODE = tags.HTTP_STATUS_CODE
|
|
7
9
|
|
|
@@ -28,9 +30,13 @@ class WSServerPlugin extends TracingPlugin {
|
|
|
28
30
|
|
|
29
31
|
ctx.args = { options }
|
|
30
32
|
|
|
33
|
+
// Extract distributed tracing context from request headers
|
|
34
|
+
const childOf = this.tracer.extract(FORMAT_HTTP_HEADERS, req.headers)
|
|
35
|
+
|
|
31
36
|
const service = this.serviceName({ pluginConfig: this.config })
|
|
32
37
|
const span = this.startSpan(this.operationName(), {
|
|
33
38
|
service,
|
|
39
|
+
childOf,
|
|
34
40
|
meta: {
|
|
35
41
|
'span.type': 'websocket',
|
|
36
42
|
'http.upgraded': 'websocket',
|
|
@@ -38,7 +44,6 @@ class WSServerPlugin extends TracingPlugin {
|
|
|
38
44
|
'http.url': uri,
|
|
39
45
|
'resource.name': `${options.method} ${route}`,
|
|
40
46
|
'span.kind': 'server'
|
|
41
|
-
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
}, ctx)
|
|
@@ -46,6 +51,13 @@ class WSServerPlugin extends TracingPlugin {
|
|
|
46
51
|
|
|
47
52
|
ctx.socket.spanContext = ctx.span._spanContext
|
|
48
53
|
ctx.socket.spanContext.spanTags = ctx.span._spanContext._tags
|
|
54
|
+
// Store the handshake span for use in message span pointers
|
|
55
|
+
ctx.socket.handshakeSpan = ctx.span
|
|
56
|
+
// Store the request headers for distributed tracing check
|
|
57
|
+
ctx.socket.requestHeaders = req.headers
|
|
58
|
+
|
|
59
|
+
// Initialize message counters for span pointers
|
|
60
|
+
initWebSocketMessageCounters(ctx.socket)
|
|
49
61
|
|
|
50
62
|
return ctx.currentStore
|
|
51
63
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// WeakMap to store message counters per socket without mutating the socket object
|
|
4
|
+
const socketCounters = new WeakMap()
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Initializes WebSocket message counters for a socket.
|
|
8
|
+
* @param {object} socket - The WebSocket socket object
|
|
9
|
+
*/
|
|
10
|
+
function initWebSocketMessageCounters (socket) {
|
|
11
|
+
if (!socketCounters.has(socket)) {
|
|
12
|
+
socketCounters.set(socket, {
|
|
13
|
+
receiveCounter: 0,
|
|
14
|
+
sendCounter: 0
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Increments and returns the WebSocket message counter.
|
|
21
|
+
* @param {object} socket - The WebSocket socket object
|
|
22
|
+
* @param {string} counterType - Either 'receiveCounter' or 'sendCounter'
|
|
23
|
+
* @returns {number} The incremented counter value
|
|
24
|
+
*/
|
|
25
|
+
function incrementWebSocketCounter (socket, counterType) {
|
|
26
|
+
if (!socketCounters.has(socket)) {
|
|
27
|
+
initWebSocketMessageCounters(socket)
|
|
28
|
+
}
|
|
29
|
+
const counters = socketCounters.get(socket)
|
|
30
|
+
counters[counterType]++
|
|
31
|
+
return counters[counterType]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Builds a WebSocket span pointer hash.
|
|
36
|
+
*
|
|
37
|
+
* Format: <prefix><128 bit hex trace id><64 bit hex span id><32 bit hex counter>
|
|
38
|
+
* Prefix: 'S' for server outgoing or client incoming, 'C' for server incoming or client outgoing
|
|
39
|
+
*
|
|
40
|
+
* @param {bigint} handshakeTraceId - The trace ID from the handshake span (as a BigInt)
|
|
41
|
+
* @param {bigint} handshakeSpanId - The span ID from the handshake span (as a BigInt)
|
|
42
|
+
* @param {number} counter - The message counter
|
|
43
|
+
* @param {boolean} isServer - Whether this is a server (true) or client (false)
|
|
44
|
+
* @param {boolean} isIncoming - Whether this is an incoming message (true) or outgoing (false)
|
|
45
|
+
* @returns {string} The span pointer hash
|
|
46
|
+
*/
|
|
47
|
+
function buildWebSocketSpanPointerHash (handshakeTraceId, handshakeSpanId, counter, isServer, isIncoming) {
|
|
48
|
+
// Determine prefix based on server/client and incoming/outgoing
|
|
49
|
+
// Server outgoing or client incoming: 'S'
|
|
50
|
+
// Server incoming or client outgoing: 'C'
|
|
51
|
+
const prefix = (isServer && !isIncoming) || (!isServer && isIncoming) ? 'S' : 'C'
|
|
52
|
+
|
|
53
|
+
// Pad trace ID to 32 hex chars (128 bits)
|
|
54
|
+
const traceIdHex = handshakeTraceId.toString(16).padStart(32, '0')
|
|
55
|
+
|
|
56
|
+
// Pad span ID to 16 hex chars (64 bits)
|
|
57
|
+
const spanIdHex = handshakeSpanId.toString(16).padStart(16, '0')
|
|
58
|
+
|
|
59
|
+
// Pad counter to 8 hex chars (32 bits)
|
|
60
|
+
const counterHex = counter.toString(16).padStart(8, '0')
|
|
61
|
+
|
|
62
|
+
return `${prefix}${traceIdHex}${spanIdHex}${counterHex}`
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Checks if the handshake span has extracted distributed tracing context.
|
|
67
|
+
* A websocket server must not set the span pointer if the handshake has not extracted a context.
|
|
68
|
+
*
|
|
69
|
+
* A span has distributed tracing context if it has a parent context that was
|
|
70
|
+
* extracted from headers (remote parent).
|
|
71
|
+
*
|
|
72
|
+
* @param {object} span - The handshake span
|
|
73
|
+
* @param {object} socket - The WebSocket socket object
|
|
74
|
+
* @returns {boolean} True if the span has distributed tracing context
|
|
75
|
+
*/
|
|
76
|
+
function hasDistributedTracingContext (span, socket) {
|
|
77
|
+
if (!span) return false
|
|
78
|
+
const context = span.context()
|
|
79
|
+
if (!context) return false
|
|
80
|
+
|
|
81
|
+
// Check if this span has a parent. If the parent was extracted from remote headers,
|
|
82
|
+
// then this span is part of a distributed trace.
|
|
83
|
+
// We check if the span has a parent by looking at _parentId.
|
|
84
|
+
// In the JavaScript tracer, when a context is extracted from headers and a child span
|
|
85
|
+
// is created, the child will have _parentId set to the extracted parent's span ID.
|
|
86
|
+
//
|
|
87
|
+
// For testing purposes, we also check if Datadog trace headers are present in the socket's
|
|
88
|
+
// upgrade request, which indicates distributed tracing context was sent by the client.
|
|
89
|
+
if (context._parentId !== null) {
|
|
90
|
+
return true
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Fallback check: look for distributed tracing headers in the stored request headers
|
|
94
|
+
if (socket && socket.requestHeaders) {
|
|
95
|
+
const headers = socket.requestHeaders
|
|
96
|
+
return !!(headers['x-datadog-trace-id'] || headers.traceparent)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return false
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = {
|
|
103
|
+
initWebSocketMessageCounters,
|
|
104
|
+
incrementWebSocketCounter,
|
|
105
|
+
buildWebSocketSpanPointerHash,
|
|
106
|
+
hasDistributedTracingContext
|
|
107
|
+
}
|
|
@@ -91,7 +91,7 @@ function wrapFunction (original, wrapper) {
|
|
|
91
91
|
* @param {Record<string | symbol, unknown> | Function | undefined} target - The target
|
|
92
92
|
* object.
|
|
93
93
|
* @param {string | symbol} name - The property key of the method to wrap.
|
|
94
|
-
* @param {(original: Function) => (...args: unknown[]) =>
|
|
94
|
+
* @param {(original: Function) => (...args: unknown[]) => unknown} wrapper - The wrapper function.
|
|
95
95
|
* @param {{ replaceGetter?: boolean }} [options] - If `replaceGetter` is set to
|
|
96
96
|
* true, the getter is accessed and the getter is replaced with one that just
|
|
97
97
|
* returns the earlier retrieved value. Use with care! This may only be done in
|
|
@@ -214,7 +214,7 @@ function wrap (target, name, wrapper, options) {
|
|
|
214
214
|
* Record<string | symbol, unknown> |
|
|
215
215
|
* Function} targets - The target objects.
|
|
216
216
|
* @param {Array<string | symbol> | string | symbol} names - The property keys of the methods to wrap.
|
|
217
|
-
* @param {(original: Function) => (...args: unknown[]) =>
|
|
217
|
+
* @param {(original: Function) => (...args: unknown[]) => unknown} wrapper - The wrapper function.
|
|
218
218
|
*/
|
|
219
219
|
function massWrap (targets, names, wrapper) {
|
|
220
220
|
targets = toArray(targets)
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const rfdc = require('../../../../vendor/dist/rfdc')({ proto: false, circles: false })
|
|
4
|
+
const log = require('../log')
|
|
5
|
+
const telemetryMetrics = require('../telemetry/metrics')
|
|
6
|
+
const tracerVersion = require('../../../../package.json').version
|
|
3
7
|
const NoopAIGuard = require('./noop')
|
|
4
8
|
const executeRequest = require('./client')
|
|
5
9
|
const {
|
|
@@ -13,19 +17,17 @@ const {
|
|
|
13
17
|
AI_GUARD_TELEMETRY_REQUESTS,
|
|
14
18
|
AI_GUARD_TELEMETRY_TRUNCATED
|
|
15
19
|
} = require('./tags')
|
|
16
|
-
const log = require('../log')
|
|
17
|
-
const telemetryMetrics = require('../telemetry/metrics')
|
|
18
|
-
const tracerVersion = require('../../../../package.json').version
|
|
19
20
|
|
|
20
21
|
const appsecMetrics = telemetryMetrics.manager.namespace('appsec')
|
|
21
22
|
|
|
22
23
|
const ALLOW = 'ALLOW'
|
|
23
24
|
|
|
24
25
|
class AIGuardAbortError extends Error {
|
|
25
|
-
constructor (reason) {
|
|
26
|
+
constructor (reason, tags) {
|
|
26
27
|
super(reason)
|
|
27
28
|
this.name = 'AIGuardAbortError'
|
|
28
29
|
this.reason = reason
|
|
30
|
+
this.tags = tags
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -77,20 +79,26 @@ class AIGuard extends NoopAIGuard {
|
|
|
77
79
|
this.#initialized = true
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Returns a safe copy of the messages to be serialized into the meta struct.
|
|
84
|
+
*
|
|
85
|
+
* - Clones each message so callers cannot mutate the data set in the meta struct.
|
|
86
|
+
* - Truncates the list of messages and `content` fields emitting metrics accordingly.
|
|
87
|
+
*/
|
|
88
|
+
#buildMessagesForMetaStruct (messages) {
|
|
81
89
|
const size = Math.min(messages.length, this.#maxMessagesLength)
|
|
82
90
|
if (messages.length > size) {
|
|
83
91
|
appsecMetrics.count(AI_GUARD_TELEMETRY_TRUNCATED, { type: 'messages' }).inc(1)
|
|
84
92
|
}
|
|
85
|
-
const result =
|
|
86
|
-
|
|
93
|
+
const result = []
|
|
87
94
|
let contentTruncated = false
|
|
88
|
-
for (let i =
|
|
89
|
-
const message =
|
|
95
|
+
for (let i = messages.length - size; i < messages.length; i++) {
|
|
96
|
+
const message = rfdc(messages[i])
|
|
90
97
|
if (message.content?.length > this.#maxContentSize) {
|
|
91
98
|
contentTruncated = true
|
|
92
|
-
|
|
99
|
+
message.content = message.content.slice(0, this.#maxContentSize)
|
|
93
100
|
}
|
|
101
|
+
result.push(message)
|
|
94
102
|
}
|
|
95
103
|
if (contentTruncated) {
|
|
96
104
|
appsecMetrics.count(AI_GUARD_TELEMETRY_TRUNCATED, { type: 'content' }).inc(1)
|
|
@@ -139,7 +147,7 @@ class AIGuard extends NoopAIGuard {
|
|
|
139
147
|
}
|
|
140
148
|
}
|
|
141
149
|
const metaStruct = {
|
|
142
|
-
messages: this.#
|
|
150
|
+
messages: this.#buildMessagesForMetaStruct(messages)
|
|
143
151
|
}
|
|
144
152
|
span.meta_struct = {
|
|
145
153
|
[AI_GUARD_META_STRUCT_KEY]: metaStruct
|
|
@@ -192,9 +200,9 @@ class AIGuard extends NoopAIGuard {
|
|
|
192
200
|
}
|
|
193
201
|
if (shouldBlock) {
|
|
194
202
|
span.setTag(AI_GUARD_BLOCKED_TAG_KEY, 'true')
|
|
195
|
-
throw new AIGuardAbortError(reason)
|
|
203
|
+
throw new AIGuardAbortError(reason, tags)
|
|
196
204
|
}
|
|
197
|
-
return { action, reason }
|
|
205
|
+
return { action, reason, tags }
|
|
198
206
|
})
|
|
199
207
|
}
|
|
200
208
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { TTLCache } = require('
|
|
3
|
+
const { TTLCache } = require('../../../../vendor/dist/@isaacs/ttlcache')
|
|
4
4
|
const web = require('../plugins/util/web')
|
|
5
5
|
const log = require('../log')
|
|
6
6
|
const { AUTO_REJECT, USER_REJECT } = require('../../../../ext/priority')
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { storage } = require('../../../datadog-core')
|
|
4
|
+
const log = require('../log')
|
|
5
|
+
const web = require('../plugins/util/web')
|
|
4
6
|
const {
|
|
5
7
|
addSpecificEndpoint,
|
|
6
8
|
specificBlockingTypes,
|
|
7
9
|
getBlockingData,
|
|
8
10
|
getBlockingAction
|
|
9
11
|
} = require('./blocking')
|
|
10
|
-
const log = require('../log')
|
|
11
12
|
const waf = require('./waf')
|
|
12
13
|
const addresses = require('./addresses')
|
|
13
|
-
const web = require('../plugins/util/web')
|
|
14
14
|
const {
|
|
15
15
|
startGraphqlResolve,
|
|
16
16
|
graphqlMiddlewareChannel,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { CODE_INJECTION } = require('../vulnerabilities')
|
|
4
|
-
const StoredInjectionAnalyzer = require('./stored-injection-analyzer')
|
|
5
4
|
const { INSTRUMENTED_SINK } = require('../telemetry/iast-metric')
|
|
6
5
|
const { storage } = require('../../../../../datadog-core')
|
|
7
6
|
const { getIastContext } = require('../iast-context')
|
|
7
|
+
const StoredInjectionAnalyzer = require('./stored-injection-analyzer')
|
|
8
8
|
|
|
9
9
|
class CodeInjectionAnalyzer extends StoredInjectionAnalyzer {
|
|
10
10
|
constructor () {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const InjectionAnalyzer = require('./injection-analyzer')
|
|
3
2
|
const { COMMAND_INJECTION } = require('../vulnerabilities')
|
|
3
|
+
const InjectionAnalyzer = require('./injection-analyzer')
|
|
4
4
|
|
|
5
5
|
class CommandInjectionAnalyzer extends InjectionAnalyzer {
|
|
6
6
|
constructor () {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const Analyzer = require('./vulnerability-analyzer')
|
|
4
3
|
const { getRelativePath } = require('../path-line')
|
|
4
|
+
const Analyzer = require('./vulnerability-analyzer')
|
|
5
5
|
|
|
6
6
|
class HardcodedBaseAnalyzer extends Analyzer {
|
|
7
7
|
constructor (type, allRules = [], valueOnlyRules = []) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const Analyzer = require('./vulnerability-analyzer')
|
|
3
2
|
const { getRanges } = require('../taint-tracking/operations')
|
|
4
3
|
const { SQL_ROW_VALUE } = require('../taint-tracking/source-types')
|
|
4
|
+
const Analyzer = require('./vulnerability-analyzer')
|
|
5
5
|
|
|
6
6
|
class InjectionAnalyzer extends Analyzer {
|
|
7
7
|
_isVulnerable (value, iastContext) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const InjectionAnalyzer = require('./injection-analyzer')
|
|
3
2
|
const { LDAP_INJECTION } = require('../vulnerabilities')
|
|
4
3
|
const { getNodeModulesPaths } = require('../path-line')
|
|
4
|
+
const InjectionAnalyzer = require('./injection-analyzer')
|
|
5
5
|
|
|
6
6
|
const EXCLUDED_PATHS = getNodeModulesPaths('ldapjs-promise')
|
|
7
7
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const InjectionAnalyzer = require('./injection-analyzer')
|
|
4
3
|
const { NOSQL_MONGODB_INJECTION } = require('../vulnerabilities')
|
|
5
4
|
const { getRanges, addSecureMark } = require('../taint-tracking/operations')
|
|
6
5
|
const { getNodeModulesPaths } = require('../path-line')
|
|
7
6
|
const { storage } = require('../../../../../datadog-core')
|
|
8
7
|
const { getIastContext } = require('../iast-context')
|
|
9
8
|
const { HTTP_REQUEST_PARAMETER, HTTP_REQUEST_BODY } = require('../taint-tracking/source-types')
|
|
10
|
-
|
|
11
|
-
const EXCLUDED_PATHS_FROM_STACK = getNodeModulesPaths('mongodb', 'mongoose', 'mquery')
|
|
12
9
|
const { NOSQL_MONGODB_INJECTION_MARK } = require('../taint-tracking/secure-marks')
|
|
13
10
|
const { iterateObjectStrings } = require('../utils')
|
|
11
|
+
const InjectionAnalyzer = require('./injection-analyzer')
|
|
12
|
+
|
|
13
|
+
const EXCLUDED_PATHS_FROM_STACK = getNodeModulesPaths('mongodb', 'mongoose', 'mquery')
|
|
14
14
|
|
|
15
15
|
const SAFE_OPERATORS = new Set(['$eq', '$gt', '$gte', '$in', '$lt', '$lte', '$ne', '$nin',
|
|
16
16
|
'$exists', '$type', '$mod', '$bitsAllClear', '$bitsAllSet', '$bitsAnyClear', '$bitsAnySet'])
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('path')
|
|
4
4
|
|
|
5
|
-
const InjectionAnalyzer = require('./injection-analyzer')
|
|
6
5
|
const { getIastContext } = require('../iast-context')
|
|
7
6
|
const { storage } = require('../../../../../datadog-core')
|
|
8
7
|
const { PATH_TRAVERSAL } = require('../vulnerabilities')
|
|
8
|
+
const InjectionAnalyzer = require('./injection-analyzer')
|
|
9
9
|
|
|
10
10
|
const ignoredOperations = new Set(['dir.close', 'close'])
|
|
11
11
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const InjectionAnalyzer = require('./injection-analyzer')
|
|
4
3
|
const { UNTRUSTED_DESERIALIZATION } = require('../vulnerabilities')
|
|
4
|
+
const InjectionAnalyzer = require('./injection-analyzer')
|
|
5
5
|
|
|
6
6
|
class UntrustedDeserializationAnalyzer extends InjectionAnalyzer {
|
|
7
7
|
constructor () {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const InjectionAnalyzer = require('./injection-analyzer')
|
|
4
3
|
const { UNVALIDATED_REDIRECT } = require('../vulnerabilities')
|
|
5
4
|
const { getNodeModulesPaths } = require('../path-line')
|
|
6
5
|
const { getRanges } = require('../taint-tracking/operations')
|
|
@@ -8,6 +7,7 @@ const {
|
|
|
8
7
|
HTTP_REQUEST_BODY,
|
|
9
8
|
HTTP_REQUEST_PARAMETER
|
|
10
9
|
} = require('../taint-tracking/source-types')
|
|
10
|
+
const InjectionAnalyzer = require('./injection-analyzer')
|
|
11
11
|
|
|
12
12
|
const EXCLUDED_PATHS = [
|
|
13
13
|
getNodeModulesPaths('express/lib/response.js'),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const Analyzer = require('./vulnerability-analyzer')
|
|
3
2
|
const { WEAK_CIPHER } = require('../vulnerabilities')
|
|
3
|
+
const Analyzer = require('./vulnerability-analyzer')
|
|
4
4
|
|
|
5
5
|
const INSECURE_CIPHERS = new Set([
|
|
6
6
|
'des', 'des-cbc', 'des-cfb', 'des-cfb1', 'des-cfb8', 'des-ecb', 'des-ede', 'des-ede-cbc', 'des-ede-cfb',
|