Skip to content

Add routing metrics #48637

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

Merged
merged 9 commits into from
Jun 10, 2023
Merged

Add routing metrics #48637

merged 9 commits into from
Jun 10, 2023

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Jun 6, 2023

Fixes #46404

Note that the route is still added as a tag to the hosting HTTP request counter. The intent of the new routing counters is to provide additional detail:

  • Request successfully matched (available today)
  • Request successfully matched to a fallback route
  • Request failed to match a route

Ready for review but blocked on merging until API review of counter names/description is done.

@JamesNK JamesNK requested a review from Tratcher June 6, 2023 08:31
@JamesNK JamesNK requested a review from javiercn as a code owner June 6, 2023 08:31
@JamesNK JamesNK added the blocked The work on this issue is blocked due to some dependency label Jun 6, 2023

public void MatchFailure()
{
_matchFailureCounter.Add(1);
Copy link
Member

Choose a reason for hiding this comment

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

We'll need to be clear in the docs that there are lots of requests handled by middleware that will be reported as route match failures. E.g. static files, auth callbacks, etc. I wonder if that will make this counter more noise than value.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@geeknoid @tekian Is this a counter you want?

Copy link
Member

Choose a reason for hiding this comment

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

We'll need to be clear in the docs that there are lots of requests handled by middleware that will be reported as route match failures. E.g. static files, auth callbacks, etc. I wonder if that will make this counter more noise than value.

Can you show an example of this? I'm not sure how desirable this is. We need to verify this for all sorts of applications. (blazor to apis)

Copy link
Member Author

@JamesNK JamesNK Jun 10, 2023

Choose a reason for hiding this comment

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

I thought about this counter more, and I think we should keep it.

  • It doesn't cost anything to have it. Implementation is simple, and the counter doesn't hurt perf if no one listens. If someone doesn't care about it, then they won't listen.
  • If people see a counter that reports route matching success, they'll expect a counter that reports failure. Provides symmetry.
  • Potential confusion about what the counter reports and what it means can be explained in the description. The description can say that unmatched requests may be handled later by other middleware, such as static files or authentication callbacks. The description could even recommend http-server-unhandled-requests if you want a counter for requests that go nowhere.

I'll make these changes and then merge this PR soon. If I don't hear feedback, I'll assume people are okay with this. It's not an end to discussion; I don't want to hold up metrics progress towards done.

@JamesNK
Copy link
Member Author

JamesNK commented Jun 7, 2023

cc @geeknoid

@JamesNK JamesNK added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares and removed area-runtime blocked The work on this issue is blocked due to some dependency labels Jun 7, 2023
@JamesNK JamesNK force-pushed the jamesnk/routing-metrics branch from 1eadab1 to f0ef1d7 Compare June 9, 2023 05:03
@JamesNK
Copy link
Member Author

JamesNK commented Jun 9, 2023

API review: #48670

@JamesNK JamesNK force-pushed the jamesnk/routing-metrics branch from a099073 to 80cc820 Compare June 10, 2023 03:06
@JamesNK JamesNK requested a review from a team as a code owner June 10, 2023 06:02
@JamesNK JamesNK merged commit 34d37ec into main Jun 10, 2023
@JamesNK JamesNK deleted the jamesnk/routing-metrics branch June 10, 2023 09:26
@ghost ghost added this to the 8.0-preview6 milestone Jun 10, 2023
@adityamandaleeka adityamandaleeka added the blog-candidate Consider mentioning this in the release blog post label Jun 28, 2023
@ghost
Copy link

ghost commented Jun 28, 2023

@JamesNK, this change will be considered for inclusion in the blog post for the release it'll ship in. Nice work!

Please ensure that the original comment in this thread contains a clear explanation of what the change does, why it's important (what problem does it solve?), and, if relevant, include things like code samples and/or performance numbers.

This content may not be exactly what goes into the blog post, but it will help the team putting together the announcement.

Thanks!

@adityamandaleeka
Copy link
Member

@JamesNK Marking this PR as blog-candidate, but we probably want to mention all the metrics work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares blog-candidate Consider mentioning this in the release blog post
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Counters & Logs for 404s and MapFallback
8 participants