Skip to content

Commit

Permalink
Updated logic to create an activity even when SamplingDecision is Drop
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla committed Jan 21, 2021
1 parent 02adc4c commit 59fdea9
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/OpenTelemetry/Trace/TracerProviderSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ internal TracerProviderSdk(
else if (sampler is AlwaysOffSampler)
{
listener.Sample = (ref ActivityCreationOptions<ActivityContext> options) =>
!Sdk.SuppressInstrumentation ? PropagateOrIgnoreData(options.Parent.TraceId) : ActivitySamplingResult.None;
!Sdk.SuppressInstrumentation ? ActivitySamplingResult.PropagationData : ActivitySamplingResult.None;
}
else
{
Expand Down Expand Up @@ -287,23 +287,9 @@ private static ActivitySamplingResult ComputeActivitySamplingResult(
{
options.SamplingTags.Add(att.Key, att.Value);
}

return activitySamplingResult;
}

return PropagateOrIgnoreData(options.Parent.TraceId);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static ActivitySamplingResult PropagateOrIgnoreData(ActivityTraceId traceId)
{
var isRootSpan = traceId == default;

// If it is the root span select PropagationData so the trace ID is preserved
// even if no activity of the trace is recorded (sampled per OpenTelemetry parlance).
return isRootSpan
? ActivitySamplingResult.PropagationData
: ActivitySamplingResult.None;
return activitySamplingResult;
}
}
}

0 comments on commit 59fdea9

Please sign in to comment.