After searching in the world wide web for metrics collecting for Google Guava Cache, all I could find are implementations with Dropwizard Metrics in java.
Don’t take me wrong, dropwizard metrics system are one of the best there is. But what about scala?

So here comes Kamon.io, an automatically instrument, monitor and debug distributed system (lots of fancy words).
I couldn’t find any example for metrics collecting for guava cache using Kamon, so I thought of sharing my implementation;

With that, using it is as simple as

object Main extends App {
  import KamonUtils._
  val cache = CacheBuilder.newBuilder()
    .removalListener(Kamon.newCacheMetricsRemovalListener("my-cache")) // optional
    .build[String, Int]()

  Kamon.metricsForCache("my-cache", cache)
}