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

public interface Meter
A named and dimensioned producer of one or more measurements.
  • Nested Class Summary

    Nested Classes
    Modifier and Type Interface Description
    static class  Meter.Builder
    Fluent builder for custom meters.
    static class  Meter.Id
    A meter is uniquely identified by its combination of name and tags.
    static class  Meter.Type
    Custom meters may emit metrics like one of these types without implementing the corresponding interface.
  • Method Summary

    Modifier and Type Method Description
    static Meter.Builder builder​(java.lang.String name, Meter.Type type, java.lang.Iterable<Measurement> measurements)  
    default void close()  
    Meter.Id getId()  
    default <T> T match​(java.util.function.Function<Gauge,​T> visitGauge, java.util.function.Function<Counter,​T> visitCounter, java.util.function.Function<Timer,​T> visitTimer, java.util.function.Function<DistributionSummary,​T> visitSummary, java.util.function.Function<LongTaskTimer,​T> visitLongTaskTimer, java.util.function.Function<TimeGauge,​T> visitTimeGauge, java.util.function.Function<FunctionCounter,​T> visitFunctionCounter, java.util.function.Function<FunctionTimer,​T> visitFunctionTimer, java.util.function.Function<Meter,​T> visitMeter)
    Match a Meter by type with series of dedicated functions for specific Meters and return a result from the matched function.
    java.lang.Iterable<Measurement> measure()
    Get a set of measurements.
    default void use​(java.util.function.Consumer<Gauge> visitGauge, java.util.function.Consumer<Counter> visitCounter, java.util.function.Consumer<Timer> visitTimer, java.util.function.Consumer<DistributionSummary> visitSummary, java.util.function.Consumer<LongTaskTimer> visitLongTaskTimer, java.util.function.Consumer<TimeGauge> visitTimeGauge, java.util.function.Consumer<FunctionCounter> visitFunctionCounter, java.util.function.Consumer<FunctionTimer> visitFunctionTimer, java.util.function.Consumer<Meter> visitMeter)
    Match a Meter with a series of dedicated functions for specific Meters and call the matching consumer.
  • Method Details

    • builder

      static Meter.Builder builder​(java.lang.String name, Meter.Type type, java.lang.Iterable<Measurement> measurements)
    • getId

      Meter.Id getId()
      Returns:
      A unique combination of name and tags
    • measure

      java.lang.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

      default <T> T match​(java.util.function.Function<Gauge,​T> visitGauge, java.util.function.Function<Counter,​T> visitCounter, java.util.function.Function<Timer,​T> visitTimer, java.util.function.Function<DistributionSummary,​T> visitSummary, java.util.function.Function<LongTaskTimer,​T> visitLongTaskTimer, java.util.function.Function<TimeGauge,​T> visitTimeGauge, java.util.function.Function<FunctionCounter,​T> visitFunctionCounter, java.util.function.Function<FunctionTimer,​T> visitFunctionTimer, java.util.function.Function<Meter,​T> visitMeter)
      Match a Meter by type with series of dedicated functions for specific Meters and return a result from the matched function.

      NOTE: This method contract will change in minor releases if ever a new Meter type 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 new Meter indicates 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 for Gauge
      visitCounter - function to apply for Counter
      visitTimer - function to apply for Timer
      visitSummary - function to apply for DistributionSummary
      visitLongTaskTimer - function to apply for LongTaskTimer
      visitTimeGauge - function to apply for TimeGauge
      visitFunctionCounter - function to apply for FunctionCounter
      visitFunctionTimer - function to apply for FunctionTimer
      visitMeter - function to apply as a fallback
      Returns:
      return value from the applied function
      Since:
      1.1.0
    • use

      default void use​(java.util.function.Consumer<Gauge> visitGauge, java.util.function.Consumer<Counter> visitCounter, java.util.function.Consumer<Timer> visitTimer, java.util.function.Consumer<DistributionSummary> visitSummary, java.util.function.Consumer<LongTaskTimer> visitLongTaskTimer, java.util.function.Consumer<TimeGauge> visitTimeGauge, java.util.function.Consumer<FunctionCounter> visitFunctionCounter, java.util.function.Consumer<FunctionTimer> visitFunctionTimer, java.util.function.Consumer<Meter> visitMeter)
      Match a Meter with a series of dedicated functions for specific Meters and call the matching consumer.

      NOTE: This method contract will change in minor releases if ever a new Meter type 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 new Meter indicates 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 for Gauge
      visitCounter - function to apply for Counter
      visitTimer - function to apply for Timer
      visitSummary - function to apply for DistributionSummary
      visitLongTaskTimer - function to apply for LongTaskTimer
      visitTimeGauge - function to apply for TimeGauge
      visitFunctionCounter - function to apply for FunctionCounter
      visitFunctionTimer - function to apply for FunctionTimer
      visitMeter - function to apply as a fallback
      Since:
      1.1.0
    • close

      default void close()