Interface Gauge<N extends Number>

Type Parameters:
N - subtype of Number which a specific gauge reports
All Superinterfaces:
Meter, Wrapper

public interface Gauge<N extends Number> extends Meter
Measures a value that can increase or decrease and is updated by external logic, not by explicit invocations of methods on this type.
  • Method Details

    • builder

      static <T> Gauge.Builder<Double> builder(String name, T stateObject, ToDoubleFunction<T> fn)
      Creates a builder for creating a new gauge based on applying a function to a state object.
      Type Parameters:
      T - type of the state object
      Parameters:
      name - gauge name
      stateObject - state object which maintains the gauge value
      fn - function which, when applied to the state object, returns the gauge value
      Returns:
      new builder
    • builder

      static <N extends Number> Gauge.Builder<N> builder(String name, Supplier<N> numberSupplier)
      Creates a builder for a supplier-based gauge.
      Type Parameters:
      N - subtype of Number which the supplier provides
      Parameters:
      name - gauge name
      numberSupplier - Supplier for an instance of a type which extends Number
      Returns:
      new builder
    • value

      N value()
      Returns the value of the gauge.

      Invoking this method triggers the sampling of the value or invocation of the function provided when the gauge was registered.

      Returns:
      current value of the gauge