Skip to content

Commit 3a0d5ec

Browse files
committed
Remove unsupported SPANSTATUS.ERROR
1 parent eb98edf commit 3a0d5ec

File tree

7 files changed

+14
-17
lines changed

7 files changed

+14
-17
lines changed

sentry_sdk/consts.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,20 +864,18 @@ class SPANSTATUS:
864864
CANCELLED = "cancelled"
865865
DATA_LOSS = "data_loss"
866866
DEADLINE_EXCEEDED = "deadline_exceeded"
867-
ERROR = "error" # OTel status code: https://opentelemetry.io/docs/concepts/signals/traces/#span-status
868867
FAILED_PRECONDITION = "failed_precondition"
869868
INTERNAL_ERROR = "internal_error"
870869
INVALID_ARGUMENT = "invalid_argument"
871870
NOT_FOUND = "not_found"
872-
OK = "ok" # HTTP 200 and OTel status code: https://opentelemetry.io/docs/concepts/signals/traces/#span-status
871+
OK = "ok"
873872
OUT_OF_RANGE = "out_of_range"
874873
PERMISSION_DENIED = "permission_denied"
875874
RESOURCE_EXHAUSTED = "resource_exhausted"
876875
UNAUTHENTICATED = "unauthenticated"
877876
UNAVAILABLE = "unavailable"
878877
UNIMPLEMENTED = "unimplemented"
879878
UNKNOWN_ERROR = "unknown_error"
880-
UNSET = "unset" # OTel status code: https://opentelemetry.io/docs/concepts/signals/traces/#span-status
881879

882880

883881
class OP:

sentry_sdk/integrations/anthropic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def _sentry_patched_create_sync(*args, **kwargs):
381381
return _execute_sync(f, *args, **kwargs)
382382
finally:
383383
span = sentry_sdk.get_current_span()
384-
if span is not None and span.status == SPANSTATUS.ERROR:
384+
if span is not None and span.status == SPANSTATUS.INTERNAL_ERROR:
385385
with capture_internal_exceptions():
386386
span.__exit__(None, None, None)
387387

@@ -420,7 +420,7 @@ async def _sentry_patched_create_async(*args, **kwargs):
420420
return await _execute_async(f, *args, **kwargs)
421421
finally:
422422
span = sentry_sdk.get_current_span()
423-
if span is not None and span.status == SPANSTATUS.ERROR:
423+
if span is not None and span.status == SPANSTATUS.INTERNAL_ERROR:
424424
with capture_internal_exceptions():
425425
span.__exit__(None, None, None)
426426

sentry_sdk/integrations/google_genai/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def new_iterator():
107107
yield chunk
108108
except Exception as exc:
109109
_capture_exception(exc)
110-
chat_span.set_status(SPANSTATUS.ERROR)
110+
chat_span.set_status(SPANSTATUS.INTERNAL_ERROR)
111111
raise
112112
finally:
113113
# Accumulate all chunks and set final response data on spans
@@ -181,7 +181,7 @@ async def new_async_iterator():
181181
yield chunk
182182
except Exception as exc:
183183
_capture_exception(exc)
184-
chat_span.set_status(SPANSTATUS.ERROR)
184+
chat_span.set_status(SPANSTATUS.INTERNAL_ERROR)
185185
raise
186186
finally:
187187
# Accumulate all chunks and set final response data on spans
@@ -244,7 +244,7 @@ def new_generate_content(self, *args, **kwargs):
244244
response = f(self, *args, **kwargs)
245245
except Exception as exc:
246246
_capture_exception(exc)
247-
chat_span.set_status(SPANSTATUS.ERROR)
247+
chat_span.set_status(SPANSTATUS.INTERNAL_ERROR)
248248
raise
249249

250250
set_span_data_for_response(chat_span, integration, response)
@@ -290,7 +290,7 @@ async def new_async_generate_content(self, *args, **kwargs):
290290
response = await f(self, *args, **kwargs)
291291
except Exception as exc:
292292
_capture_exception(exc)
293-
chat_span.set_status(SPANSTATUS.ERROR)
293+
chat_span.set_status(SPANSTATUS.INTERNAL_ERROR)
294294
raise
295295

296296
set_span_data_for_response(chat_span, integration, response)

sentry_sdk/integrations/openai_agents/spans/execute_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def update_execute_tool_span(span, agent, tool, result):
4242
if isinstance(result, str) and result.startswith(
4343
"An error occurred while running the tool"
4444
):
45-
span.set_status(SPANSTATUS.ERROR)
45+
span.set_status(SPANSTATUS.INTERNAL_ERROR)
4646

4747
if should_send_default_pii():
4848
span.set_data(SPANDATA.GEN_AI_TOOL_OUTPUT, result)

sentry_sdk/integrations/openai_agents/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,4 @@ def _create_mcp_execute_tool_spans(span, result):
196196
SPANDATA.GEN_AI_TOOL_OUTPUT, output.output
197197
)
198198
if output.error:
199-
execute_tool_span.set_status(SPANSTATUS.ERROR)
199+
execute_tool_span.set_status(SPANSTATUS.INTERNAL_ERROR)

sentry_sdk/tracing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ def __enter__(self):
408408
def __exit__(self, ty, value, tb):
409409
# type: (Optional[Any], Optional[Any], Optional[Any]) -> None
410410
if value is not None and should_be_treated_as_error(ty, value):
411-
if self.status != SPANSTATUS.ERROR:
412-
self.set_status(SPANSTATUS.INTERNAL_ERROR)
411+
self.set_status(SPANSTATUS.INTERNAL_ERROR)
413412

414413
with capture_internal_exceptions():
415414
scope, old_span = self._context_manager_state

sentry_sdk/tracing_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,14 +933,14 @@ def get_current_span(scope=None):
933933
def set_span_errored(span=None):
934934
# type: (Optional[Span]) -> None
935935
"""
936-
Set the status of the current or given span to ERROR.
937-
Also sets the status of the transaction (root span) to ERROR.
936+
Set the status of the current or given span to INTERNAL_ERROR.
937+
Also sets the status of the transaction (root span) to INTERNAL_ERROR.
938938
"""
939939
span = span or get_current_span()
940940
if span is not None:
941-
span.set_status(SPANSTATUS.ERROR)
941+
span.set_status(SPANSTATUS.INTERNAL_ERROR)
942942
if span.containing_transaction is not None:
943-
span.containing_transaction.set_status(SPANSTATUS.ERROR)
943+
span.containing_transaction.set_status(SPANSTATUS.INTERNAL_ERROR)
944944

945945

946946
def _generate_sample_rand(

0 commit comments

Comments
 (0)