Interface Gauge

All Superinterfaces:
Meter
All Known Subinterfaces:
TimeGauge
All Known Implementing Classes:
DefaultGauge, DropwizardGauge, NoopGauge, NoopTimeGauge

public interface Gauge extends Meter
A gauge tracks a value that may go up or down. The value that is published for gauges is an instantaneous sample of the gauge at publishing time.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Fluent builder for gauges.

    Nested classes/interfaces inherited from interface io.micrometer.core.instrument.Meter

    Meter.Id, Meter.Type
  • Method Summary

    Modifier and Type
    Method
    Description
    A convenience method for building a gauge from a supplying function, holding a strong reference to this function.
    static <T> Gauge.Builder<T>
    builder(String name, T obj, ToDoubleFunction<T> f)
     
    Get a set of measurements.
    double
    The act of observing the value by calling this method triggers sampling of the underlying number or user-defined function that defines the value for the gauge.

    Methods inherited from interface io.micrometer.core.instrument.Meter

    close, getId, match, use
  • Method Details

    • builder

      static <T> Gauge.Builder<T> builder(String name, @Nullable T obj, ToDoubleFunction<T> f)
      Type Parameters:
      T - The type of object to gauge.
      Parameters:
      name - The gauge's name.
      obj - An object with some state or function which the gauge's instantaneous value is determined from.
      f - A function that yields a double value for the gauge, based on the state of obj.
      Returns:
      A new gauge builder.
    • builder

      @Incubating(since="1.1.0") static Gauge.Builder<Supplier<Number>> builder(String name, Supplier<Number> f)
      A convenience method for building a gauge from a supplying function, holding a strong reference to this function.
      Parameters:
      name - The gauge's name.
      f - A function that yields a double value for the gauge.
      Returns:
      A new gauge builder.
      Since:
      1.1.0
    • value

      double value()
      The act of observing the value by calling this method triggers sampling of the underlying number or user-defined function that defines the value for the gauge.
      Returns:
      The current value.
    • measure

      default Iterable<Measurement> measure()
      Description copied from interface: Meter
      Get a set of measurements. Should always return the same number of measurements and in the same order, regardless of the level of activity or the lack thereof.
      Specified by:
      measure in interface Meter
      Returns:
      The set of measurements that represents the instantaneous value of this meter.