Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Micrometer @Timed annotation

Can anyone explain me what are the differences between _count and _sum metrics exposed by micrometer @Timed annotation.

Here you have two examples of metrics values as results of a @Timed annotation post upon a method.

GET_CARD_LIMITS_BY_LIMIT_TYPE_seconds_count{class="ro.orange.productsbff.infrastructure.adapter.cms.integration.CmsClient",method="getCardLimitsByType",} 9.0

GET_CARD_LIMITS_BY_LIMIT_TYPE_seconds_sum{class="ro.orange.productsbff.infrastructure.adapter.cms.integration.CmsClient",method="getCardLimitsByType",} 1.838999262

Thank you!

like image 362
Dina Bogdan Avatar asked Apr 04 '19 11:04

Dina Bogdan


1 Answers

The count is the total measurements that the timer has taken. The sum is the cumulative duration of all the measurements that the time has taken. So by dividing the sum by the count you can see that average timing:

GET_CARD_LIMITS_BY_LIMIT_TYPE_seconds_sum / 
GET_CARD_LIMITS_BY_LIMIT_TYPE_seconds_count

However that can become less useful over time since that average could hide spikes as the values grow.

Since both those numbers will only go up (accounting for restarts), Prometheus can leverage that knowledge and you can see the 1 minute average latency for that timer like so:

increase(GET_CARD_LIMITS_BY_LIMIT_TYPE_seconds_sum[1m]) /   
increase(GET_CARD_LIMITS_BY_LIMIT_TYPE_seconds_count[1m])
like image 184
checketts Avatar answered Nov 07 '22 15:11

checketts