diff --git a/sentry_sdk/integrations/anthropic.py b/sentry_sdk/integrations/anthropic.py index a41005ed20..87e69a3113 100644 --- a/sentry_sdk/integrations/anthropic.py +++ b/sentry_sdk/integrations/anthropic.py @@ -7,7 +7,6 @@ from sentry_sdk.integrations import DidNotEnable, Integration from sentry_sdk.scope import should_send_default_pii from sentry_sdk.utils import ( - _serialize_span_attribute, capture_internal_exceptions, event_from_exception, package_version, @@ -127,7 +126,7 @@ def _add_ai_data_to_span( complete_message = "".join(content_blocks) span.set_data( SPANDATA.AI_RESPONSES, - _serialize_span_attribute([{"type": "text", "text": complete_message}]), + [{"type": "text", "text": complete_message}], ) total_tokens = input_tokens + output_tokens record_token_usage(span, input_tokens, output_tokens, total_tokens) @@ -166,16 +165,11 @@ def _sentry_patched_create_common(f, *args, **kwargs): span.set_data(SPANDATA.AI_STREAMING, False) if should_send_default_pii() and integration.include_prompts: - span.set_data( - SPANDATA.AI_INPUT_MESSAGES, _serialize_span_attribute(messages) - ) + span.set_data(SPANDATA.AI_INPUT_MESSAGES, messages) if hasattr(result, "content"): if should_send_default_pii() and integration.include_prompts: - span.set_data( - SPANDATA.AI_RESPONSES, - _serialize_span_attribute(_get_responses(result.content)), - ) + span.set_data(SPANDATA.AI_RESPONSES, _get_responses(result.content)) _calculate_token_usage(result, span) span.__exit__(None, None, None) diff --git a/sentry_sdk/tracing.py b/sentry_sdk/tracing.py index fd76c50b50..31312c9ad3 100644 --- a/sentry_sdk/tracing.py +++ b/sentry_sdk/tracing.py @@ -18,6 +18,7 @@ from sentry_sdk.consts import SPANSTATUS, SPANDATA from sentry_sdk.profiler.continuous_profiler import get_profiler_id from sentry_sdk.utils import ( + _serialize_span_attribute, get_current_thread_meta, is_valid_sample_rate, logger, @@ -1519,7 +1520,7 @@ def get_attribute(self, name): def set_attribute(self, key, value): # type: (str, Any) -> None - self._otel_span.set_attribute(key, value) + self._otel_span.set_attribute(key, _serialize_span_attribute(value)) def set_status(self, status): # type: (str) -> None diff --git a/sentry_sdk/tracing_utils.py b/sentry_sdk/tracing_utils.py index b9d4fb9335..fc701e27b7 100644 --- a/sentry_sdk/tracing_utils.py +++ b/sentry_sdk/tracing_utils.py @@ -23,7 +23,6 @@ _is_external_source, _is_in_project_root, _module_in_list, - _serialize_span_attribute, ) from typing import TYPE_CHECKING @@ -134,13 +133,13 @@ def record_sql_queries( data = {} if params_list is not None: - data["db.params"] = _serialize_span_attribute(params_list) + data["db.params"] = params_list if paramstyle is not None: - data["db.paramstyle"] = _serialize_span_attribute(paramstyle) + data["db.paramstyle"] = paramstyle if executemany: data["db.executemany"] = True if record_cursor_repr and cursor is not None: - data["db.cursor"] = _serialize_span_attribute(cursor) + data["db.cursor"] = cursor with capture_internal_exceptions(): sentry_sdk.add_breadcrumb(message=query, category="query", data=data)