Document .NET 11 native OpenTelemetry HTTP server metrics and traces - #37528
Document .NET 11 native OpenTelemetry HTTP server metrics and traces#37528wadepickett with Copilot wants to merge 11 commits into
Conversation
…etrics.md Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
…callout Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the ASP.NET Core metrics guidance to document .NET 11’s native OpenTelemetry HTTP server metrics/tracing behavior (including the pitfall when the Microsoft.AspNetCore activity source isn’t registered) and refreshes related wording/metadata.
Changes:
- Updated article metadata and introductory explanations of metrics/collection.
- Added an
>= aspnetcore-11.0OpenTelemetry overview and an[!IMPORTANT]tracing pitfall callout with anAddSource("Microsoft.AspNetCore")fix. - Refreshed wording throughout and expanded the “meters and counters” closing guidance to mention OpenTelemetry semantic convention alignment in ASP.NET Core 11+.
Suppressed comments (3)
aspnetcore/log-mon/metrics/metrics.md:122
- Grammar: the comma after “metadata” is incorrect here. Consider removing it so the sentence reads naturally.
You can exclude HTTP requests to an endpoint from metrics by adding metadata, with either the [DisableHttpMetrics](xref:Microsoft.AspNetCore.Http.DisableHttpMetricsAttribute) attribute or the [DisableHttpMetrics](xref:Microsoft.AspNetCore.Builder.HttpMetricsEndpointConventionBuilderExtensions.DisableHttpMetrics``1(``0)) method:
aspnetcore/log-mon/metrics/metrics.md:333
- “these meters emit data that conforms … [HTTP server semantic conventions]” reads like it applies to all ASP.NET Core meters/counters in the linked list. The HTTP server semantic conventions only apply to the HTTP server meters (for example
Microsoft.AspNetCore.HostingandMicrosoft.AspNetCore.Server.Kestrel), so it should be scoped accordingly to avoid overclaiming.
For a list of ASP.NET Core meters and counters, see [ASP.NET Core metrics](/dotnet/core/diagnostics/built-in-metrics-aspnetcore). In ASP.NET Core 11 and later, these meters emit data that conforms to the required parts of the [OpenTelemetry HTTP server semantic conventions](https://opentelemetry.io/docs/specs/semconv/http/). You can consume them with the OpenTelemetry SDK without the `OpenTelemetry.Instrumentation.AspNetCore` package.
aspnetcore/log-mon/metrics/metrics.md:191
- This sentence points to
built-in-http, which is the HTTP-specific reference page. To avoid implying it lists all built-in instruments, clarify that it’s the list of built-in HTTP instruments/attributes.
Starting in ASP.NET Core 11, the framework's built-in HTTP server metrics and traces comply with the required parts of the [OpenTelemetry HTTP server semantic conventions](https://opentelemetry.io/docs/specs/semconv/http/). The HTTP server request activity emits these attributes by default, matching the built-in metrics. As a result, the [`OpenTelemetry.Instrumentation.AspNetCore`](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.AspNetCore) NuGet package is optional for collecting HTTP server metrics and traces. The sample in this article uses only the built-in meters (`Microsoft.AspNetCore.Hosting` and `Microsoft.AspNetCore.Server.Kestrel`) and doesn't reference the instrumentation package. For the list of built-in instruments and their attributes, see <xref:log-mon/metrics/built-in-http>.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Wade Pickett <wpickett@microsoft.com>
Co-authored-by: Wade Pickett <wpickett@microsoft.com>
Clarified instructions for enabling OpenTelemetry tracing in ASP.NET Core without the instrumentation package. Added example code for registering the HTTP server activity source.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
aspnetcore/log-mon/metrics/metrics.md:8
- The PR metadata shows the current date as 2026-08-25, but
ms.dateis set to 08/24/2026. Repo guidance requiresms.dateto be set to today's date (MM/DD/YYYY).
ms.date: 08/24/2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
aspnetcore/log-mon/metrics/metrics.md:8
ms.dateshould match today’s date (MM/DD/YYYY). The PR updates substantial content in this article, butms.dateis set to 08/24/2026 while today is 08/25/2026.
ms.date: 08/24/2026
| > [!IMPORTANT] | ||
| > When you enable OpenTelemetry *tracing* (in addition to metrics) without the `OpenTelemetry.Instrumentation.AspNetCore` package, register the framework's HTTP server <xref:System.Diagnostics.ActivitySource> so that the request activity is recorded. ASP.NET Core's HTTP server activity source is named `Microsoft.AspNetCore`, and the framework creates a request activity named `Microsoft.AspNetCore.Hosting.HttpRequestIn` for each request to propagate trace context. If the `Microsoft.AspNetCore` source isn't registered with the OpenTelemetry SDK, the request activity isn't recorded, and the default `ParentBased` sampler silently drops any custom child spans started during the request. |
There was a problem hiding this comment.
Depending on the target audience (someone adding telemetry vs. someone upgrading from 10 to 11 that already has telemetry), it might be worth calling out that removing OpenTelemetry.Instrumentation.AspNetCore will cause some recommended attributes to no longer be emitted (and also the conditionally required url.query attribute, see dotnet/aspnetcore#65873).
The OTel instrumentation also registers additional metrics and sources for Blazor and SignalR.
There was a problem hiding this comment.
I took a shot at addressing this, see the latest version now after my last commit. Thanks.
Clarify the differences between built-in instrumentation and the OpenTelemetry package for HTTP server metrics in ASP.NET Core 11. Provide guidance on registering activity sources for tracing.
Clarified the role of the package in enabling telemetry for Blazor and SignalR, and emphasized the need to register sources and meters manually if the package is removed.
In ASP.NET Core 11, the HTTP server
Activityemits the required OpenTelemetry HTTP server-span semantic-convention tags by default (SuppressActivityOpenTelemetryDatanow defaults tofalse), making theOpenTelemetry.Instrumentation.AspNetCorepackage optional. Adopters who drop the package hit a pitfall (opentelemetry-dotnet#7426): custom child spans are silently dropped when the framework activity source isn't registered.Updates
aspnetcore/log-mon/metrics/metrics.md(moniker-gated to>= aspnetcore-11.0):[!IMPORTANT]callout explaining that the request activity is created but unrecorded when the source isn't registered, so the defaultParentBasedsampler drops custom child spans, plus the fix.The registration snippet uses the activity source name
Microsoft.AspNetCore(verified againstdotnet/aspnetcoreWebHostBuilder.csand the shipped release-notes include) — not the meter nameMicrosoft.AspNetCore.Hosting:Scope
Limited to
metrics.md. Thebuilt-in.md/built-in-http.mdreference pages are tracked separately in #37272; YARP and SignalR articles are candidates for their own article-level tracking issues per the triage summary.Internal previews