Class MetricUtils


  • public final class MetricUtils
    extends java.lang.Object
    Utility class to help in gathering metrics with io.dropwizard.metrics:metrics-code library
    • Method Detail

      • getMetricRegistry

        public static java.util.Optional<com.codahale.metrics.MetricRegistry> getMetricRegistry()
        Returns:
        metricRegistry spring bean from currently active tenant. If no tenant is active, empty optional object is returned
      • metricName

        public static MetricUtils.MetricNameBuilder metricName​(java.lang.String name,
                                                               java.lang.String... names)
        Parameters:
        name - required metric name
        names - additional (optional) parts of metric name
        Returns:
        metric name builder
      • metricCache

        public static <K> MetricUtils.CachedMetrics<K> metricCache()
        The method creates a cache for metrics to reduce the number of times the metric name is created. When required, new metric will be created with metricRegistry spring bean available in current tenant.
        Type Parameters:
        K - type of objects that will be used as keys in the metrics cache
      • metricCache

        public static <K> MetricUtils.CachedMetrics<K> metricCache​(com.codahale.metrics.MetricRegistry metricRegistry)
        The method creates a cache for metrics to reduce the number of times the metric name is created
        Type Parameters:
        K - type of objects that will be used as keys in the metrics cache
        Parameters:
        metricRegistry - the metric registry that should be used when creating the metrics. If null, the metricRegistry spring bean available current tenant will be used