datadog_agent_config_overlay_model/
smoke_test_support.rs

1//! Types necessary to keep the configuration smoke tests working. Intended to be transitional
2//! until we can get Saluki/ADP to stop deserializing directly from Agent configuration. At that
3//! time the smoke tests will be rendered inert and can be removed.
4use serde::{Deserialize, Serialize};
5
6/// A configuration consumer tracked by the legacy smoke-test registry.
7///
8/// Most variants name structs that consume Agent configuration directly. Sentinel variants track
9/// consumers that do not fit the legacy deserialization test model.
10#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)]
11pub enum ConfigurationStruct {
12    AggregateConfiguration,
13    ContainerdConfiguration,
14    DatadogApmStatsEncoderConfiguration,
15    DatadogEventsConfiguration,
16    DatadogLogsConfiguration,
17    DatadogMetricsConfiguration,
18    DatadogServiceChecksConfiguration,
19    DatadogTraceConfiguration,
20    DogStatsDConfiguration,
21    DogStatsDDebugLogConfiguration,
22    DogStatsDMapperConfiguration,
23    DogStatsDPrefixFilterConfiguration,
24    ForwarderConfiguration,
25    MrfConfiguration,
26    ProxyConfiguration,
27    RemoteAgentClientConfiguration,
28    TagFilterlistConfiguration,
29    TraceObfuscationConfiguration,
30
31    /// Keys consumed through the typed configuration translation system.
32    TypedConfigSystem,
33
34    /// Keys read via `get_typed` / `try_get_typed` rather than struct deserialization.
35    #[serde(rename = "get_typed")]
36    GetTyped,
37
38    /// Sentinel for supported keys that are being promoted during the transition to
39    /// typed-configuration access. These were missing from our inventory when config smoke
40    /// testing was introduced and for various reasons may not be legitimate targets for that
41    /// testing modality. Regardless, these fields will be part of the typed translation system
42    /// and this sentinel can be removed when our testing model moves over to that system.
43    #[serde(rename = "NO_SMOKE")]
44    NoSmoke,
45}
46
47impl ConfigurationStruct {
48    /// Apparently we travel back and forth between string constant representation and the struct
49    /// names themselves. This function recovers the string constant name for a struct.
50    pub fn as_smoke_test_const(&self) -> &'static str {
51        match self {
52            ConfigurationStruct::AggregateConfiguration => "AGGREGATE_CONFIGURATION",
53            ConfigurationStruct::ContainerdConfiguration => "CONTAINERD_CONFIGURATION",
54            ConfigurationStruct::DatadogApmStatsEncoderConfiguration => "DATADOG_APM_STATS_ENCODER_CONFIGURATION",
55            ConfigurationStruct::DatadogEventsConfiguration => "DATADOG_EVENTS_CONFIGURATION",
56            ConfigurationStruct::DatadogLogsConfiguration => "DATADOG_LOGS_CONFIGURATION",
57            ConfigurationStruct::DatadogMetricsConfiguration => "DATADOG_METRICS_CONFIGURATION",
58            ConfigurationStruct::DatadogServiceChecksConfiguration => "DATADOG_SERVICE_CHECKS_CONFIGURATION",
59            ConfigurationStruct::DatadogTraceConfiguration => "DATADOG_TRACE_CONFIGURATION",
60            ConfigurationStruct::DogStatsDConfiguration => "DOGSTATSD_CONFIGURATION",
61            ConfigurationStruct::DogStatsDDebugLogConfiguration => "DOGSTATSD_DEBUG_LOG_CONFIGURATION",
62            ConfigurationStruct::DogStatsDMapperConfiguration => "DOGSTATSD_MAPPER_CONFIGURATION",
63            ConfigurationStruct::DogStatsDPrefixFilterConfiguration => "DOGSTATSD_PREFIX_FILTER_CONFIGURATION",
64            ConfigurationStruct::ForwarderConfiguration => "FORWARDER_CONFIGURATION",
65            ConfigurationStruct::MrfConfiguration => "MRF_CONFIGURATION",
66            ConfigurationStruct::ProxyConfiguration => "PROXY_CONFIGURATION",
67            ConfigurationStruct::RemoteAgentClientConfiguration => "REMOTE_AGENT_CLIENT_CONFIGURATION",
68            ConfigurationStruct::TagFilterlistConfiguration => "TAG_FILTERLIST_CONFIGURATION",
69            ConfigurationStruct::TraceObfuscationConfiguration => "TRACE_OBFUSCATION_CONFIGURATION",
70            ConfigurationStruct::TypedConfigSystem => "TYPED_CONFIG_SYSTEM",
71            ConfigurationStruct::GetTyped => "GET_TYPED",
72            ConfigurationStruct::NoSmoke => "NO_SMOKE",
73        }
74    }
75}