Skip to content

Commit

Permalink
test(celery): Add test for nonzero retry count
Browse files Browse the repository at this point in the history
Add a test to verify that retry count gets set correctly, also for nonzero values.
  • Loading branch information
szokeasaurusrex committed Apr 26, 2024
1 parent 4a0692b commit 5baf5dd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/integrations/celery/test_celery.py
Expand Up @@ -661,7 +661,7 @@ def task(): ...
assert "messaging.destination.name" not in span["data"]


def test_retry_count(init_celery, capture_events):
def test_retry_count_zero(init_celery, capture_events):
celery = init_celery(enable_tracing=True)
events = capture_events()

Expand All @@ -673,3 +673,20 @@ def task(): ...
(event,) = events
(span,) = event["spans"]
assert span["data"]["messaging.message.retry.count"] == 0


@mock.patch("celery.app.task.Task.request")
def test_retry_count_nonzero(mock_request, init_celery, capture_events):
mock_request.retries = 3

celery = init_celery(enable_tracing=True)
events = capture_events()

@celery.task()
def task(): ...

task.apply_async()

(event,) = events
(span,) = event["spans"]
assert span["data"]["messaging.message.retry.count"] == 3

0 comments on commit 5baf5dd

Please sign in to comment.