Search code examples
springgoogle-guava-cache

Spring metrics don't show Guava hit/miss


In the metrics endpoint I get all the caches size, but not hit/miss (as expected from https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html#production-ready-datasource-cache)

Example: "cache.mytest.size":19

I expected also the hit/miss counters... I'm using Guava.


Solution

  • Had to enable them on a per-cache basis:

    https://github.com/google/guava/wiki/CachesExplained#statistics

    cacheBuilder.recordStats();