Interface FunctionCounter

All Superinterfaces:
Meter
All Known Implementing Classes:
CompositeFunctionCounter, CumulativeFunctionCounter, DropwizardFunctionCounter, NoopFunctionCounter, StepFunctionCounter

public interface FunctionCounter extends Meter
A counter that tracks a monotonically increasing function.
  • Method Details

    • builder

      static <T> FunctionCounter.Builder<T> builder(String name, T obj, ToDoubleFunction<T> f)
      Build a function-tracking counter that produces a monotonically increasing count from the state object.
      Type Parameters:
      T - The type of the state object.
      Parameters:
      name - The counter's name.
      obj - State object used to compute a count.
      f - Function that produces a monotonically increasing count from the state object.
      Returns:
      A new function counter builder.
    • builder

      static <T> FunctionCounter.TimeBasedBuilder<T> builder(String name, T obj, ToDoubleFunction<T> objToCountFunction, TimeUnit sourceUnit)
      Build a function-tracking counter for a function that tracks monotonically increasing time. The time value will automatically scale to the base time unit expected by each registry implementation.
      Type Parameters:
      T - The type of the state object.
      Parameters:
      name - The counter's name.
      obj - State object used to compute a value.
      objToCountFunction - Function that produces a monotonically increasing time count from the state object.
      sourceUnit - Time unit of the value returned by the count function.
      Returns:
      A new time-based function counter builder.
      Since:
      1.18.0
    • count

      double count()
      Returns:
      The cumulative count since this counter was created.
    • 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.