Interface Timer

  • All Superinterfaces:
    Meter
    All Known Implementing Classes:
    DropwizardTypes.DescribableTimer

    public interface Timer
    extends Meter
    Timer intended to track of a large number of short running events. Example would be something like an HTTP request. Though "short running" is a bit subjective the assumption is that it should be under a minute.
    • Method Detail

      • builder

        static Timer.Builder builder​(Timed timed,
                                     String defaultName)
        Create a timer builder from a Timed annotation.
        Parameters:
        timed - The annotation instance to base a new timer on.
        defaultName - A default name to use in the event that the value attribute is empty.
      • record

        void record​(long amount,
                    TimeUnit unit)
        Updates the statistics kept by the counter with the specified amount.
        Parameters:
        amount - Duration of a single event being measured by this timer. If the amount is less than 0 the value will be dropped.
        unit - Time unit for the amount being recorded.
      • record

        default void record​(Duration duration)
        Updates the statistics kept by the counter with the specified amount.
        Parameters:
        duration - Duration of a single event being measured by this timer.
      • record

        <T> T record​(Supplier<T> f)
        Executes the Supplier `f` and records the time taken.
        Parameters:
        f - Function to execute and measure the execution time.
        Returns:
        The return value of `f`.
      • recordCallable

        <T> T recordCallable​(Callable<T> f)
                      throws Exception
        Executes the callable `f` and records the time taken.
        Parameters:
        f - Function to execute and measure the execution time.
        Returns:
        The return value of `f`.
        Throws:
        Exception
      • record

        void record​(Runnable f)
        Executes the runnable `f` and records the time taken.
        Parameters:
        f - Function to execute and measure the execution time.
      • wrap

        default Runnable wrap​(Runnable f)
        Wrap a Runnable so that it is timed when invoked.
        Parameters:
        f - The Runnable to time when it is invoked.
        Returns:
        The wrapped Runnable.
      • wrap

        default <T> Callable<T> wrap​(Callable<T> f)
        Wrap a Callable so that it is timed when invoked.
        Parameters:
        f - The Callable to time when it is invoked.
        Returns:
        The wrapped Callable.
      • count

        long count()
        The number of times that stop has been called on this timer.
      • totalTime

        double totalTime​(TimeUnit unit)
        The total time of recorded events.
      • mean

        default double mean​(TimeUnit unit)
      • max

        double max​(TimeUnit unit)
        The maximum time of a single event.
      • percentile

        double percentile​(double percentile,
                          TimeUnit unit)
        The latency at a specific percentile. This value is non-aggregable across dimensions.
      • histogramCountAtValue

        double histogramCountAtValue​(long valueNanos)
      • takeSnapshot

        HistogramSnapshot takeSnapshot​(boolean supportsAggregablePercentiles)
      • measure

        default Iterable<Measurement> measure()
        Description copied from interface: Meter
        Get a set of measurements. Should always return the same number of measurements and in the same order, regardless of the level of activity or the lack thereof.
        Specified by:
        measure in interface Meter
        Returns:
        The set of measurements that represents the instantaneous value of this meter.