Class OpenTelemetryResilienceMetrics

java.lang.Object
io.github.teceli.resiliencia.opentelemetry.OpenTelemetryResilienceMetrics
All Implemented Interfaces:
ResilienceMetrics

public final class OpenTelemetryResilienceMetrics extends Object implements ResilienceMetrics
ResilienceMetrics backed by an OpenTelemetry Meter.

Duration metrics (resilience.timeout.duration, resilience.circuitbreaker.calls) are recorded according to the configured DurationInstrumentationModeSAFE (default, lock-free counter pair) or DETAILED (opt-in, DoubleHistogram, see that enum's Javadoc for the pinning risk it accepts).

Every metric emitted here is tagged with the pattern instance's name (the "name" attribute key). That name must be a static, compile-time-known string — never request-derived or tenant-derived — since it becomes a cardinality-bounded attribute value in the OpenTelemetry SDK; unbounded distinct names would cause unbounded memory growth in the metrics backend.

  • Constructor Details

    • OpenTelemetryResilienceMetrics

      public OpenTelemetryResilienceMetrics(io.opentelemetry.api.metrics.Meter meter)
    • OpenTelemetryResilienceMetrics

      public OpenTelemetryResilienceMetrics(io.opentelemetry.api.metrics.Meter meter, DurationInstrumentationMode durationMode)
  • Method Details

    • observe

      public void observe(Snapshot snapshot)
      Description copied from interface: ResilienceMetrics
      Observe a gauge-worthy snapshot of live state from CircuitBreaker, Bulkhead, or RateLimiter.
      Specified by:
      observe in interface ResilienceMetrics
      Parameters:
      snapshot - the snapshot to observe; never null
    • observe

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