dotnet / dotnet/aspnetcore

http.server.request.duration reports the error-page route after pipeline re-execution

Open
#68,551 0 comments 0 reactions 0 assignees View on GitHub
area-middleware
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

When UseExceptionHandler or UseStatusCodePagesWithReExecute re-executes a request, the  http.server.request.duration metric reports http.route as  Error/{statusCode:int?} instead of the original endpoint. This prevents per-endpoint failure metrics.

### Expected Behavior

http.route should identify the original failing endpoint, such as Throw  or the Index route

### Steps To Reproduce

1. Clone https://github.com/Lei863/HttpRouteMetricRepro.
2. Run  dotnet run .
3. Request:
/Throw
/?fail=true
4. Observe both failures report:
http.route=Error/{statusCode:int?}

### Exceptions (if any)

The  /Throw  scenario intentionally throws  InvalidOperationException

### .NET Version

.NET 8 / ASP.NET Core 8.0.11

### Anything else?

Related PR: https://github.com/dotnet/aspnetcore/pull/52652. Its original-endpoint stash is ignored because routing assigns the error endpoint during re-execution

Contributor guide

Open the contributing guide

Research direction

Start by running the HttpRouteMetricRepro project with the listed /Throw and /?fail=true requests, then inspect the UseExceptionHandler and UseStatusCodePagesWithReExecute re-execution flow alongside related PR #52652. Verify that http.server.request.duration retains the original endpoint route rather than Error/{statusCode:int?}, and add or update coverage for both failing scenarios.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.