[Breaking change]: Activity.Recorded behavior change for PropagationData sampling result with Recorded parent #44282
Labels
breaking-change
Indicates a .NET Core breaking change
🏁 Release: .NET 10
Work items for the .NET 10 release
doc-idea
Indicates issues that are suggestions for new topics [org][type][category]
Pri1
High priority, do before Pri2 and Pri3
⌚ Not Triaged
Not triaged
Description
The
ActivitySource.CreateActivity
andActivitySource.StartActivity
APIs only return anActivity
when there is a registered listener which decides the instance should be created. This is generally known as sampling.The
ActivitySamplingResult
enum
defines the possible sampling decisions.When creating an
Activity
without a parent,ActivitySamplingResult
drives whether theActivity
is created and then how theRecorded
andIsAllDataRequested
properties are set:It is also possible to create an
Activity
with a parent. The parent could be in the same process, or it could be a remote parent propagated to the current process.An issue was discovered where if the parent has
Recorded=true
AND theActivitySamplingResult
isPropagationData
then the createdActivity
has aRecorded
value which breaks with the above:This may cause issues for users:
OpenTelemetry .NET, for example, will capture/export any
Activity
withRecorded=true
. AnActivity
sampled asPropagationData
should not be recorded by definition.When performing external operations (such as HTTP calls) the current
Activity
is propagated to downstream systems. APropagationData
Activity
should be propagated, but the current design causes it to be propagated asRecorded
which may lead downstream systems to treat the trace as sampled.dotnet/runtime#111289 adjusts the logic as such:
This is a breaking change but one that corrects the behavior following the OpenTelemetry Specification.
Version
.NET 10 Preview 1
Previous behavior
When creating an
Activity
asPropagationData
with a parent marked asRecorded
:New behavior
When creating an
Activity
asPropagationData
with a parent marked asRecorded
:Type of breaking change
Reason for change
The existing behavior does not follow the OpenTelemetry Specification.
Recommended action
Users who have implemented
ActivityListener.Sample
directly AND useActivitySamplingResult.PropagationData
should verify they are not reliant on the flawed behavior.Activity.ActivityTraceFlags
may be set toRecorded
after theCreateActivity
orStartActivity
call to restore the previous behavior.Users using OpenTelemetry .NET should verify their sampler configuration. The default OpenTelemetry .NET configuration uses a parent-based algorithm which is not impacted. Only users who have customized the sampler should verify the behavior.
Feature area
Other (please put exact area in description textbox)
Affected APIs
ActivitySource.CreateActivity
ActivitySource.StartActivity
The text was updated successfully, but these errors were encountered: