Skip to content

Distinguish Azure AI SDKs in statsbeats#42016

Merged
lmolkova merged 6 commits intoAzure:mainfrom
lmolkova:statbeats-azure-ai-sdks
Jul 17, 2025
Merged

Distinguish Azure AI SDKs in statsbeats#42016
lmolkova merged 6 commits intoAzure:mainfrom
lmolkova:statbeats-azure-ai-sdks

Conversation

@lmolkova
Copy link
Copy Markdown

@lmolkova lmolkova commented Jul 15, 2025

  • 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 review requested due to automatic review settings July 15, 2025 00:03
@github-actions github-actions Bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Jul 15, 2025
Copy link
Copy Markdown
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 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"):

Copy link
Copy Markdown
Member

@lzchen lzchen left a comment

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 lmolkova force-pushed the statbeats-azure-ai-sdks branch from 6a8fffa to 194d05a Compare July 16, 2025 22:30
@lmolkova lmolkova merged commit d88d394 into Azure:main Jul 17, 2025
19 checks passed
@lzchen lzchen mentioned this pull request Jul 25, 2025
@jeremydvoss
Copy link
Copy Markdown
Member

jeremydvoss commented Jul 28, 2025

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