Class CacheMetricsRegistrar


  • public class CacheMetricsRegistrar
    extends java.lang.Object
    Register supported Cache to a MeterRegistry.
    Since:
    1.2.0
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheMetricsRegistrar​(io.micrometer.core.instrument.MeterRegistry registry, java.util.Collection<CacheMeterBinderProvider<?>> binderProviders)
      Creates a new registrar.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean bindCacheToRegistry​(org.springframework.cache.Cache cache, io.micrometer.core.instrument.Tag... tags)
      Attempt to bind the specified Cache to the registry.
      protected java.lang.Iterable<io.micrometer.core.instrument.Tag> getAdditionalTags​(org.springframework.cache.Cache cache)
      Return additional tags to be associated with the given Cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CacheMetricsRegistrar

        public CacheMetricsRegistrar​(io.micrometer.core.instrument.MeterRegistry registry,
                                     java.util.Collection<CacheMeterBinderProvider<?>> binderProviders)
        Creates a new registrar.
        Parameters:
        registry - the MeterRegistry to use
        binderProviders - the CacheMeterBinderProvider instances that should be used to detect compatible caches
    • Method Detail

      • bindCacheToRegistry

        public boolean bindCacheToRegistry​(org.springframework.cache.Cache cache,
                                           io.micrometer.core.instrument.Tag... tags)
        Attempt to bind the specified Cache to the registry. Return true if the cache is supported and was bound to the registry, false otherwise.
        Parameters:
        cache - the cache to handle
        tags - the tags to associate with the metrics of that cache
        Returns:
        true if the cache is supported and was registered
      • getAdditionalTags

        protected java.lang.Iterable<io.micrometer.core.instrument.Tag> getAdditionalTags​(org.springframework.cache.Cache cache)
        Return additional tags to be associated with the given Cache.
        Parameters:
        cache - the cache
        Returns:
        a list of additional tags to associate to that cache.