Skip to content

The metric "cache.load.duration" in CaffeineCacheMetrics binder has the wrong Meter type. #5803

Open
@wikthewiz

Description

Describe the bug
In the binder CaffeineCacheMetrics.java (the metric cache.load.duration metric) uses a TimeGauge to store the value reported from method in totalLoadTime() in caffeine, which is an ever growing value: (https://www.javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/2.2.2/com/github/benmanes/caffeine/cache/stats/CacheStats.html#totalLoadTime--).

Environment
I found this in our production environment

  • micrometer version: 1.12.4 but it is present in the latest version also
  • Prometheus
  • Linux
  • openjdk 21.0.4 2024-07-16 LTS

To Reproduce

TimeGauge.builder("cache.load.duration", cache, TimeUnit.NANOSECONDS, c -> c.stats().totalLoadTime())

Expected behavior
The expected behaviour is to have the cache.load.duration as a meter of Counter Type.

Additional context
I asked in the slack channel about this and @jonatan-ivanov kindly answered and asked me to report this a as bug. He also had some good suggestions on how what type to use. Here is a link to that answer: https://micrometer-metrics.slack.com/archives/C98P1USPR/p1736375533224759?thread_ts=1736323360.611049&cid=C98P1USPR

Metadata

Assignees

No one assigned

    Labels

    bugA general bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions