Skip to content

Conversation

@lmolkova
Copy link

@lmolkova lmolkova commented Jul 14, 2025

az.namespace is used by the Azure Monitor to distinguish telemetry coming from different Azure SDKs and simplify resource discovery based on telemetry. This works along with #42016

All azure SDKs should report it, but it's missing in agents.

Schema URL is used to help telemetry consumers map telemetry format and deal with breaking changes (that are coming to GenAI conventions - open-telemetry/semantic-conventions#2046)

Copilot AI review requested due to automatic review settings July 14, 2025 23:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds the az.namespace attribute and OpenTelemetry schema URL to spans in the Azure AI Agents library for consistent telemetry reporting.

  • Defines new constants for namespace and schema version in _utils.py and updates start_span to pass the schema version and add az.namespace
  • Imports namespace constants in the instrumentor (_ai_agents_instrumentor.py)
  • Updates tests (gen_ai_trace_verifier.py) to verify the schema URL and expected namespace attribute

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/gen_ai_trace_verifier.py Asserts instrumentation scope’s schema URL and includes az.namespace in expected attributes
telemetry/_utils.py Adds AZ_NAMESPACE, AZ_NAMESPACE_VALUE, GEN_AI_SEMCONV_SCHEMA_VERSION, and updates span instantiation to include schema_version and namespace attribute
telemetry/_ai_agents_instrumentor.py Imports new namespace constants for use in instrumentation
Comments suppressed due to low confidence (3)

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

  • The test only checks attribute presence; add an assertion like assert span.attributes["az.namespace"] == "Microsoft.CognitiveServices" to verify the value is correct.
        attribute_dict["az.namespace"] = "Microsoft.CognitiveServices"

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

  • [nitpick] This constant holds a schema URL version but is named ..._VERSION, which may be confusing. Consider renaming to GEN_AI_SEMCONV_SCHEMA_URL if you store the full URL, or include the full URL in this constant.
GEN_AI_SEMCONV_SCHEMA_VERSION = "1.34.0"

sdk/ai/azure-ai-agents/azure/ai/agents/telemetry/_ai_agents_instrumentor.py:50

  • [nitpick] Imported AZ_NAMESPACE and AZ_NAMESPACE_VALUE but they are not used in this file. Remove the unused imports or add code to utilize them for consistency.
    AZ_NAMESPACE,

@jhakulin jhakulin requested a review from M-Hietala July 15, 2025 17:24
@lmolkova lmolkova merged commit 83ebd8b into Azure:main Jul 17, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants