Interface MetricsService


  • @ProviderType
    public interface MetricsService
    The MetricsService enables creation of various types of Metric.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static MetricsService NOOP
      Dummy variant of MetricsService which does not collect any metric
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <A> A adaptTo​(java.lang.Class<A> type)
      Adapts the service to the specified type.
      Counter counter​(java.lang.String name)
      Creates a new Counter and registers it under the given name.
      <T> Gauge<T> gauge​(java.lang.String name, java.util.function.Supplier<T> supplier)
      Creates a new Gauge and registers it under the given name.
      Histogram histogram​(java.lang.String name)
      Creates a new Histogram and registers it under the given name.
      Meter meter​(java.lang.String name)
      Creates a new Meter and registers it under the given name.
      Timer timer​(java.lang.String name)
      Creates a new Timer and registers it under the given name.
    • Field Detail

      • NOOP

        static final MetricsService NOOP
        Dummy variant of MetricsService which does not collect any metric
    • Method Detail

      • timer

        Timer timer​(java.lang.String name)
        Creates a new Timer and registers it under the given name. If a timer with same name exists then same instance is returned
        Parameters:
        name - the name of the metric
        Returns:
        a new Timer
      • histogram

        Histogram histogram​(java.lang.String name)
        Creates a new Histogram and registers it under the given name. If a histogram with same name exists then same instance is returned.
        Parameters:
        name - the name of the metric
        Returns:
        a new Histogram
      • counter

        Counter counter​(java.lang.String name)
        Creates a new Counter and registers it under the given name. If a counter with same name exists then same instance is returned
        Parameters:
        name - the name of the metric
        Returns:
        a new Counter
      • meter

        Meter meter​(java.lang.String name)
        Creates a new Meter and registers it under the given name. If a meter with same name exists then same instance is returned
        Parameters:
        name - the name of the metric
        Returns:
        a new Meter
      • gauge

        <T> Gauge<T> gauge​(java.lang.String name,
                           java.util.function.Supplier<T> supplier)
        Creates a new Gauge and registers it under the given name. If a gauge with teh same exists already the the same instance is returned.
        Type Parameters:
        T - the type of the metric
        Parameters:
        name - the name of the gauge
        supplier - provides the values which are returned by the gauge
        Returns:
        the gauge
      • adaptTo

        <A> A adaptTo​(java.lang.Class<A> type)
        Adapts the service to the specified type. This can be used to get instance to underlying MetricRegistry
        Type Parameters:
        A - The type to which this metric is to be adapted.
        Parameters:
        type - Class object for the type to which this metric is to be adapted.
        Returns:
        The object, of the specified type, to which this metric has been adapted or null if this metric cannot be adapted to the specified type.