Interface FunctionalCounter
A read-only counter which wraps some other object that provides the counter value via a function.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface Meter
Meter.BaseUnits, Meter.Id, Meter.Scope, Meter.TypeModifier and TypeInterfaceDescriptionstatic classCommon unit declarations (inspired by the list from MicroProfile metrics).static interfaceUnique idenfier for a meter.static classDeprecated, for removal: This API element is subject to removal in a future version.Core metrics ignores scope values, and this type will be removed.static enumType of meter. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> FunctionalCounter.Builder<?> Deprecated, for removal: This API element is subject to removal in a future version.this method uses service registry to get aMetricsFactoryinstance, which may be inefficient, useMetricsFactory.functionalCounterBuilder(String, Object, java.util.function.Function)insteadlongcount()Returns the counter value.Methods inherited from interface Meter
baseUnit, description, id, scope, typeModifier and TypeMethodDescriptionbaseUnit()Returns the meter's base unit.Returns the meter's description.id()Returns the meter ID.scope()Deprecated, for removal: This API element is subject to removal in a future version.Core metrics does not assign scopes, and this method will be removed.type()Returns the meter type.
-
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 aMetricsFactoryinstance, which may be inefficient, useMetricsFactory.functionalCounterBuilder(String, Object, java.util.function.Function)insteadReturns a builder for registering or locating a functional counter.- Type Parameters:
T- type of the state object- Parameters:
name- functional counter namestateObject- object which provides the counter value on demandfn- 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
-