Skip to content

Fix Huey tests #3759

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 1 commit into from
Nov 11, 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
3 changes: 2 additions & 1 deletion sentry_sdk/integrations/huey.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def _sentry_execute(self, task, timestamp=None):
source=TRANSACTION_SOURCE_TASK,
origin=HueyIntegration.origin,
) as transaction:
return_value = old_execute(self, task, timestamp)
transaction.set_status(SPANSTATUS.OK)
return old_execute(self, task, timestamp)
return return_value

Huey._execute = _sentry_execute
14 changes: 9 additions & 5 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1541,13 +1541,17 @@ def set_attribute(self, key, value):
def set_status(self, status):
# type: (str) -> None
if status == SPANSTATUS.OK:
otel_status = StatusCode.OK
otel_description = None
# Do not set status if it's already set.
# We would override an error status with OK.
if self._otel_span.status.status_code == StatusCode.UNSET:
self._otel_span.set_status(StatusCode.OK, None)
else:
otel_status = StatusCode.ERROR
otel_description = status
# OpenTelemetry does not allow setting and error status
# if the span is already set to OK
if self._otel_span.status.status_code == StatusCode.OK:
return

self._otel_span.set_status(otel_status, otel_description)
self._otel_span.set_status(StatusCode.ERROR, status)

def set_measurement(self, name, value, unit=""):
# type: (str, float, MeasurementUnit) -> None
Expand Down
Loading