Class ProducerTimingRecorder

java.lang.Object
dagger.producers.monitoring.ProducerTimingRecorder

public abstract class ProducerTimingRecorder extends Object
A hook for recording the timing of the execution of individual producer methods. See ProductionComponentTimingRecorder for how to install these monitors.

If any of the recorder's methods throw, then the exception will be logged and processing will continue unaffected.

All timings are measured at nanosecond precision, but not necessarily nanosecond resolution. That is, timings will be reported in nanoseconds, but the timing source will not necessarily update at nanosecond resolution. For example, System.nanoTime() would satisfy these constraints.

Since:
2.1
  • Constructor Details

    • ProducerTimingRecorder

      public ProducerTimingRecorder()
  • Method Details

    • recordMethod

      public void recordMethod(long startedNanos, long durationNanos)
      Reports that the producer method has finished executing with the given statistics.

      If the producer was skipped due to any of its inputs failing, then this will not be called.

      Parameters:
      startedNanos - the wall-clock time, in nanoseconds, when the producer method started executing, measured from when the first method on the production component was called.
      durationNanos - the wall-clock time, in nanoseconds, that the producer method took to execute.
    • recordSuccess

      public void recordSuccess(long latencyNanos)
      Reports that the producer's future has succeeded with the given statistics.

      If the producer was skipped due to any of its inputs failing, then this will not be called.

      Parameters:
      latencyNanos - the wall-clock time, in nanoseconds, of the producer's latency, measured from when the producer method started to when the future finished.
    • recordFailure

      public void recordFailure(Throwable exception, long latencyNanos)
      Reports that the producer's future has failed with the given statistics.
      Parameters:
      exception - the exception that the future failed with.
      latencyNanos - the wall-clock time, in nanoseconds, of the producer's latency, measured from when the producer method started to when the future finished.
    • recordSkip

      public void recordSkip(Throwable exception)
      Reports that the producer was skipped because one of its inputs failed.
      Parameters:
      exception - the exception that its input failed with. If multiple inputs failed, this exception will be chosen arbitrarily from the input failures.
    • noOp

      public static ProducerTimingRecorder noOp()
      Returns a producer recorder that does nothing.