Interface Gauge
-
- All Superinterfaces:
Meter
- All Known Subinterfaces:
TimeGauge
- All Known Implementing Classes:
DropwizardTypes.DescribableGauge
public interface Gauge extends Meter
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Gauge.Builder<T>
Fluent builder for gauges.-
Nested classes/interfaces inherited from interface org.forgerock.monitoring.api.instrument.Meter
Meter.Id, Meter.Type
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <T> Gauge.Builder<T>
builder(String name, T obj, ToDoubleFunction<T> f)
Setup aGauge.Builder
that will create a gauge that reports the value returned by the provided function.static <T extends Number>
Gauge.Builder<T>constantGauge(String name, T number)
Setup aGauge.Builder
that will create a gauge that reports the value of theNumber
.static <T> Gauge.Builder<T>
doubleGauge(String name, DoubleSupplier valueFunction)
Setup aGauge.Builder
that will create a gauge that reports the size of theMap
.static <T extends Collection<?>>
Gauge.Builder<T>gaugeCollectionSize(String name, T collection)
Setup aGauge.Builder
that will create a gauge that reports the size of theCollection
.static <T extends Map<?,?>>
Gauge.BuildergaugeMapSize(String name, T map)
Setup aGauge.Builder
that will create a gauge that reports the size of theMap
.default Iterable<Measurement>
measure()
Get a set of measurements.double
value()
Returns the current value.
-
-
-
Method Detail
-
builder
static <T> Gauge.Builder<T> builder(String name, @Nullable T obj, ToDoubleFunction<T> f)
Setup aGauge.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 monitorf
- 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 aGauge.Builder
that will create a gauge that reports the size of theMap
. The collection implementation used should be thread safe. Note that callingMap.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 aGauge.Builder
that will create a gauge that reports the value of theNumber
.
-
gaugeCollectionSize
@Nullable static <T extends Collection<?>> Gauge.Builder<T> gaugeCollectionSize(String name, T collection)
Setup aGauge.Builder
that will create a gauge that reports the size of theCollection
. The collection implementation used should be thread safe. Note that callingCollection.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 ofCollection
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 aGauge.Builder
that will create a gauge that reports the size of theMap
. The collection implementation used should be thread safe. Note that callingMap.size()
can be expensive for some collection implementations and should be considered before registering.
-
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.
-
-