[Breaking change]: ActivitySource does not retain creation tags or links for PropagationData
メンテナーはふだん 1 日以内に返信
@BillWagner がすでに取り組んでいます。
2026年10月7日 から。
評価
この issue はまだ評価されていません。
説明
Description
When an ActivityListener samples an activity as ActivitySamplingResult.PropagationData, ActivitySource.CreateActivity and ActivitySource.StartActivity no longer copy caller-supplied creation tags and links to the created Activity. The tags and links remain available to the sampling callback through ActivityCreationOptions<T>.Tags and ActivityCreationOptions<T>.Links.
For more information, see dotnet/runtime#135277.
Version
.NET 12 Preview 1
Previous behavior
CreateActivity and StartActivity copied caller-supplied creation tags and links to the returned Activity even when the combined sampling result was PropagationData.
using System.Diagnostics;
using ActivitySource source = new("Example");
using ActivityListener listener = new()
{
ShouldListenTo = activitySource => ReferenceEquals(activitySource, source),
Sample = (ref ActivityCreationOptions<ActivityContext> _) =>
ActivitySamplingResult.PropagationData,
};
ActivitySource.AddActivityListener(listener);
using Activity activity = source.StartActivity(
"Request",
ActivityKind.Server,
default(ActivityContext),
tags: [new("http.request.method", "GET")],
links: [new ActivityLink(default)])!;
// The activity retained the creation tag and link.
Console.WriteLine(activity.TagObjects.Count()); // 1
Console.WriteLine(activity.Links.Count()); // 1
New behavior
When the combined sampling result is PropagationData, caller-supplied creation tags and links are not copied to the created Activity.
using System.Diagnostics;
using ActivitySource source = new("Example");
using ActivityListener listener = new()
{
ShouldListenTo = activitySource => ReferenceEquals(activitySource, source),
Sample = (ref ActivityCreationOptions<ActivityContext> options) =>
{
// Creation tags and links remain available to the sampler.
Console.WriteLine(options.Tags.Count());
Console.WriteLine(options.Links.Count());
return ActivitySamplingResult.PropagationData;
},
};
ActivitySource.AddActivityListener(listener);
using Activity activity = source.StartActivity(
"Request",
ActivityKind.Server,
default(ActivityContext),
tags: [new("http.request.method", "GET")],
links: [new ActivityLink(default)])!;
// The activity does not retain the creation tag or link.
Console.WriteLine(activity.TagObjects.Count()); // 0
Console.WriteLine(activity.Links.Count()); // 0
Tags added by a sampler through ActivityCreationOptions<T>.SamplingTags continue to be copied to the created activity. If any listener returns ActivitySamplingResult.AllData or ActivitySamplingResult.AllDataAndRecorded, the combined sampling result requests all data and the caller-supplied creation tags and links are retained.
Type of breaking change
- Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
- Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
- Behavioral change: Existing binaries might behave differently at run time.
Reason for change
PropagationData creates an activity only to propagate its identity and baggage; tags and links are unnecessary on the created activity. Avoiding their copies reduces the time and allocations for sampled-out operations while preserving their availability to samplers. For example, the PR reduced allocations from 976 B to 416 B when creating an activity with nine tags and one link.
Recommended action
Applications whose samplers need to examine creation tags or links require no changes; continue to read them from ActivityCreationOptions<T>.Tags and ActivityCreationOptions<T>.Links.
Applications that need caller-supplied creation tags or links on the returned Activity or in ActivityStarted callbacks must have a listener return ActivitySamplingResult.AllData or ActivitySamplingResult.AllDataAndRecorded for those activities. Do not return PropagationData when those properties must be retained. This retains the data but also requests all activity data and its associated allocation cost.
Feature area
Core .NET libraries
Affected APIs
All overloads that accept tags and links:
System.Diagnostics.ActivitySource.CreateActivitySystem.Diagnostics.ActivitySource.StartActivity
- 主要言語
- 言語のデータがありません
- スター
- 4.8k
- フォーク
- 6.1k
- 平均マージ
- 22時間 46分
- マージ済み PR(30日)
- 296
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/docs のほかの issue
-
Examenオープンdotnet-csharp/svc lang-reference/subsvc needs-more-info
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
dotnet/docs#56845 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Update the .NET Framework 3.5 on Windows 11 FAQ to mention Windows 11 26H2対応中かも @BillWagner が 3 日前に担当しました。 オープン:pushpin: seQUESTered dotnet/svc
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
dotnet/docs#56791 · リアクション 1 件 · 担当者 2 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
Improve description of `limitations of extensions`対応中かも @Manish-1kumar が 11 日前に担当しました。 オープンadvanced-concepts/subsvc dotnet-csharp/svc
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
dotnet/docs#56626 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Document unit-test / theory-data impact of .NET 11 double→decimal conversion対応中かも @SkyDevLab が 22 日前に担当しました。 オープン:watch: Not Triaged dotnet-fundamentals/svc
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信