Skip to content

Distinguish Azure AI SDKs in statsbeats - #42016

Merged
Liudmila Molkova (lmolkova) merged 6 commits into
Azure:mainfrom
lmolkova:statbeats-azure-ai-sdks
Jul 17, 2025
Merged

Distinguish Azure AI SDKs in statsbeats#42016
Liudmila Molkova (lmolkova) merged 6 commits into
Azure:mainfrom
lmolkova:statbeats-azure-ai-sdks

Conversation

@lmolkova

@lmolkova Liudmila Molkova (lmolkova) commented Jul 15, 2025

Copy link
Copy Markdown
  • separate Azure AI and the rest of Azure SDKs in statbeats
  • detect azure sdk spans by scope name - it's consistent with other instrumentations and also would cover all existing Azure SDKs. az.namespace is set by very few of them

This works along with #42015

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support to differentiate Azure AI SDK spans from general Azure SDKs in statsbeats by inspecting the span’s instrumentation scope and the az.namespace attribute.

  • Introduced a new _AZURE_AI_SDK_NAME constant for Azure AI SDK instrumentation
  • Updated _check_instrumentation_span to detect any OpenTelemetry spans with scope names starting with “azure” and treat AI SDK calls specially
  • Appended the Azure AI SDK name into the instrumentation list in constants

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_exporter.py Imported new constant and added branch to detect Azure AI SDK spans
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_constants.py Defined _AZURE_AI_SDK_NAME, updated instrumentation list, and left a TODO for naming consistency
Comments suppressed due to low confidence (2)

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_constants.py:198

  • [nitpick] The constant value "azure-ai" differs from other instrumentation names that include -opentelemetry. Consider renaming it (e.g., "azure-ai-opentelemetry") or aligning naming conventions across SDKs.
_AZURE_AI_SDK_NAME = "azure-ai"

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_exporter.py:534

  • This new branch handles Azure SDK spans and AI-specific spans; please add unit tests to cover both the general Azure detection and the Microsoft.CognitiveServices (AI) path to ensure statsbeats metrics report correctly.
    if span.instrumentation_scope.name.startswith("azure"):

@lzchen Leighton Chen (lzchen) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few nits.

Liudmila Molkova and others added 6 commits July 16, 2025 15:29
…/opentelemetry/exporter/export/trace/_exporter.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…/opentelemetry/exporter/export/trace/_exporter.py

Co-authored-by: Leighton Chen <lechen@microsoft.com>
…/opentelemetry/exporter/_constants.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@lmolkova
Liudmila Molkova (lmolkova) merged commit d88d394 into Azure:main Jul 17, 2025
19 checks passed
@jeremydvoss

Jeremy Voss (jeremydvoss) commented Jul 28, 2025

Copy link
Copy Markdown
Member

In response to breaking change which was released with OTel 1.35.0/0.56b0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants