Interface FunctionCounter
- All Superinterfaces:
Meter
- All Known Implementing Classes:
CompositeFunctionCounter, CumulativeFunctionCounter, DropwizardFunctionCounter, NoopFunctionCounter, StepFunctionCounter
A counter that tracks a monotonically increasing function.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classFluent builder for function counters.static final classFluent builder for function counters that count monotonically increasing time.Nested classes/interfaces inherited from interface Meter
Meter.Id, Meter.MeterProvider<T>, Meter.Type -
Method Summary
Modifier and TypeMethodDescriptionstatic <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.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.doublecount()default Iterable<Measurement> measure()Get a set of measurements.
-
Method Details
-
builder
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
Description copied from interface:MeterGet 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.
-