Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(utils): Add helpers for circuit breaker and circuit breaker tests #74559

Merged
merged 3 commits into from
Jul 23, 2024

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Jul 19, 2024

This is a follow-up to #74557, which added the beginnings of a rate-limit-based circuit breaker, in the form of a new CircuitBreaker class. In this PR, various helpers, for checking the state of the breaker and the underlying rate limiters and for communicating with redis, have been added to the class. It also adds a MockCircuitBreaker subclass for use in tests, which contains a number of methods for mocking both circuit breaker and rate limiter state.

Note that though these helpers don't have accompanying tests, they are tested (indirectly) in the final PR in the series, as part of testing the methods which use them.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 19, 2024
Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 42.85714% with 32 lines in your changes missing coverage. Please review.

Project coverage is 78.14%. Comparing base (7fc3a3d) to head (8609b63).

Additional details and impacted files
@@                           Coverage Diff                           @@
##           kmclb-add-CircuitBreaker-class-stub   #74559      +/-   ##
=======================================================================
- Coverage                                78.14%   78.14%   -0.01%     
=======================================================================
  Files                                     6731     6731              
  Lines                                   300065   300119      +54     
  Branches                                 51620    51636      +16     
=======================================================================
+ Hits                                    234495   234520      +25     
- Misses                                   59245    59276      +31     
+ Partials                                  6325     6323       -2     
Files Coverage Δ
src/sentry/utils/circuit_breaker2.py 67.01% <42.85%> (-32.99%) ⬇️

... and 8 files with indirect coverage changes

@lobsterkatie lobsterkatie marked this pull request as ready for review July 19, 2024 15:53
@lobsterkatie lobsterkatie force-pushed the kmclb-add-CircuitBreaker-class-stub branch from f9e498f to 2ba434a Compare July 23, 2024 00:47
@lobsterkatie lobsterkatie force-pushed the kmclb-add-helpers-to-CircuitBreaker-class branch from 55205da to 20822f6 Compare July 23, 2024 00:48
@lobsterkatie lobsterkatie force-pushed the kmclb-add-CircuitBreaker-class-stub branch from 2ba434a to 7fc3a3d Compare July 23, 2024 06:16
@lobsterkatie lobsterkatie force-pushed the kmclb-add-helpers-to-CircuitBreaker-class branch from 9b4a941 to d5c9975 Compare July 23, 2024 06:17
Base automatically changed from kmclb-add-CircuitBreaker-class-stub to master July 23, 2024 17:17
@lobsterkatie lobsterkatie force-pushed the kmclb-add-helpers-to-CircuitBreaker-class branch from 8609b63 to df575da Compare July 23, 2024 17:34
@lobsterkatie lobsterkatie merged commit 0d530a6 into master Jul 23, 2024
50 checks passed
@lobsterkatie lobsterkatie deleted the kmclb-add-helpers-to-CircuitBreaker-class branch July 23, 2024 18:07
lobsterkatie added a commit that referenced this pull request Jul 23, 2024
This completes the work, started in #74557 and #74559, of adding a new, class-and-rate-limit-based circuit breaker implementation to the codebase. In this PR, the core `record_error` and `should_allow_request` methods are added to the `CircuitBreaker` class, along with accompaying tests.
@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants