Package io.micrometer.core.instrument
Interface Gauge
- All Superinterfaces:
Meter
- All Known Subinterfaces:
TimeGauge
- All Known Implementing Classes:
DefaultGauge
,DropwizardGauge
,NoopGauge
,NoopTimeGauge
public interface Gauge extends Meter
A gauge tracks a value that may go up or down. The value that is published for gauges is
an instantaneous sample of the gauge at publishing time.
-
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 io.micrometer.core.instrument.Meter
Meter.Id, Meter.Type
-
Method Summary
Modifier and Type Method Description static Gauge.Builder<java.util.function.Supplier<java.lang.Number>>
builder(java.lang.String name, java.util.function.Supplier<java.lang.Number> f)
A convenience method for building a gauge from a supplying function, holding a strong reference to this function.static <T> Gauge.Builder<T>
builder(java.lang.String name, T obj, java.util.function.ToDoubleFunction<T> f)
default java.lang.Iterable<Measurement>
measure()
Get a set of measurements.double
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.
-
Method Details
-
builder
static <T> Gauge.Builder<T> builder(java.lang.String name, @Nullable T obj, java.util.function.ToDoubleFunction<T> f)- Type Parameters:
T
- The type of object to gauge.- Parameters:
name
- The gauge's name.obj
- An object with some state or function which the gauge's instantaneous value is determined from.f
- A function that yields a double value for the gauge, based on the state ofobj
.- Returns:
- A new gauge builder.
-
builder
@Incubating(since="1.1.0") static Gauge.Builder<java.util.function.Supplier<java.lang.Number>> builder(java.lang.String name, java.util.function.Supplier<java.lang.Number> f)A convenience method for building a gauge from a supplying function, holding a strong reference to this function.- Parameters:
name
- The gauge's name.f
- A function that yields a double value for the gauge.- Returns:
- A new gauge builder.
- Since:
- 1.1.0
-
value
double 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.- Returns:
- The current value.
-
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.
-