Interface ResilienceMetrics

All Known Implementing Classes:
FakeResilienceMetrics, MicrometerResilienceMetrics, NoOpMetrics, OpenTelemetryResilienceMetrics

public interface ResilienceMetrics
Backend-facing contract that concrete metrics implementations (Micrometer, OpenTelemetry, custom) must implement to observe pattern and Policy events as metrics.

Implementation contract:

  • Non-blocking: No I/O, no lock acquisition that could wait.
  • Allocation-light: Avoid unnecessary object creation on the hot path.
  • Virtual-thread-safe: Must not pin virtual threads in code resiliencia itself writes. This applies to the event→metric mapping code, not to any concrete backend registry the consuming application wires in at runtime.

Each backend implementation performs its own exhaustive switch over the sealed Snapshot and Counters hierarchies inside its observe(...) method bodies, guaranteed to compile only when all cases are handled.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    observe(Counters counters)
    Observe a counter/timer-worthy occurrence from any pattern (Retry, Timeout, CircuitBreaker, Bulkhead, RateLimiter) or from Policy's order validation.
    void
    observe(Snapshot snapshot)
    Observe a gauge-worthy snapshot of live state from CircuitBreaker, Bulkhead, or RateLimiter.
  • Method Details

    • observe

      void observe(Snapshot snapshot)
      Observe a gauge-worthy snapshot of live state from CircuitBreaker, Bulkhead, or RateLimiter.
      Parameters:
      snapshot - the snapshot to observe; never null
    • observe

      void observe(Counters counters)
      Observe a counter/timer-worthy occurrence from any pattern (Retry, Timeout, CircuitBreaker, Bulkhead, RateLimiter) or from Policy's order validation.
      Parameters:
      counters - the counter event to observe; never null