Interface Gauge

All Superinterfaces:
Meter
All Known Subinterfaces:
TimeGauge
All Known Implementing Classes:
DropwizardTypes.DescribableGauge

public interface Gauge extends Meter
  • Method Details

    • builder

      static <T> Gauge.Builder<T> builder(String name, @Nullable T obj, ToDoubleFunction<T> f)
      Setup a Gauge.Builder that will create a gauge that reports the value returned by the provided function.
      Type Parameters:
      T - The type of the object to monitor
      Parameters:
      name - Name of the gauge being registered.
      obj - The object to monitor
      f - The function to apply to the object to monitor
      Returns:
      A builder to create a Gauge.
    • doubleGauge

      @Nullable static <T> Gauge.Builder<T> doubleGauge(String name, DoubleSupplier valueFunction)
      Setup a Gauge.Builder that will create a gauge that reports the size of the Map. The collection implementation used should be thread safe. Note that calling Map.size() can be expensive for some collection implementations and should be considered before registering.
      Type Parameters:
      T - The type of the state object from which the gauge value is extracted.
      Parameters:
      name - Name of the gauge being registered.
      valueFunction - a function which returns a double
      Returns:
      A builder to create a Gauge.
    • constantGauge

      static <T extends Number> Gauge.Builder<T> constantGauge(String name, T number)
      Setup a Gauge.Builder that will create a gauge that reports the value of the Number.
      Type Parameters:
      T - The type of the number from which the gauge value is extracted.
      Parameters:
      name - Name of the gauge being registered.
      number - Thread-safe implementation of Number used to access the value.
      Returns:
      A builder to create a Gauge.
    • gaugeCollectionSize

      @Nullable static <T extends Collection<?>> Gauge.Builder<T> gaugeCollectionSize(String name, T collection)
      Setup a Gauge.Builder that will create a gauge that reports the size of the Collection. The collection implementation used should be thread safe. Note that calling Collection.size() can be expensive for some collection implementations and should be considered before registering.
      Type Parameters:
      T - The type of the state object from which the gauge value is extracted.
      Parameters:
      name - Name of the gauge being registered.
      collection - Thread-safe implementation of Collection used to access the value.
      Returns:
      A builder to create a Gauge.
    • gaugeMapSize

      @Nullable static <T extends Map<?, ?>> Gauge.Builder gaugeMapSize(String name, T map)
      Setup a Gauge.Builder that will create a gauge that reports the size of the Map. The collection implementation used should be thread safe. Note that calling Map.size() can be expensive for some collection implementations and should be considered before registering.
      Type Parameters:
      T - The type of the state object from which the gauge value is extracted.
      Parameters:
      name - Name of the gauge being registered.
      map - Thread-safe implementation of Map used to access the value.
      Returns:
      A builder to create a Gauge.
    • value

      double value()
      Returns the current 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.
    • 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.