datadog_agent_config/classifier/mod.rs
1//! Configuration key classifier.
2//!
3//! Looks up the Datadog keys whose value can warrant a compatibility warning at runtime: `partial`
4//! keys marked `warn`, `none` keys, and `unknown` keys with a `severity`. Each entry carries the
5//! key's canonical YAML path, support level, affected pipelines and schema default, so a caller can
6//! tell whether a configured value differs from the default. Fully supported and excluded keys have
7//! no entry.
8//!
9//! The entries are generated at build time from the `inventory` section of
10//! `lib/datadog-agent/config/schema/schema_overlay.yaml`. `SchemaOverlay::load()` fails the build
11//! if a key in the vendored schema is missing from the overlay.
12
13#[allow(clippy::module_inception)]
14mod classifier;
15
16pub use classifier::{Classification, ConfigClassifier};
17
18/// The ADP pipeline a config key affects.
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
20pub enum Pipeline {
21 /// DogStatsD metrics pipeline.
22 DogStatsD,
23 /// Agent checks pipeline.
24 Checks,
25 /// OTLP ingestion frontend.
26 Otlp,
27 /// Internal trace processing. Active when OTLP is enabled and proxy/relay mode (which uses the
28 /// core Agent for transport) is off.
29 Traces,
30 /// ADP's logs pipeline (encoding and forwarding). Active when ADP handles logs itself: native
31 /// OTLP logs, rather than relaying them to the core Agent, or check logs.
32 Logs,
33}
34
35/// Which pipelines a config key affects.
36#[derive(Clone, Copy, Debug, PartialEq, Eq)]
37pub enum PipelineAffinity {
38 /// The list of pipelines affected by the key.
39 ///
40 /// Overlay validation rejects empty pipeline lists.
41 Pipelines(&'static [Pipeline]),
42 /// The key affects all pipelines or ADP behavior as a whole.
43 CrossCutting,
44}
45
46/// The `Severity` level of a config key that Saluki doesn't support.
47#[derive(Clone, Copy, Debug, PartialEq, Eq)]
48pub enum Severity {
49 /// Saluki's incompatibility with the key is considered minor.
50 Low,
51
52 /// Saluki's incompatibility with the key is considered potentially impactful.
53 Medium,
54
55 /// Saluki's incompatibility with the key is considered problematic.
56 High,
57}
58
59/// The support level for a given configuration key.
60///
61/// Full support is omitted from the enum and those keys are not classified since there is nothing
62/// to be done about them downstream.
63#[derive(Clone, Copy, Debug, PartialEq, Eq)]
64pub enum SupportLevel {
65 /// Partially supported.
66 Partial,
67 /// Explicitly incompatible.
68 Incompatible(Severity),
69 /// Intentionally ignored.
70 #[allow(unused)]
71 Ignored,
72 /// Unrecognized.
73 #[allow(unused)]
74 Unrecognized,
75}
76
77/// The default value for a config key, as resolved at build time from the Agent schema.
78///
79/// Durations are normalized to nanoseconds during codegen (the build fails if a `format:
80/// duration` default isn't a valid Go duration), so the runtime default check never has to parse a
81/// schema default. Other keys keep their JSON-literal default and are compared structurally.
82#[derive(Clone, Copy, Debug, PartialEq, Eq)]
83pub enum DefaultValue {
84 /// The schema declares no default for this key.
85 Missing,
86 /// A JSON-encoded default value (for example, `"\"tlsv1.2\""` or `"1"`).
87 Json(&'static str),
88 /// A `format: duration` default, already parsed to nanoseconds. The Agent transmits durations
89 /// as integer nanoseconds, so the incoming value is normalized the same way before comparing.
90 DurationNanos(u64),
91}
92
93/// Slim per-key data generated at build time for the classifier.
94///
95/// Carries only what the classifier needs: enough to look up a key, determine its support level,
96/// check whether a value is the default, and report which pipelines are affected.
97pub struct ClassifierEntry {
98 /// Canonical dot-separated YAML path.
99 pub yaml_path: &'static str,
100 /// How well saluki supports this key.
101 pub support_level: SupportLevel,
102 /// Which pipelines this key affects.
103 pub pipeline_affinity: PipelineAffinity,
104 /// Default value from the Agent schema (normalized at build time).
105 pub default: DefaultValue,
106 /// Whether the overlay marks the Agent's behavior as depending on whether the key is set.
107 pub presence_matters: bool,
108}
109
110use crate::generated::classifier_data::CLASSIFIER_ENTRIES;