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

fix(integrations): Check retries_left before capturing exception #3803

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions sentry_sdk/integrations/rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ def sentry_patched_perform_job(self, job, *args, **kwargs):

def sentry_patched_handle_exception(self, job, *exc_info, **kwargs):
# type: (Worker, Any, *Any, **Any) -> Any
# Note, the order of the `or` here is important,
# because calling `job.is_failed` will change `_status`.
if job._status == JobStatus.FAILED or job.is_failed:
retry = (
hasattr(job, "retries_left")
and job.retries_left
and job.retries_left > 0
)
failed = job._status == JobStatus.FAILED or job.is_failed
if failed and not retry:
_capture_exception(exc_info)

return old_handle_exception(self, job, *exc_info, **kwargs)
Expand Down
5 changes: 0 additions & 5 deletions tests/integrations/rq/test_rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,6 @@ def test_traces_sampler_gets_correct_values_in_sampling_context(
@pytest.mark.skipif(
parse_version(rq.__version__) < (1, 5), reason="At least rq-1.5 required"
)
@pytest.mark.skipif(
parse_version(rq.__version__) >= (2,),
reason="Test broke in RQ 2.0. Investigate and fix. "
"See https://github.com/getsentry/sentry-python/issues/3707.",
)
def test_job_with_retries(sentry_init, capture_events):
sentry_init(integrations=[RqIntegration()])
events = capture_events()
Expand Down
Loading