Interface Gauge<T>

  • Type Parameters:
    T - the type of the metric's value

    @ConsumerType
    public interface Gauge<T>
    A gauge metric is an instantaneous reading of a particular value. Since package version 1.3.0 a gauge can directly created via the MetricsService MetricsService.gauge(String,Supplier), which should be used for the majority of cases.

    Nevertheless it's still possible to register a gauge instance with OSGi ServiceRegistry with Gauge#NAME set to Gauge name. Then the Gauge instance would be registered with MetricService via the whiteboard pattern. To instrument a queue's depth, for example:

    
     final Queue<String> queue = new ConcurrentLinkedQueue<String>();
     final Gauge<Integer> queueDepth = new Gauge<Integer>() {
         public Integer getValue() {
             return queue.size();
         }
     };
     
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NAME
      Service property name which determines the name of the Gauge
    • Field Detail

      • NAME

        static final java.lang.String NAME
        Service property name which determines the name of the Gauge
        See Also:
        Constant Field Values
    • Method Detail

      • getValue

        T getValue()
        Returns the metric's current value.
        Returns:
        the metric's current value