Skip to content

Commit d47b4ee

Browse files
committed
Fix current OTLP traces correctness test errors
1 parent 527d3bc commit d47b4ee

File tree

12 files changed

+350
-183
lines changed

12 files changed

+350
-183
lines changed

bin/correctness/ground-truth/src/analysis/traces/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ static IGNORED_FIELDS_DIFF: &[&str] = &[
1818
"meta._dd.install.id",
1919
"meta._dd.install.time",
2020
"meta._dd.install.type",
21+
"agent_metadata.agent_version",
22+
// Deprecated
23+
"metrics._sampling_priority_rate_v1",
2124
];
2225

2326
static CUSTOM_FIELD_COMPARATORS: &[(&str, &dyn FieldComparator)] = &[("start", &check_start_diff)];
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
use saluki_config::GenericConfiguration;
2+
use saluki_error::GenericError;
3+
use serde::Deserialize;
4+
5+
const fn default_target_traces_per_second() -> f64 {
6+
10.0
7+
}
8+
9+
const fn default_errors_per_second() -> f64 {
10+
10.0
11+
}
12+
13+
/// APM configuration.
14+
///
15+
/// This configuration mirrors the Agent's trace agent configuration..
16+
#[derive(Clone, Debug, Deserialize)]
17+
struct ApmConfiguration {
18+
#[serde(default)]
19+
apm_config: ApmConfig,
20+
}
21+
22+
#[derive(Clone, Debug, Deserialize, Default)]
23+
pub struct ApmConfig {
24+
/// Target traces per second for priority sampling.
25+
///
26+
/// Defaults to 10.0.
27+
#[serde(default = "default_target_traces_per_second")]
28+
target_traces_per_second: f64,
29+
30+
/// Target traces per second for error sampling.
31+
///
32+
/// Defaults to 10.0.
33+
#[serde(default = "default_errors_per_second")]
34+
errors_per_second: f64,
35+
}
36+
37+
impl ApmConfig {
38+
pub fn from_configuration(config: &GenericConfiguration) -> Result<Self, GenericError> {
39+
let wrapper = config.as_typed::<ApmConfiguration>()?;
40+
Ok(wrapper.apm_config.clone())
41+
}
42+
43+
/// Returns the target traces per second for priority sampling.
44+
pub const fn target_traces_per_second(&self) -> f64 {
45+
self.target_traces_per_second
46+
}
47+
48+
/// Returns the target traces per second for error sampling.
49+
pub const fn errors_per_second(&self) -> f64 {
50+
self.errors_per_second
51+
}
52+
}

lib/saluki-components/src/common/datadog/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod apm;
12
pub mod config;
23
pub mod endpoints;
34
pub mod io;

lib/saluki-components/src/common/otlp/config.rs

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,153 @@ impl Default for HttpConfig {
9696
}
9797
}
9898
}
99+
100+
/// OTLP configuration.
101+
///
102+
/// This mirrors the Agent's `otlp_config` and contains configuration for
103+
/// the OTLP receiver as well as signal-specific settings (metrics, logs, traces).
104+
#[derive(Deserialize, Debug, Default)]
105+
pub struct OtlpConfig {
106+
/// OTLP receiver configuration.
107+
#[serde(default)]
108+
pub receiver: Receiver,
109+
110+
/// Metrics-specific OTLP configuration.
111+
#[serde(default)]
112+
pub metrics: MetricsConfig,
113+
114+
/// Logs-specific OTLP configuration.
115+
#[serde(default)]
116+
pub logs: LogsConfig,
117+
118+
/// Traces-specific OTLP configuration.
119+
#[serde(default)]
120+
pub traces: TracesConfig,
121+
}
122+
123+
/// Configuration for OTLP logs processing.
124+
#[derive(Deserialize, Debug)]
125+
pub struct LogsConfig {
126+
/// Whether to enable OTLP logs support.
127+
///
128+
/// Defaults to true.
129+
#[serde(default = "default_logs_enabled")]
130+
pub enabled: bool,
131+
}
132+
133+
fn default_logs_enabled() -> bool {
134+
true
135+
}
136+
137+
impl Default for LogsConfig {
138+
fn default() -> Self {
139+
Self {
140+
enabled: default_logs_enabled(),
141+
}
142+
}
143+
}
144+
145+
/// Configuration for OTLP metrics processing.
146+
#[derive(Deserialize, Debug)]
147+
pub struct MetricsConfig {
148+
/// Whether to enable OTLP metrics support.
149+
///
150+
/// Defaults to true.
151+
#[serde(default = "default_metrics_enabled")]
152+
pub enabled: bool,
153+
}
154+
155+
fn default_metrics_enabled() -> bool {
156+
true
157+
}
158+
159+
impl Default for MetricsConfig {
160+
fn default() -> Self {
161+
Self {
162+
enabled: default_metrics_enabled(),
163+
}
164+
}
165+
}
166+
167+
/// Configuration for OTLP traces processing.
168+
///
169+
/// Mirrors the Agent's `otlp_config.traces` configuration.
170+
#[derive(Clone, Deserialize, Debug)]
171+
pub struct TracesConfig {
172+
/// Whether to enable OTLP traces support.
173+
///
174+
/// Defaults to true.
175+
#[serde(default = "default_traces_enabled")]
176+
pub enabled: bool,
177+
178+
/// Whether to skip deriving Datadog fields from standard OTLP attributes.
179+
///
180+
/// When true, only uses explicit `datadog.*` prefixed attributes and skips
181+
/// fallback resolution from OTLP semantic conventions.
182+
///
183+
/// Corresponds to `otlp_config.traces.ignore_missing_datadog_fields` in the Agent.
184+
///
185+
/// Defaults to false.
186+
#[serde(default)]
187+
pub ignore_missing_datadog_fields: bool,
188+
189+
/// When true, `_top_level` and `_dd.measured` are derived using the OTLP span kind.
190+
///
191+
/// Corresponds to the `enable_otlp_compute_top_level_by_span_kind` feature flag
192+
/// in the Agent's `apm_config.features`.
193+
///
194+
/// Defaults to false.
195+
#[serde(default = "default_enable_otlp_compute_top_level_by_span_kind")]
196+
pub enable_otlp_compute_top_level_by_span_kind: bool,
197+
198+
/// Probabilistic sampler configuration for OTLP traces.
199+
///
200+
/// Corresponds to `otlp_config.traces.probabilistic_sampler` in the Agent.
201+
#[serde(default)]
202+
pub probabilistic_sampler: ProbabilisticSampler,
203+
}
204+
205+
/// Configuration for OTLP traces probabilistic sampling.
206+
#[derive(Clone, Deserialize, Debug)]
207+
pub struct ProbabilisticSampler {
208+
/// Percentage of traces to ingest (0, 100].
209+
///
210+
/// Invalid values (<= 0 || > 100) are disconsidered and the default is used.
211+
///
212+
/// Corresponds to `otlp_config.traces.probabilistic_sampler.sampling_percentage` in the Agent.
213+
///
214+
/// Defaults to 100.0 (100% sampling).
215+
#[serde(default = "default_sampling_percentage")]
216+
pub sampling_percentage: f64,
217+
}
218+
219+
const fn default_sampling_percentage() -> f64 {
220+
100.0
221+
}
222+
223+
impl Default for ProbabilisticSampler {
224+
fn default() -> Self {
225+
Self {
226+
sampling_percentage: default_sampling_percentage(),
227+
}
228+
}
229+
}
230+
231+
const fn default_enable_otlp_compute_top_level_by_span_kind() -> bool {
232+
false
233+
}
234+
235+
fn default_traces_enabled() -> bool {
236+
true
237+
}
238+
239+
impl Default for TracesConfig {
240+
fn default() -> Self {
241+
Self {
242+
enabled: default_traces_enabled(),
243+
ignore_missing_datadog_fields: false,
244+
enable_otlp_compute_top_level_by_span_kind: default_enable_otlp_compute_top_level_by_span_kind(),
245+
probabilistic_sampler: ProbabilisticSampler::default(),
246+
}
247+
}
248+
}

0 commit comments

Comments
 (0)