Skip to content
Open
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
7 changes: 3 additions & 4 deletions sentry_sdk/integrations/anthropic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import json
from collections.abc import Iterable
from functools import wraps
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -217,11 +218,9 @@ def _set_input_data(
if isinstance(system_instructions, str) or isinstance(
system_instructions, Iterable
):
set_data_normalized(
span,
span.set_data(
SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS,
_transform_system_instructions(system_instructions),
unpack=False,
json.dumps(_transform_system_instructions(system_instructions)),
)

normalized_messages = []
Expand Down
7 changes: 3 additions & 4 deletions sentry_sdk/integrations/google_genai/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import json
import inspect
from functools import wraps
from .consts import ORIGIN, TOOL_ATTRIBUTES_MAP, GEN_AI_SYSTEM
Expand Down Expand Up @@ -808,11 +809,9 @@ def set_span_data_for_request(
system_instructions = config.get("system_instruction")

if system_instructions is not None:
set_data_normalized(
Copy link
Member

@sl0thentr0py sl0thentr0py Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i generally dislike this function, garbage signature, just creates clutter

span,
span.set_data(
SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS,
_transform_system_instructions(system_instructions),
unpack=False,
json.dumps(_transform_system_instructions(system_instructions)),
)

# Extract messages from contents
Expand Down
7 changes: 3 additions & 4 deletions sentry_sdk/integrations/langchain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import contextvars
import itertools
import sys
import json
import warnings
from collections import OrderedDict
from functools import wraps
Expand Down Expand Up @@ -467,11 +468,9 @@ def on_chat_model_start(
if should_send_default_pii() and self.include_prompts:
system_instructions = _get_system_instructions(messages)
if len(system_instructions) > 0:
set_data_normalized(
span,
span.set_data(
SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS,
_transform_system_instructions(system_instructions),
unpack=False,
json.dumps(_transform_system_instructions(system_instructions)),
)

normalized_messages = []
Expand Down
31 changes: 14 additions & 17 deletions sentry_sdk/integrations/openai.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import json
from functools import wraps

import sentry_sdk
Expand Down Expand Up @@ -271,16 +272,16 @@ def _set_responses_api_input_data(
and explicit_instructions is not None
and _is_given(explicit_instructions)
):
set_data_normalized(
span,
span.set_data(
SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS,
[
{
"type": "text",
"content": explicit_instructions,
}
],
unpack=False,
json.dumps(
[
{
"type": "text",
"content": explicit_instructions,
}
]
),
)

set_data_normalized(span, SPANDATA.GEN_AI_OPERATION_NAME, "responses")
Expand All @@ -307,11 +308,9 @@ def _set_responses_api_input_data(
instructions_text_parts += _transform_system_instructions(system_instructions)

if len(instructions_text_parts) > 0:
set_data_normalized(
span,
span.set_data(
SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS,
instructions_text_parts,
unpack=False,
json.dumps(instructions_text_parts),
)

if isinstance(messages, str):
Expand Down Expand Up @@ -364,11 +363,9 @@ def _set_completions_api_input_data(

system_instructions = _get_system_instructions_completions(messages)
if len(system_instructions) > 0:
set_data_normalized(
span,
span.set_data(
SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS,
_transform_system_instructions(system_instructions),
unpack=False,
json.dumps(_transform_system_instructions(system_instructions)),
)

if isinstance(messages, str):
Expand Down
8 changes: 4 additions & 4 deletions sentry_sdk/integrations/openai_agents/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

import sentry_sdk
from sentry_sdk.ai.utils import (
GEN_AI_ALLOWED_MESSAGE_ROLES,
Expand Down Expand Up @@ -140,11 +142,9 @@ def _set_input_data(
instructions_text_parts += _transform_system_instructions(system_instructions)

if len(instructions_text_parts) > 0:
set_data_normalized(
span,
span.set_data(
SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS,
instructions_text_parts,
unpack=False,
json.dumps(instructions_text_parts),
)

non_system_messages = [
Expand Down
12 changes: 7 additions & 5 deletions sentry_sdk/integrations/pydantic_ai/spans/ai_client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

import sentry_sdk
from sentry_sdk._types import BLOB_DATA_SUBSTITUTE
from sentry_sdk.ai.utils import (
Expand Down Expand Up @@ -101,13 +103,13 @@ def _set_input_messages(span: "sentry_sdk.tracing.Span", messages: "Any") -> Non

permanent_instructions, current_instructions = _get_system_instructions(messages)
if len(permanent_instructions) > 0 or len(current_instructions) > 0:
set_data_normalized(
span,
span.set_data(
SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS,
_transform_system_instructions(
permanent_instructions, current_instructions
json.dumps(
_transform_system_instructions(
permanent_instructions, current_instructions
)
),
unpack=False,
)

try:
Expand Down
Loading