agent_data_plane_config/domains/apm.rs
1//! APM domain: the experimental trace receiver proxy.
2//!
3//! With the proxy enabled, ADP takes over the trace-agent's receiver: it listens where the trace-agent normally listens
4//! and forwards every request to the trace-agent, which the Datadog Agent moves to
5//! [`proxy_destination`](Domain::proxy_destination). Trace *processing* (obfuscation, sampling, stats) is shared with
6//! the OTLP path and lives in the [`traces`](super::traces) domain.
7//!
8//! The listen settings are the trace-agent's own `apm_config.*` keys, so ADP binds exactly the address tracers are
9//! already configured to reach. The global `bind_host` also applies, and lives in the shared configuration.
10
11use serde::Serialize;
12
13use crate::defaults::DEFAULT_APM_PROXY_DESTINATION;
14use crate::ConfigValue;
15
16/// Resolved APM configuration.
17#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
18pub struct Domain {
19 /// TCP port the trace receiver listens on (`apm_config.receiver_port`).
20 ///
21 /// `0` disables the TCP listener.
22 pub receiver_port: u16,
23
24 /// Unix domain socket path the trace receiver listens on (`apm_config.receiver_socket`).
25 ///
26 /// `None` disables the Unix domain socket listener. Defaults to `/var/run/datadog/apm.socket` on Linux and AIX,
27 /// matching the trace-agent, and to disabled elsewhere.
28 pub receiver_socket: Option<String>,
29
30 /// Whether the TCP listener accepts traffic from other hosts (`apm_config.apm_non_local_traffic`).
31 ///
32 /// When `true`, the listener binds every interface, overriding `bind_host`, as the trace-agent does.
33 ///
34 /// The trace-agent also binds every interface when it runs in a container and neither `bind_host` nor
35 /// `apm_config.apm_non_local_traffic` was set explicitly. That fallback isn't part of the configuration, so the
36 /// provenance is kept for the APM relay to apply it.
37 pub non_local_traffic: ConfigValue<bool>,
38
39 /// Where the relocated trace-agent listens, as a URL (`data_plane.experimental.apm.proxy_destination`).
40 ///
41 /// Either `http://host:port` or `unix:///path/to/socket`. Every request is forwarded
42 /// here. Defaults to `http://127.0.0.1:8127`. (not in Datadog Agent config schema)
43 ///
44 /// Over a Unix domain socket, the trace-agent attributes a request that carries no container headers to the peer
45 /// of the connection, which is ADP. That covers requests from TCP clients that send no container headers, and from
46 /// Unix domain socket clients whose container ADP couldn't resolve. An `http://` destination leaves their origin
47 /// unknown instead.
48 pub proxy_destination: String,
49}
50
51impl Default for Domain {
52 fn default() -> Self {
53 Self {
54 // Saluki-only settings retain these defaults when unset.
55 proxy_destination: DEFAULT_APM_PROXY_DESTINATION.to_string(),
56 // Witnessed settings are overwritten during translation.
57 receiver_port: 0,
58 receiver_socket: None,
59 non_local_traffic: ConfigValue::defaulted(false),
60 }
61 }
62}