Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Activity http.route and name #5026

Merged
merged 18 commits into from
Nov 17, 2023

Conversation

alanwest
Copy link
Member

@alanwest alanwest commented Nov 3, 2023

Fixes #3485
Fixes #3461
Fixes #2967
Fixes #3771

This PR fixes a number of items with respect to the Activity.DisplayName and http.route attribute:

  • Activity.DisplayName now conforms to the specification
    • It is set to {http.method} {http.route} when there is a low-cardinality http.route
    • It is {http.method} when there is not a low-cardinality http.route
  • http.route was missing for some attribute-based routing scenarios
  • http.route was missing when using minimal API
  • http.route, when present, is now the same for both the Activity and metric emitted

There remain scenarios not fixed by this PR and also changes their behavior. You can review this readme for the scenarios that remain unresolved. In summary:

  • When using conventional-based routing, http.route is set to the matched route template. This does not accurately reflect the actual route when the controller/action invoked are not the defaults. For example:
    • See this test case.
      • The path invoked is /ConventionalRoute/ActionWithStringParameter/2?num=3
      • http.route is set to {controller=ConventionalRoute}/{action=Default}/{id?}
      • Ideally, http.route would be something like ConventionalRoute/ActionWithStringParameter/{id?}.
  • When using Razor pages and invoking the root path (e.g. http://example.com/), http.route is empty.
    • See this test case
      • The path invoked is '/'
      • http.route attribute is not set
      • Ideally, http.route would be /Index because that is the default page.

These scenarios are unfortunate because it limits users from meaningfully querying metrics and faceting them by http.route. See open-telemetry/opentelemetry-dotnet-contrib#1730 and open-telemetry/opentelemetry-dotnet-contrib#1729.

Copy link

codecov bot commented Nov 9, 2023

Codecov Report

Merging #5026 (dbb9e37) into main (2a228f9) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    open-telemetry/opentelemetry-dotnet#5026      +/-   ##
==========================================
+ Coverage   83.61%   83.69%   +0.08%     
==========================================
  Files         296      296              
  Lines       12484    12483       -1     
==========================================
+ Hits        10438    10448      +10     
+ Misses       2046     2035      -11     
Flag Coverage Δ
unittests 83.69% <100.00%> (+0.08%) ⬆️

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

Files Coverage Δ
...umentation.AspNetCore/AspNetCoreInstrumentation.cs 100.00% <ø> (ø)
...tation.AspNetCore/Implementation/HttpInListener.cs 91.57% <100.00%> (-0.30%) ⬇️
...AspNetCore/Implementation/HttpInMetricsListener.cs 89.23% <100.00%> (-0.17%) ⬇️
src/Shared/RequestMethodHelper.cs 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

@alanwest alanwest force-pushed the alanwest/fix-activity-http-route branch from 098c528 to 55965ba Compare November 14, 2023 00:01
@alanwest alanwest force-pushed the alanwest/fix-activity-http-route branch from 2367168 to 2ce8425 Compare November 14, 2023 00:15
@alanwest alanwest marked this pull request as ready for review November 14, 2023 01:56
@alanwest alanwest requested a review from a team November 14, 2023 01:56
@vishweshbankwar
Copy link
Member

vishweshbankwar commented Nov 14, 2023

Tagging few other issues: #3485 #2967 #3771

Copy link
Member

@vishweshbankwar vishweshbankwar left a comment

Choose a reason for hiding this comment

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

Proposed changes looks good to me.

Comment on lines +49 to +52
There remain scenarios when using conventional routing or Razor pages where
`http.route` is still incorrect. See [#5056](https://github.com/open-telemetry/opentelemetry-dotnet/issues/5056)
and [#5057](https://github.com/open-telemetry/opentelemetry-dotnet/issues/5057)
for more details.
Copy link
Member Author

Choose a reason for hiding this comment

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

Opened these issues to highlight the remaining known issues related to http.route.

@JamesNK I'm interested in your thoughts. I'm hoping we can coordinate to resolve these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants