Skip to content

Fix Huey tests in POTel #3843

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

Merged
merged 4 commits into from
Dec 4, 2024
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
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/huey.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _sentry_execute(self, task, timestamp=None):

sentry_headers = task.kwargs.pop("sentry_headers", {})
with sentry_sdk.continue_trace(sentry_headers):
with sentry_sdk.start_transaction(
with sentry_sdk.start_span(
name=task.name,
op=OP.QUEUE_TASK_HUEY,
source=TRANSACTION_SOURCE_TASK,
Expand Down
7 changes: 6 additions & 1 deletion sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,12 @@ def __exit__(self, ty, value, tb):
if value is not None:
self.set_status(SPANSTATUS.INTERNAL_ERROR)
else:
self.set_status(SPANSTATUS.OK)
status_unset = (
hasattr(self._otel_span, "status")
and self._otel_span.status.status_code == StatusCode.UNSET
)
if status_unset:
self.set_status(SPANSTATUS.OK)

self.finish()
context.detach(self._ctx_token)
Expand Down
8 changes: 4 additions & 4 deletions tests/integrations/huey/test_huey.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from decimal import DivisionByZero

from sentry_sdk import start_transaction
import sentry_sdk
from sentry_sdk.integrations.huey import HueyIntegration
from sentry_sdk.utils import parse_version

Expand Down Expand Up @@ -160,7 +160,7 @@ def dummy_task():

events = capture_events()

with start_transaction() as transaction:
with sentry_sdk.start_span() as transaction:
dummy_task()

(event,) = events
Expand All @@ -182,7 +182,7 @@ def test_huey_propagate_trace(init_huey, capture_events):
def propagated_trace_task():
pass

with start_transaction() as outer_transaction:
with sentry_sdk.start_span() as outer_transaction:
execute_huey_task(huey, propagated_trace_task)

assert (
Expand All @@ -200,7 +200,7 @@ def dummy_task():

events = capture_events()

with start_transaction():
with sentry_sdk.start_span():
dummy_task()

(event,) = events
Expand Down
Loading