Skip to content

Commit dc9e4a3

Browse files
committed
Do not access lower level otel_span from integration
1 parent f0b8eb6 commit dc9e4a3

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

sentry_sdk/integrations/arq.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ async def _sentry_run_job(self, job_id, score):
119119
) as span:
120120
return_value = await old_run_job(self, job_id, score)
121121

122-
status_unset = (
123-
hasattr(span._otel_span, "status")
124-
and span._otel_span.status.status_code == StatusCode.UNSET
125-
)
126-
if status_unset:
122+
if span.status is None:
127123
span.set_status(SPANSTATUS.OK)
128124

129125
return return_value

sentry_sdk/tracing.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,22 @@ def set_attribute(self, key, value):
15831583

15841584
self._otel_span.set_attribute(key, _serialize_span_attribute(value))
15851585

1586+
@property
1587+
def status(self):
1588+
# type: () -> Optional[str]
1589+
if not hasattr(self._otel_span, "status"):
1590+
return None
1591+
1592+
if self._otel_span.status.status_code == StatusCode.OK:
1593+
return SPANSTATUS.OK
1594+
else:
1595+
return SPANSTATUS.UNKNOWN_ERROR
1596+
1597+
@status.setter
1598+
def status(self, value):
1599+
# type: (Optional[Any]) -> None
1600+
raise NotImplementedError("Use set_status instead")
1601+
15861602
def set_status(self, status):
15871603
# type: (str) -> None
15881604
if status == SPANSTATUS.OK:

0 commit comments

Comments
 (0)