Skip to content

Commit

Permalink
Rename trace config with_default_sampler to with_sampler (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtescher authored Mar 16, 2021
1 parent e9ef3e2 commit a49d6f5
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion examples/aws-xray/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion examples/aws-xray/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion examples/http/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion examples/http/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion examples/stdout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {});
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-datadog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-datadog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-jaeger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
.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)
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-jaeger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
.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)
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-zipkin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
.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)
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-zipkin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions opentelemetry/src/sdk/trace/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ pub struct Config {

impl Config {
/// Specify the default sampler to be used.
pub fn with_default_sampler<T: sdk::trace::ShouldSample + 'static>(
mut self,
sampler: T,
) -> Self {
pub fn with_sampler<T: sdk::trace::ShouldSample + 'static>(mut self, sampler: T) -> Self {
self.default_sampler = Box::new(sampler);
self
}
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry/src/sdk/trace/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit a49d6f5

Please sign in to comment.