Class CounterMetric

  • All Implemented Interfaces:

    
    public final class CounterMetric
    extends Metric<Long>
                        

    A long metric wrapper for Prometheus Counters, which are monotonically increasing. Provides atomic operations such as incAndGet.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final String name
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      String getName() the name of this metric
      Long get() Supplies the current value of this metric.
      final Unit add(Long delta) Atomically adds the given value to this counter.
      final Long addAndGet(Long delta) Atomically adds the given value to this counter, returning the updated value.
      final Long incAndGet() Atomically increments the value of this counter by one, returning the updated value.
      final Unit inc() Atomically increments the value of this counter by one.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • get

         Long get()

        Supplies the current value of this metric.

      • add

         final Unit add(Long delta)

        Atomically adds the given value to this counter.

      • addAndGet

         final Long addAndGet(Long delta)

        Atomically adds the given value to this counter, returning the updated value.

        Returns:

        the updated value

      • incAndGet

         final Long incAndGet()

        Atomically increments the value of this counter by one, returning the updated value.

        Returns:

        the updated value

      • inc

         final Unit inc()

        Atomically increments the value of this counter by one.