Interface RetryMetrics

All Known Implementing Classes:
RetryMetrics.NoOpRetryMetrics

public interface RetryMetrics
Interface for recording retry operation metrics.

This interface provides a clean abstraction for metrics recording that can be implemented by different metrics systems (Micrometer, custom metrics, etc.) without creating dependencies in the core retry infrastructure.

All methods in this interface should be implemented to be non-blocking and should handle any internal exceptions gracefully to avoid impacting retry logic.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    No-op implementation for when metrics are disabled.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a no-op implementation that performs no metrics recording.
    void
    recordRetryAttempt(RetryContext context, int attemptNumber, Duration attemptDuration, boolean successful)
    Records a single retry attempt.
    void
    recordRetryComplete(RetryContext context, Duration totalDuration, boolean successful, int totalAttempts)
    Records the completion of a retry operation (success or failure after all attempts).
    void
    recordRetryDelay(RetryContext context, int attemptNumber, Duration plannedDelay, Duration actualDelay)
    Records the actual delay time between retry attempts.
    void
    Records the start of a complete retry operation.
  • Method Details

    • recordRetryStart

      Records the start of a complete retry operation. This should be called once per retry operation, before any attempts.
      Parameters:
      context - retry context information
    • recordRetryComplete

      void recordRetryComplete(RetryContext context, Duration totalDuration, boolean successful, int totalAttempts)
      Records the completion of a retry operation (success or failure after all attempts).
      Parameters:
      context - retry context information
      totalDuration - total duration including all attempts and delays
      successful - whether the retry operation ultimately succeeded
      totalAttempts - total number of attempts made
    • recordRetryAttempt

      void recordRetryAttempt(RetryContext context, int attemptNumber, Duration attemptDuration, boolean successful)
      Records a single retry attempt.
      Parameters:
      context - retry context information
      attemptNumber - the attempt number (1-based)
      attemptDuration - duration of this specific attempt (excluding delay)
      successful - whether this specific attempt succeeded
    • recordRetryDelay

      void recordRetryDelay(RetryContext context, int attemptNumber, Duration plannedDelay, Duration actualDelay)
      Records the actual delay time between retry attempts.
      Parameters:
      context - retry context information
      attemptNumber - the attempt number that will follow this delay
      plannedDelay - the calculated delay duration
      actualDelay - the actual delay duration (may differ due to interruption)
    • noOp

      static RetryMetrics noOp()
      Creates a no-op implementation that performs no metrics recording. Useful when metrics are disabled or not available.
      Returns:
      a metrics recorder that does nothing