Skip to content

Commit 14b0de7

Browse files
committed
Sample traces based on the parent span if available
1 parent f527c17 commit 14b0de7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/cli/src/telemetry.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,14 @@ fn otlp_tracer_provider(
119119
let batch_processor =
120120
BatchSpanProcessor::builder(exporter, opentelemetry_sdk::runtime::Tokio).build();
121121

122+
// We sample traces based on the parent if we have one, and if not, we
123+
// sample a ratio based on the configured sample rate
124+
let sampler = Sampler::ParentBased(Box::new(Sampler::TraceIdRatioBased(sample_rate)));
125+
122126
let tracer_provider = SdkTracerProvider::builder()
123127
.with_span_processor(batch_processor)
124128
.with_resource(resource())
125-
.with_sampler(Sampler::TraceIdRatioBased(sample_rate))
129+
.with_sampler(sampler)
126130
.build();
127131

128132
Ok(tracer_provider)

0 commit comments

Comments
 (0)