Skip to content

Commit 83ebd8b

Browse files
authored
Azure AI Agents: add az.namespace attribute and schema url (#42015)
1 parent d88d394 commit 83ebd8b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

sdk/ai/azure-ai-agents/azure/ai/agents/telemetry/_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
GEN_AI_SYSTEM = "gen_ai.system"
3939
SERVER_ADDRESS = "server.address"
4040
AZ_AI_AGENT_SYSTEM = "az.ai.agents"
41+
AZ_NAMESPACE = "az.namespace"
42+
AZ_NAMESPACE_VALUE = "Microsoft.CognitiveServices"
4143
GEN_AI_TOOL_NAME = "gen_ai.tool.name"
4244
GEN_AI_TOOL_CALL_ID = "gen_ai.tool.call.id"
4345
GEN_AI_REQUEST_RESPONSE_FORMAT = "gen_ai.request.response_format"
@@ -50,7 +52,7 @@
5052
GEN_AI_RUN_STEP_STATUS = "gen_ai.run_step.status"
5153
ERROR_TYPE = "error.type"
5254
ERROR_MESSAGE = "error.message"
53-
55+
GEN_AI_SEMANTIC_CONVENTIONS_SCHEMA_VERSION = "1.34.0"
5456

5557
class OperationName(Enum):
5658
CREATE_AGENT = "create_agent"
@@ -114,9 +116,11 @@ def start_span(
114116
if _span_impl_type is None:
115117
return None
116118

117-
span = _span_impl_type(name=span_name or operation_name.value, kind=kind)
119+
120+
span = _span_impl_type(name=span_name or operation_name.value, kind=kind, schema_version=GEN_AI_SEMANTIC_CONVENTIONS_SCHEMA_VERSION)
118121

119122
if span and span.span_instance.is_recording:
123+
span.add_attribute(AZ_NAMESPACE, AZ_NAMESPACE_VALUE)
120124
if gen_ai_system:
121125
span.add_attribute(GEN_AI_SYSTEM, AZ_AI_AGENT_SYSTEM)
122126

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
class GenAiTraceVerifier:
1313

1414
def check_span_attributes(self, span, attributes):
15+
assert "https://opentelemetry.io/schemas/1.34.0" == span.instrumentation_scope.schema_url
16+
1517
# Convert the list of tuples to a dictionary for easier lookup
1618
attribute_dict = dict(attributes)
19+
attribute_dict["az.namespace"] = "Microsoft.CognitiveServices"
1720

1821
for attribute_name in span.attributes.keys():
1922
# Check if the attribute name exists in the input attributes

0 commit comments

Comments
 (0)