Interface Meter
- All Known Subinterfaces:
Counter,DistributionSummary,FunctionCounter,FunctionTimer,Gauge,HistogramSupport,LongTaskTimer,TimeGauge,Timer
- All Known Implementing Classes:
AbstractDistributionSummary,AbstractMeter,AbstractTimer,CompositeFunctionCounter,CumulativeCounter,CumulativeDistributionSummary,CumulativeFunctionCounter,CumulativeFunctionTimer,CumulativeHistogramLongTaskTimer,CumulativeTimer,DefaultGauge,DefaultLongTaskTimer,DefaultMeter,DropwizardCounter,DropwizardDistributionSummary,DropwizardFunctionCounter,DropwizardFunctionTimer,DropwizardGauge,DropwizardTimer,NoopCounter,NoopDistributionSummary,NoopFunctionCounter,NoopFunctionTimer,NoopGauge,NoopLongTaskTimer,NoopMeter,NoopTimeGauge,NoopTimer,StepCounter,StepDistributionSummary,StepFunctionCounter,StepFunctionTimer,StepTimer
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classFluent builder for custom meters.static classA meter is uniquely identified by its combination of name and tags.static interfaceMeter.MeterProvider<T extends Meter>Convenience interface to create new meters from tags based on a common "template"/builder.static enumCustom meters may emit metrics like one of these types without implementing the corresponding interface. -
Method Summary
Modifier and TypeMethodDescriptionstatic Meter.Builderbuilder(String name, Meter.Type type, Iterable<Measurement> measurements) default voidclose()getId()default <T> Tmatch(Function<Gauge, T> visitGauge, Function<Counter, T> visitCounter, Function<Timer, T> visitTimer, Function<DistributionSummary, T> visitSummary, Function<LongTaskTimer, T> visitLongTaskTimer, Function<TimeGauge, T> visitTimeGauge, Function<FunctionCounter, T> visitFunctionCounter, Function<FunctionTimer, T> visitFunctionTimer, Function<Meter, T> visitMeter) measure()Get a set of measurements.default voiduse(Consumer<Gauge> visitGauge, Consumer<Counter> visitCounter, Consumer<Timer> visitTimer, Consumer<DistributionSummary> visitSummary, Consumer<LongTaskTimer> visitLongTaskTimer, Consumer<TimeGauge> visitTimeGauge, Consumer<FunctionCounter> visitFunctionCounter, Consumer<FunctionTimer> visitFunctionTimer, Consumer<Meter> visitMeter)
-
Method Details
-
builder
-
getId
Meter.Id getId()- Returns:
- A unique combination of name and tags
-
measure
Iterable<Measurement> measure()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.- Returns:
- The set of measurements that represents the instantaneous value of this meter.
-
match
@NullUnmarked default <T> T match(Function<Gauge, T> visitGauge, Function<Counter, T> visitCounter, Function<Timer, T> visitTimer, Function<DistributionSummary, T> visitSummary, Function<LongTaskTimer, T> visitLongTaskTimer, Function<TimeGauge, T> visitTimeGauge, Function<FunctionCounter, T> visitFunctionCounter, Function<FunctionTimer, T> visitFunctionTimer, Function<Meter, T> visitMeter) Match aMeterby type with series of dedicated functions for specificMeters and return a result from the matched function.NOTE: This method contract will change in minor releases if ever a new
Metertype is created. In this case only, this is considered a feature. By using this method, you are declaring that you want to be sure to handle all types of meters. A breaking API change during the introduction of a newMeterindicates that there is a new meter type for you to consider and the compiler will effectively require you to consider it.- Type Parameters:
T- return type of function to apply- Parameters:
visitGauge- function to apply forGaugevisitCounter- function to apply forCountervisitTimer- function to apply forTimervisitSummary- function to apply forDistributionSummaryvisitLongTaskTimer- function to apply forLongTaskTimervisitTimeGauge- function to apply forTimeGaugevisitFunctionCounter- function to apply forFunctionCountervisitFunctionTimer- function to apply forFunctionTimervisitMeter- function to apply as a fallback- Returns:
- return value from the applied function
- Since:
- 1.1.0
-
use
default void use(Consumer<Gauge> visitGauge, Consumer<Counter> visitCounter, Consumer<Timer> visitTimer, Consumer<DistributionSummary> visitSummary, Consumer<LongTaskTimer> visitLongTaskTimer, Consumer<TimeGauge> visitTimeGauge, Consumer<FunctionCounter> visitFunctionCounter, Consumer<FunctionTimer> visitFunctionTimer, Consumer<Meter> visitMeter) Match aMeterwith a series of dedicated functions for specificMeters and call the matching consumer.NOTE: This method contract will change in minor releases if ever a new
Metertype is created. In this case only, this is considered a feature. By using this method, you are declaring that you want to be sure to handle all types of meters. A breaking API change during the introduction of a newMeterindicates that there is a new meter type for you to consider and the compiler will effectively require you to consider it.- Parameters:
visitGauge- function to apply forGaugevisitCounter- function to apply forCountervisitTimer- function to apply forTimervisitSummary- function to apply forDistributionSummaryvisitLongTaskTimer- function to apply forLongTaskTimervisitTimeGauge- function to apply forTimeGaugevisitFunctionCounter- function to apply forFunctionCountervisitFunctionTimer- function to apply forFunctionTimervisitMeter- function to apply as a fallback- Since:
- 1.1.0
-
close
default void close()
-