diff --git a/sdk/ai/azure-ai-agents/azure/ai/agents/telemetry/_utils.py b/sdk/ai/azure-ai-agents/azure/ai/agents/telemetry/_utils.py index 10c6f252a3e5..b24d07345d72 100644 --- a/sdk/ai/azure-ai-agents/azure/ai/agents/telemetry/_utils.py +++ b/sdk/ai/azure-ai-agents/azure/ai/agents/telemetry/_utils.py @@ -38,6 +38,8 @@ GEN_AI_SYSTEM = "gen_ai.system" SERVER_ADDRESS = "server.address" AZ_AI_AGENT_SYSTEM = "az.ai.agents" +AZ_NAMESPACE = "az.namespace" +AZ_NAMESPACE_VALUE = "Microsoft.CognitiveServices" GEN_AI_TOOL_NAME = "gen_ai.tool.name" GEN_AI_TOOL_CALL_ID = "gen_ai.tool.call.id" GEN_AI_REQUEST_RESPONSE_FORMAT = "gen_ai.request.response_format" @@ -50,7 +52,7 @@ GEN_AI_RUN_STEP_STATUS = "gen_ai.run_step.status" ERROR_TYPE = "error.type" ERROR_MESSAGE = "error.message" - +GEN_AI_SEMANTIC_CONVENTIONS_SCHEMA_VERSION = "1.34.0" class OperationName(Enum): CREATE_AGENT = "create_agent" @@ -114,9 +116,11 @@ def start_span( if _span_impl_type is None: return None - span = _span_impl_type(name=span_name or operation_name.value, kind=kind) + + span = _span_impl_type(name=span_name or operation_name.value, kind=kind, schema_version=GEN_AI_SEMANTIC_CONVENTIONS_SCHEMA_VERSION) if span and span.span_instance.is_recording: + span.add_attribute(AZ_NAMESPACE, AZ_NAMESPACE_VALUE) if gen_ai_system: span.add_attribute(GEN_AI_SYSTEM, AZ_AI_AGENT_SYSTEM) diff --git a/sdk/ai/azure-ai-agents/tests/gen_ai_trace_verifier.py b/sdk/ai/azure-ai-agents/tests/gen_ai_trace_verifier.py index 94ffdf1fd832..805ba951cdb6 100644 --- a/sdk/ai/azure-ai-agents/tests/gen_ai_trace_verifier.py +++ b/sdk/ai/azure-ai-agents/tests/gen_ai_trace_verifier.py @@ -12,8 +12,11 @@ class GenAiTraceVerifier: def check_span_attributes(self, span, attributes): + assert "https://opentelemetry.io/schemas/1.34.0" == span.instrumentation_scope.schema_url + # Convert the list of tuples to a dictionary for easier lookup attribute_dict = dict(attributes) + attribute_dict["az.namespace"] = "Microsoft.CognitiveServices" for attribute_name in span.attributes.keys(): # Check if the attribute name exists in the input attributes