Class Timer.Sample

java.lang.Object
io.micrometer.core.instrument.Timer.Sample
Enclosing interface:
Timer

public static class Timer.Sample
extends java.lang.Object
Maintains state on the clock's start position for a latency sample. Complete the timing by calling stop(Timer). Note how the Timer isn't provided until the sample is stopped, allowing you to determine the timer's tags at the last minute.
  • Method Summary

    Modifier and Type Method Description
    long stop​(MeterRegistry registry, Timer.Builder timerBuilder)
    Records the duration of the operation.
    long stop​(Timer timer)
    Records the duration of the operation.
    Timer.Sample tags​(java.lang.Iterable<Tag> tags)  
    Timer.Sample tags​(java.lang.String... tags)  

    Methods inherited from class java.lang.Object

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

    • stop

      public long stop​(Timer timer)
      Records the duration of the operation. Using this method, any tags stored on the sample are NOT recorded with the timing.
      Parameters:
      timer - The timer to record the sample to.
      Returns:
      The total duration of the sample in nanoseconds
    • stop

      @Incubating(since="1.4.0") public long stop​(MeterRegistry registry, Timer.Builder timerBuilder)
      Records the duration of the operation. Using this method, any tags stored on the sample are recorded with the timing.
      Parameters:
      registry - The registry to which the timer will be registered.
      timerBuilder - The timer to record the sample to.
      Returns:
      The total duration of the sample in nanoseconds
      Since:
      1.4.0
    • tags

      @Incubating(since="1.4.0") public Timer.Sample tags​(java.lang.String... tags)
      Parameters:
      tags - Must be an even number of arguments representing key/value pairs of tags.
      Returns:
      This builder.
      Since:
      1.4.0
    • tags

      @Incubating(since="1.4.0") public Timer.Sample tags​(java.lang.Iterable<Tag> tags)
      Parameters:
      tags - Tags to add to the eventual timer.
      Returns:
      The sample with added tags.
      Since:
      1.4.0