[AspNetCore] Align route behaviour#3992
Conversation
Align the behaviour for computing the route with the logic of ASP.NET Core 8+ itself. The metric route is incorrectly empty in .NET 8 and 9 so the test data has been adjusted to account for that.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3992 +/- ##
==========================================
+ Coverage 71.75% 71.90% +0.14%
==========================================
Files 458 448 -10
Lines 17869 17823 -46
==========================================
- Hits 12822 12815 -7
+ Misses 5047 5008 -39
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Aligns http.route computation in the ASP.NET Core instrumentation with ASP.NET Core 8+ internal routing/diagnostics behavior, and updates route test expectations accordingly (including known .NET 8/9 metrics-route quirks).
Changes:
- Update route extraction to use
IRouteDiagnosticsMetadataand normalize empty routes to/, mirroring ASP.NET Core behavior. - Adjust route test case data and generated README outputs for .NET 8/9/10 to reflect the updated route/display-name behavior.
- Document the behavioral change in the ASP.NET Core instrumentation changelog.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/OpenTelemetry.Instrumentation.AspNetCore.Tests/RouteTests/RoutingTestCases.json | Updates expected/current route values for root path scenarios and .NET version-specific metrics expectations. |
| test/OpenTelemetry.Instrumentation.AspNetCore.Tests/RouteTests/README.net8.0.md | Updates recorded activity display name and route for RazorPages root path. |
| test/OpenTelemetry.Instrumentation.AspNetCore.Tests/RouteTests/README.net9.0.md | Updates recorded activity display name and route for RazorPages root path. |
| test/OpenTelemetry.Instrumentation.AspNetCore.Tests/RouteTests/README.net10.0.md | Updates recorded activity display name and route for RazorPages root path. |
| src/OpenTelemetry.Instrumentation.AspNetCore/HttpContextExtensions.cs | Reworks route resolution to use ASP.NET Core diagnostics metadata and original-endpoint fallback. |
| src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md | Notes the alignment of http.route behavior with ASP.NET Core. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
See martincostello#2 (comment).
Relates to #3808.
Changes
Align the behaviour for computing the route with the logic of ASP.NET Core 8+ itself.
The metric route is incorrectly empty in .NET 8 and 9 so the test data has been adjusted to account for that.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)