-
Notifications
You must be signed in to change notification settings - Fork 511
Description
Describe your environment
Ubuntu22.04
OpenTelemetry-cpp v1.22.0
Steps to reproduce
- Process1: Start a span, and set it to active, as parent, propogate(IsSampled=true)
- Process2: Start a child span, with custom sampler, which returns Decision::DROP
- Check the child span trace flag, it would be true
What is the expected behavior?
Per the spec, TraceFlags::kIsSampled must reflect the sampler decision.
Dropped spans should have the sampled bit unset.
What is the actual behavior?
The child span always get the same IsSampled()=true if the parent is sampled, no matter what the custom sampler returns.
Root Cause
The code copies the parent’s flags (see this line) and only sets the sampled bit when ShouldSample returns RECORD_AND_SAMPLE(see this line). It never clears the bit for DROP/RECORD_ONLY. When a drop decision occurs, the SDK still creates a SpanContext with kIsSampled set and wraps it in a NoopSpan, so span->GetContext().IsSampled() remains true.
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.