Skip to content

Commit

Permalink
test(celery): Test that messaging.system gets set
Browse files Browse the repository at this point in the history
The messaging.system span data attribute should be set to the Celery broker being used, e.g. "amqp" for RabbitMQ, "redis" for Redis, and "sqs" for Amazon SQS.

ref #2951
  • Loading branch information
szokeasaurusrex committed May 7, 2024
1 parent 2b51425 commit fa16def
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/integrations/celery/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def init_celery(sentry_init, request):
def inner(propagate_traces=True, backend="always_eager", **kwargs):
sentry_init(
integrations=[CeleryIntegration(propagate_traces=propagate_traces)],
**kwargs
**kwargs,
)
celery = Celery(__name__)

Expand Down Expand Up @@ -704,3 +704,21 @@ def task(): ...
(event,) = events
(span,) = event["spans"]
assert span["data"]["messaging.message.retry.count"] == 3


@pytest.mark.parametrize("system", ("redis", "amqp"))
def test_messaging_system(system, init_celery, capture_events):
celery = init_celery(enable_tracing=True)
events = capture_events()

# Does not need to be a real URL, since we use always eager
celery.conf.broker_url = f"{system}://example.com" # noqa: E231

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

task.apply_async()

(event,) = events
(span,) = event["spans"]
assert span["data"]["messaging.system"] == system

0 comments on commit fa16def

Please sign in to comment.