Class MockClock

java.lang.Object
io.micrometer.core.instrument.MockClock
All Implemented Interfaces:
Clock

public class MockClock
extends java.lang.Object
implements Clock
  • Field Summary

    Fields inherited from interface io.micrometer.core.instrument.Clock

    SYSTEM
  • Constructor Summary

    Constructors
    Constructor Description
    MockClock()  
  • Method Summary

    Modifier and Type Method Description
    long add​(long amount, java.util.concurrent.TimeUnit unit)  
    long add​(java.time.Duration duration)  
    long addSeconds​(long amount)  
    static MockClock clock​(MeterRegistry registry)  
    long monotonicTime()
    Current time from a monotonic clock source.
    long wallTime()
    Current wall time in milliseconds since the epoch.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MockClock

      public MockClock()
  • Method Details

    • monotonicTime

      public long monotonicTime()
      Description copied from interface: Clock
      Current time from a monotonic clock source. The value is only meaningful when compared with another snapshot to determine the elapsed time for an operation. The difference between two samples will have a unit of nanoseconds. The returned value is typically equivalent to System.nanoTime.
      Specified by:
      monotonicTime in interface Clock
      Returns:
      Monotonic time in nanoseconds
    • wallTime

      public long wallTime()
      Description copied from interface: Clock
      Current wall time in milliseconds since the epoch. Typically equivalent to System.currentTimeMillis. Should not be used to determine durations. Used for timestamping metrics being pushed to a monitoring system or for determination of step boundaries (e.g. StepLong.
      Specified by:
      wallTime in interface Clock
      Returns:
      Wall time in milliseconds
    • add

      public long add​(long amount, java.util.concurrent.TimeUnit unit)
    • add

      public long add​(java.time.Duration duration)
    • addSeconds

      public long addSeconds​(long amount)
    • clock

      public static MockClock clock​(MeterRegistry registry)