44from unittest .mock import MagicMock , patch
55import os
66import json
7+ import logging
78
89import sentry_sdk
910from sentry_sdk import start_span
1011from sentry_sdk .consts import SPANDATA
1112from sentry_sdk .integrations .openai_agents import OpenAIAgentsIntegration
13+ from sentry_sdk .integrations .logging import LoggingIntegration
1214from sentry_sdk .integrations .openai_agents .utils import _set_input_data , safe_serialize
1315from sentry_sdk .utils import parse_version
1416
@@ -1489,7 +1491,11 @@ async def test_error_handling(sentry_init, capture_events, test_agent):
14891491 mock_get_response .side_effect = Exception ("Model Error" )
14901492
14911493 sentry_init (
1492- integrations = [OpenAIAgentsIntegration ()],
1494+ disabled_integrations = [],
1495+ integrations = [
1496+ OpenAIAgentsIntegration (),
1497+ LoggingIntegration (event_level = logging .CRITICAL ),
1498+ ],
14931499 traces_sample_rate = 1.0 ,
14941500 )
14951501
@@ -1501,7 +1507,6 @@ async def test_error_handling(sentry_init, capture_events, test_agent):
15011507 )
15021508
15031509 (
1504- error_log ,
15051510 error_event ,
15061511 transaction ,
15071512 ) = events
@@ -1538,7 +1543,10 @@ async def test_error_captures_input_data(sentry_init, capture_events, test_agent
15381543 mock_get_response .side_effect = Exception ("API Error" )
15391544
15401545 sentry_init (
1541- integrations = [OpenAIAgentsIntegration ()],
1546+ integrations = [
1547+ OpenAIAgentsIntegration (),
1548+ LoggingIntegration (event_level = logging .CRITICAL ),
1549+ ],
15421550 traces_sample_rate = 1.0 ,
15431551 send_default_pii = True ,
15441552 )
@@ -1551,7 +1559,6 @@ async def test_error_captures_input_data(sentry_init, capture_events, test_agent
15511559 )
15521560
15531561 (
1554- error_log ,
15551562 error_event ,
15561563 transaction ,
15571564 ) = events
@@ -1584,7 +1591,10 @@ async def test_span_status_error(sentry_init, capture_events, test_agent):
15841591 mock_get_response .side_effect = ValueError ("Model Error" )
15851592
15861593 sentry_init (
1587- integrations = [OpenAIAgentsIntegration ()],
1594+ integrations = [
1595+ OpenAIAgentsIntegration (),
1596+ LoggingIntegration (event_level = logging .CRITICAL ),
1597+ ],
15881598 traces_sample_rate = 1.0 ,
15891599 )
15901600
@@ -1595,7 +1605,7 @@ async def test_span_status_error(sentry_init, capture_events, test_agent):
15951605 test_agent , "Test input" , run_config = test_run_config
15961606 )
15971607
1598- (error_log , error , transaction ) = events
1608+ (error , transaction ) = events
15991609 assert error ["level" ] == "error"
16001610 assert transaction ["spans" ][0 ]["status" ] == "internal_error"
16011611 assert transaction ["spans" ][0 ]["tags" ]["status" ] == "internal_error"
0 commit comments