dd-trace 6.25.0 → 6.27.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.
Files changed (190) hide show
  1. package/README.md +3 -0
  2. package/ci/cypress/support.js +2 -1
  3. package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
  4. package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
  5. package/ci/vitest-no-worker-init-setup.mjs +729 -724
  6. package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
  7. package/index.d.ts +58 -1
  8. package/initialize.mjs +5 -3
  9. package/package.json +36 -32
  10. package/packages/datadog-esbuild/index.js +8 -15
  11. package/packages/datadog-esbuild/src/log.js +2 -29
  12. package/packages/datadog-instrumentations/src/ai.js +88 -122
  13. package/packages/datadog-instrumentations/src/aws-lambda.js +9 -0
  14. package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
  15. package/packages/datadog-instrumentations/src/helpers/bundler-esm-exports.js +23 -1
  16. package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
  17. package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +9 -6
  18. package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
  19. package/packages/datadog-instrumentations/src/helpers/hooks.js +0 -1
  20. package/packages/datadog-instrumentations/src/helpers/instrument.js +1 -3
  21. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +6 -0
  22. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +12 -1
  23. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +2 -0
  24. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +5 -3
  25. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-client.js +30 -0
  26. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
  27. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +21 -0
  28. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
  29. package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +30 -0
  30. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +6 -0
  31. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
  32. package/packages/datadog-instrumentations/src/microgateway-core.js +1 -2
  33. package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
  34. package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +32 -2
  35. package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +43 -0
  36. package/packages/datadog-instrumentations/src/next.js +184 -20
  37. package/packages/datadog-instrumentations/src/path-to-regexp.js +11 -11
  38. package/packages/datadog-instrumentations/src/router.js +52 -13
  39. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1 -1
  40. package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
  41. package/packages/datadog-plugin-aws-lambda/src/arn.js +41 -0
  42. package/packages/datadog-plugin-aws-lambda/src/context/events.js +167 -0
  43. package/packages/datadog-plugin-aws-lambda/src/context/extractor.js +153 -0
  44. package/packages/datadog-plugin-aws-lambda/src/context/http.js +50 -0
  45. package/packages/datadog-plugin-aws-lambda/src/context/span-context.js +26 -0
  46. package/packages/datadog-plugin-aws-lambda/src/context/step-functions.js +142 -0
  47. package/packages/datadog-plugin-aws-lambda/src/context/types.d.ts +17 -0
  48. package/packages/datadog-plugin-aws-lambda/src/context/xray.js +67 -0
  49. package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
  50. package/packages/datadog-plugin-aws-lambda/src/index.js +52 -4
  51. package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
  52. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
  53. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
  54. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
  55. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
  56. package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
  57. package/packages/datadog-plugin-azure-functions/src/index.js +68 -12
  58. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +30 -4
  59. package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
  60. package/packages/datadog-plugin-express/src/code_origin.js +2 -2
  61. package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
  62. package/packages/datadog-plugin-fetch/src/index.js +7 -0
  63. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -0
  64. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +2 -0
  65. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +7 -0
  66. package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
  67. package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
  68. package/packages/datadog-plugin-http/src/client.js +14 -1
  69. package/packages/datadog-plugin-http/src/server.js +18 -4
  70. package/packages/datadog-plugin-http2/src/client.js +2 -1
  71. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
  72. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
  73. package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
  74. package/packages/datadog-plugin-postgres/src/index.js +118 -41
  75. package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
  76. package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
  77. package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
  78. package/packages/datadog-plugin-vitest/src/index.js +3 -2
  79. package/packages/datadog-plugin-ws/src/close.js +3 -5
  80. package/packages/datadog-plugin-ws/src/producer.js +1 -4
  81. package/packages/datadog-plugin-ws/src/receiver.js +3 -5
  82. package/packages/datadog-plugin-ws/src/server.js +44 -13
  83. package/packages/datadog-vite/index.js +537 -0
  84. package/packages/datadog-vite/src/log.js +5 -0
  85. package/packages/datadog-webpack/src/log.js +2 -29
  86. package/packages/dd-trace/src/aiguard/client.js +7 -9
  87. package/packages/dd-trace/src/aiguard/evaluation.js +7 -2
  88. package/packages/dd-trace/src/aiguard/index.js +1 -1
  89. package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
  90. package/packages/dd-trace/src/aiguard/messages/utils.js +2 -2
  91. package/packages/dd-trace/src/aiguard/sdk.js +7 -2
  92. package/packages/dd-trace/src/appsec/api_security/normalized-route.js +273 -167
  93. package/packages/dd-trace/src/appsec/blocking/index.js +17 -1
  94. package/packages/dd-trace/src/appsec/channels.js +8 -0
  95. package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
  96. package/packages/dd-trace/src/appsec/graphql.js +10 -13
  97. package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
  98. package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
  99. package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
  100. package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
  101. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +21 -14
  102. package/packages/dd-trace/src/appsec/index.js +9 -0
  103. package/packages/dd-trace/src/appsec/lambda.js +17 -17
  104. package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
  105. package/packages/dd-trace/src/appsec/rasp/index.js +64 -3
  106. package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
  107. package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
  108. package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
  109. package/packages/dd-trace/src/appsec/rasp/utils.js +47 -3
  110. package/packages/dd-trace/src/appsec/recommended.json +70 -3
  111. package/packages/dd-trace/src/appsec/reporter.js +9 -0
  112. package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
  113. package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
  114. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
  115. package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
  116. package/packages/dd-trace/src/appsec/waf/index.js +65 -6
  117. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
  118. package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
  119. package/packages/dd-trace/src/carrier.js +7 -1
  120. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +4 -2
  121. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +31 -19
  122. package/packages/dd-trace/src/config/generated-config-types.d.ts +14 -5
  123. package/packages/dd-trace/src/config/index.js +73 -27
  124. package/packages/dd-trace/src/config/parsers.js +60 -0
  125. package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
  126. package/packages/dd-trace/src/config/remote_config.js +2 -1
  127. package/packages/dd-trace/src/config/supported-configurations.json +41 -13
  128. package/packages/dd-trace/src/datastreams/fnv.js +27 -0
  129. package/packages/dd-trace/src/datastreams/http.js +57 -0
  130. package/packages/dd-trace/src/datastreams/index.js +24 -0
  131. package/packages/dd-trace/src/datastreams/pathway.js +142 -28
  132. package/packages/dd-trace/src/datastreams/processor.js +27 -7
  133. package/packages/dd-trace/src/debugger/config.js +1 -1
  134. package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
  135. package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
  136. package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
  137. package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
  138. package/packages/dd-trace/src/debugger/index.js +2 -2
  139. package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
  140. package/packages/dd-trace/src/debugger/pause-duration-histogram.js +4 -1
  141. package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
  142. package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
  143. package/packages/dd-trace/src/git_metadata.js +2 -1
  144. package/packages/dd-trace/src/index.js +6 -3
  145. package/packages/dd-trace/src/lambda/facade.js +6 -5
  146. package/packages/dd-trace/src/lambda/handler-paths.js +1 -1
  147. package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
  148. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +86 -3
  149. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +182 -1
  150. package/packages/dd-trace/src/llmobs/span_processor.js +3 -0
  151. package/packages/dd-trace/src/llmobs/tagger.js +9 -0
  152. package/packages/dd-trace/src/noop/span.js +0 -4
  153. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +3 -0
  154. package/packages/dd-trace/src/openfeature/configuration_source.js +20 -0
  155. package/packages/dd-trace/src/openfeature/flagging_provider.js +17 -0
  156. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +2 -1
  157. package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +2 -1
  158. package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +16 -1
  159. package/packages/dd-trace/src/opentelemetry/trace/index.js +5 -4
  160. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +10 -6
  161. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +42 -26
  162. package/packages/dd-trace/src/opentracing/propagation/text_map.js +4 -4
  163. package/packages/dd-trace/src/plugin_manager.js +2 -0
  164. package/packages/dd-trace/src/plugins/ci_plugin.js +104 -9
  165. package/packages/dd-trace/src/plugins/index.js +2 -0
  166. package/packages/dd-trace/src/plugins/util/ci.js +34 -0
  167. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +9 -14
  168. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +3 -5
  169. package/packages/dd-trace/src/plugins/util/test.js +28 -1
  170. package/packages/dd-trace/src/plugins/util/url.js +9 -6
  171. package/packages/dd-trace/src/plugins/util/user-provided-git.js +4 -4
  172. package/packages/dd-trace/src/process-tags/index.js +1 -1
  173. package/packages/dd-trace/src/profiler.js +74 -12
  174. package/packages/dd-trace/src/profiling/profiler.js +30 -2
  175. package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
  176. package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
  177. package/packages/dd-trace/src/profiling/remote-config.js +354 -0
  178. package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
  179. package/packages/dd-trace/src/propagation-hash/index.js +7 -0
  180. package/packages/dd-trace/src/proxy.js +13 -1
  181. package/packages/dd-trace/src/register-loader.js +43 -0
  182. package/register.js +10 -44
  183. package/register.mjs +27 -0
  184. package/vendor/dist/@opentelemetry/core/LICENSE +11 -0
  185. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  186. package/vite.d.ts +7 -0
  187. package/vite.js +3 -0
  188. package/lambda.d.ts +0 -39
  189. package/lambda.js +0 -3
  190. package/packages/datadog-plugin-cypress/src/support.js +0 -1348
@@ -9,6 +9,7 @@ export interface GeneratedConfig {
9
9
  aiguard: {
10
10
  DD_AI_GUARD_ANALYZE_STREAM_RESPONSES_ENABLED: boolean;
11
11
  DD_AI_GUARD_BLOCK: boolean;
12
+ DD_AI_GUARD_DISABLED_INTEGRATIONS: string[] | undefined;
12
13
  DD_AI_GUARD_ENABLED: boolean;
13
14
  DD_AI_GUARD_ENDPOINT: string | undefined;
14
15
  DD_AI_GUARD_MAX_CONTENT_SIZE: number;
@@ -81,6 +82,7 @@ export interface GeneratedConfig {
81
82
  DD_CRASHTRACKING_ENABLED: boolean;
82
83
  DD_CUSTOM_PARENT_ID: string | undefined;
83
84
  DD_CUSTOM_TRACE_ID: string | undefined;
85
+ DD_DATA_STREAMS_HTTP_ENABLED: boolean;
84
86
  DD_DURABLE_CROSS_INVOCATION_TRACING_ENABLED: boolean;
85
87
  DD_ENABLE_LAGE_PACKAGE_NAME: boolean;
86
88
  DD_ENABLE_NX_SERVICE_NAME: boolean;
@@ -497,6 +499,9 @@ export interface GeneratedConfig {
497
499
  };
498
500
  logInjection: boolean;
499
501
  logLevel: "debug" | "info" | "warn" | "error";
502
+ mcp: {
503
+ DD_MCP_CAPTURE_INTENT: boolean;
504
+ };
500
505
  middlewareTracingEnabled: boolean;
501
506
  openai: {
502
507
  DD_OPENAI_LOGS_ENABLED: boolean;
@@ -522,14 +527,15 @@ export interface GeneratedConfig {
522
527
  OTEL_EXPORTER_OTLP_TIMEOUT: number;
523
528
  OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: string;
524
529
  OTEL_EXPORTER_OTLP_TRACES_HEADERS: Record<string, string> | undefined;
525
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: "http/json";
530
+ OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: "grpc" | "http/json" | "http/protobuf";
526
531
  OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: number;
527
532
  OTEL_LOGS_EXPORTER: "none" | "otlp" | undefined;
528
533
  OTEL_METRIC_EXPORT_INTERVAL: number;
529
534
  OTEL_METRIC_EXPORT_TIMEOUT: number;
530
535
  OTEL_METRICS_EXPORTER: "none" | "otlp" | undefined;
536
+ OTEL_PROPAGATORS: string[] | undefined;
531
537
  OTEL_RESOURCE_ATTRIBUTES: Record<string, string>;
532
- OTEL_SDK_DISABLED: boolean;
538
+ OTEL_SDK_DISABLED: boolean | undefined;
533
539
  OTEL_TRACES_EXPORTER: "none" | "otlp" | undefined;
534
540
  OTEL_TRACES_SAMPLER: "always_on" | "always_off" | "traceidratio" | "parentbased_always_on" | "parentbased_always_off" | "parentbased_traceidratio";
535
541
  OTEL_TRACES_SAMPLER_ARG: number | undefined;
@@ -645,6 +651,7 @@ export interface GeneratedEnvVarConfig {
645
651
  DD_AGENTLESS_LOG_SUBMISSION_URL: string | undefined;
646
652
  DD_AI_GUARD_ANALYZE_STREAM_RESPONSES_ENABLED: boolean;
647
653
  DD_AI_GUARD_BLOCK: boolean;
654
+ DD_AI_GUARD_DISABLED_INTEGRATIONS: string[] | undefined;
648
655
  DD_AI_GUARD_ENABLED: boolean;
649
656
  DD_AI_GUARD_ENDPOINT: string | undefined;
650
657
  DD_AI_GUARD_MAX_CONTENT_SIZE: number;
@@ -720,6 +727,7 @@ export interface GeneratedEnvVarConfig {
720
727
  DD_CUSTOM_PARENT_ID: string | undefined;
721
728
  DD_CUSTOM_TRACE_ID: string | undefined;
722
729
  DD_DATA_STREAMS_ENABLED: boolean;
730
+ DD_DATA_STREAMS_HTTP_ENABLED: boolean;
723
731
  DD_DBM_INJECT_SQL_BASEHASH: boolean;
724
732
  DD_DBM_PROPAGATION_MODE: "disabled" | "service" | "full" | "dynamic_service";
725
733
  DD_DECODE_AUTHORIZER_CONTEXT: boolean;
@@ -823,6 +831,7 @@ export interface GeneratedEnvVarConfig {
823
831
  DD_LOG_LEVEL: "debug" | "info" | "warn" | "error";
824
832
  DD_LOGS_INJECTION: boolean;
825
833
  DD_LOGS_OTEL_ENABLED: boolean;
834
+ DD_MCP_CAPTURE_INTENT: boolean;
826
835
  DD_MERGE_XRAY_TRACES: boolean;
827
836
  DD_METRICS_OTEL_ENABLED: boolean;
828
837
  DD_MIN_COLD_START_DURATION: number;
@@ -1215,16 +1224,16 @@ export interface GeneratedEnvVarConfig {
1215
1224
  OTEL_EXPORTER_OTLP_TIMEOUT: number;
1216
1225
  OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: string | undefined;
1217
1226
  OTEL_EXPORTER_OTLP_TRACES_HEADERS: Record<string, string> | undefined;
1218
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: "http/json";
1227
+ OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: "grpc" | "http/json" | "http/protobuf";
1219
1228
  OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: number;
1220
1229
  OTEL_LOG_LEVEL: "debug" | "info" | "warn" | "error";
1221
1230
  OTEL_LOGS_EXPORTER: "none" | "otlp" | undefined;
1222
1231
  OTEL_METRIC_EXPORT_INTERVAL: number;
1223
1232
  OTEL_METRIC_EXPORT_TIMEOUT: number;
1224
1233
  OTEL_METRICS_EXPORTER: "none" | "otlp" | undefined;
1225
- OTEL_PROPAGATORS: string[];
1234
+ OTEL_PROPAGATORS: string[] | undefined;
1226
1235
  OTEL_RESOURCE_ATTRIBUTES: Record<string, string>;
1227
- OTEL_SDK_DISABLED: boolean;
1236
+ OTEL_SDK_DISABLED: boolean | undefined;
1228
1237
  OTEL_SERVICE_NAME: string | undefined;
1229
1238
  OTEL_TRACES_EXPORTER: "none" | "otlp" | undefined;
1230
1239
  OTEL_TRACES_SAMPLER: "always_on" | "always_off" | "traceidratio" | "parentbased_always_on" | "parentbased_always_off" | "parentbased_traceidratio";
@@ -32,6 +32,7 @@ const { createSiteUrl } = require('../exporters/common/url')
32
32
  const { getUnsupportedRuntime } = require('../debugger/unsupported-runtime')
33
33
  const ConfigBase = require('./config-base')
34
34
  const {
35
+ getConfiguredEnvName,
35
36
  getEnvironmentVariable,
36
37
  getEnvironmentVariables,
37
38
  getStableConfigSources,
@@ -437,6 +438,15 @@ class Config extends ConfigBase {
437
438
  this.OTEL_METRICS_EXPORTER === 'none') {
438
439
  setAndTrack(this, 'DD_METRICS_OTEL_ENABLED', false)
439
440
  }
441
+ // OTEL_SDK_DISABLED disables every OpenTelemetry signal, so unlike the other OTel settings it
442
+ // overrides an explicit Datadog opt-in. Tracing is handled at the entry point (src/index.js),
443
+ // where an explicit DD_TRACE_ENABLED takes precedence. That override keeps tracing only: OTLP
444
+ // span metrics are part of the metrics signal.
445
+ if (this.OTEL_SDK_DISABLED) {
446
+ this.#deactivateForOtelSdkDisabled('DD_METRICS_OTEL_ENABLED')
447
+ this.#deactivateForOtelSdkDisabled('DD_LOGS_OTEL_ENABLED')
448
+ this.#deactivateForOtelSdkDisabled('OTEL_TRACES_SPAN_METRICS_ENABLED')
449
+ }
440
450
 
441
451
  const agentlessTracingEnabled = this.DD_AGENTLESS_ENABLED ||
442
452
  isTrue(getEnvironmentVariable('_DD_APM_TRACING_AGENTLESS_ENABLED'))
@@ -704,6 +714,14 @@ class Config extends ConfigBase {
704
714
  setAndTrack(this, 'logInjection', false)
705
715
  }
706
716
 
717
+ // OTEL_PROPAGATORS is not an alias, as its values differ: an empty value is unset and `none` disables
718
+ // propagation on its own. A set DD_TRACE_PROPAGATION_STYLE takes precedence, even when its value is invalid
719
+ // and its own default applies. Runs before the fallbacks so the inject and extract styles inherit it.
720
+ if (trackedConfigOrigins.has('OTEL_PROPAGATORS') &&
721
+ getConfiguredEnvName('DD_TRACE_PROPAGATION_STYLE') === undefined) {
722
+ setAndTrack(this, 'DD_TRACE_PROPAGATION_STYLE', this.OTEL_PROPAGATORS)
723
+ }
724
+
707
725
  // Apply all fallbacks to the calculated config.
708
726
  for (const [configName, alias] of fallbackConfigurations) {
709
727
  if (!trackedConfigOrigins.has(configName) && trackedConfigOrigins.has(alias)) {
@@ -834,11 +852,29 @@ class Config extends ConfigBase {
834
852
 
835
853
  const unsupportedRuntime = getUnsupportedRuntime()
836
854
  if (unsupportedRuntime !== undefined) {
837
- this.#deactivateOnUnsupportedRuntime(
855
+ if (unsupportedRuntime === 'Bun') {
856
+ this.#deactivate(
857
+ 'runtimeMetrics.native',
858
+ 'Native runtime metrics are disabled, because they do not work on Bun.'
859
+ )
860
+ this.#deactivate(
861
+ 'DD_PROFILING_HEAP_ENABLED',
862
+ 'Heap profiling is disabled, because it does not work on Bun.'
863
+ )
864
+ // An unset heap flag inherits the legacy profiler list, which includes space by default.
865
+ if (this.DD_PROFILING_HEAP_ENABLED === undefined && this.DD_PROFILING_PROFILERS.includes('space')) {
866
+ setAndTrack(this, 'DD_PROFILING_HEAP_ENABLED', false)
867
+ }
868
+ this.#deactivate(
869
+ 'iast.DD_IAST_ENABLED',
870
+ 'IAST is disabled, because it does not work on Bun.'
871
+ )
872
+ }
873
+ this.#deactivate(
838
874
  'dynamicInstrumentation.DD_DYNAMIC_INSTRUMENTATION_ENABLED',
839
875
  `Live Debugger/Dynamic Instrumentation is disabled, because it is not supported on ${unsupportedRuntime}.`
840
876
  )
841
- this.#deactivateOnUnsupportedRuntime(
877
+ this.#deactivate(
842
878
  'testOptimization.DD_TEST_FAILED_TEST_REPLAY_ENABLED',
843
879
  'Failed Test Replay is disabled, ' +
844
880
  `because Live Debugger/Dynamic Instrumentation is not supported on ${unsupportedRuntime}.`
@@ -852,13 +888,20 @@ class Config extends ConfigBase {
852
888
  }
853
889
 
854
890
  /**
855
- * Only explains the deactivation of an option that was explicitly set, since Failed Test Replay is enabled by
856
- * default.
891
+ * @param {'DD_METRICS_OTEL_ENABLED' | 'DD_LOGS_OTEL_ENABLED' | 'OTEL_TRACES_SPAN_METRICS_ENABLED'} name
892
+ */
893
+ #deactivateForOtelSdkDisabled (name) {
894
+ this.#deactivate(name, `${name} is disabled, because OTEL_SDK_DISABLED=true disables the OpenTelemetry SDK.`)
895
+ }
896
+
897
+ /**
898
+ * Deactivates an option. Only explains why once, and only when the option was explicitly set: defaults such as
899
+ * Failed Test Replay need no explanation, and recalculating the config must not repeat it.
857
900
  *
858
901
  * @param {ConfigPath} name
859
902
  * @param {string} reason
860
903
  */
861
- #deactivateOnUnsupportedRuntime (name, reason) {
904
+ #deactivate (name, reason) {
862
905
  if (!get(this, name)) return
863
906
 
864
907
  if (this.startupLogs && trackedConfigOrigins.has(name) && !this.#explainedDeactivations.has(name)) {
@@ -924,35 +967,38 @@ function getFromOtelSamplerMap (otelTracesSampler, otelTracesSamplerArg) {
924
967
  function warnWrongOtelSettings () {
925
968
  // This mostly works for non-aliased environment variables only.
926
969
  // TODO: Adjust this to work across all sources.
927
- for (const [otelEnvVar, ddEnvVar, key = otelEnvVar] of [
928
- // eslint-disable-next-line eslint-rules/eslint-env-aliases
929
- ['OTEL_LOG_LEVEL', 'DD_TRACE_LOG_LEVEL', 'logLevel'],
970
+ // eslint-disable-next-line eslint-rules/eslint-process-env
971
+ const envs = process.env
972
+ // Each OpenTelemetry variable lists its Datadog equivalents, then the config path tracking its value when it
973
+ // differs from the variable name. The first equivalent tags `otel.env.invalid`.
974
+ for (const [otelEnvVar, ddEnvVars, key = otelEnvVar] of /** @type {Array<[string, string[], string?]>} */ ([
930
975
  // eslint-disable-next-line eslint-rules/eslint-env-aliases
931
- ['OTEL_PROPAGATORS', 'DD_TRACE_PROPAGATION_STYLE', 'DD_TRACE_PROPAGATION_STYLE'],
976
+ ['OTEL_LOG_LEVEL', ['DD_TRACE_LOG_LEVEL'], 'logLevel'],
977
+ ['OTEL_PROPAGATORS', ['DD_TRACE_PROPAGATION_STYLE']],
932
978
  // eslint-disable-next-line eslint-rules/eslint-env-aliases
933
- ['OTEL_SERVICE_NAME', 'DD_SERVICE', 'service'],
934
- ['OTEL_TRACES_SAMPLER', 'DD_TRACE_SAMPLE_RATE'],
935
- ['OTEL_TRACES_SAMPLER_ARG', 'DD_TRACE_SAMPLE_RATE'],
936
- ['OTEL_TRACES_EXPORTER', 'DD_TRACE_ENABLED'],
937
- ['OTEL_METRICS_EXPORTER', 'DD_RUNTIME_METRICS_ENABLED'],
938
- ['OTEL_RESOURCE_ATTRIBUTES', 'DD_TAGS'],
939
- ['OTEL_SDK_DISABLED', 'DD_TRACE_OTEL_ENABLED'],
940
- ['OTEL_LOGS_EXPORTER'],
941
- ]) {
942
- // eslint-disable-next-line eslint-rules/eslint-process-env
943
- const envs = process.env
979
+ ['OTEL_SERVICE_NAME', ['DD_SERVICE'], 'service'],
980
+ ['OTEL_TRACES_SAMPLER', ['DD_TRACE_SAMPLE_RATE']],
981
+ ['OTEL_TRACES_SAMPLER_ARG', ['DD_TRACE_SAMPLE_RATE']],
982
+ ['OTEL_TRACES_EXPORTER', ['DD_TRACE_ENABLED']],
983
+ ['OTEL_METRICS_EXPORTER', ['DD_RUNTIME_METRICS_ENABLED']],
984
+ ['OTEL_RESOURCE_ATTRIBUTES', ['DD_TAGS']],
985
+ // OTEL_SDK_DISABLED maps to DD_TRACE_ENABLED and also gates the DD_TRACE_OTEL_ENABLED provider hook.
986
+ // DD_TRACE_OTEL_ENABLED comes first to keep the established `otel.env.invalid` tag.
987
+ ['OTEL_SDK_DISABLED', ['DD_TRACE_OTEL_ENABLED', 'DD_TRACE_ENABLED']],
988
+ ['OTEL_LOGS_EXPORTER', []],
989
+ ])) {
990
+ if (!envs[otelEnvVar]) continue
991
+
944
992
  const otelSource = trackedConfigOrigins.get(/** @type {ConfigPath} */ (key))
945
- const otelEnvValue = envs[otelEnvVar]
946
- if (otelEnvValue) {
993
+ for (const ddEnvVar of ddEnvVars) {
947
994
  if (envs[ddEnvVar]) {
948
995
  log.warn('Conflicting %s and %s environment variables are set for %s', ddEnvVar, otelEnvVar, otelSource)
949
996
  increaseCounter('otel.env.hiding', ddEnvVar, otelEnvVar)
950
997
  }
951
-
952
- const invalidOtelValue = !otelSource
953
- if (invalidOtelValue) {
954
- increaseCounter('otel.env.invalid', ddEnvVar, otelEnvVar)
955
- }
998
+ }
999
+ // An invalid value is one mistake, however many Datadog equivalents the variable has.
1000
+ if (!otelSource) {
1001
+ increaseCounter('otel.env.invalid', ddEnvVars[0], otelEnvVar)
956
1002
  }
957
1003
  }
958
1004
  }
@@ -105,6 +105,41 @@ const transformers = {
105
105
  }
106
106
  return tags
107
107
  },
108
+ /**
109
+ * Resolves an OpenTelemetry exporter list (e.g. `console,otlp`) to the single exporter the
110
+ * tracer supports. `none` disables export and cannot be combined with any other entry: such a
111
+ * list is invalid and resolves to unset. Otherwise `otlp` anywhere selects OTLP. Other entries
112
+ * are ignored with a warning; a list without a supported entry resolves to unset.
113
+ *
114
+ * @param {string[]} value
115
+ * @param {string} optionName
116
+ * @param {string} source
117
+ * @param {boolean} [reportInvalid]
118
+ * @returns {'none' | 'otlp' | undefined}
119
+ */
120
+ parseOtelExporterList (value, optionName, source, reportInvalid = true) {
121
+ const entries = transformers.toLowerCase(value)
122
+
123
+ if (entries.includes('none')) {
124
+ if (entries.every(entry => entry === 'none')) {
125
+ return 'none'
126
+ }
127
+ if (reportInvalid) {
128
+ warnInvalidValue(entries.join(','), optionName, source, "'none' cannot be combined with other exporters")
129
+ }
130
+ return
131
+ }
132
+
133
+ const exporter = entries.includes('otlp') ? 'otlp' : undefined
134
+
135
+ const ignored = entries.filter(entry => entry !== 'otlp')
136
+ if (ignored.length > 0 && reportInvalid) {
137
+ const outcome = exporter === undefined ? 'picked default' : null
138
+ warnInvalidValue(ignored.join(','), optionName, source, 'Unsupported exporters ignored', undefined, outcome)
139
+ }
140
+
141
+ return exporter
142
+ },
108
143
  normalizeProfilingEnabled (configValue) {
109
144
  if (configValue == null) {
110
145
  return
@@ -241,6 +276,31 @@ const transformers = {
241
276
  }
242
277
  return value
243
278
  },
279
+ /**
280
+ * Validates like `validatePropagationStyles`, with the OpenTelemetry semantics: an empty list resolves to
281
+ * unset, and `none` disables propagation even when combined with other propagators, as the OpenTelemetry
282
+ * JavaScript SDK does. `DD_TRACE_PROPAGATION_STYLE` keeps its own handling of both.
283
+ *
284
+ * @param {string[]} value
285
+ * @param {string} optionName
286
+ * @param {string} source
287
+ * @param {boolean} [reportInvalid]
288
+ * @returns {string[] | undefined}
289
+ */
290
+ validateOtelPropagators (value, optionName, source, reportInvalid = true) {
291
+ if (value.length === 0) return
292
+ value = transformers.toLowerCase(value)
293
+ if (value.includes('none')) {
294
+ if (reportInvalid && value.some(propagator => propagator !== 'none')) {
295
+ warnInvalidValue(
296
+ value.join(','), optionName, source, "'none' cannot be combined with other propagators",
297
+ undefined, 'disabled propagation'
298
+ )
299
+ }
300
+ return ['none']
301
+ }
302
+ return transformers.validatePropagationStyles(value, optionName, source, reportInvalid)
303
+ },
244
304
  }
245
305
 
246
306
  const telemetryTransformers = {
@@ -0,0 +1,38 @@
1
+ 'use strict'
2
+
3
+ const { getEnvironmentVariables } = require('./helper')
4
+
5
+ /**
6
+ * @typedef {ReturnType<import('./index')>} Config
7
+ * @typedef {'APM_TRACING' | 'APM_PROFILING'} Product
8
+ * @typedef {Partial<Record<import('./helper').SupportedEnvKey, string>>} Settings
9
+ */
10
+
11
+ /** @type {WeakMap<Config, Record<Product, Settings | null>>} */
12
+ const layersByConfig = new WeakMap()
13
+
14
+ /**
15
+ * Replace a product's settings and apply the settings of every active product. For a setting
16
+ * both products supply, APM_PROFILING takes precedence over the broader APM_TRACING, whatever the
17
+ * order of updates.
18
+ *
19
+ * @param {Config} config
20
+ * @param {Product} product
21
+ * @param {Settings | null} settings
22
+ */
23
+ module.exports = function applyRemoteConfig (config, product, settings) {
24
+ let layers = layersByConfig.get(config)
25
+ if (layers === undefined) {
26
+ layers = { APM_TRACING: null, APM_PROFILING: null }
27
+ layersByConfig.set(config, layers)
28
+ }
29
+ layers[product] = settings
30
+
31
+ const { APM_TRACING: tracing, APM_PROFILING: profiling } = layers
32
+ if (tracing === null || profiling === null) {
33
+ config.setRemoteConfig(tracing ?? profiling)
34
+ return
35
+ }
36
+ // Resolve aliases first, so that each setting has a single key across products.
37
+ config.setRemoteConfig({ ...getEnvironmentVariables(tracing, true), ...getEnvironmentVariables(profiling, true) })
38
+ }
@@ -2,6 +2,7 @@
2
2
 
3
3
  const RemoteConfigCapabilities = require('../remote_config/capabilities')
4
4
  const log = require('../log')
5
+ const applyRemoteConfig = require('./remote-config-layers')
5
6
 
6
7
  module.exports = {
7
8
  enable,
@@ -181,7 +182,7 @@ function enable (rc, config, onConfigUpdated) {
181
182
  transaction.ack(item.path)
182
183
  }
183
184
 
184
- config.setRemoteConfig(sdkConfigManager.getMergedConfig())
185
+ applyRemoteConfig(config, 'APM_TRACING', sdkConfigManager.getMergedConfig())
185
186
 
186
187
  onConfigUpdated()
187
188
  })
@@ -131,6 +131,14 @@
131
131
  "default": "false"
132
132
  }
133
133
  ],
134
+ "DD_MCP_CAPTURE_INTENT": [
135
+ {
136
+ "implementation": "A",
137
+ "type": "boolean",
138
+ "default": "false",
139
+ "namespace": "mcp"
140
+ }
141
+ ],
134
142
  "DD_MIN_COLD_START_DURATION": [
135
143
  {
136
144
  "implementation": "B",
@@ -185,6 +193,15 @@
185
193
  ]
186
194
  }
187
195
  ],
196
+ "DD_AI_GUARD_DISABLED_INTEGRATIONS": [
197
+ {
198
+ "implementation": "A",
199
+ "type": "array",
200
+ "namespace": "aiguard",
201
+ "default": null,
202
+ "description": "Comma-separated integration names for which AI Guard automatic evaluation is disabled."
203
+ }
204
+ ],
188
205
  "DD_AI_GUARD_ANALYZE_STREAM_RESPONSES_ENABLED": [
189
206
  {
190
207
  "implementation": "A",
@@ -894,6 +911,13 @@
894
911
  ]
895
912
  }
896
913
  ],
914
+ "DD_DATA_STREAMS_HTTP_ENABLED": [
915
+ {
916
+ "implementation": "A",
917
+ "type": "boolean",
918
+ "default": "true"
919
+ }
920
+ ],
897
921
  "DD_DBM_INJECT_SQL_BASEHASH": [
898
922
  {
899
923
  "implementation": "A",
@@ -4086,10 +4110,7 @@
4086
4110
  "implementation": "D",
4087
4111
  "type": "array",
4088
4112
  "default": "datadog,tracecontext,baggage",
4089
- "transform": "validatePropagationStyles",
4090
- "aliases": [
4091
- "OTEL_PROPAGATORS"
4092
- ]
4113
+ "transform": "validatePropagationStyles"
4093
4114
  }
4094
4115
  ],
4095
4116
  "DD_TRACE_PROPAGATION_STYLE_EXTRACT": [
@@ -4593,10 +4614,10 @@
4593
4614
  ],
4594
4615
  "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL": [
4595
4616
  {
4596
- "implementation": "B",
4617
+ "implementation": "C",
4597
4618
  "type": "string",
4598
- "default": "http/json",
4599
- "allowed": "http/json",
4619
+ "default": "http/protobuf",
4620
+ "allowed": "grpc|http/json|http/protobuf",
4600
4621
  "transform": "toLowerCase",
4601
4622
  "aliases": [
4602
4623
  "OTEL_EXPORTER_OTLP_PROTOCOL"
@@ -4757,6 +4778,14 @@
4757
4778
  "default": "7500"
4758
4779
  }
4759
4780
  ],
4781
+ "OTEL_PROPAGATORS": [
4782
+ {
4783
+ "implementation": "A",
4784
+ "type": "array",
4785
+ "default": "",
4786
+ "transform": "validateOtelPropagators"
4787
+ }
4788
+ ],
4760
4789
  "OTEL_RESOURCE_ATTRIBUTES": [
4761
4790
  {
4762
4791
  "implementation": "A",
@@ -4767,18 +4796,17 @@
4767
4796
  ],
4768
4797
  "OTEL_SDK_DISABLED": [
4769
4798
  {
4770
- "implementation": "C",
4799
+ "implementation": "B",
4771
4800
  "type": "boolean",
4772
- "default": "true"
4801
+ "default": null
4773
4802
  }
4774
4803
  ],
4775
4804
  "OTEL_TRACES_EXPORTER": [
4776
4805
  {
4777
- "implementation": "H",
4778
- "type": "string",
4806
+ "implementation": "J",
4807
+ "type": "array",
4779
4808
  "default": null,
4780
- "allowed": "none|otlp",
4781
- "transform": "toLowerCase"
4809
+ "transform": "parseOtelExporterList"
4782
4810
  }
4783
4811
  ],
4784
4812
  "OTEL_TRACES_SAMPLER": [
@@ -20,6 +20,33 @@ function fnv64 (data) {
20
20
  return fnv(byteArray, FNV1_64_INIT, FNV_64_PRIME, 2n ** 64n)
21
21
  }
22
22
 
23
+ /**
24
+ * FNV-1 64 of `data`, written into `target` at `offset` as a uint64 little-endian. With `seed`, an
25
+ * earlier result in the same layout, it continues that hash, like dd-trace-java's
26
+ * FNV64Hash.continueHash.
27
+ *
28
+ * Same hash as `fnv64`, computed on two uint32 halves because BigInt arithmetic per byte is several
29
+ * times slower on the per-message DSM path. FNV_64_PRIME is 2^40 + 0x1b3, so multiplying by it is
30
+ * a 40-bit shift plus a multiply by 0x1b3, and every intermediate stays below 2^53.
31
+ *
32
+ * @param {Uint8Array} data
33
+ * @param {Buffer} target
34
+ * @param {number} offset
35
+ * @param {Buffer} [seed]
36
+ */
37
+ function writeFnv64LE (data, target, offset, seed) {
38
+ let high = seed === undefined ? 0xCB_F2_9C_E4 : seed.readUInt32LE(4)
39
+ let low = seed === undefined ? 0x84_22_23_25 : seed.readUInt32LE(0)
40
+ for (let i = 0; i < data.length; i++) {
41
+ const lowProduct = low * 0x1_B3
42
+ high = (high * 0x1_B3 + Math.floor(lowProduct / 0x1_00_00_00_00) + (low << 8)) >>> 0
43
+ low = ((lowProduct >>> 0) ^ data[i]) >>> 0
44
+ }
45
+ target.writeUInt32LE(low, offset)
46
+ target.writeUInt32LE(high, offset + 4)
47
+ }
48
+
23
49
  module.exports = {
24
50
  fnv64,
51
+ writeFnv64LE,
25
52
  }
@@ -0,0 +1,57 @@
1
+ 'use strict'
2
+
3
+ const { DsmPathwayCodec } = require('./pathway')
4
+
5
+ // Same tag set as dd-trace-java's DataStreamsContext.forHttpClient/forHttpServer. Kept pre-sorted because
6
+ // computePathwayHash sorts edge tags in place.
7
+ const CLIENT_EDGE_TAGS = ['direction:out', 'type:http']
8
+ const SERVER_EDGE_TAGS = ['direction:in', 'type:http']
9
+
10
+ /**
11
+ * Records an outbound HTTP checkpoint and writes its pathway context into `headers`.
12
+ *
13
+ * The returned context belongs on the request's own store: storing it on the caller's store would make sibling
14
+ * requests chain from each other instead of from the caller's checkpoint.
15
+ *
16
+ * @param {import('../tracer')} tracer
17
+ * @param {import('../opentracing/span')} span
18
+ * @param {object | null | undefined} parentContext The caller's data streams context.
19
+ * @param {Record<string, unknown>} headers Outgoing request headers.
20
+ * @returns {object | undefined}
21
+ */
22
+ function setHttpClientCheckpoint (tracer, span, parentContext, headers) {
23
+ const ctx = tracer._dataStreamsProcessor.setCheckpoint(CLIENT_EDGE_TAGS, span, parentContext, 0, 0)
24
+ DsmPathwayCodec.encode(ctx, headers)
25
+ return ctx
26
+ }
27
+
28
+ /**
29
+ * Records an inbound HTTP checkpoint, parented on the pathway context in the request headers if there is one.
30
+ *
31
+ * @param {import('../tracer')} tracer
32
+ * @param {import('../opentracing/span')} span
33
+ * @param {Record<string, unknown>} headers Incoming request headers, with lowercase names.
34
+ * @returns {object | undefined}
35
+ */
36
+ function setHttpServerCheckpoint (tracer, span, headers) {
37
+ const parentContext = DsmPathwayCodec.decode(headers)
38
+ return tracer._dataStreamsProcessor.setCheckpoint(SERVER_EDGE_TAGS, span, parentContext, 0, 0)
39
+ }
40
+
41
+ /**
42
+ * dd-trace-java leaves requests sent by an AWS SDK out of HTTP propagation, and so without an HTTP checkpoint: they are
43
+ * signed, and a messaging call records its own checkpoint. SDK v3 marks every request with `amz-sdk-invocation-id`, and
44
+ * the aws-sdk plugin's span is the parent of v2 and v3 requests.
45
+ *
46
+ * @param {import('../opentracing/span') | null | undefined} parentSpan
47
+ * @param {unknown} invocationId The request's `amz-sdk-invocation-id` header value.
48
+ */
49
+ function isAwsSdkRequest (parentSpan, invocationId) {
50
+ return invocationId !== undefined || parentSpan?._integrationName === 'aws-sdk'
51
+ }
52
+
53
+ module.exports = {
54
+ isAwsSdkRequest,
55
+ setHttpClientCheckpoint,
56
+ setHttpServerCheckpoint,
57
+ }
@@ -116,6 +116,26 @@ const SchemaBuilder = lazyClass(() => require('./schemas/schema_builder').Schema
116
116
  'getSchema',
117
117
  ])
118
118
 
119
+ let http
120
+
121
+ /** @type {typeof import('./http').setHttpClientCheckpoint} */
122
+ function setHttpClientCheckpoint (tracer, span, parentContext, headers) {
123
+ http ??= require('./http')
124
+ return http.setHttpClientCheckpoint(tracer, span, parentContext, headers)
125
+ }
126
+
127
+ /** @type {typeof import('./http').isAwsSdkRequest} */
128
+ function isAwsSdkRequest (parentSpan, invocationId) {
129
+ http ??= require('./http')
130
+ return http.isAwsSdkRequest(parentSpan, invocationId)
131
+ }
132
+
133
+ /** @type {typeof import('./http').setHttpServerCheckpoint} */
134
+ function setHttpServerCheckpoint (tracer, span, headers) {
135
+ http ??= require('./http')
136
+ return http.setHttpServerCheckpoint(tracer, span, headers)
137
+ }
138
+
119
139
  module.exports = {
120
140
  DsmPathwayCodec,
121
141
  DataStreamsCheckpointer,
@@ -129,4 +149,8 @@ module.exports = {
129
149
  getHeadersSize,
130
150
  getMessageSize,
131
151
  getSizeOrZero,
152
+
153
+ isAwsSdkRequest,
154
+ setHttpClientCheckpoint,
155
+ setHttpServerCheckpoint,
132
156
  }