Skip to content

Commit d8e5bef

Browse files
committed
fix(jaeger): Move CommonConfig and HasRequiredConfig to private mod to meet MSRV requirement. Rename CommonConfig to TransformationConfig.
1 parent f98ef88 commit d8e5bef

File tree

3 files changed

+62
-51
lines changed

3 files changed

+62
-51
lines changed

opentelemetry-jaeger/src/exporter/config/agent.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::exporter::agent::{AgentAsyncClientUdp, AgentSyncClientUdp};
22
use crate::exporter::config::{
3-
build_config_and_process, install_tracer_provider_and_get_tracer, CommonConfig,
4-
HasRequiredConfig,
3+
build_config_and_process,
4+
common::{TransformationConfig, HasRequiredConfig},
5+
install_tracer_provider_and_get_tracer,
56
};
67
use crate::exporter::uploader::{AsyncUploader, SyncUploader, Uploader};
78
use crate::{Error, Exporter, JaegerTraceRuntime};
@@ -45,7 +46,7 @@ const DEFAULT_AGENT_ENDPOINT: &str = "127.0.0.1:6831";
4546
/// is not set, the exporter will use 127.0.0.1 as the host.
4647
#[derive(Debug)]
4748
pub struct AgentPipeline {
48-
common_config: CommonConfig,
49+
common_config: TransformationConfig,
4950
trace_config: Option<sdk::trace::Config>,
5051
agent_endpoint: Result<Vec<net::SocketAddr>, crate::Error>,
5152
max_packet_size: usize,
@@ -71,6 +72,20 @@ impl Default for AgentPipeline {
7172
}
7273
}
7374

75+
// implement the seal trait
76+
impl HasRequiredConfig for AgentPipeline {
77+
fn set_transformation_config<T>(&mut self, f: T)
78+
where
79+
T: FnOnce(&mut TransformationConfig),
80+
{
81+
f(self.common_config.borrow_mut())
82+
}
83+
84+
fn set_trace_config(&mut self, config: Config) {
85+
self.trace_config = Some(config)
86+
}
87+
}
88+
7489
/// Start a new pipeline to configure a exporter that target a jaeger agent.
7590
///
7691
/// See details for each configurations at [`AgentPipeline`]
@@ -273,16 +288,3 @@ impl AgentPipeline {
273288
Ok(Box::new(SyncUploader::Agent(agent)))
274289
}
275290
}
276-
277-
impl HasRequiredConfig for AgentPipeline {
278-
fn set_common_config<T>(&mut self, f: T)
279-
where
280-
T: FnOnce(&mut CommonConfig),
281-
{
282-
f(self.common_config.borrow_mut())
283-
}
284-
285-
fn set_trace_config(&mut self, config: Config) {
286-
self.trace_config = Some(config)
287-
}
288-
}

opentelemetry-jaeger/src/exporter/config/collector/mod.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::exporter::config::{
2-
build_config_and_process, install_tracer_provider_and_get_tracer, CommonConfig,
3-
HasRequiredConfig,
2+
build_config_and_process,
3+
common::{TransformationConfig, HasRequiredConfig},
4+
install_tracer_provider_and_get_tracer,
45
};
56
use crate::exporter::uploader::{AsyncUploader, Uploader};
67
use crate::{Exporter, JaegerTraceRuntime};
@@ -85,7 +86,7 @@ const ENV_PASSWORD: &str = "OTEL_EXPORTER_JAEGER_PASSWORD";
8586
/// [reqwest blocking client]: reqwest::blocking::Client
8687
#[derive(Debug)]
8788
pub struct CollectorPipeline {
88-
common_config: CommonConfig,
89+
common_config: TransformationConfig,
8990
trace_config: Option<TraceConfig>,
9091

9192
#[cfg(feature = "collector_client")]
@@ -139,6 +140,20 @@ impl Default for CollectorPipeline {
139140
}
140141
}
141142

143+
// implement the seal trait
144+
impl HasRequiredConfig for CollectorPipeline {
145+
fn set_transformation_config<T>(&mut self, f: T)
146+
where
147+
T: FnOnce(&mut TransformationConfig),
148+
{
149+
f(self.common_config.borrow_mut())
150+
}
151+
152+
fn set_trace_config(&mut self, config: TraceConfig) {
153+
self.trace_config = Some(config)
154+
}
155+
}
156+
142157
#[derive(Debug)]
143158
enum ClientConfig {
144159
#[cfg(feature = "collector_client")]
@@ -401,19 +416,6 @@ impl CollectorPipeline {
401416
}
402417
}
403418

404-
impl HasRequiredConfig for CollectorPipeline {
405-
fn set_common_config<T>(&mut self, f: T)
406-
where
407-
T: FnOnce(&mut CommonConfig),
408-
{
409-
f(self.common_config.borrow_mut())
410-
}
411-
412-
fn set_trace_config(&mut self, config: TraceConfig) {
413-
self.trace_config = Some(config)
414-
}
415-
}
416-
417419
#[cfg(test)]
418420
#[cfg(feature = "rt-tokio")]
419421
mod tests {

opentelemetry-jaeger/src/exporter/config/mod.rs

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,34 @@ pub mod agent;
2323
#[cfg(any(feature = "collector_client", feature = "wasm_collector_client"))]
2424
pub mod collector;
2525

26-
#[derive(Debug)]
27-
struct CommonConfig {
28-
export_instrument_library: bool,
29-
service_name: Option<String>,
30-
}
26+
mod common {
27+
use opentelemetry::sdk;
28+
29+
30+
// configurations and overrides on how to transform OTLP spans to Jaeger spans.
31+
#[derive(Debug)]
32+
pub struct TransformationConfig {
33+
pub export_instrument_library: bool,
34+
pub service_name: Option<String>,
35+
}
3136

32-
impl Default for CommonConfig {
33-
fn default() -> Self {
34-
CommonConfig {
35-
export_instrument_library: true,
36-
service_name: None,
37+
impl Default for TransformationConfig {
38+
fn default() -> Self {
39+
TransformationConfig {
40+
export_instrument_library: true,
41+
service_name: None,
42+
}
3743
}
3844
}
39-
}
4045

41-
trait HasRequiredConfig {
42-
fn set_common_config<T>(&mut self, f: T)
43-
where
44-
T: FnOnce(&mut CommonConfig);
46+
// pipeline must have transformation config and trace config.
47+
pub trait HasRequiredConfig {
48+
fn set_transformation_config<T>(&mut self, f: T)
49+
where
50+
T: FnOnce(&mut TransformationConfig);
4551

46-
fn set_trace_config(&mut self, config: sdk::trace::Config);
52+
fn set_trace_config(&mut self, config: sdk::trace::Config);
53+
}
4754
}
4855

4956
/// Common configurations shared by the agent and the collector. You can use those functions
@@ -116,17 +123,17 @@ pub trait Configurable: Sized {
116123

117124
impl<B> Configurable for B
118125
where
119-
B: HasRequiredConfig,
126+
B: common::HasRequiredConfig,
120127
{
121128
fn with_service_name<T: Into<String>>(mut self, service_name: T) -> Self {
122-
self.set_common_config(|mut config| {
129+
self.set_transformation_config(|mut config| {
123130
config.service_name = Some(service_name.into());
124131
});
125132
self
126133
}
127134

128135
fn with_instrumentation_library_tags(mut self, export_instrument_library: bool) -> Self {
129-
self.set_common_config(|mut config| {
136+
self.set_transformation_config(|mut config| {
130137
config.export_instrument_library = export_instrument_library;
131138
});
132139
self

0 commit comments

Comments
 (0)