简体   繁体   中英

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!

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])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM