Interface Gauge<N extends Number>

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

public interface Gauge<N extends Number> extends Meter
Exposes as a meter 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

      @Deprecated(forRemoval=true, since="27.0.0") static <T> Gauge.Builder<Double> builder(String name, T stateObject, ToDoubleFunction<T> fn)
      Deprecated, for removal: This API element is subject to removal in a future version.
      this method uses service registry to get a MetricsFactory instance, which may be inefficient, use MetricsFactory.gaugeBuilder(String, Object, java.util.function.ToDoubleFunction) instead
      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

      @Deprecated(forRemoval=true, since="27.0.0") static <N extends Number> Gauge.Builder<N> builder(String name, Supplier<N> numberSupplier)
      Deprecated, for removal: This API element is subject to removal in a future version.
      this method uses service registry to get a MetricsFactory instance, which may be inefficient, use MetricsFactory.gaugeBuilder(String, java.util.function.Supplier) instead
      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