Skip to content

[AspNetCore] Align route behaviour#3992

Merged
martincostello merged 1 commit into
open-telemetry:mainfrom
martincostello:aspnetcore-route-alignment
Mar 20, 2026
Merged

[AspNetCore] Align route behaviour#3992
martincostello merged 1 commit into
open-telemetry:mainfrom
martincostello:aspnetcore-route-alignment

Conversation

@martincostello
Copy link
Copy Markdown
Member

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

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

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.
@github-actions github-actions Bot added the comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore label Mar 19, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.90%. Comparing base (22ad929) to head (e71f9a0).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests-Instrumentation.AspNet 77.37% <ø> (ø)
unittests-Instrumentation.AspNetCore 70.09% <100.00%> (+0.45%) ⬆️
unittests-Instrumentation.Cassandra ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...nstrumentation.AspNetCore/HttpContextExtensions.cs 100.00% <100.00%> (ø)

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Kielek Kielek requested a review from RassK March 19, 2026 12:11
@martincostello martincostello marked this pull request as ready for review March 19, 2026 12:37
@martincostello martincostello requested a review from a team as a code owner March 19, 2026 12:37
Copilot AI review requested due to automatic review settings March 19, 2026 12:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 IRouteDiagnosticsMetadata and 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.

@martincostello martincostello added this pull request to the merge queue Mar 20, 2026
Merged via the queue into open-telemetry:main with commit 43e35e5 Mar 20, 2026
76 checks passed
@martincostello martincostello deleted the aspnetcore-route-alignment branch March 20, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants