You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[OpenTelemetry] Hosting replaces an Activity.DisplayName that the app set, when a route matches #70516
.NET 11 (#64851) sets Activity.DisplayName to {method} {route} at the end of the request when a route matches. It does not check the current name (HostingApplicationDiagnostics.cs#L595-L601). This means that a name that the app sets during the request is lost.
In .NET 10, hosting does not write DisplayName at the end of the request, and the name from the app stays. The repro below prints custom-name on .NET 10 and GET /items/{id} on .NET 11.
The OpenTelemetry instrumentation had the same problem on .NET 10 and earlier (open-telemetry/opentelemetry-dotnet-contrib#1948). On .NET 11 the instrumentation leaves the rename to hosting, so it cannot keep the name.
Expected Behavior
Hosting replaces the name only when it still has the method-only name that hosting set at the start (L486). A name that the app sets stays.
If the app does not set a name, the result does not change: the span gets {method} {route}. The check is one string comparison at the end of the request.
usingSystem.Diagnostics;usingMicrosoft.AspNetCore.Http.Features;usingvarlistener=newActivityListener{ShouldListenTo= source =>source.Name=="Microsoft.AspNetCore",Sample=(refActivityCreationOptions<ActivityContext>_)=>ActivitySamplingResult.AllDataAndRecorded,ActivityStopped= activity =>Console.WriteLine($"Stopped: DisplayName = '{activity.DisplayName}'"),};ActivitySource.AddActivityListener(listener);varbuilder=WebApplication.CreateBuilder(args);builder.WebHost.UseUrls("http://127.0.0.1:5099");builder.Logging.ClearProviders();varapp=builder.Build();app.MapGet("/items/{id}",(HttpContextcontext)=>{// The app gives the span a more useful name.context.Features.Get<IHttpActivityFeature>()!.Activity.DisplayName="custom-name";return"ok";});awaitapp.StartAsync();usingvarclient=newHttpClient();awaitclient.GetStringAsync("http://127.0.0.1:5099/items/1");awaitapp.StopAsync();
Activity
github-actions commentedon Nov 11, 2026
Triage Summary
Area:
area-hosting(HostingApplicationDiagnosticsinsrc/Hosting/Hosting)Type:
Bug(preserved)Regression Info
Activity.DisplayName(custom-name) is kept on .NET 10 but replaced byGET /items/{id}on .NET 11.Potential Duplicates