Skip to content

Commit a5523ae

Browse files
author
Craig Pastro
authored
The probability sampler should ignore the parent sampled flag (#154)
1 parent 53113ad commit a5523ae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/sdk/trace/sampler.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ impl api::Sampler for Sampler {
4444
}
4545
},
4646
),
47-
// Match parent or probabilistically sample the trace.
47+
// Probabilistically sample the trace.
4848
Sampler::Probability(prob) => {
49-
if *prob >= 1.0 || parent_context.map(|ctx| ctx.is_sampled()).unwrap_or(false) {
49+
if *prob >= 1.0 {
5050
api::SamplingDecision::RecordAndSampled
5151
} else {
5252
let prob_upper_bound = (prob.max(0.0) * (1u64 << 63) as f64) as u64;
@@ -107,9 +107,9 @@ mod tests {
107107
("unsampled_parent_or_else_with_always_off", Sampler::ParentOrElse(Box::new(Sampler::AlwaysOff)), 0.0, true, false),
108108
("unsampled_parent_or_else_with_probability", Sampler::ParentOrElse(Box::new(Sampler::Probability(0.25))), 0.0, true, false),
109109

110-
// Spans with a parent that is sampled, will always sample, regardless of the probability
111-
("sampled_parent_with_probability_-1", Sampler::Probability(-1.0), 1.0, true, true),
112-
("sampled_parent_with_probability_.25", Sampler::Probability(0.25), 1.0, true, true),
110+
// A probability sampler with a parent that is sampled will ignore the parent
111+
("sampled_parent_with_probability_-1", Sampler::Probability(-1.0), 0.0, true, true),
112+
("sampled_parent_with_probability_.25", Sampler::Probability(0.25), 0.25, true, true),
113113
("sampled_parent_with_probability_2.0", Sampler::Probability(2.0), 1.0, true, true),
114114

115115
// Spans with a parent that is sampled, will always sample, regardless of the delegate sampler

0 commit comments

Comments
 (0)