Skip to content

Commit b3084d1

Browse files
committed
Revert tracing set_status change and just set OK properly in huey
1 parent 706300c commit b3084d1

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

sentry_sdk/integrations/huey.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ def _sentry_execute(*args, **kwargs):
135135
exc_info = sys.exc_info()
136136
_capture_exception(exc_info)
137137
reraise(*exc_info)
138+
else:
139+
sentry_sdk.get_current_scope().transaction.set_status(SPANSTATUS.OK)
138140

139141
return result
140142

@@ -165,9 +167,7 @@ def _sentry_execute(self, task, timestamp=None):
165167
op=OP.QUEUE_TASK_HUEY,
166168
source=TRANSACTION_SOURCE_TASK,
167169
origin=HueyIntegration.origin,
168-
) as transaction:
169-
return_value = old_execute(self, task, timestamp)
170-
transaction.set_status(SPANSTATUS.OK)
171-
return return_value
170+
):
171+
return old_execute(self, task, timestamp)
172172

173173
Huey._execute = _sentry_execute

sentry_sdk/tracing.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,17 +1541,13 @@ def set_attribute(self, key, value):
15411541
def set_status(self, status):
15421542
# type: (str) -> None
15431543
if status == SPANSTATUS.OK:
1544-
# Do not set status if it's already set.
1545-
# We would override an error status with OK.
1546-
if self._otel_span.status.status_code == StatusCode.UNSET:
1547-
self._otel_span.set_status(StatusCode.OK, None)
1544+
otel_status = StatusCode.OK
1545+
otel_description = None
15481546
else:
1549-
# OpenTelemetry does not allow setting and error status
1550-
# if the span is already set to OK
1551-
if self._otel_span.status.status_code == StatusCode.OK:
1552-
return
1547+
otel_status = StatusCode.ERROR
1548+
otel_description = status
15531549

1554-
self._otel_span.set_status(StatusCode.ERROR, status)
1550+
self._otel_span.set_status(otel_status, otel_description)
15551551

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

0 commit comments

Comments
 (0)