Interface Gauge
- All Superinterfaces:
Meter
- All Known Subinterfaces:
TimeGauge
- All Known Implementing Classes:
DropwizardTypes.DescribableGauge
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface Meter
Meter.Id, Meter.Type -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Gauge.Builder<T> builder(String name, T obj, ToDoubleFunction<T> f) Setup aGauge.Builderthat 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.Builderthat will create a gauge that reports the value of theNumber.static <T> Gauge.Builder<T> doubleGauge(String name, DoubleSupplier valueFunction) Setup aGauge.Builderthat will create a gauge that reports the size of theMap.static <T extends Collection<?>>
Gauge.Builder<T> gaugeCollectionSize(String name, T collection) Setup aGauge.Builderthat will create a gauge that reports the size of theCollection.static <T extends Map<?,?>>
Gauge.BuildergaugeMapSize(String name, T map) Setup aGauge.Builderthat will create a gauge that reports the size of theMap.default Iterable<Measurement> measure()Get a set of measurements.doublevalue()Returns the current value.
-
Method Details
-
builder
Setup aGauge.Builderthat 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
Setup aGauge.Builderthat 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
Setup aGauge.Builderthat 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.Builderthat 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 ofCollectionused to access the value.- Returns:
- A builder to create a
Gauge.
-
gaugeMapSize
Setup aGauge.Builderthat 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
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.
-