Skip to content

Commit 294bc99

Browse files
merge
2 parents bdacfd1 + b565fbd commit 294bc99

7 files changed

Lines changed: 101 additions & 123 deletions

File tree

‎sentry_sdk/integrations/flask.py‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
RequestExtractor,
99
)
1010
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
11-
from sentry_sdk.scope import should_send_default_pii
1211
from sentry_sdk.traces import SegmentNameSource
1312
from sentry_sdk.utils import (
1413
capture_internal_exceptions,
1514
ensure_integration_enabled,
1615
event_from_exception,
17-
has_data_collection_enabled,
1816
package_version,
1917
)
2018

@@ -146,13 +144,7 @@ def _request_started(app: "Flask", **kwargs: "Any") -> None:
146144

147145
scope = sentry_sdk.get_isolation_scope()
148146

149-
if has_data_collection_enabled(client.options):
150-
if client.options["data_collection"]["user_info"]:
151-
with capture_internal_exceptions():
152-
user_properties = _get_flask_user_properties()
153-
if user_properties:
154-
scope.set_user(user_properties)
155-
elif should_send_default_pii():
147+
if client.options["data_collection"]["user_info"]:
156148
with capture_internal_exceptions():
157149
user_properties = _get_flask_user_properties()
158150
if user_properties:
@@ -205,11 +197,7 @@ def inner(event: "Event", hint: "dict[str, Any]") -> "Event":
205197
FlaskRequestExtractor(request).extract_into_event(event)
206198

207199
client_options = sentry_sdk.get_client().options
208-
if has_data_collection_enabled(client_options):
209-
if client_options["data_collection"]["user_info"]:
210-
with capture_internal_exceptions():
211-
_add_user_to_event(event)
212-
elif should_send_default_pii():
200+
if client_options["data_collection"]["user_info"]:
213201
with capture_internal_exceptions():
214202
_add_user_to_event(event)
215203

‎sentry_sdk/integrations/openai_agents/spans/ai_client.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,18 @@ def ai_client_context(
217217
},
218218
)
219219

220-
model_name: "Optional[str]" = None
220+
context.span.set_attribute(SPANDATA.GEN_AI_PROVIDER_NAME, "openai")
221+
222+
request_model_name: "Optional[str]" = None
221223
if isinstance(agent.model, Model) and hasattr(agent.model, "model"):
222-
model_name = agent.model.model
224+
request_model_name = agent.model.model
223225
elif isinstance(agent.model, str):
224-
model_name = agent.model
226+
request_model_name = agent.model
225227
elif hasattr(agent, "_sentry_request_model"):
226-
model_name = agent._sentry_request_model
228+
request_model_name = agent._sentry_request_model
227229

228-
if model_name:
229-
context.span.set_attribute(SPANDATA.GEN_AI_REQUEST_MODEL, model_name)
230+
if request_model_name:
231+
context.span.set_attribute(SPANDATA.GEN_AI_REQUEST_MODEL, request_model_name)
230232

231233
_set_agent_data(context.span, agent)
232234

‎sentry_sdk/integrations/openai_agents/utils.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ def _capture_exception(exc: "Any") -> None:
4444

4545

4646
def _set_agent_data(span: "Span", agent: "agents.Agent") -> None:
47-
span.set_attribute(
48-
SPANDATA.GEN_AI_PROVIDER_NAME, "openai"
49-
) # See footnote for https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-system for explanation why.
5047

5148
span.set_attribute(SPANDATA.GEN_AI_AGENT_NAME, agent.name)
5249

‎sentry_sdk/integrations/pydantic_ai/spans/ai_client.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,17 @@ def ai_client_context(
290290
)
291291

292292
_set_agent_data(context.span, agent)
293+
294+
# Extract model information
295+
model_obj = model
296+
if not model_obj and agent and hasattr(agent, "model"):
297+
model_obj = agent.model
298+
299+
if model_obj:
300+
# Set system from model
301+
if hasattr(model_obj, "system"):
302+
context.span.set_attribute(SPANDATA.GEN_AI_PROVIDER_NAME, model_obj.system)
303+
293304
_set_model_data(context.span, agent, model, model_settings)
294305
_set_available_tools(context.span, agent)
295306

‎sentry_sdk/integrations/pydantic_ai/utils.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ def _set_model_data(
7474
model_obj = agent.model
7575

7676
if model_obj:
77-
# Set system from model
78-
if hasattr(model_obj, "system"):
79-
span.set_attribute(SPANDATA.GEN_AI_PROVIDER_NAME, model_obj.system)
80-
8177
# Set model name
8278
model_name = _get_model_name(model_obj)
8379
if model_name:

0 commit comments

Comments
 (0)