[bug] TraceStateString is not set when the sampler returns SamplingDecision.Drop
#6054
Labels
bug
Something isn't working
needs-triage
New issues which have not been classified or triaged by a community member
pkg:OpenTelemetry
Issues related to OpenTelemetry NuGet package
Package
OpenTelemetry
Package Version
Runtime Version
net472;net6.0;net7.0;net8.0
Description
The TraceStateString cannot be controlled by the sampler when the sample decision is PropagationData only, despite it being a tool used during trace propagation.
The below code is wrapped in an if block
if (activitySamplingResult != ActivitySamplingResult.PropagationData)
opentelemetry-dotnet/src/OpenTelemetry/Trace/TracerProviderSdk.cs
Lines 518 to 522 in cd31c57
Steps to Reproduce
Expected Result
I expect to see the TraceStateString on the PropagationData-only Activity object.
Actual Result
The TraceStateString is null after the Activity object receives the Drop decision.
Additional Context
We use the TraceStateString to determine whether a trace is initiated from within our ecosystem or from outside of it. In this way, we can restart traces that originate from 3rd parties, and we can propagate traces that originate from our system.
However, when sampling drops the trace, our TraceStateString no longer gets applied, and so downstream services treat the request as if it's coming from an external party. Those downstream services might then become the root of the trace (which is misleading when that service cannot possibly be the root of a trace).
Because the TraceState is used as part of the trace propagation process (it is included in HTTP Headers for example), the sampler should always set the trace state -- not only when the trace is sampled.
The text was updated successfully, but these errors were encountered: