In case of processing errors, Microsoft.AspNetCore.Server.Kestrel diagnostic metrics contain duplicates of error.type in the output statistics for kestrel.connection.duration, both when viewed by standard diagnostic tools and when publishing values to Prometheus/OpenTelemetry, which leads to failures due to duplication error.
The application works fine with .NET 8, the issue occurs when migrating to .NET 9 Preview 7
Expected Behavior
The tags on the metrics should not be duplicated
Steps To Reproduce
Run the example application below using dotnet run
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", (HttpContext context, CancellationToken _) => Console.WriteLine(context.Connection.RemoteIpAddress));
app.Run();
Attach using dotnet-counters collect -n DuplicateTagRepro Microsoft.AspNetCore.Server.Kestrel (or any other tooling that allows seeing the Microsoft.AspNetCore.Server.Kestrel metrics.
Simulate errors, e.g., by running the following code 1 or more times, adjusting the connection port to match the running application (see step 1)
using System.Net;
using System.Net.Sockets;
using var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
socket.LingerState = new LingerOption(false, 0);
socket.Connect(IPAddress.Loopback, 62203);
socket.Send("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"u8);
socket.Close();
Observe that metrics now show Microsoft.AspNetCore.Server.Kestrel,kestrel.connection.duration metrics with duplicated error.type=invalid_request_line tags
E.g. Microsoft.AspNetCore.Server.Kestrel,kestrel.connection.duration (s)[error.type=invalid_request_line;error.type=invalid_request_line;network.protocol.name=http;network.protocol.version=1.1;network.transport=tcp;network.type=ipv4;server.address=127.0.0.1;server.port=62203;Percentile=95],Metric,0.00519561767578125
Is there an existing issue for this?
Describe the bug
In case of processing errors,
Microsoft.AspNetCore.Server.Kestrel
diagnostic metrics contain duplicates oferror.type
in the output statistics forkestrel.connection.duration
, both when viewed by standard diagnostic tools and when publishing values toPrometheus
/OpenTelemetry
, which leads to failures due to duplication error.The issue is similar to the situation in https://github.com/dotnet/aspnetcore/issues/55159.
Examples of publishing to prometheus:
The application works fine with .NET 8, the issue occurs when migrating to .NET 9 Preview 7
Expected Behavior
The tags on the metrics should not be duplicated
Steps To Reproduce
dotnet run
Attach using
dotnet-counters collect -n DuplicateTagRepro Microsoft.AspNetCore.Server.Kestrel
(or any other tooling that allows seeing theMicrosoft.AspNetCore.Server.Kestrel
metrics.Simulate errors, e.g., by running the following code 1 or more times, adjusting the connection port to match the running application (see step 1)
Microsoft.AspNetCore.Server.Kestrel,kestrel.connection.duration
metrics with duplicatederror.type=invalid_request_line
tagsE.g.
Microsoft.AspNetCore.Server.Kestrel,kestrel.connection.duration (s)[error.type=invalid_request_line;error.type=invalid_request_line;network.protocol.name=http;network.protocol.version=1.1;network.transport=tcp;network.type=ipv4;server.address=127.0.0.1;server.port=62203;Percentile=95],Metric,0.00519561767578125
Exceptions (if any)
No response
.NET Version
9.0.100-preview.7.24407.12
Anything else?
No response