Skip to main content

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 struct in the Saluki repository that deserializes Datadog Agent configuration.
7///
8/// Used as values in `schema_overlay.yaml` `used_by` fields to declare which structs consume a
9/// given key. Adding a new struct here is the first step when registering its configuration keys.
10///
11/// This construct has been carried over from the original `config_registry` in order to support
12/// configuration smoke test code generation. Each variant in this enum should be an exact name
13/// match to a struct that consumes its value directly from Agent configuration either by
14/// deserializing or by environment variable.
15#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)]
16pub enum ConfigurationStruct {
17    AggregateConfiguration,
18    ContainerdConfiguration,
19    DatadogApmStatsEncoderConfiguration,
20    DatadogEventsConfiguration,
21    DatadogLogsConfiguration,
22    DatadogMetricsConfiguration,
23    DatadogServiceChecksConfiguration,
24    DatadogTraceConfiguration,
25    DogStatsDConfiguration,
26    DogStatsDDebugLogConfiguration,
27    DogStatsDMapperConfiguration,
28    DogStatsDPrefixFilterConfiguration,
29    ForwarderConfiguration,
30    MrfConfiguration,
31    OtlpConfiguration,
32    OtlpDecoderConfiguration,
33    OtlpRelayConfiguration,
34    ProxyConfiguration,
35    RemoteAgentClientConfiguration,
36    TagFilterlistConfiguration,
37    TraceObfuscationConfiguration,
38
39    /// Keys read via `get_typed` / `try_get_typed` rather than struct deserialization.
40    #[serde(rename = "get_typed")]
41    GetTyped,
42}
43
44impl ConfigurationStruct {
45    /// Apparently we travel back and forth between string constant representation and the struct
46    /// names themselves. This function recovers the string constant name for a struct.
47    pub fn as_smoke_test_const(&self) -> &'static str {
48        match self {
49            ConfigurationStruct::AggregateConfiguration => "AGGREGATE_CONFIGURATION",
50            ConfigurationStruct::ContainerdConfiguration => "CONTAINERD_CONFIGURATION",
51            ConfigurationStruct::DatadogApmStatsEncoderConfiguration => "DATADOG_APM_STATS_ENCODER_CONFIGURATION",
52            ConfigurationStruct::DatadogEventsConfiguration => "DATADOG_EVENTS_CONFIGURATION",
53            ConfigurationStruct::DatadogLogsConfiguration => "DATADOG_LOGS_CONFIGURATION",
54            ConfigurationStruct::DatadogMetricsConfiguration => "DATADOG_METRICS_CONFIGURATION",
55            ConfigurationStruct::DatadogServiceChecksConfiguration => "DATADOG_SERVICE_CHECKS_CONFIGURATION",
56            ConfigurationStruct::DatadogTraceConfiguration => "DATADOG_TRACE_CONFIGURATION",
57            ConfigurationStruct::DogStatsDConfiguration => "DOGSTATSD_CONFIGURATION",
58            ConfigurationStruct::DogStatsDDebugLogConfiguration => "DOGSTATSD_DEBUG_LOG_CONFIGURATION",
59            ConfigurationStruct::DogStatsDMapperConfiguration => "DOGSTATSD_MAPPER_CONFIGURATION",
60            ConfigurationStruct::DogStatsDPrefixFilterConfiguration => "DOGSTATSD_PREFIX_FILTER_CONFIGURATION",
61            ConfigurationStruct::ForwarderConfiguration => "FORWARDER_CONFIGURATION",
62            ConfigurationStruct::MrfConfiguration => "MRF_CONFIGURATION",
63            ConfigurationStruct::OtlpConfiguration => "OTLP_CONFIGURATION",
64            ConfigurationStruct::OtlpDecoderConfiguration => "OTLP_DECODER_CONFIGURATION",
65            ConfigurationStruct::OtlpRelayConfiguration => "OTLP_RELAY_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::GetTyped => "GET_TYPED",
71        }
72    }
73}