Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 3 additions & 9 deletions sentry_sdk/integrations/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions sentry_sdk/tracing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
_is_external_source,
_is_in_project_root,
_module_in_list,
_serialize_span_attribute,
)

from typing import TYPE_CHECKING
Expand Down Expand Up @@ -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)
Expand Down
Loading