Class MetricUtils.CachedMetrics<K>

  • Type Parameters:
    K - class of cache key object. The class should meet all requirements of class used as a Map key.
    Enclosing class:
    MetricUtils

    public static final class MetricUtils.CachedMetrics<K>
    extends java.lang.Object
    Class used as a container to cache used Metric entities. Main advantage is the reduced need of recalculating the metric name for each time the metric is used (which might be very often). The cache is storing metrics divided per tenant. The key of the cache should contain all data that differentiate the metric name.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<com.codahale.metrics.Meter> getMeter​(K key, java.lang.String tenantID, java.util.function.Function<MetricUtils.MetricNameSupplierContext<K>,​java.lang.String> metricNameSupplier)  
      • Methods inherited from class java.lang.Object

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

      • getMeter

        public java.util.Optional<com.codahale.metrics.Meter> getMeter​(K key,
                                                                       java.lang.String tenantID,
                                                                       java.util.function.Function<MetricUtils.MetricNameSupplierContext<K>,​java.lang.String> metricNameSupplier)
        Parameters:
        key - cache key for reuired metric
        tenantID - the tenant identifier
        metricNameSupplier - the method to calculate the metric name based on the key and tenantId
        Returns:
        the Meter object from cache. If cache does not contain the object for provided key, new object will be created for name calculated with provided metricNameSupplier. If creating a metric object can't be accomplished the return Optional will be emtpy.