datadog_agent_config/classifier/mod.rs
1//! Configuration key classifier.
2//!
3//! A programmatic registry of all recognized configuration keys. Each entry describes the key
4//! purely from the configuration system's perspective: its canonical YAML path, the environment
5//! variables that map to it, the shape of its value, and which internal config structs consume it.
6//!
7//! This registry is intentionally free of Rust field names and struct internals—it models the
8//! configuration surface as an operator would see it, and can be used at runtime to detect
9//! unknown or unsupported keys in a loaded configuration file.
10//!
11//! ## User Guide
12//!
13//! The registry is generated at build time from `schema_overlay.yaml`, which partitions every
14//! key in `core_schema.yaml` into exactly one of: supported, unsupported, or ignored. Data
15//! integrity (uniqueness, full coverage, sorted sections) is enforced by `SchemaOverlay::load()`
16//! during the build.
17//!
18//! ### Adding a Configuration Key
19//!
20//! Add a `supported` entry in `lib/datadog-agent/config/schema/schema_overlay.yaml` with
21//! `support_level`, `pipelines`, `used_by`, `description`, and `config_registry_filename`.
22//! The build generates the annotation constants automatically.
23//!
24//! ### Updating the Vendored Schema
25//!
26//! After updating `core_schema.yaml`, the build will fail if any new keys are not covered
27//! by the overlay. For each new key, add it to the appropriate section of
28//! `schema_overlay.yaml`.
29
30#[allow(clippy::module_inception)]
31mod classifier;
32
33pub use classifier::{Classification, ConfigClassifier};
34
35/// Identifiers for known configuration consumers.
36///
37/// Used as values in annotation `used_by` fields to declare which consumers incorporate a key.
38pub mod structs {
39 /// Identifier for `ProxyConfiguration`.
40 pub const PROXY_CONFIGURATION: &str = "ProxyConfiguration";
41 /// Identifier for `ForwarderConfiguration`.
42 pub const FORWARDER_CONFIGURATION: &str = "ForwarderConfiguration";
43 /// Identifier for `DogStatsDConfiguration`.
44 pub const DOGSTATSD_CONFIGURATION: &str = "DogStatsDConfiguration";
45 /// Identifier for `ContainerdConfiguration`.
46 pub const CONTAINERD_CONFIGURATION: &str = "ContainerdConfiguration";
47 /// Identifier for `AggregateConfiguration`.
48 pub const AGGREGATE_CONFIGURATION: &str = "AggregateConfiguration";
49 /// Identifier for `DogStatsDMapperConfiguration`.
50 pub const DOGSTATSD_MAPPER_CONFIGURATION: &str = "DogStatsDMapperConfiguration";
51 /// Identifier for `DogStatsDDebugLogConfiguration`.
52 pub const DOGSTATSD_DEBUG_LOG_CONFIGURATION: &str = "DogStatsDDebugLogConfiguration";
53 /// Identifier for `DogStatsDPrefixFilterConfiguration`.
54 pub const DOGSTATSD_PREFIX_FILTER_CONFIGURATION: &str = "DogStatsDPrefixFilterConfiguration";
55 /// Identifier for `DatadogMetricsConfiguration`.
56 pub const DATADOG_METRICS_CONFIGURATION: &str = "DatadogMetricsConfiguration";
57 /// Identifier for `DatadogTraceConfiguration`.
58 pub const DATADOG_TRACE_CONFIGURATION: &str = "DatadogTraceConfiguration";
59 /// Identifier for `DatadogLogsConfiguration`.
60 pub const DATADOG_LOGS_CONFIGURATION: &str = "DatadogLogsConfiguration";
61 /// Identifier for `DatadogEventsConfiguration`.
62 pub const DATADOG_EVENTS_CONFIGURATION: &str = "DatadogEventsConfiguration";
63 /// Identifier for `DatadogServiceChecksConfiguration`.
64 pub const DATADOG_SERVICE_CHECKS_CONFIGURATION: &str = "DatadogServiceChecksConfiguration";
65 /// Identifier for `DatadogApmStatsEncoderConfiguration`.
66 pub const DATADOG_APM_STATS_ENCODER_CONFIGURATION: &str = "DatadogApmStatsEncoderConfiguration";
67 /// Identifier for `MrfConfiguration`.
68 pub const MRF_CONFIGURATION: &str = "MrfConfiguration";
69 /// Identifier for `TraceObfuscationConfiguration`.
70 pub const TRACE_OBFUSCATION_CONFIGURATION: &str = "TraceObfuscationConfiguration";
71 /// Identifier for `RemoteAgentClientConfiguration`.
72 pub const REMOTE_AGENT_CLIENT_CONFIGURATION: &str = "RemoteAgentClientConfiguration";
73 /// Identifier for `TagFilterlistConfiguration`.
74 pub const TAG_FILTERLIST_CONFIGURATION: &str = "TagFilterlistConfiguration";
75 /// Keys consumed through the typed configuration translation system.
76 pub const TYPED_CONFIG_SYSTEM: &str = "TypedConfigSystem";
77 /// Keys read via `get_typed` / `try_get_typed` rather than struct deserialization.
78 pub const GET_TYPED: &str = "get_typed";
79}
80
81/// The ADP pipeline a config key affects.
82#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
83pub enum Pipeline {
84 /// DogStatsD metrics pipeline.
85 DogStatsD,
86 /// Agent checks pipeline.
87 Checks,
88 /// OTLP ingestion frontend.
89 Otlp,
90 /// Internal trace processing. Active when OTLP is enabled and proxy/relay mode (which uses the
91 /// core Agent for transport) is off.
92 Traces,
93}
94
95/// Which pipelines a config key affects.
96#[derive(Clone, Copy, Debug, PartialEq, Eq)]
97pub enum PipelineAffinity {
98 /// The list of pipelines affected by the key.
99 ///
100 /// This list must be non-empty, enforced by test.
101 Pipelines(&'static [Pipeline]),
102 /// The key affects all pipelines or ADP behavior as a whole.
103 CrossCutting,
104}
105
106/// The `Severity` level of a config key that Saluki doesn't support.
107#[derive(Clone, Copy, Debug, PartialEq, Eq)]
108pub enum Severity {
109 /// Saluki's incompatibility with the key is considered minor.
110 Low,
111
112 /// Saluki's incompatibility with the key is considered potentially impactful.
113 Medium,
114
115 /// Saluki's incompatibility with the key is considered problematic.
116 High,
117}
118
119/// The support level for a given configuration key.
120///
121/// Full support is omitted from the enum and those keys are not classified since there is nothing
122/// to be done about them downstream.
123#[derive(Clone, Copy, Debug, PartialEq, Eq)]
124pub enum SupportLevel {
125 /// Partially supported.
126 Partial,
127 /// Explicitly incompatible.
128 Incompatible(Severity),
129 /// Intentionally ignored.
130 #[allow(unused)]
131 Ignored,
132 /// Unrecognized.
133 #[allow(unused)]
134 Unrecognized,
135}
136
137/// The default value for a config key, as resolved at build time from the Agent schema.
138///
139/// Durations are normalized to nanoseconds during codegen (the build fails if a `format:
140/// duration` default isn't a valid Go duration), so the runtime default check never has to parse a
141/// schema default. Other keys keep their JSON-literal default and are compared structurally.
142#[derive(Clone, Copy, Debug, PartialEq, Eq)]
143pub enum DefaultValue {
144 /// The schema declares no default for this key.
145 Missing,
146 /// A JSON-encoded default value (for example, `"\"tlsv1.2\""` or `"1"`).
147 Json(&'static str),
148 /// A `format: duration` default, already parsed to nanoseconds. The Agent transmits durations
149 /// as integer nanoseconds, so the incoming value is normalized the same way before comparing.
150 DurationNanos(u64),
151}
152
153/// Slim per-key data generated at build time for the classifier.
154///
155/// Carries only what the classifier needs: enough to look up a key, determine its support level,
156/// check whether a value is the default, and report which pipelines are affected.
157pub struct ClassifierEntry {
158 /// Canonical dot-separated YAML path.
159 pub yaml_path: &'static str,
160 /// Additional YAML paths (aliases) that resolve to this key.
161 pub aliases: &'static [&'static str],
162 /// How well saluki supports this key.
163 pub support_level: SupportLevel,
164 /// Which pipelines this key affects.
165 pub pipeline_affinity: PipelineAffinity,
166 /// Default value from the Agent schema (normalized at build time).
167 pub default: DefaultValue,
168}
169
170use crate::generated::classifier_data::CLASSIFIER_ENTRIES;