@@ -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