@@ -639,41 +639,62 @@ async def test_nonstreaming_create_message_data_collection_async(
639639@pytest .mark .parametrize ("span_streaming" , [True , False ])
640640@pytest .mark .parametrize ("stream_gen_ai_spans" , [True , False ])
641641@pytest .mark .parametrize (
642- "data_collection,send_default_pii,include_prompts,outputs_collected" ,
642+ "data_collection,send_default_pii,include_prompts,outputs_collected,tool_calls_collected " ,
643643 [
644644 pytest .param (
645645 {"gen_ai" : {"outputs" : True }},
646646 False ,
647647 False ,
648648 True ,
649+ True ,
649650 id = "gen-ai-outputs-enabled-overrides-pii-and-include-prompts" ,
650651 ),
651652 pytest .param (
652653 {"gen_ai" : {"outputs" : False }},
653654 True ,
654655 True ,
655656 False ,
656- id = "gen-ai-outputs-disabled-overrides-pii-and-include-prompts" ,
657+ True ,
658+ id = "gen-ai-outputs-disabled-still-collects-tool-calls-gated-on-inputs" ,
659+ ),
660+ pytest .param (
661+ {"gen_ai" : {"inputs" : False }},
662+ True ,
663+ True ,
664+ True ,
665+ False ,
666+ id = "gen-ai-inputs-disabled-drops-tool-calls-only" ,
667+ ),
668+ pytest .param (
669+ {"gen_ai" : {"inputs" : False , "outputs" : False }},
670+ True ,
671+ True ,
672+ False ,
673+ False ,
674+ id = "gen-ai-inputs-and-outputs-disabled-overrides-pii-and-include-prompts" ,
657675 ),
658676 pytest .param (
659677 {"gen_ai" : {}},
660678 False ,
661679 False ,
662680 True ,
663- id = "gen-ai-outputs-omitted-defaults-to-enabled" ,
681+ True ,
682+ id = "gen-ai-inputs-and-outputs-omitted-defaults-to-enabled" ,
664683 ),
665684 pytest .param (
666685 None ,
667686 True ,
668687 True ,
669688 True ,
689+ True ,
670690 id = "legacy-pii-and-include-prompts-enabled" ,
671691 ),
672692 pytest .param (
673693 None ,
674694 False ,
675695 True ,
676696 False ,
697+ False ,
677698 id = "legacy-pii-disabled" ,
678699 ),
679700 ],
@@ -686,6 +707,7 @@ def test_nonstreaming_create_message_data_collection_outputs(
686707 send_default_pii ,
687708 include_prompts ,
688709 outputs_collected ,
710+ tool_calls_collected ,
689711 stream_gen_ai_spans ,
690712 span_streaming ,
691713):
@@ -743,12 +765,15 @@ def test_nonstreaming_create_message_data_collection_outputs(
743765 span_data [SPANDATA .GEN_AI_RESPONSE_TEXT ]
744766 == DATA_COLLECTION_EXPECTED_RESPONSE_TEXT
745767 )
768+ else :
769+ assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span_data
770+
771+ if tool_calls_collected :
746772 assert (
747773 json .loads (span_data [SPANDATA .GEN_AI_RESPONSE_TOOL_CALLS ])
748774 == DATA_COLLECTION_EXPECTED_TOOL_CALLS
749775 )
750776 else :
751- assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span_data
752777 assert SPANDATA .GEN_AI_RESPONSE_TOOL_CALLS not in span_data
753778
754779
@@ -760,41 +785,62 @@ def test_nonstreaming_create_message_data_collection_outputs(
760785@pytest .mark .parametrize ("stream_gen_ai_spans" , [True , False ])
761786@pytest .mark .asyncio
762787@pytest .mark .parametrize (
763- "data_collection,send_default_pii,include_prompts,outputs_collected" ,
788+ "data_collection,send_default_pii,include_prompts,outputs_collected,tool_calls_collected " ,
764789 [
765790 pytest .param (
766791 {"gen_ai" : {"outputs" : True }},
767792 False ,
768793 False ,
769794 True ,
795+ True ,
770796 id = "gen-ai-outputs-enabled-overrides-pii-and-include-prompts" ,
771797 ),
772798 pytest .param (
773799 {"gen_ai" : {"outputs" : False }},
774800 True ,
775801 True ,
776802 False ,
777- id = "gen-ai-outputs-disabled-overrides-pii-and-include-prompts" ,
803+ True ,
804+ id = "gen-ai-outputs-disabled-still-collects-tool-calls-gated-on-inputs" ,
805+ ),
806+ pytest .param (
807+ {"gen_ai" : {"inputs" : False }},
808+ True ,
809+ True ,
810+ True ,
811+ False ,
812+ id = "gen-ai-inputs-disabled-drops-tool-calls-only" ,
813+ ),
814+ pytest .param (
815+ {"gen_ai" : {"inputs" : False , "outputs" : False }},
816+ True ,
817+ True ,
818+ False ,
819+ False ,
820+ id = "gen-ai-inputs-and-outputs-disabled-overrides-pii-and-include-prompts" ,
778821 ),
779822 pytest .param (
780823 {"gen_ai" : {}},
781824 False ,
782825 False ,
783826 True ,
784- id = "gen-ai-outputs-omitted-defaults-to-enabled" ,
827+ True ,
828+ id = "gen-ai-inputs-and-outputs-omitted-defaults-to-enabled" ,
785829 ),
786830 pytest .param (
787831 None ,
788832 True ,
789833 True ,
790834 True ,
835+ True ,
791836 id = "legacy-pii-and-include-prompts-enabled" ,
792837 ),
793838 pytest .param (
794839 None ,
795840 False ,
796841 True ,
797842 False ,
843+ False ,
798844 id = "legacy-pii-disabled" ,
799845 ),
800846 ],
@@ -807,6 +853,7 @@ async def test_nonstreaming_create_message_data_collection_outputs_async(
807853 send_default_pii ,
808854 include_prompts ,
809855 outputs_collected ,
856+ tool_calls_collected ,
810857 stream_gen_ai_spans ,
811858 span_streaming ,
812859):
@@ -864,12 +911,15 @@ async def test_nonstreaming_create_message_data_collection_outputs_async(
864911 span_data [SPANDATA .GEN_AI_RESPONSE_TEXT ]
865912 == DATA_COLLECTION_EXPECTED_RESPONSE_TEXT
866913 )
914+ else :
915+ assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span_data
916+
917+ if tool_calls_collected :
867918 assert (
868919 json .loads (span_data [SPANDATA .GEN_AI_RESPONSE_TOOL_CALLS ])
869920 == DATA_COLLECTION_EXPECTED_TOOL_CALLS
870921 )
871922 else :
872- assert SPANDATA .GEN_AI_RESPONSE_TEXT not in span_data
873923 assert SPANDATA .GEN_AI_RESPONSE_TOOL_CALLS not in span_data
874924
875925
0 commit comments