Top Inners Fields Constructors Methods
io.github.resilience4j.circuitbreaker.internal

pack-priv Class CircuitBreakerMetrics

extends Object
implements Metrics
Class Inheritance
All Implemented Interfaces
io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics
Imports
io.github.resilience4j.circuitbreaker.CircuitBreaker, .CircuitBreakerConfig, .CircuitBreakerConfig.SlidingWindowSynchronizationStrategy, io.github.resilience4j.core.metrics.*, java.time.Clock, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.LongAdder

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

Modifier and TypeField and Description
private final float
private final Metrics
private int
private final LongAdder
private final long
private final float

Constructor Summary

AccessConstructor and Description
private
CircuitBreakerMetrics(int slidingWindowSize, CircuitBreakerConfig.SlidingWindowType slidingWindowType, CircuitBreakerConfig circuitBreakerConfig)

private
CircuitBreakerMetrics(int slidingWindowSize, CircuitBreakerConfig circuitBreakerConfig)

Method Summary

Modifier and TypeMethod and Description
private Metrics
buildCountBasedMetrics(int slidingWindowSize, CircuitBreakerConfig.SlidingWindowSynchronizationStrategy slidingWindowSynchronizationStrategy)

private Metrics
buildTimeBasedMetrics(int slidingWindowSize, Clock clock, CircuitBreakerConfig.SlidingWindowSynchronizationStrategy slidingWindowSynchronizationStrategy)

private CircuitBreakerMetrics.Result

Returns:

false, if the thresholds haven't been exceeded.
checkIfThresholdsExceeded
(Snapshot
a metrics snapshot
snapshot
)

Checks if the failure rate is above the threshold or if the slow calls percentage is above the threshold.

pack-priv static CircuitBreakerMetrics
forClosed(CircuitBreakerConfig circuitBreakerConfig)

pack-priv static CircuitBreakerMetrics
forDisabled(CircuitBreakerConfig circuitBreakerConfig)

pack-priv static CircuitBreakerMetrics
forForcedOpen(CircuitBreakerConfig circuitBreakerConfig)

pack-priv static CircuitBreakerMetrics
forHalfOpen(int permittedNumberOfCallsInHalfOpenState, CircuitBreakerConfig circuitBreakerConfig)

pack-priv static CircuitBreakerMetrics
forMetricsOnly(CircuitBreakerConfig circuitBreakerConfig)

private float
public float
getFailureRate()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getFailureRate.

Returns the current failure rate in percentage.

public int
getNumberOfBufferedCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfBufferedCalls.

Returns the current total number of buffered calls in the ring buffer.

public int
getNumberOfFailedCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfFailedCalls.

Returns the current number of failed buffered calls in the ring buffer.

public long
getNumberOfNotPermittedCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfNotPermittedCalls.

Returns the current number of not permitted calls, when the state is OPEN.

public int
getNumberOfSlowCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSlowCalls.

Returns the current total number of calls which were slower than a certain threshold.

public int
getNumberOfSlowFailedCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSlowFailedCalls.

Returns the current number of failed calls which were slower than a certain threshold.

public int
getNumberOfSlowSuccessfulCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSlowSuccessfulCalls.

Returns the current number of successful calls which were slower than a certain threshold.

public int
getNumberOfSuccessfulCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSuccessfulCalls.

Returns the current number of successful buffered calls in the ring buffer.

private float
public float
getSlowCallRate()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getSlowCallRate.

Returns the current percentage of calls which were slower than a certain threshold.

pack-priv void
onCallNotPermitted()

Records a call which was not permitted, because the CircuitBreaker state is OPEN.

public CircuitBreakerMetrics.Result

Returns:

the result of the check
onError
(long duration, TimeUnit durationUnit)

Records a failed call and checks if the thresholds are exceeded.

public CircuitBreakerMetrics.Result

Returns:

the result of the check
onSuccess
(long duration, TimeUnit durationUnit)

Records a successful call and checks if the thresholds are exceeded.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

failureRateThresholdback to summary
private final float failureRateThreshold
metricsback to summary
private final Metrics metrics
minimumNumberOfCallsback to summary
private int minimumNumberOfCalls
numberOfNotPermittedCallsback to summary
private final LongAdder numberOfNotPermittedCalls
slowCallDurationThresholdInNanosback to summary
private final long slowCallDurationThresholdInNanos
slowCallRateThresholdback to summary
private final float slowCallRateThreshold

Constructor Detail

CircuitBreakerMetricsback to summary
private CircuitBreakerMetrics(int slidingWindowSize, CircuitBreakerConfig.SlidingWindowType slidingWindowType, CircuitBreakerConfig circuitBreakerConfig)
CircuitBreakerMetricsback to summary
private CircuitBreakerMetrics(int slidingWindowSize, CircuitBreakerConfig circuitBreakerConfig)

Method Detail

buildCountBasedMetricsback to summary
private Metrics buildCountBasedMetrics(int slidingWindowSize, CircuitBreakerConfig.SlidingWindowSynchronizationStrategy slidingWindowSynchronizationStrategy)
buildTimeBasedMetricsback to summary
private Metrics buildTimeBasedMetrics(int slidingWindowSize, Clock clock, CircuitBreakerConfig.SlidingWindowSynchronizationStrategy slidingWindowSynchronizationStrategy)
checkIfThresholdsExceededback to summary
private CircuitBreakerMetrics.Result checkIfThresholdsExceeded(Snapshot snapshot)

Checks if the failure rate is above the threshold or if the slow calls percentage is above the threshold.

Parameters
snapshot:Snapshot

a metrics snapshot

Returns:CircuitBreakerMetrics.Result

false, if the thresholds haven't been exceeded.

forClosedback to summary
pack-priv static CircuitBreakerMetrics forClosed(CircuitBreakerConfig circuitBreakerConfig)
forDisabledback to summary
pack-priv static CircuitBreakerMetrics forDisabled(CircuitBreakerConfig circuitBreakerConfig)
forForcedOpenback to summary
pack-priv static CircuitBreakerMetrics forForcedOpen(CircuitBreakerConfig circuitBreakerConfig)
forHalfOpenback to summary
pack-priv static CircuitBreakerMetrics forHalfOpen(int permittedNumberOfCallsInHalfOpenState, CircuitBreakerConfig circuitBreakerConfig)
forMetricsOnlyback to summary
pack-priv static CircuitBreakerMetrics forMetricsOnly(CircuitBreakerConfig circuitBreakerConfig)
getFailureRateback to summary
private float getFailureRate(Snapshot snapshot)
getFailureRateback to summary
public float getFailureRate()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getFailureRate.

Doc from io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getFailureRate.

Returns the current failure rate in percentage. If the number of measured calls is below the minimum number of measured calls, it returns -1.

Returns:float

the failure rate in percentage

Annotations
@Override
getNumberOfBufferedCallsback to summary
public int getNumberOfBufferedCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfBufferedCalls.

Doc from io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfBufferedCalls.

Returns the current total number of buffered calls in the ring buffer.

Returns:int

he current total number of buffered calls in the ring buffer

Annotations
@Override
getNumberOfFailedCallsback to summary
public int getNumberOfFailedCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfFailedCalls.

Doc from io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfFailedCalls.

Returns the current number of failed buffered calls in the ring buffer.

Returns:int

the current number of failed buffered calls in the ring buffer

Annotations
@Override
getNumberOfNotPermittedCallsback to summary
public long getNumberOfNotPermittedCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfNotPermittedCalls.

Doc from io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfNotPermittedCalls.

Returns the current number of not permitted calls, when the state is OPEN.

The number of denied calls is always 0, when the CircuitBreaker state is CLOSED or HALF_OPEN. The number of denied calls is only increased when the CircuitBreaker state is OPEN.

Returns:long

the current number of not permitted calls

Annotations
@Override
getNumberOfSlowCallsback to summary
public int getNumberOfSlowCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSlowCalls.

Doc from io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSlowCalls.

Returns the current total number of calls which were slower than a certain threshold.

Returns:int

the current total number of calls which were slower than a certain threshold

Annotations
@Override
getNumberOfSlowFailedCallsback to summary
public int getNumberOfSlowFailedCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSlowFailedCalls.

Doc from io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSlowFailedCalls.

Returns the current number of failed calls which were slower than a certain threshold.

Returns:int

the current number of failed calls which were slower than a certain threshold

Annotations
@Override
getNumberOfSlowSuccessfulCallsback to summary
public int getNumberOfSlowSuccessfulCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSlowSuccessfulCalls.

Doc from io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSlowSuccessfulCalls.

Returns the current number of successful calls which were slower than a certain threshold.

Returns:int

the current number of successful calls which were slower than a certain threshold

Annotations
@Override
getNumberOfSuccessfulCallsback to summary
public int getNumberOfSuccessfulCalls()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSuccessfulCalls.

Doc from io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getNumberOfSuccessfulCalls.

Returns the current number of successful buffered calls in the ring buffer.

Returns:int

the current number of successful buffered calls in the ring buffer

Annotations
@Override
getSlowCallRateback to summary
private float getSlowCallRate(Snapshot snapshot)
getSlowCallRateback to summary
public float getSlowCallRate()

Implements io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getSlowCallRate.

Doc from io.github.resilience4j.circuitbreaker.CircuitBreaker.Metrics.getSlowCallRate.

Returns the current percentage of calls which were slower than a certain threshold. If the number of measured calls is below the minimum number of measured calls, it returns -1.

Returns:float

the failure rate in percentage

Annotations
@Override
onCallNotPermittedback to summary
pack-priv void onCallNotPermitted()

Records a call which was not permitted, because the CircuitBreaker state is OPEN.

onErrorback to summary
public CircuitBreakerMetrics.Result onError(long duration, TimeUnit durationUnit)

Records a failed call and checks if the thresholds are exceeded.

Returns:CircuitBreakerMetrics.Result

the result of the check

onSuccessback to summary
public CircuitBreakerMetrics.Result onSuccess(long duration, TimeUnit durationUnit)

Records a successful call and checks if the thresholds are exceeded.

Returns:CircuitBreakerMetrics.Result

the result of the check

io.github.resilience4j.circuitbreaker.internal back to summary

pack-priv final Enum CircuitBreakerMetrics.Result

extends Enum<CircuitBreakerMetrics.Result>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final CircuitBreakerMetrics.Result
public static final CircuitBreakerMetrics.Result
public static final CircuitBreakerMetrics.Result
public static final CircuitBreakerMetrics.Result
public static final CircuitBreakerMetrics.Result

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean
public static boolean
public static boolean
public static CircuitBreakerMetrics.Result
public static CircuitBreakerMetrics.Result[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ABOVE_THRESHOLDSback to summary
public static final CircuitBreakerMetrics.Result ABOVE_THRESHOLDS
BELOW_MINIMUM_CALLS_THRESHOLDback to summary
public static final CircuitBreakerMetrics.Result BELOW_MINIMUM_CALLS_THRESHOLD
BELOW_THRESHOLDSback to summary
public static final CircuitBreakerMetrics.Result BELOW_THRESHOLDS
FAILURE_RATE_ABOVE_THRESHOLDSback to summary
public static final CircuitBreakerMetrics.Result FAILURE_RATE_ABOVE_THRESHOLDS
SLOW_CALL_RATE_ABOVE_THRESHOLDSback to summary
public static final CircuitBreakerMetrics.Result SLOW_CALL_RATE_ABOVE_THRESHOLDS

Constructor Detail

Resultback to summary
private Result()

Method Detail

hasExceededThresholdsback to summary
public static boolean hasExceededThresholds(CircuitBreakerMetrics.Result result)
hasFailureRateExceededThresholdback to summary
public static boolean hasFailureRateExceededThreshold(CircuitBreakerMetrics.Result result)
hasSlowCallRateExceededThresholdback to summary
public static boolean hasSlowCallRateExceededThreshold(CircuitBreakerMetrics.Result result)
valueOfback to summary
public static CircuitBreakerMetrics.Result valueOf(String name)
valuesback to summary
public static CircuitBreakerMetrics.Result[] values()