Skip to content

Commit f39bb85

Browse files
authored
Enable recordings for Agent function tool, and switch over to new recording decorators (#44292)
1 parent 8132a9d commit f39bb85

11 files changed

+584
-332
lines changed

sdk/ai/azure-ai-projects/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/ai/azure-ai-projects",
5-
"Tag": "python/ai/azure-ai-projects_3c34f28cdc"
5+
"Tag": "python/ai/azure-ai-projects_6bcfd85170"
66
}

sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from azure.core.settings import settings
1313
from gen_ai_trace_verifier import GenAiTraceVerifier
1414
from openai import OpenAI
15-
from devtools_testutils import recorded_by_proxy
15+
from devtools_testutils import recorded_by_proxy, RecordedTransport
1616
from azure.ai.projects.models import PromptAgentDefinition, FunctionTool
1717

18-
from test_base import servicePreparer, recorded_by_proxy_httpx
18+
from test_base import servicePreparer
1919
from test_ai_instrumentor_base import (
2020
TestAiAgentsInstrumentorBase,
2121
CONTENT_TRACING_ENV_VARIABLE,
@@ -188,7 +188,7 @@ def set_env_var(var_name, value):
188188

189189
@pytest.mark.usefixtures("instrument_with_content")
190190
@servicePreparer()
191-
@recorded_by_proxy_httpx
191+
@recorded_by_proxy(RecordedTransport.HTTPX)
192192
def test_sync_non_streaming_with_content_recording(self, **kwargs):
193193
"""Test synchronous non-streaming responses with content recording enabled."""
194194
self.cleanup()
@@ -268,7 +268,7 @@ def test_sync_non_streaming_with_content_recording(self, **kwargs):
268268

269269
@pytest.mark.usefixtures("instrument_without_content")
270270
@servicePreparer()
271-
@recorded_by_proxy_httpx
271+
@recorded_by_proxy(RecordedTransport.HTTPX)
272272
def test_sync_non_streaming_without_content_recording(self, **kwargs):
273273
"""Test synchronous non-streaming responses with content recording disabled."""
274274
self.cleanup()
@@ -348,7 +348,7 @@ def test_sync_non_streaming_without_content_recording(self, **kwargs):
348348

349349
@pytest.mark.usefixtures("instrument_with_content")
350350
@servicePreparer()
351-
@recorded_by_proxy_httpx
351+
@recorded_by_proxy(RecordedTransport.HTTPX)
352352
def test_sync_streaming_with_content_recording(self, **kwargs):
353353
"""Test synchronous streaming responses with content recording enabled."""
354354
from openai.types.responses.response_input_param import FunctionCallOutput
@@ -438,7 +438,7 @@ def test_sync_streaming_with_content_recording(self, **kwargs):
438438

439439
@pytest.mark.usefixtures("instrument_with_content")
440440
@servicePreparer()
441-
@recorded_by_proxy_httpx
441+
@recorded_by_proxy(RecordedTransport.HTTPX)
442442
def test_sync_conversations_create(self, **kwargs):
443443
"""Test synchronous conversations.create() method."""
444444
self.cleanup()
@@ -482,7 +482,7 @@ def test_sync_conversations_create(self, **kwargs):
482482

483483
@pytest.mark.usefixtures("instrument_with_content")
484484
@servicePreparer()
485-
@recorded_by_proxy_httpx
485+
@recorded_by_proxy(RecordedTransport.HTTPX)
486486
def test_sync_list_conversation_items_with_content_recording(self, **kwargs):
487487
"""Test synchronous list_conversation_items with content recording enabled."""
488488
self.cleanup()
@@ -558,7 +558,7 @@ def test_sync_list_conversation_items_with_content_recording(self, **kwargs):
558558

559559
@pytest.mark.usefixtures("instrument_without_content")
560560
@servicePreparer()
561-
@recorded_by_proxy_httpx
561+
@recorded_by_proxy(RecordedTransport.HTTPX)
562562
def test_sync_list_conversation_items_without_content_recording(self, **kwargs):
563563
"""Test synchronous list_conversation_items with content recording disabled."""
564564
self.cleanup()
@@ -670,7 +670,7 @@ def test_no_instrumentation_no_spans(self):
670670

671671
@pytest.mark.usefixtures("instrument_with_content")
672672
@servicePreparer()
673-
@recorded_by_proxy_httpx
673+
@recorded_by_proxy(RecordedTransport.HTTPX)
674674
def test_sync_non_streaming_without_conversation(self, **kwargs):
675675
"""Test synchronous non-streaming responses without conversation parameter."""
676676
self.cleanup()
@@ -1778,7 +1778,7 @@ def test_sync_function_tool_list_conversation_items_without_content_recording(se
17781778

17791779
@pytest.mark.usefixtures("instrument_with_content")
17801780
@servicePreparer()
1781-
@recorded_by_proxy_httpx
1781+
@recorded_by_proxy(RecordedTransport.HTTPX)
17821782
def test_sync_multiple_text_inputs_with_content_recording_non_streaming(self, **kwargs):
17831783
"""Test synchronous non-streaming responses with multiple text inputs and content recording enabled."""
17841784
self.cleanup()
@@ -1874,7 +1874,7 @@ def test_sync_multiple_text_inputs_with_content_recording_non_streaming(self, **
18741874

18751875
@pytest.mark.usefixtures("instrument_with_content")
18761876
@servicePreparer()
1877-
@recorded_by_proxy_httpx
1877+
@recorded_by_proxy(RecordedTransport.HTTPX)
18781878
def test_sync_multiple_text_inputs_with_content_recording_streaming(self, **kwargs):
18791879
"""Test synchronous streaming responses with multiple text inputs and content recording enabled."""
18801880
self.cleanup()
@@ -1978,7 +1978,7 @@ def test_sync_multiple_text_inputs_with_content_recording_streaming(self, **kwar
19781978

19791979
@pytest.mark.usefixtures("instrument_without_content")
19801980
@servicePreparer()
1981-
@recorded_by_proxy_httpx
1981+
@recorded_by_proxy(RecordedTransport.HTTPX)
19821982
def test_sync_multiple_text_inputs_without_content_recording_non_streaming(self, **kwargs):
19831983
"""Test synchronous non-streaming responses with multiple text inputs and content recording disabled."""
19841984
self.cleanup()
@@ -2074,7 +2074,7 @@ def test_sync_multiple_text_inputs_without_content_recording_non_streaming(self,
20742074

20752075
@pytest.mark.usefixtures("instrument_without_content")
20762076
@servicePreparer()
2077-
@recorded_by_proxy_httpx
2077+
@recorded_by_proxy(RecordedTransport.HTTPX)
20782078
def test_sync_multiple_text_inputs_without_content_recording_streaming(self, **kwargs):
20792079
"""Test synchronous streaming responses with multiple text inputs and content recording disabled."""
20802080
self.cleanup()
@@ -2173,7 +2173,7 @@ def test_sync_multiple_text_inputs_without_content_recording_streaming(self, **k
21732173

21742174
@pytest.mark.usefixtures("instrument_without_content")
21752175
@servicePreparer()
2176-
@recorded_by_proxy_httpx
2176+
@recorded_by_proxy(RecordedTransport.HTTPX)
21772177
def test_image_only_content_off_binary_off_non_streaming(self, **kwargs):
21782178
"""Test image only with content recording OFF and binary data OFF (non-streaming)."""
21792179
self.cleanup()
@@ -2243,7 +2243,7 @@ def test_image_only_content_off_binary_off_non_streaming(self, **kwargs):
22432243

22442244
@pytest.mark.usefixtures("instrument_without_content")
22452245
@servicePreparer()
2246-
@recorded_by_proxy_httpx
2246+
@recorded_by_proxy(RecordedTransport.HTTPX)
22472247
def test_image_only_content_off_binary_on_non_streaming(self, **kwargs):
22482248
"""Test image only with content recording OFF and binary data ON (non-streaming)."""
22492249
self.cleanup()
@@ -2312,7 +2312,7 @@ def test_image_only_content_off_binary_on_non_streaming(self, **kwargs):
23122312

23132313
@pytest.mark.usefixtures("instrument_with_content")
23142314
@servicePreparer()
2315-
@recorded_by_proxy_httpx
2315+
@recorded_by_proxy(RecordedTransport.HTTPX)
23162316
def test_image_only_content_on_binary_off_non_streaming(self, **kwargs):
23172317
"""Test image only with content recording ON and binary data OFF (non-streaming)."""
23182318
self.cleanup()
@@ -2381,7 +2381,7 @@ def test_image_only_content_on_binary_off_non_streaming(self, **kwargs):
23812381

23822382
@pytest.mark.usefixtures("instrument_with_content")
23832383
@servicePreparer()
2384-
@recorded_by_proxy_httpx
2384+
@recorded_by_proxy(RecordedTransport.HTTPX)
23852385
def test_image_only_content_on_binary_on_non_streaming(self, **kwargs):
23862386
"""Test image only with content recording ON and binary data ON (non-streaming)."""
23872387
self.cleanup()
@@ -2454,7 +2454,7 @@ def test_image_only_content_on_binary_on_non_streaming(self, **kwargs):
24542454

24552455
@pytest.mark.usefixtures("instrument_without_content")
24562456
@servicePreparer()
2457-
@recorded_by_proxy_httpx
2457+
@recorded_by_proxy(RecordedTransport.HTTPX)
24582458
def test_text_and_image_content_off_binary_off_non_streaming(self, **kwargs):
24592459
"""Test text + image with content recording OFF and binary data OFF (non-streaming)."""
24602460
self.cleanup()
@@ -2528,7 +2528,7 @@ def test_text_and_image_content_off_binary_off_non_streaming(self, **kwargs):
25282528

25292529
@pytest.mark.usefixtures("instrument_without_content")
25302530
@servicePreparer()
2531-
@recorded_by_proxy_httpx
2531+
@recorded_by_proxy(RecordedTransport.HTTPX)
25322532
def test_text_and_image_content_off_binary_on_non_streaming(self, **kwargs):
25332533
"""Test text + image with content recording OFF and binary data ON (non-streaming)."""
25342534
self.cleanup()
@@ -2601,7 +2601,7 @@ def test_text_and_image_content_off_binary_on_non_streaming(self, **kwargs):
26012601

26022602
@pytest.mark.usefixtures("instrument_with_content")
26032603
@servicePreparer()
2604-
@recorded_by_proxy_httpx
2604+
@recorded_by_proxy(RecordedTransport.HTTPX)
26052605
def test_text_and_image_content_on_binary_off_non_streaming(self, **kwargs):
26062606
"""Test text + image with content recording ON and binary data OFF (non-streaming)."""
26072607
self.cleanup()
@@ -2674,7 +2674,7 @@ def test_text_and_image_content_on_binary_off_non_streaming(self, **kwargs):
26742674

26752675
@pytest.mark.usefixtures("instrument_with_content")
26762676
@servicePreparer()
2677-
@recorded_by_proxy_httpx
2677+
@recorded_by_proxy(RecordedTransport.HTTPX)
26782678
def test_text_and_image_content_on_binary_on_non_streaming(self, **kwargs):
26792679
"""Test text + image with content recording ON and binary data ON (non-streaming)."""
26802680
self.cleanup()
@@ -2751,7 +2751,7 @@ def test_text_and_image_content_on_binary_on_non_streaming(self, **kwargs):
27512751

27522752
@pytest.mark.usefixtures("instrument_without_content")
27532753
@servicePreparer()
2754-
@recorded_by_proxy_httpx
2754+
@recorded_by_proxy(RecordedTransport.HTTPX)
27552755
def test_image_only_content_off_binary_off_streaming(self, **kwargs):
27562756
"""Test image only with content recording OFF and binary data OFF (streaming)."""
27572757
self.cleanup()
@@ -2829,7 +2829,7 @@ def test_image_only_content_off_binary_off_streaming(self, **kwargs):
28292829

28302830
@pytest.mark.usefixtures("instrument_without_content")
28312831
@servicePreparer()
2832-
@recorded_by_proxy_httpx
2832+
@recorded_by_proxy(RecordedTransport.HTTPX)
28332833
def test_image_only_content_off_binary_on_streaming(self, **kwargs):
28342834
"""Test image only with content recording OFF and binary data ON (streaming)."""
28352835
self.cleanup()
@@ -2906,7 +2906,7 @@ def test_image_only_content_off_binary_on_streaming(self, **kwargs):
29062906

29072907
@pytest.mark.usefixtures("instrument_with_content")
29082908
@servicePreparer()
2909-
@recorded_by_proxy_httpx
2909+
@recorded_by_proxy(RecordedTransport.HTTPX)
29102910
def test_image_only_content_on_binary_off_streaming(self, **kwargs):
29112911
"""Test image only with content recording ON and binary data OFF (streaming)."""
29122912
self.cleanup()
@@ -2983,7 +2983,7 @@ def test_image_only_content_on_binary_off_streaming(self, **kwargs):
29832983

29842984
@pytest.mark.usefixtures("instrument_with_content")
29852985
@servicePreparer()
2986-
@recorded_by_proxy_httpx
2986+
@recorded_by_proxy(RecordedTransport.HTTPX)
29872987
def test_image_only_content_on_binary_on_streaming(self, **kwargs):
29882988
"""Test image only with content recording ON and binary data ON (streaming)."""
29892989
self.cleanup()
@@ -3064,7 +3064,7 @@ def test_image_only_content_on_binary_on_streaming(self, **kwargs):
30643064

30653065
@pytest.mark.usefixtures("instrument_without_content")
30663066
@servicePreparer()
3067-
@recorded_by_proxy_httpx
3067+
@recorded_by_proxy(RecordedTransport.HTTPX)
30683068
def test_text_and_image_content_off_binary_off_streaming(self, **kwargs):
30693069
"""Test text + image with content recording OFF and binary data OFF (streaming)."""
30703070
self.cleanup()
@@ -3145,7 +3145,7 @@ def test_text_and_image_content_off_binary_off_streaming(self, **kwargs):
31453145

31463146
@pytest.mark.usefixtures("instrument_without_content")
31473147
@servicePreparer()
3148-
@recorded_by_proxy_httpx
3148+
@recorded_by_proxy(RecordedTransport.HTTPX)
31493149
def test_text_and_image_content_off_binary_on_streaming(self, **kwargs):
31503150
"""Test text + image with content recording OFF and binary data ON (streaming)."""
31513151
self.cleanup()
@@ -3226,7 +3226,7 @@ def test_text_and_image_content_off_binary_on_streaming(self, **kwargs):
32263226

32273227
@pytest.mark.usefixtures("instrument_with_content")
32283228
@servicePreparer()
3229-
@recorded_by_proxy_httpx
3229+
@recorded_by_proxy(RecordedTransport.HTTPX)
32303230
def test_text_and_image_content_on_binary_off_streaming(self, **kwargs):
32313231
"""Test text + image with content recording ON and binary data OFF (streaming)."""
32323232
self.cleanup()
@@ -3307,7 +3307,7 @@ def test_text_and_image_content_on_binary_off_streaming(self, **kwargs):
33073307

33083308
@pytest.mark.usefixtures("instrument_with_content")
33093309
@servicePreparer()
3310-
@recorded_by_proxy_httpx
3310+
@recorded_by_proxy(RecordedTransport.HTTPX)
33113311
def test_text_and_image_content_on_binary_on_streaming(self, **kwargs):
33123312
"""Test text + image with content recording ON and binary data ON (streaming)."""
33133313
self.cleanup()
@@ -3392,7 +3392,7 @@ def test_text_and_image_content_on_binary_on_streaming(self, **kwargs):
33923392

33933393
@pytest.mark.usefixtures("instrument_with_content")
33943394
@servicePreparer()
3395-
@recorded_by_proxy_httpx
3395+
@recorded_by_proxy(RecordedTransport.HTTPX)
33963396
def test_responses_stream_method_with_content_recording(self, **kwargs):
33973397
"""Test sync responses.stream() method with content recording enabled."""
33983398
os.environ["AZURE_TRACING_GEN_AI_INSTRUMENT_RESPONSES_API"] = "True"
@@ -3465,7 +3465,7 @@ def test_responses_stream_method_with_content_recording(self, **kwargs):
34653465

34663466
@pytest.mark.usefixtures("instrument_without_content")
34673467
@servicePreparer()
3468-
@recorded_by_proxy_httpx
3468+
@recorded_by_proxy(RecordedTransport.HTTPX)
34693469
def test_responses_stream_method_without_content_recording(self, **kwargs):
34703470
"""Test sync responses.stream() method without content recording."""
34713471
os.environ["AZURE_TRACING_GEN_AI_INSTRUMENT_RESPONSES_API"] = "True"
@@ -3538,7 +3538,7 @@ def test_responses_stream_method_without_content_recording(self, **kwargs):
35383538

35393539
@pytest.mark.usefixtures("instrument_with_content")
35403540
@servicePreparer()
3541-
@recorded_by_proxy_httpx
3541+
@recorded_by_proxy(RecordedTransport.HTTPX)
35423542
def test_responses_stream_method_with_tools_with_content_recording(self, **kwargs):
35433543
"""Test sync responses.stream() method with function tools and content recording enabled."""
35443544
from openai.types.responses.response_input_param import FunctionCallOutput
@@ -3685,7 +3685,7 @@ def test_responses_stream_method_with_tools_with_content_recording(self, **kwarg
36853685

36863686
@pytest.mark.usefixtures("instrument_without_content")
36873687
@servicePreparer()
3688-
@recorded_by_proxy_httpx
3688+
@recorded_by_proxy(RecordedTransport.HTTPX)
36893689
def test_responses_stream_method_with_tools_without_content_recording(self, **kwargs):
36903690
"""Test sync responses.stream() method with function tools without content recording."""
36913691
from openai.types.responses.response_input_param import FunctionCallOutput

0 commit comments

Comments
 (0)