Reputation: 303
As of now in order to get percentiles on Quarkus using micrometer one would need to use the timed annotation as shown below
@GET
@Produces(MediaType.TEXT_PLAIN)
@Timed(percentiles = {0.5,0.7,0.9})
public String hello() {
return "Hello RESTEasy";
}
My main problem with this behavior is that it would be necessary to put this timed annotation on every Rest endpoint. Is there a way to set some percentiles as default for Rest endpoints using micrometer from quarkus? (I know it is possible with microprofiler but they recommend the usage of micrometer)
Upvotes: 2
Views: 1020
Reputation: 1280
Quarkus micrometer support does already emit timers for all rest endpoints (unless you've disabled that capability). You need to enable collection of additional data for existing http server request timers explicitly using a MeterFilter (bound generally or just to the registry type). Something like this, for example:
/** Enable histogram buckets for a specific timer */
@Produces
@Singleton
public MeterFilter enableHistogram() {
return new MeterFilter() {
@Override
public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticConfig config) {
if(id.getName().startsWith("http.server.requests")) {
return DistributionStatisticConfig.builder()
.percentiles(0.5, 0.95) // median and 95th percentile, not aggregable
.percentilesHistogram(true) // histogram buckets (e.g. prometheus histogram_quantile)
.build()
.merge(config);
}
return config;
}
};
}
Look at the emitted metrics to make sure that http server request metrics are present (they haven't been disabled somewhere along the way), and then consider the conditions that should be applied for pre-collecting either histogram or percentile data (as it can be expensive).
References:
Upvotes: 3