Skip to content

Commit cc9b09a

Browse files
authored
adding tool call instrumentation (#43799)
* adding tool call instrumentation * fixing code checker issues * moving import into test functions
1 parent 19ba455 commit cc9b09a

File tree

7 files changed

+1982
-81
lines changed

7 files changed

+1982
-81
lines changed

sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_ai_project_instrumentor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,9 @@ def _add_instructions_event(
437437
event_body: Dict[str, Any] = {}
438438
if _trace_agents_content and (instructions or additional_instructions):
439439
if instructions and additional_instructions:
440-
event_body["content"] = f"{instructions} {additional_instructions}"
440+
event_body["text"] = f"{instructions} {additional_instructions}"
441441
else:
442-
event_body["content"] = instructions or additional_instructions
442+
event_body["text"] = instructions or additional_instructions
443443

444444
attributes = self._create_event_attributes(agent_id=agent_id, thread_id=thread_id)
445445
attributes[GEN_AI_EVENT_CONTENT] = json.dumps(event_body, ensure_ascii=False)

sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_responses_instrumentor.py

Lines changed: 581 additions & 64 deletions
Large diffs are not rendered by default.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def check_span_events(self, span, expected_events):
187187
raise AssertionError("check_span_events: event not found")
188188

189189
if len(span_events) > 0: # If there are any additional events in the span_events
190-
raise AssertionError("check_span_events: unexpected event found")
190+
unexpected_event_names = [event.name for event in span_events]
191+
raise AssertionError(f"check_span_events: unexpected event(s) found: {unexpected_event_names}")
191192

192193
return True

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def test_agent_creation_with_tracing_content_recording_enabled(self, **kwargs):
237237
"name": "gen_ai.system.instruction",
238238
"attributes": {
239239
"gen_ai.system": "az.ai.agents",
240-
"gen_ai.event.content": '{"content": "You are a helpful AI assistant. Be polite and provide accurate information."}',
240+
"gen_ai.event.content": '{"text": "You are a helpful AI assistant. Be polite and provide accurate information."}',
241241
},
242242
}
243243
]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def test_create_agent_with_tracing_content_recording_enabled(self, **kwarg
114114
"name": "gen_ai.system.instruction",
115115
"attributes": {
116116
"gen_ai.system": "az.ai.agents",
117-
"gen_ai.event.content": '{"content": "You are a helpful AI assistant. Always be polite and provide accurate information."}',
117+
"gen_ai.event.content": '{"text": "You are a helpful AI assistant. Always be polite and provide accurate information."}',
118118
},
119119
}
120120
]

0 commit comments

Comments
 (0)