From ae5f1301fd7f91c988075ad5b69d217c992688ed Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 23 Dec 2024 12:30:48 +0100 Subject: [PATCH] Some cleanup --- sentry_sdk/integrations/celery/__init__.py | 10 +++++++--- tests/conftest.py | 4 +--- tests/integrations/celery/test_celery.py | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index fd7a6073b5..b211b637cc 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -322,9 +322,13 @@ def _inner(*args, **kwargs): # for some reason, args[1] is a list if non-empty but a # tuple if empty attributes=_prepopulate_attributes(task, list(args[1]), args[2]), - ) as transaction: - transaction.set_status(SPANSTATUS.OK) - return f(*args, **kwargs) + ) as root_span: + return_value = f(*args, **kwargs) + + if root_span.status is None: + root_span.set_status(SPANSTATUS.OK) + + return return_value return _inner # type: ignore diff --git a/tests/conftest.py b/tests/conftest.py index ffeae7fc3d..7c42325d3e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -68,9 +68,7 @@ def benchmark(): ) -# Disabling this, because this leads in Potel to Celery tests failing -# TODO: Check if disabling this broke a bunch of other test (not sure how to do) -# @pytest.fixture(autouse=True) +@pytest.fixture(autouse=True) def clean_scopes(): """ Resets the scopes for every test to avoid leaking data between tests. diff --git a/tests/integrations/celery/test_celery.py b/tests/integrations/celery/test_celery.py index fd5f4a5c72..de1d9e6f4b 100644 --- a/tests/integrations/celery/test_celery.py +++ b/tests/integrations/celery/test_celery.py @@ -237,6 +237,9 @@ def dummy_task(x, y): "timestamp": submission_event["spans"][0]["timestamp"], "trace_id": str(span.trace_id), "status": "ok", + "tags": { + "status": "ok", + } } ]