Interface FunctionalCounter

All Superinterfaces:
Meter, Wrapper, Wrapper

public interface FunctionalCounter extends Meter
A read-only counter which wraps some other object that provides the counter value via a function.
  • Method Details

    • builder

      @Deprecated(forRemoval=true, since="27.0.0") static <T> FunctionalCounter.Builder<?> builder(String name, T stateObject, Function<T,Long> 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.functionalCounterBuilder(String, Object, java.util.function.Function) instead
      Returns a builder for registering or locating a functional counter.
      Type Parameters:
      T - type of the state object
      Parameters:
      name - functional counter name
      stateObject - object which provides the counter value on demand
      fn - function which, when applied to the state object, returns the counter value
      Returns:
      new builder
    • count

      long count()
      Returns the counter value.
      Returns:
      counter value