Interface MetricTimer


@Internal @ParametersAreNonnullByDefault public interface MetricTimer
Object that is used to collect time metrics about the execution a block of code.
     MetricTimer timer = Metrics.timer("my-metric");
     try (Ticker ignored = timer.start()) {
         // monitored code block
     }
 
or
     MetricTimer timer = Metrics.timer("my-metric");
     timer.update(5, TimeUnit.MILLISECONDS);
 
Since:
3.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Starts a ticker for a monitored code block
    default void
    update(long time, TimeUnit timeUnit)
    Updates the metric with an additional value
    void
    Updates the metric with an additional value
  • Method Details

    • start

      @Nonnull Ticker start()
      Starts a ticker for a monitored code block
      Returns:
      the ticker
    • update

      default void update(long time, TimeUnit timeUnit)
      Updates the metric with an additional value
      Parameters:
      time - the time to record
      timeUnit - the time unit of time
    • update

      void update(Duration time)
      Updates the metric with an additional value
      Parameters:
      time - the time to record
      Since:
      3.4