-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Change default ActivityIdFormat to W3C
The W3C ActivityIdFormat was introduced as an alternative to the hierarchical ActivityIdFormat in .NET Core 3.0. In an attempt to preserve compatibility this format wasn't made as the default format.
In .NET 5.0, we are changing the default format.
Version introduced
.NET 5
Any app targeting any platform other than .NET 5.0 will not get this change and will experience the old behavior which is setting the default ActivityIdFormat to Hierarchical. This will include the platforms net45+, netstandard1.1+, and netcoreapp (1.x, 2.x, and 3.x)
Old behavior
The default identifier format used for activity was the hierarchical activity format.
Activity.DefaultIdFormat = ActivityIdFormat.HierarchicalNew behavior
The default identifier format used for activity is the W3C activity format.
Activity.DefaultIdFormat = ActivityIdFormat.W3CReason for change
However, as the W3C format has been ratified and gains traction across multiple language implementations it makes sense to change the default ActivityIdFormat to W3C.
Recommended action
Given that libraries such as ASP.NET Core can consume, and HttpClient can propagate both versions of the ActivityIdFormat, there is no recommended action if the user's application is agnostic to the identifier used for distributed tracing.
Assuming interoperability with existing systems is required OR the current systems rely on the format of the identifier, there are a few options to preserve existing behavior.
- Use the existing public API,
Activity.DefaultIdFormat = ActivityIdFormat.Hierarchical - Set an AppContext switch to revert to the old behavior, this can be done using one of the following options:
- in the project
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Diagnostics.DefaultActivityIdFormatIsHierarchial" Value="true" />
</ItemGroup>- in runtimeconfig.json file
{
"runtimeOptions": {
"configProperties": {
"System.Diagnostics.DefaultActivityIdFormatIsHierarchial": true
}
}
}- Setting the environment variable value `DOTNET_SYSTEM_DIAGNOSTICS_DEFAULTACTIVITYIDFORMATISHIERARCHIAL` to true or 1.
Category
Core .NET libraries
Affected APIs
https://docs.microsoft.com/dotnet/api/system.diagnostics.activity.defaultidformat
Issue metadata
- Issue type: breaking-change