- 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 ClassesModifier and TypeInterfaceDescriptionstatic final classNo-op implementation for when metrics are disabled. -
Method Summary
Modifier and TypeMethodDescriptionstatic RetryMetricsnoOp()Creates a no-op implementation that performs no metrics recording.voidrecordRetryAttempt(RetryContext context, int attemptNumber, Duration attemptDuration, boolean successful) Records a single retry attempt.voidrecordRetryComplete(RetryContext context, Duration totalDuration, boolean successful, int totalAttempts) Records the completion of a retry operation (success or failure after all attempts).voidrecordRetryDelay(RetryContext context, int attemptNumber, Duration plannedDelay, Duration actualDelay) Records the actual delay time between retry attempts.voidrecordRetryStart(RetryContext context) 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 informationtotalDuration- total duration including all attempts and delayssuccessful- whether the retry operation ultimately succeededtotalAttempts- 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 informationattemptNumber- 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 informationattemptNumber- the attempt number that will follow this delayplannedDelay- the calculated delay durationactualDelay- the actual delay duration (may differ due to interruption)
-
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
-