You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
using OpenTelemetry.Trace;
namespace Example;
public sealed class TraceStateAlwaysOffSampler: Sampler {
public override SamplingResult ShouldSample( in SamplingParameters samplingParameters ) {
return new SamplingResult(
decision: SamplingDecision.Drop,
traceStateString: "traces-never-see-this"
);
}
}
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:
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: