[Instrumentation.AspNet] Fix multiple routes of same template in attribute-based routing#2250
Conversation
|
Please sign EasyCLA. It is hard requirement to accept any contribution to this repository. |
Thanks. Working with my company to figure this out. |
|
Okay, I finally got my company to sign the CLA. Please proceed with reviewing! |
|
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
ysolomchenko
left a comment
There was a problem hiding this comment.
Add an entry to the Changelog
ysolomchenko
left a comment
There was a problem hiding this comment.
Update the PR title to start with [Instrumentation.AspNet]
Co-authored-by: Rasmus Kuusmann <rkuusmann@splunk.com>
Co-authored-by: Yevhenii Solomchenko <ysolomchenko@splunk.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2250 +/- ##
==========================================
+ Coverage 73.91% 76.73% +2.81%
==========================================
Files 267 15 -252
Lines 9615 361 -9254
==========================================
- Hits 7107 277 -6830
+ Misses 2508 84 -2424
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Changes
ASP.NET instrumentation fails to extract route for attribute-based routing, if multiple HTTP methods use the same route template--a common scenario for RESTful APIs. For example:
In this case, the
MS_Subroutesarray will have multiple elements, each corresponding to a different HTTP method.The original code only extracts the route template if there's only one element in the array. The correct thing to do is to just extract the template from the first subroute, since all subroutes have the same template.
It's not possible for MS_Subroutes array to have different templates in its elements. WebAPI would fail to route and throw an exception, if you declare multiple actions for the same method/template
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changes