Metrics value refresh

19 views
Skip to first unread message

Tiese Barrell

unread,
Nov 13, 2019, 2:25:01 AM11/13/19
to Eclipse MicroProfile

We are trying to figure out what behaviour to expect with the metrics API with regards to updates to the values in the metric. We are providing some custom metrics from our application's internals, in our case mainly gauges. The spec is unclear to us in section 6.1. If we were to define a gauge using an @Gauge annotated method, the metric is registered and its value can be requested through the default /metrics endpoint. But when and how is the value updated to the current value? Does that happen on each request by invoking the method or is the application responsible for updating the value? For metrics we instantiate ourselves, it states this is the case, but it's unclear what is the behaviour for metrics from annotations.

Jan Martiska

unread,
Nov 13, 2019, 3:25:12 AM11/13/19
to Eclipse MicroProfile
Hi Tiese,
the gauge value gets recomputed with every request, there is no caching or so. The application should make sure that the computation is as fast as possible, because it basically blocks the return of the /metrics request. If some sort of caching of the result is desired (to avoid doing the expensive computation too often), it needs to be done at the application level.

I'm thinking that part of the spec made you confused about this. Was it this sentence?
  • The implementation must watch the annotated objects and update internal data structures when the values of the annotated objects change.

I agree this is somewhat misleading, especially when it comes to gauges. We'll get this clarified for the next release.

Cheers
Jan

Tiese Barrell

unread,
Nov 13, 2019, 4:44:06 AM11/13/19
to Eclipse MicroProfile
Hi Jan,

thanks for the explanation. It was precisely that part of the spec that wasn't clear to me what was meant by it.

I see the point that it's up to the application to compute the metrics as fast as possible and we assumed that recalculation on every hit of the endpoint was the implementation. However, since there's now an API defined and the implementation is strongly linked to that, it's inconvenient to somehow plug any kind of caching if you need it because everything at that point is handled directly by the application server. 

Thanks,
Tiese 
Reply all
Reply to author
Forward
0 new messages