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
Ignore trailing slash by default when recording web metrics #18207
Comments
@rswart Thanks for the report. I've transferred this issue to the Spring Framework team to see if they can deal with this when setting the |
I'm probably missing something. The attribute reflects the matched handler. Shouldn't that be the same in both cases? |
@rswart Did you mean |
Yes, apologies. I didn't look into it deeply enough. So apparently 2 patterns are created for the same handler when |
The I am quite certain that what is a "fix" for some will cause regression for others. A valid counter-argument would be that it's better to present the complete information, and the trailing slash can then be easily filtered out or ignored. I think it would make more sense for a metrics filter to decide whether to strip trailing slashes or not, possibly making that configurable. |
I am closing this from a Spring Framework perspective, but feel free to re-open and transfer back to Spring Boot if that makes sense. |
The team decided to strip trailing slashes in our metrics filter, but still offer a configuration property in case trailing slashes are meaningful for some applications. |
The
WebMvcMetricsFilter
uses theHandlerMapping.BEST_MATCHING_HANDLER_ATTRIBUTE
to determine which handler the metric should be labeled with.Since
useTrailingSlashMatch
is true by default most mvc controllers configured with a request mapping like:will match both
/foo
and/foo/
and as a resultBEST_MATCHING_HANDLER_ATTRIBUTE
for this request mapping can have 2 values.This leads to split metrics for the same request mapping: one for
/foo
and one for/foo/
.For now I have worked around this with a
MeterRegistryCustomizer
that strips the trailing slash, but I wonder if this does not deserve a more structural solution, e.g inside the metrics filter itself.The text was updated successfully, but these errors were encountered: