Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 6 additions & 1 deletion sentry_sdk/integrations/arq.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys

from opentelemetry.trace.status import StatusCode

import sentry_sdk
from sentry_sdk.consts import OP, SPANSTATUS
from sentry_sdk.integrations import DidNotEnable, Integration
Expand Down Expand Up @@ -116,7 +118,10 @@ async def _sentry_run_job(self, job_id, score):
origin=ArqIntegration.origin,
) as span:
return_value = await old_run_job(self, job_id, score)
span.set_status(SPANSTATUS.OK)

if span.status is None:
span.set_status(SPANSTATUS.OK)

return return_value

Worker.run_job = _sentry_run_job
Expand Down
16 changes: 16 additions & 0 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,22 @@ def set_attribute(self, key, value):

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

@property
def status(self):
# type: () -> Optional[str]
if not hasattr(self._otel_span, "status"):
return None

if self._otel_span.status.status_code == StatusCode.OK:
return SPANSTATUS.OK
else:
return SPANSTATUS.UNKNOWN_ERROR

@status.setter
def status(self, value):
# type: (Optional[Any]) -> None
raise NotImplementedError("Use set_status instead")

def set_status(self, status):
# type: (str) -> None
if status == SPANSTATUS.OK:
Expand Down
Loading