Interface DurationTracker

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
StatisticDurationTracker, StubDurationTracker

public interface DurationTracker extends AutoCloseable
Interface to be implemented by objects which can track duration. It extends AutoCloseable to fit into a try-with-resources statement, but then strips out the throws Exception aspect of the signature so it doesn't force code to add extra handling for any failures. If a duration is declared as "failed()" then the failure counters will be updated.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Duration
    Get the duration of an operation as a java Duration instance.
    void
    Finish tracking: update the statistics with the timings.
    void
    The operation failed.
  • Method Details

    • failed

      void failed()
      The operation failed. Failure statistics will be updated.
    • close

      void close()
      Finish tracking: update the statistics with the timings.
      Specified by:
      close in interface AutoCloseable
    • asDuration

      default Duration asDuration()
      Get the duration of an operation as a java Duration instance. If the duration tracker hasn't completed, or its duration tracking doesn't actually measure duration, returns Duration.ZERO.
      Returns:
      a duration, value of ZERO until close().