Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
from azure.core.tracing import AbstractSpan
from ._utils import (
AZ_AI_AGENT_SYSTEM,
AZ_NAMESPACE,
AZ_NAMESPACE_VALUE,
ERROR_TYPE,
GEN_AI_AGENT_DESCRIPTION,
GEN_AI_AGENT_ID,
Expand Down
8 changes: 6 additions & 2 deletions sdk/ai/azure-ai-agents/azure/ai/agents/telemetry/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
lmolkova marked this conversation as resolved.
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"
Expand All @@ -50,7 +52,7 @@
GEN_AI_RUN_STEP_STATUS = "gen_ai.run_step.status"
ERROR_TYPE = "error.type"
ERROR_MESSAGE = "error.message"

GEN_AI_SEMCONV_SCHEMA_VERSION = "1.34.0"

class OperationName(Enum):
CREATE_AGENT = "create_agent"
Expand Down Expand Up @@ -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_SEMCONV_SCHEMA_VERSION)
Comment thread
lmolkova marked this conversation as resolved.
Outdated

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)

Expand Down
3 changes: 3 additions & 0 deletions sdk/ai/azure-ai-agents/tests/gen_ai_trace_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading