Skip to main content

saluki_components/config_registry/datadog/
mod.rs

1//! Datadog Agent configuration registry entries.
2
3pub mod aggregate;
4pub mod dogstatsd;
5pub mod dogstatsd_mapper;
6pub mod dogstatsd_prefix_filter;
7pub mod encoders;
8pub mod forwarder;
9pub mod otlp;
10pub mod proxy;
11pub mod trace_obfuscation;
12
13use std::sync::LazyLock;
14
15use super::{ConfigKey, SalukiAnnotation};
16
17/// All saluki annotations across every sub-system, in registration order.
18///
19/// The source of truth for which config keys saluki knows about and how they are consumed.
20/// Used by the smoke test runner and runtime unknown-key detection.
21pub static ALL_ANNOTATIONS: LazyLock<Vec<&'static SalukiAnnotation>> = LazyLock::new(|| {
22    let mut v = Vec::new();
23    v.extend_from_slice(aggregate::ALL);
24    v.extend_from_slice(dogstatsd::ALL);
25    v.extend_from_slice(dogstatsd_mapper::ALL);
26    v.extend_from_slice(forwarder::ALL);
27    v.extend_from_slice(dogstatsd_prefix_filter::ALL);
28    v.extend_from_slice(encoders::ALL);
29    v.extend_from_slice(otlp::ALL);
30    v.extend_from_slice(proxy::ALL);
31    v.extend_from_slice(trace_obfuscation::ALL);
32    v
33});
34
35/// All resolved [`ConfigKey`] entries, derived from [`ALL_ANNOTATIONS`] at first access.
36///
37/// Provides a flattened, owned view suitable for runtime unknown-key detection.
38pub static ALL_KEYS: LazyLock<Vec<ConfigKey>> =
39    LazyLock::new(|| ALL_ANNOTATIONS.iter().map(|a| ConfigKey::from(*a)).collect());
40
41#[cfg(test)]
42mod registry_tests {
43    use super::*;
44    use crate::config_registry::SupportLevel;
45
46    #[test]
47    fn annotation_invariants() {
48        for annotation in ALL_ANNOTATIONS.iter() {
49            let path = annotation.yaml_path();
50            match annotation.support_level {
51                SupportLevel::Full | SupportLevel::Partial => {
52                    assert!(
53                        !annotation.used_by.is_empty(),
54                        "annotation '{}' has support level {:?} but used_by is empty — \
55                         add the consuming struct name(s) to used_by, or change the support level",
56                        path,
57                        annotation.support_level,
58                    );
59                }
60                SupportLevel::Incompatible => {
61                    assert!(
62                        annotation.used_by.is_empty(),
63                        "annotation '{}' has support level Incompatible but used_by is not empty — \
64                         remove the struct name(s) from used_by, or change the support level",
65                        path,
66                    );
67                }
68                SupportLevel::Ignored => {
69                    panic!(
70                        "annotation '{}' has support level Ignored — \
71                         Ignored is reserved for unannotated schema keys and must not appear \
72                         in a hand-written SalukiAnnotation",
73                        path,
74                    );
75                }
76            }
77        }
78    }
79}