-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[release/10.0-rc1] Initialize hosting trace with OTEL tags for sampling #63338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wtgodbe
merged 11 commits into
release/10.0-rc1
from
backport/pr-62090-to-release/10.0-rc1
Aug 20, 2025
Merged
[release/10.0-rc1] Initialize hosting trace with OTEL tags for sampling #63338
wtgodbe
merged 11 commits into
release/10.0-rc1
from
backport/pr-62090-to-release/10.0-rc1
Aug 20, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
also fixed up unshipped API documentation
This removes the need to expose a new Feature or make any other public changes.
Hi @@github-actions[bot]. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed. |
JamesNK
approved these changes
Aug 20, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #62090 to release/10.0-rc1
/cc @JamesNK @rkargMsft
Initialize hosting trace with OTEL tags for sampling
Description
ASP.NET Core hosting layer creates an
Activity
for tracing HTTP requests. This can be listened to usingActivityListener
. One of the features ofActivityListener
is deciding whether to sample the activity. i.e. a callback that decides whether to invest resources to create and record the activity. See https://www.jimmybogard.com/activitysource-and-listener-in-net-5/ for more info..NET 9 and earlier the activity was created without any metadata about the HTTP request. It isn't possible to use info about the current HTTP request decide to sample activities based on the matching route. For example, I want my app to sample all
/api/*
requests and ignore everything else.This PR adds HTTP tags to the activity as it's being created so apps can improve trace sampling. These HTTP tags are off by default and are opt-in in .NET 10 by setting
AppContext.SetSwitch("Microsoft.AspNetCore.Hosting.SuppressActivityOpenTelemetryData", false)
. They're defaulted to off because we don't want ASP.NET Core to add only some OTEL HTTP info to the activity.(in .NET 11 we'll do more work to improve default telemetry experience in ASP.NET Core. All OTEL HTTP info will be added to the activity. The OTEL tags will be on by default and are opt-out in .NET 11 by setting
AppContext.SetSwitch("Microsoft.AspNetCore.Hosting.SuppressActivityOpenTelemetryData", true)
)Fixes #50488
Customer Impact
Apps are unable to sample traces based on HTTP request information.
(note: you can do this kind of sampling if you using .NET OTEL SDK which adds its own mechanism for sampling, but not everyone uses that library)
Regression?
[If yes, specify the version the behavior has regressed from]
Risk
Changes default to off by default. Users who want this functionality will have to set
AppContext.SetSwitch("Microsoft.AspNetCore.Hosting.SuppressActivityOpenTelemetryData", false)
.Verification
Packaging changes reviewed?
When servicing release/2.1