-
Notifications
You must be signed in to change notification settings - Fork 41.1k
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
Missing functionality or Different behavior of ServerRequestObservationConvention, does not provide a way to add tags to long task timers #41747
Comments
The To add a tag to a metric, you can use a @Bean
MeterFilter meterFilter() {
return new MeterFilter() {
@Override
public Meter.Id map(Meter.Id id) {
if (id.getName().equals("aws.scrape")) {
return id.withTag(Tag.of("additional", "tag"));
}
return id;
}
};
} If you want to have an observation instead, use Btw, Does that solve your problem? |
The problem statement is to add custom tags to long task timers annotated in the handlers of a controller in a centralized way without knowing specific metername This was exactly solved by WebMvcMetricsFilter before. The earlier implementation i.e till 2.7.18, WebMvcMetricFilter had a logic to get all Timed annotations from the handler of the controller and allowed to add custom tags for long task timers via WebMvcTagsProvider . For reference, this is the filter . This was nice because we had a centralized way of adding custom tags for handlers with long task timers. MeterFilter does not know about request context and thus it's not straightforward to differentiate if the metric is from handlers of a controller or it's coming from any scheduled service or from somewhere else. Any thoughts on how we could achieve the same ? or at least we could mention in migration documentation about this missed fucntionality and guidance on how to achieve the same |
@marcingrzejszczak @jonatan-ivanov Do you know any solution to this? |
nudge to @marcingrzejszczak @jonatan-ivanov |
Sorry, I completely missed this issue (Marcin was on leave).
I think this is not possible anymore out of the box like it was in 2.x but bear with me, I might have a solution for you. In Boot 2.x, these annotations on the controllers were mainly handled by Boot (see: If this does not work for you for some reason, you can create a
Maybe given that this is a major version change with a completely different API but if you can let go using
@santoshdahal12 Could you please point me to those unanswered StackOverflow questions? @wilkinsona Do you happen to know if |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
We have auto-timer support for Spring Data repository metrics but not, IIRC, for anything else. |
With Spring boot 2.7 and earlier, WebMvcTagsProvider had a method that allowed to add custom tags for long task timers. However, after migrating to Spring Boot 3.3 and using recommended migration strategy of extending DefaultServerRequestObservationConvention or implementing ServerRequestObservationConvention from the docs here, the behavior is not the same.
The getLowCardinalityKeyValues method cannot be used to add custom tags to long task timers or handlers annotated with for example @ Timed(value = "aws.scrape", longTask = true)
The migration guide does not speak anything about this missed functionality and I found few developers asking questions in stackoverflow not being answered. So wanted to know if there is any guidance about this ?
The text was updated successfully, but these errors were encountered: