[OpenTelemetry] Hosting replaces an Activity.DisplayName that the app set, when a route matches
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- csharp
Línea de trabajo
Empieza en src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs, especialmente en el código citado alrededor de las líneas 486 y 595-601, para rastrear dónde Hosting establece y luego reemplaza Activity.DisplayName. Revisa las pruebas relacionadas de diagnósticos de hosting y ejecuta las pruebas específicas de este comportamiento. Se considera terminado cuando se conserva un nombre establecido por la aplicación, mientras que un nombre sin cambios que solo contiene el método sigue convirtiéndose en {method} {route}.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
.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.
Steps To Reproduce
Repro: https://github.com/PetarJerinic/aspnetcore-displayname-repro
using System.Diagnostics;
using Microsoft.AspNetCore.Http.Features;
using var listener = new ActivityListener
{
ShouldListenTo = source => source.Name == "Microsoft.AspNetCore",
Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllDataAndRecorded,
ActivityStopped = activity => Console.WriteLine($"Stopped: DisplayName = '{activity.DisplayName}'"),
};
ActivitySource.AddActivityListener(listener);
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls("http://127.0.0.1:5099");
builder.Logging.ClearProviders();
var app = builder.Build();
app.MapGet("/items/{id}", (HttpContext context) =>
{
// The app gives the span a more useful name.
context.Features.Get<IHttpActivityFeature>()!.Activity.DisplayName = "custom-name";
return "ok";
});
await app.StartAsync();
using var client = new HttpClient();
await client.GetStringAsync("http://127.0.0.1:5099/items/1");
await app.StopAsync();
dotnet run output:
net10.0(10.0.13):Stopped: DisplayName = 'custom-name'net11.0(11.0.0):Stopped: DisplayName = 'GET /items/{id}'
Exceptions (if any)
No response
.NET Version
11.0.100
Anything else?
- ASP.NET Core version: 11.0.0
- OS: macOS
- Lenguaje dominante
- C#
- Estrellas
- 38.5k
- Forks
- 12.3k
- Merge medio
- 3 d 2 h
- PR fusionados (30 d)
- 283
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnet/aspnetcore
-
area-infrastructure
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dotnet/aspnetcore#70524 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[SSE] ServerSentEventsResult.WrapEvents is missing [EnumeratorCancellation], so RequestAborted never reaches the app's generator on the IAsyncEnumerable<T> overloadPosiblemente ocupada @bharatprajapati-coder la tomó hoy. Abiertoarea-minimal
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dotnet/aspnetcore#70419 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[Blazor] DefaultInMemoryCircuitPersistenceProvider never disposes the retention CancellationTokenSource when a persist is rejected at capacityPosiblemente ocupada @Vinoth2562000 la tomó hoy. Abiertoarea-blazor
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
dotnet/aspnetcore#70418 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
FieldIdentifier.Create throws ArgumentException when an indexer argument is a captured long, Guid or other non-int value typePosiblemente ocupada @Yuvan111 la tomó hace 1 día. Abiertoarea-blazor NativeAOT
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
dotnet/aspnetcore#70406 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dotnet/aspnetcore#70370 ·
Los mantenedores suelen responder en 1 día
Todos los issues de dotnet/aspnetcore
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ReubenBond/fast-caspaxos#18 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
openrewrite/rewrite#9835 ·
Los mantenedores suelen responder en 1 día
-
Same-repo PRs never get the required appveyor/pr checkPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
activescott/lessmsi#309 · 3 comentarios ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
corvus-dotnet/Corvus.JsonSchema#1068 ·
Los mantenedores suelen responder en 1 día
-
Aurora: the wavetable stack is drawn magnified and cut off on a scaled Windows display (125 %)Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día