Skip to content

Commit

Permalink
WIP: Attempt to test #2984
Browse files Browse the repository at this point in the history
Struggling to get this test to work due to complex test setup
  • Loading branch information
szokeasaurusrex committed Apr 25, 2024
1 parent 5a99aad commit da438e6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/conftest.py
Expand Up @@ -9,6 +9,8 @@
import pytest
import jsonschema

from sentry_sdk.integrations.celery import CeleryIntegration

try:
import gevent
except ImportError:
Expand Down Expand Up @@ -172,7 +174,7 @@ def reset_integrations():
_processed_integrations.clear()


@pytest.fixture
@pytest.fixture(scope="session")
def sentry_init(request):
def inner(*a, **kw):
hub = sentry_sdk.Hub.current
Expand All @@ -190,6 +192,15 @@ def inner(*a, **kw):
yield inner


@pytest.fixture(scope="session")
def celery_config(sentry_init):
sentry_init(integrations=[CeleryIntegration()], enable_tracing=True)
return {
"broker_backend": "memory://",
"broker_url": "memory://",
}


class TestTransport(Transport):
def __init__(self):
Transport.__init__(self)
Expand Down
17 changes: 17 additions & 0 deletions tests/integrations/celery/test_celery.py
Expand Up @@ -616,3 +616,20 @@ def example_task():
pytest.fail("Calling `apply_async` without arguments raised a TypeError")

assert result.get() == "success"


def test_queue_task_name(capture_events, celery_app, celery_worker):
@celery_app.task(name="dummy_task", bind=True)
def dummy_task(self):
print(self.request)
return 42

celery_worker.reload()
events = capture_events()
dummy_task.delay()

(event,) = events
breakpoint()
(span,) = event["spans"]

assert span["data"]["messaging.destination.name"] == "celery"

0 comments on commit da438e6

Please sign in to comment.