From a49d6f5612754d6f120210ca7690438b1d11245e Mon Sep 17 00:00:00 2001 From: Julian Tescher Date: Tue, 16 Mar 2021 13:18:16 -0700 Subject: [PATCH] Rename trace config with_default_sampler to with_sampler (#482) --- examples/aws-xray/src/client.rs | 2 +- examples/aws-xray/src/server.rs | 2 +- examples/http/src/client.rs | 2 +- examples/http/src/server.rs | 2 +- examples/stdout.rs | 2 +- opentelemetry-datadog/README.md | 2 +- opentelemetry-datadog/src/lib.rs | 2 +- opentelemetry-jaeger/README.md | 2 +- opentelemetry-jaeger/src/lib.rs | 2 +- opentelemetry-otlp/README.md | 2 +- opentelemetry-otlp/src/lib.rs | 2 +- opentelemetry-zipkin/README.md | 2 +- opentelemetry-zipkin/src/lib.rs | 2 +- opentelemetry/src/sdk/trace/config.rs | 5 +---- opentelemetry/src/sdk/trace/tracer.rs | 6 +++--- 15 files changed, 17 insertions(+), 20 deletions(-) diff --git a/examples/aws-xray/src/client.rs b/examples/aws-xray/src/client.rs index cc7472d8a8..b7989fddb8 100644 --- a/examples/aws-xray/src/client.rs +++ b/examples/aws-xray/src/client.rs @@ -18,7 +18,7 @@ fn init_tracer() -> sdktrace::Tracer { stdout::new_pipeline() .with_trace_config( sdktrace::config() - .with_default_sampler(sdktrace::Sampler::AlwaysOn) + .with_sampler(sdktrace::Sampler::AlwaysOn) .with_id_generator(sdktrace::XrayIdGenerator::default()), ) .install() diff --git a/examples/aws-xray/src/server.rs b/examples/aws-xray/src/server.rs index 2c104e70f8..85c7a171e4 100644 --- a/examples/aws-xray/src/server.rs +++ b/examples/aws-xray/src/server.rs @@ -39,7 +39,7 @@ fn init_tracer() -> sdktrace::Tracer { stdout::new_pipeline() .with_trace_config( sdktrace::config() - .with_default_sampler(sdktrace::Sampler::AlwaysOn) + .with_sampler(sdktrace::Sampler::AlwaysOn) .with_id_generator(sdktrace::XrayIdGenerator::default()), ) .install() diff --git a/examples/http/src/client.rs b/examples/http/src/client.rs index 320840a982..0478aaa990 100644 --- a/examples/http/src/client.rs +++ b/examples/http/src/client.rs @@ -17,7 +17,7 @@ fn init_tracer() -> impl Tracer { // For the demonstration, use `Sampler::AlwaysOn` sampler to sample all traces. In a production // application, use `Sampler::ParentBased` or `Sampler::TraceIdRatioBased` with a desired ratio. stdout::new_pipeline() - .with_trace_config(trace::config().with_default_sampler(Sampler::AlwaysOn)) + .with_trace_config(trace::config().with_sampler(Sampler::AlwaysOn)) .install() } diff --git a/examples/http/src/server.rs b/examples/http/src/server.rs index e1c6328639..ccdecf4662 100644 --- a/examples/http/src/server.rs +++ b/examples/http/src/server.rs @@ -29,7 +29,7 @@ fn init_tracer() -> impl Tracer { // For the demonstration, use `Sampler::AlwaysOn` sampler to sample all traces. In a production // application, use `Sampler::ParentBased` or `Sampler::TraceIdRatioBased` with a desired ratio. stdout::new_pipeline() - .with_trace_config(trace::config().with_default_sampler(Sampler::AlwaysOn)) + .with_trace_config(trace::config().with_sampler(Sampler::AlwaysOn)) .install() } diff --git a/examples/stdout.rs b/examples/stdout.rs index b87a95fbb1..9e41ae0d56 100644 --- a/examples/stdout.rs +++ b/examples/stdout.rs @@ -9,7 +9,7 @@ fn main() { // For the demonstration, use `Sampler::AlwaysOn` sampler to sample all traces. In a production // application, use `Sampler::ParentBased` or `Sampler::TraceIdRatioBased` with a desired ratio. let tracer = stdout::new_pipeline() - .with_trace_config(trace::config().with_default_sampler(Sampler::AlwaysOn)) + .with_trace_config(trace::config().with_sampler(Sampler::AlwaysOn)) .install(); tracer.in_span("operation", |_cx| {}); diff --git a/opentelemetry-datadog/README.md b/opentelemetry-datadog/README.md index 1e187f6b81..84debd7554 100644 --- a/opentelemetry-datadog/README.md +++ b/opentelemetry-datadog/README.md @@ -73,7 +73,7 @@ to [`Datadog`]. .with_agent_endpoint("http://localhost:8126") .with_trace_config( trace::config() - .with_default_sampler(Sampler::AlwaysOn) + .with_sampler(Sampler::AlwaysOn) .with_id_generator(IdGenerator::default()) ) .install()?; diff --git a/opentelemetry-datadog/src/lib.rs b/opentelemetry-datadog/src/lib.rs index bf2eb5d07f..2410c826c5 100644 --- a/opentelemetry-datadog/src/lib.rs +++ b/opentelemetry-datadog/src/lib.rs @@ -105,7 +105,7 @@ //! .with_agent_endpoint("http://localhost:8126") //! .with_trace_config( //! trace::config() -//! .with_default_sampler(Sampler::AlwaysOn) +//! .with_sampler(Sampler::AlwaysOn) //! .with_id_generator(IdGenerator::default()) //! ) //! .install()?; diff --git a/opentelemetry-jaeger/README.md b/opentelemetry-jaeger/README.md index a05dccd99b..b34ee4345f 100644 --- a/opentelemetry-jaeger/README.md +++ b/opentelemetry-jaeger/README.md @@ -156,7 +156,7 @@ fn main() -> Result<(), Box> { .with_max_packet_size(9_216) .with_trace_config( trace::config() - .with_default_sampler(Sampler::AlwaysOn) + .with_sampler(Sampler::AlwaysOn) .with_id_generator(IdGenerator::default()) .with_max_events_per_span(64) .with_max_attributes_per_span(16) diff --git a/opentelemetry-jaeger/src/lib.rs b/opentelemetry-jaeger/src/lib.rs index c4670da54e..c6f3b8c46c 100644 --- a/opentelemetry-jaeger/src/lib.rs +++ b/opentelemetry-jaeger/src/lib.rs @@ -118,7 +118,7 @@ //! .with_max_packet_size(9_216) //! .with_trace_config( //! trace::config() -//! .with_default_sampler(Sampler::AlwaysOn) +//! .with_sampler(Sampler::AlwaysOn) //! .with_id_generator(IdGenerator::default()) //! .with_max_events_per_span(64) //! .with_max_attributes_per_span(16) diff --git a/opentelemetry-otlp/README.md b/opentelemetry-otlp/README.md index 84cb3a9b83..2171fdc38d 100644 --- a/opentelemetry-otlp/README.md +++ b/opentelemetry-otlp/README.md @@ -123,7 +123,7 @@ fn main() -> Result<(), Box> { .with_timeout(Duration::from_secs(3)) .with_trace_config( trace::config() - .with_default_sampler(Sampler::AlwaysOn) + .with_sampler(Sampler::AlwaysOn) .with_id_generator(IdGenerator::default()) .with_max_events_per_span(64) .with_max_attributes_per_span(16) diff --git a/opentelemetry-otlp/src/lib.rs b/opentelemetry-otlp/src/lib.rs index 56e3564156..1e2548724a 100644 --- a/opentelemetry-otlp/src/lib.rs +++ b/opentelemetry-otlp/src/lib.rs @@ -94,7 +94,7 @@ //! .with_timeout(Duration::from_secs(3)) //! .with_trace_config( //! trace::config() -//! .with_default_sampler(Sampler::AlwaysOn) +//! .with_sampler(Sampler::AlwaysOn) //! .with_id_generator(IdGenerator::default()) //! .with_max_events_per_span(64) //! .with_max_attributes_per_span(16) diff --git a/opentelemetry-zipkin/README.md b/opentelemetry-zipkin/README.md index 3b2b3bf01e..34c73c2781 100644 --- a/opentelemetry-zipkin/README.md +++ b/opentelemetry-zipkin/README.md @@ -134,7 +134,7 @@ fn main() -> Result<(), Box> { .with_collector_endpoint("http://localhost:9411/api/v2/spans") .with_trace_config( trace::config() - .with_default_sampler(Sampler::AlwaysOn) + .with_sampler(Sampler::AlwaysOn) .with_id_generator(IdGenerator::default()) .with_max_events_per_span(64) .with_max_attributes_per_span(16) diff --git a/opentelemetry-zipkin/src/lib.rs b/opentelemetry-zipkin/src/lib.rs index fd2c9ff2f4..566eff68e5 100644 --- a/opentelemetry-zipkin/src/lib.rs +++ b/opentelemetry-zipkin/src/lib.rs @@ -114,7 +114,7 @@ //! .with_collector_endpoint("http://localhost:9411/api/v2/spans") //! .with_trace_config( //! trace::config() -//! .with_default_sampler(Sampler::AlwaysOn) +//! .with_sampler(Sampler::AlwaysOn) //! .with_id_generator(IdGenerator::default()) //! .with_max_events_per_span(64) //! .with_max_attributes_per_span(16) diff --git a/opentelemetry/src/sdk/trace/config.rs b/opentelemetry/src/sdk/trace/config.rs index e405eca5f9..ccbf4460a4 100644 --- a/opentelemetry/src/sdk/trace/config.rs +++ b/opentelemetry/src/sdk/trace/config.rs @@ -31,10 +31,7 @@ pub struct Config { impl Config { /// Specify the default sampler to be used. - pub fn with_default_sampler( - mut self, - sampler: T, - ) -> Self { + pub fn with_sampler(mut self, sampler: T) -> Self { self.default_sampler = Box::new(sampler); self } diff --git a/opentelemetry/src/sdk/trace/tracer.rs b/opentelemetry/src/sdk/trace/tracer.rs index 71ceeaff3b..29d29fa4dc 100644 --- a/opentelemetry/src/sdk/trace/tracer.rs +++ b/opentelemetry/src/sdk/trace/tracer.rs @@ -346,7 +346,7 @@ mod tests { fn allow_sampler_to_change_trace_state() { // Setup let sampler = TestSampler {}; - let config = Config::default().with_default_sampler(sampler); + let config = Config::default().with_sampler(sampler); let tracer_provider = sdk::trace::TracerProvider::builder() .with_config(config) .build(); @@ -373,7 +373,7 @@ mod tests { #[test] fn drop_parent_based_children() { let sampler = Sampler::ParentBased(Box::new(Sampler::AlwaysOn)); - let config = Config::default().with_default_sampler(sampler); + let config = Config::default().with_sampler(sampler); let tracer_provider = sdk::trace::TracerProvider::builder() .with_config(config) .build(); @@ -388,7 +388,7 @@ mod tests { #[test] fn uses_current_context_for_builders_if_unset() { let sampler = Sampler::ParentBased(Box::new(Sampler::AlwaysOn)); - let config = Config::default().with_default_sampler(sampler); + let config = Config::default().with_sampler(sampler); let tracer_provider = sdk::trace::TracerProvider::builder() .with_config(config) .build();