question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Respecting the clock set in the CircuitBreakerStateMachine for detecting slow calls

See original GitHub issue

Resilience4j version: implementation ‘io.github.resilience4j:resilience4j-kotlin:1.1.0’ implementation ‘io.github.resilience4j:resilience4j-circuitbreaker:1.1.0’

Java version: 12

Problem description:

I’m writing unit tests to assert some of my assumptions of how the CircuitBreaker works. Especially how the it reacts to slow calls. To simulate it without a really big delay in running tests I can either set the slow threshold really low. Or I can mock the Clock (which was my initial approach).

I am setting up the CircuitBreaker with a config and injecting a Clock like this: CircuitBreakerStateMachine("myBreaker", circuitBreakerConfig, clock) . But even if I progress the clock beyond the slow threshold for each call to the operation, it does not detect slow operations. A simple sleep provokes it (but takes a “long” time). I suspect that is because in decorateCallable(...) it uses System.nanoTime() to time the execution of the function.

Wouldn’t it make sense to use the same Clock here? Or are there performance issues related to that?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Amaneuszcommented, Jul 2, 2020

I’ll try to find some time and take care of it 😃

1reaction
RobWincommented, Jul 2, 2020

No, the Registry does not allow to override the Clock. We could create a factory method. Would you like to create a PR?

Read more comments on GitHub >

github_iconTop Results From Across the Web

resilience4j/resilience4j v1.6.0 on GitHub - NewReleases.io
... backoff with constant behaviour after certain time #1044; Respecting the clock set in the CircuitBreakerStateMachine for detecting slow calls #734 ...
Read more >
CircuitBreakerStateMachine (resilience4j-circuitbreaker 1.6.1 ...
Acquires a permission to execute a call, only if one is available at the time of invocation. Methods inherited from class java.lang.Object. clone,...
Read more >
Implementing a Circuit Breaker with Resilience4j - Reflectoring
A count-based circuit breaker switches state from closed to open if the last N number of calls failed or were slow. A time-based...
Read more >
v1.6.0 · 标签· mirrors / resilience4j / resilience4j · GitCode
... backoff with constant behaviour after certain time #1044; Respecting the clock set in the CircuitBreakerStateMachine for detecting slow calls #734 ...
Read more >
Model-Based Analysis of Microservice Resiliency Patterns
or too slow, in which case the client service receives an error ... 3: Circuit breaker state machine (adapted from [16]). process request....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found