agent_data_plane_config/domains/
traces.rs

1//! Traces domain: APM trace processing, including environment, sampling, and obfuscation.
2
3use serde::Serialize;
4
5/// Resolved traces configuration.
6#[derive(Clone, Debug, Default, PartialEq, Serialize)]
7pub struct Domain {
8    /// Environment tag applied to traces.
9    pub env: String,
10
11    /// Environment used for traces that carry no explicit environment. (not in Datadog Agent config
12    /// schema)
13    pub default_env: String,
14
15    /// Whether trace stats are computed separately per span kind.
16    pub compute_stats_by_span_kind: bool,
17
18    /// Span tags promoted to peer tags for peer-service aggregation.
19    pub peer_tags: Vec<String>,
20
21    /// Whether stats are aggregated by peer tags.
22    pub peer_tags_aggregation: bool,
23
24    /// Whether error spans are sampled independently of the base sampler. (not in Datadog Agent
25    /// config schema)
26    pub error_sampling_enabled: bool,
27
28    /// Whether error tracking runs standalone, without full trace ingestion.
29    pub error_tracking_standalone_enabled: bool,
30
31    /// Target number of error traces sampled per second.
32    pub errors_per_second: f64,
33
34    /// Target number of traces sampled per second.
35    pub target_traces_per_second: f64,
36
37    /// Whether the rare-span sampler is enabled.
38    pub enable_rare_sampler: bool,
39
40    /// Rare-span sampler settings.
41    pub rare_sampler: RareSampler,
42
43    /// Probabilistic sampler settings.
44    pub probabilistic_sampler: ProbabilisticSampler,
45
46    /// Per-subsystem trace obfuscation settings.
47    pub obfuscation: Obfuscation,
48
49    /// OTTL span-drop filter settings.
50    pub ottl_filter: OttlFilter,
51
52    /// OTTL span-transform settings.
53    pub ottl_transform: OttlTransform,
54}
55
56/// Rare-span sampler.
57#[derive(Clone, Debug, Default, PartialEq, Serialize)]
58pub struct RareSampler {
59    /// Maximum number of distinct span signatures tracked. (not in Datadog Agent config schema)
60    pub cardinality: usize,
61
62    /// Cooldown, in seconds, before a signature may be sampled again. (not in Datadog Agent config
63    /// schema)
64    pub cooldown: f64,
65
66    /// Target rare-span traces sampled per second. (not in Datadog Agent config schema)
67    pub tps: f64,
68}
69
70/// APM probabilistic sampler.
71#[derive(Clone, Debug, Default, PartialEq, Serialize)]
72pub struct ProbabilisticSampler {
73    /// Whether the probabilistic sampler is enabled.
74    pub enabled: bool,
75
76    /// Percentage of traces the probabilistic sampler keeps.
77    pub sampling_percentage: f64,
78}
79
80/// Trace obfuscation, one group per supported subsystem.
81#[derive(Clone, Debug, Default, PartialEq, Serialize)]
82pub struct Obfuscation {
83    /// Credit-card obfuscation in span metadata.
84    pub credit_cards: CreditCardObfuscation,
85
86    /// Elasticsearch query obfuscation.
87    pub elasticsearch: JsonQueryObfuscation,
88
89    /// HTTP path and query obfuscation.
90    pub http: HttpObfuscation,
91
92    /// Memcached command obfuscation.
93    pub memcached: MemcachedObfuscation,
94
95    /// MongoDB query obfuscation.
96    pub mongodb: JsonQueryObfuscation,
97
98    /// OpenSearch query obfuscation.
99    pub opensearch: JsonQueryObfuscation,
100
101    /// Redis command obfuscation.
102    pub redis: CacheObfuscation,
103
104    /// Valkey command obfuscation.
105    pub valkey: CacheObfuscation,
106
107    /// SQL query obfuscation. (not in Datadog Agent config schema)
108    pub sql: SqlObfuscation,
109}
110
111/// Credit-card obfuscation.
112#[derive(Clone, Debug, Default, PartialEq, Serialize)]
113pub struct CreditCardObfuscation {
114    /// Whether credit-card numbers are obfuscated.
115    pub enabled: bool,
116
117    /// Tag or field names whose values are not obfuscated.
118    pub keep_values: Vec<String>,
119
120    /// Whether a Luhn check is applied before a value is treated as a card number.
121    pub luhn: bool,
122}
123
124/// Obfuscation shape shared by the JSON-query engines (Elasticsearch, MongoDB, OpenSearch).
125#[derive(Clone, Debug, Default, PartialEq, Serialize)]
126pub struct JsonQueryObfuscation {
127    /// Whether queries are obfuscated.
128    pub enabled: bool,
129
130    /// JSON keys whose values are not obfuscated.
131    pub keep_values: Vec<String>,
132
133    /// JSON keys whose values are obfuscated as embedded SQL.
134    pub obfuscate_sql_values: Vec<String>,
135}
136
137/// HTTP path/query obfuscation.
138#[derive(Clone, Debug, Default, PartialEq, Serialize)]
139pub struct HttpObfuscation {
140    /// Whether path segments containing digits are removed.
141    pub remove_paths_with_digits: bool,
142
143    /// Whether the query string is removed.
144    pub remove_query_string: bool,
145}
146
147/// Memcached command obfuscation.
148#[derive(Clone, Debug, Default, PartialEq, Serialize)]
149pub struct MemcachedObfuscation {
150    /// Whether Memcached commands are obfuscated.
151    pub enabled: bool,
152
153    /// Whether the command verb is preserved.
154    pub keep_command: bool,
155}
156
157/// Obfuscation shape shared by the key/value caches (redis, valkey).
158#[derive(Clone, Debug, Default, PartialEq, Serialize)]
159pub struct CacheObfuscation {
160    /// Whether cache commands are obfuscated.
161    pub enabled: bool,
162
163    /// Whether all command arguments are removed.
164    pub remove_all_args: bool,
165}
166
167/// SQL obfuscation.
168#[derive(Clone, Debug, Default, PartialEq, Serialize)]
169pub struct SqlObfuscation {
170    /// SQL dialect the obfuscator parses against.
171    pub dbms: String,
172
173    /// Whether dollar-quoted function bodies are preserved.
174    pub dollar_quoted_func: bool,
175
176    /// Whether column and table aliases are preserved.
177    pub keep_sql_alias: bool,
178
179    /// Whether digits in identifiers are replaced with a placeholder.
180    pub replace_digits: bool,
181
182    /// Whether table names are collected as metadata.
183    pub table_names: bool,
184}
185
186/// Error-handling mode for OTTL condition/statement evaluation, shared by the OTTL filter and
187/// transform processors.
188#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize)]
189pub enum OttlErrorMode {
190    /// Log evaluation errors and continue.
191    Ignore,
192    /// Swallow evaluation errors silently and continue.
193    Silent,
194    /// Propagate the error up the pipeline; the payload is dropped.
195    #[default]
196    Propagate,
197}
198
199/// OTTL filter processor: span-drop conditions applied during trace enrichment.
200#[derive(Clone, Debug, Default, PartialEq, Serialize)]
201pub struct OttlFilter {
202    /// How evaluation errors in the filter conditions are handled. (not in Datadog Agent config
203    /// schema)
204    pub error_mode: OttlErrorMode,
205
206    /// OTTL conditions; a span matching any of them is dropped. (not in Datadog Agent config
207    /// schema)
208    pub span_conditions: Vec<String>,
209}
210
211/// OTTL transform processor: span-mutating statements applied during trace enrichment.
212#[derive(Clone, Debug, Default, PartialEq, Serialize)]
213pub struct OttlTransform {
214    /// How evaluation errors in the transform statements are handled. (not in Datadog Agent config
215    /// schema)
216    pub error_mode: OttlErrorMode,
217
218    /// OTTL statements applied to each span. (not in Datadog Agent config schema)
219    pub trace_statements: Vec<String>,
220}