Class TimerGauge

  • All Implemented Interfaces:
    Gauge<Long>, Metric, View

    public class TimerGauge
    extends Object
    implements Gauge<Long>, View
    TimerGauge measures how much time is spent in a given state, with entry into that state being signaled by markStart(). Measuring is stopped by markEnd(). This class in particularly takes care of the case, when update() is called when some measurement started but has not yet finished. For example even if next markEnd() call is expected to happen in a couple of hours, the returned value will account for this ongoing measurement.
    • Constructor Detail

      • TimerGauge

        public TimerGauge()
      • TimerGauge

        public TimerGauge​(int timeSpanInSeconds)
      • TimerGauge

        public TimerGauge​(Clock clock)
      • TimerGauge

        public TimerGauge​(Clock clock,
                          int timeSpanInSeconds)
    • Method Detail

      • markStart

        public void markStart()
      • markEnd

        public void markEnd()
      • update

        public void update()
        Description copied from interface: View
        This method will be called regularly to update the metric.
        Specified by:
        update in interface View
      • getValue

        public Long getValue()
        Description copied from interface: Gauge
        Calculates and returns the measured value.
        Specified by:
        getValue in interface Gauge<Long>
        Returns:
        calculated value
      • getMaxSingleMeasurement

        public long getMaxSingleMeasurement()
        Returns:
        the longest marked period as measured by the given * TimerGauge. For example the longest consecutive back pressured period.
      • getAccumulatedCount

        public long getAccumulatedCount()
        Returns:
        the accumulated period by the given * TimerGauge.