Skip to content

Add tracing configuration docs - #55758

Draft
rosebyte wants to merge 1 commit into
dotnet:mainfrom
rosebyte:rosebyte-tracing-configuration-docs
Draft

Add tracing configuration docs#55758
rosebyte wants to merge 1 commit into
dotnet:mainfrom
rosebyte:rosebyte-tracing-configuration-docs

Conversation

@rosebyte

@rosebyte rosebyte commented Aug 27, 2026

Copy link
Copy Markdown
Member

Summary

Adds documentation for the .NET 11 distributed tracing configuration APIs and links it from the distributed tracing overview and diagnostics table of contents.

Content sources

  • Copied verbatim: None.
  • Adapted from runtime implementation and tests: API registration, configuration schema, rule matching and precedence, global and local source scopes, configuration reload behaviour, and invalid-configuration behaviour.
  • Newly written explanatory content: Article organisation, schema tables, examples, guidance, and runnable C# and Visual Basic samples. These sections require domain-owner review.

The existing .NET 11 What's New entry remains unchanged.

Related to dotnet/runtime#129380.


Internal previews

File Preview link
docs/core/diagnostics/distributed-tracing-configuration.md Learn preview
docs/core/diagnostics/distributed-tracing.md Learn preview
docs/core/diagnostics/snippets/distributed-tracing-configuration/appsettings.json Learn preview
docs/core/diagnostics/snippets/distributed-tracing-configuration/csharp/Program.cs Learn preview
docs/core/diagnostics/snippets/distributed-tracing-configuration/vb/Program.vb Learn preview
docs/navigate/tools-diagnostics/toc.yml Learn preview

Build report

Copilot AI lite review requested due to automatic review settings August 27, 2026 13:32
@dotnetrepoman dotnetrepoman Bot added this to the August 2026 milestone Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new documentation article that explains how to register and configure the .NET 11 distributed tracing configuration APIs, and wires the new article into existing navigation for diagnostics/distributed tracing.

Changes:

  • Adds a new “Configure distributed tracing” article covering rule schema, matching, precedence, scopes, reload behavior, and invalid configuration behavior.
  • Adds runnable C# and Visual Basic sample projects plus an appsettings.json example used by the article.
  • Links the new article from the distributed tracing overview and the tools/diagnostics TOC.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/navigate/tools-diagnostics/toc.yml Adds a TOC entry for the new configuration article under distributed tracing.
docs/core/diagnostics/distributed-tracing.md Adds a link to the new configuration article from the distributed tracing overview.
docs/core/diagnostics/distributed-tracing-configuration.md New article documenting tracing listener registration and configuration rules, including samples and schema guidance.
docs/core/diagnostics/snippets/distributed-tracing-configuration/appsettings.json Adds a JSON configuration example referenced from the article.
docs/core/diagnostics/snippets/distributed-tracing-configuration/csharp/TracingConfiguration.csproj Adds a runnable C# console sample project targeting net11.0.
docs/core/diagnostics/snippets/distributed-tracing-configuration/csharp/Program.cs Adds the C# runnable sample used in the article.
docs/core/diagnostics/snippets/distributed-tracing-configuration/vb/TracingConfiguration.vbproj Adds a runnable VB console sample project targeting net11.0.
docs/core/diagnostics/snippets/distributed-tracing-configuration/vb/Program.vb Adds the VB runnable sample used in the article.
Suppressed comments (1)

docs/core/diagnostics/distributed-tracing-configuration.md:144

  • This xref uses the System.Diagnostics namespace, but ActivitySourceFactory is in Microsoft.Extensions.Diagnostics.Tracing. As written, the xref likely won't resolve.
Use <xref:System.Diagnostics.ActivitySourceFactory.Create*> when you want the dependency injection container to manage the source and its tracing listeners. A factory's listeners ignore local sources created by a different factory. Rules in `EnabledTracing` apply to both source types.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

- Configure the listener's sampling and notification delegates through <xref:Microsoft.Extensions.Diagnostics.Tracing.ActivityListenerBuilder>. The tracing infrastructure owns `ShouldListenTo`, source subscriptions, and the listener lifetime.
- Call <xref:Microsoft.Extensions.Diagnostics.Tracing.TracingBuilderConfigurationExtensions.AddConfiguration*> with the configuration section that contains the rules. For a section named `Tracing`, pass `configuration.GetSection("Tracing")`.

The [complete sample](#run-the-sample) shows all three calls. A .NET host activates tracing subscriptions when the host starts. If you use dependency injection without a host, resolve the registered <xref:System.Diagnostics.ActivitySourceFactory> to construct the listeners and activate their subscriptions. The complete sample resolves the factory directly.

The configuration loader silently ignores a leaf value that isn't a valid Boolean. It also ignores unknown or malformed sections that don't match the supported schema. Check key names carefully because these cases don't produce an exception.

A source expression can contain at most one `*` wildcard. A rule with more than one wildcard throws an <xref:System.ArgumentException> when the rule is materialised, either during app startup or after configuration reload. For programmatic rules, <xref:Microsoft.Extensions.Diagnostics.Tracing.ActivitySourceScopes.None> also causes an <xref:System.ArgumentOutOfRangeException>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants