Skip to content

Python: Add Microsoft OpenTelemetry Distro sample - #5632

Merged
Tao Chen (TaoChenOSU) merged 5 commits into
microsoft:mainfrom
TaoChenOSU:feature/python-microsoft-opentelemetry-distro
Jul 13, 2026
Merged

Python: Add Microsoft OpenTelemetry Distro sample#5632
Tao Chen (TaoChenOSU) merged 5 commits into
microsoft:mainfrom
TaoChenOSU:feature/python-microsoft-opentelemetry-distro

Conversation

@TaoChenOSU

@TaoChenOSU Tao Chen (TaoChenOSU) commented May 4, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

Microsoft OpenTelemetry Distro provides a single onboarding experience for observability across Azure Monitor, OTLP-compatible backends, and Microsoft Agent 365 integrations.

Description

We are adding a sample to show how to use the distro with agent framework.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@TaoChenOSU Tao Chen (TaoChenOSU) self-assigned this May 4, 2026
Copilot AI review requested due to automatic review settings May 4, 2026 22:26
@TaoChenOSU Tao Chen (TaoChenOSU) added python Usage: [Issues, PRs], Target: Python observability Usage: [Issues, PRs], Target: observability related features labels May 4, 2026

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new Python sample demonstrating how to enable telemetry for an Agent Framework agent using the Microsoft OpenTelemetry Distro and Azure Monitor.

Changes:

  • Adds a new observability sample that configures the Microsoft OpenTelemetry Distro.
  • Demonstrates tracing a simple weather agent conversation and printing the active trace ID.
  • Shows a tool-backed streaming agent workflow using FoundryChatClient and AzureCliCredential.

@github-actions github-actions Bot changed the title Add Microsoft OpenTelemetry Distro sample Python: Add Microsoft OpenTelemetry Distro sample May 4, 2026

@github-actions github-actions Bot 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.

Automated Code Review

Reviewers: 4 | Confidence: 78%

✓ Correctness

The new sample follows the same structural pattern as the existing agent_observability.py sample (calling the setup function inside main() after imports). The Agent Framework's observability uses the standard OpenTelemetry API proxy pattern (get_tracer() delegates to whatever TracerProvider is currently set), so import ordering relative to use_microsoft_opentelemetry is not a correctness issue for framework-generated spans. The existing unresolved comments about Azure Monitor configuration documentation remain relevant. No new correctness bugs found beyond those already flagged.

✓ Security Reliability

This new sample demonstrates using the Microsoft OpenTelemetry Distro for observability. The existing review comments already cover the primary reliability concerns (import ordering for auto-instrumentation and missing Azure Monitor configuration documentation). After investigating the Agent Framework's observability internals (observability.py:1256 gates telemetry behind OBSERVABILITY_SETTINGS.ENABLED, which defaults to False at line 680), I noted that the sample relies on use_microsoft_opentelemetry to automatically enable framework instrumentation per its inline comment. No additional security vulnerabilities (no secrets, no injection risks, no unsafe deserialization, no resource leaks) were identified beyond what existing comments address.

✓ Test Coverage

This PR adds a new observability sample using Microsoft OpenTelemetry Distro. No tests accompany it, which is consistent with the existing pattern for 02-agents samples (only getting_started samples have tests). However, there are no integration or unit tests anywhere in the project validating the observability module's behavior (get_tracer, tracing instrumentation), meaning this new integration path with the Microsoft distro is completely untested. The sample itself is straightforward and follows the structure of the existing agent_observability.py sample.

✗ Design Approach

The new sample picks the wrong observability layer for the behavior it is trying to demonstrate. It configures the Microsoft OpenTelemetry distro, but never enables Agent Framework's own instrumentation switch, so the Agent/Foundry spans this sample is supposed to showcase will be skipped. The repo also already has a Foundry-specific configure_azure_monitor() helper that retrieves the Application Insights connection string and enables instrumentation in one place, which is a better fit for this scenario than a lower-level distro call.

Suggestions

  • For a Foundry-based sample, prefer await client.configure_azure_monitor(...) instead of wiring Azure Monitor through the distro directly. The implementation in _chat_client.py:261-314 both retrieves the project connection string and enables Agent Framework instrumentation in one call, which is the documented Foundry path in the README.

Automated review by TaoChenOSU's agents

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.

looks nice! Just the header that tells the user/uv which package to install and README update, and probably good to note how to setup sensitive data as well (if desired) (through env)

@TaoChenOSU Tao Chen (TaoChenOSU) moved this to In Progress in Agent Framework May 6, 2026
@moonbox3

Copy link
Copy Markdown
Contributor

Tao Chen (@TaoChenOSU) do we still need this? If not, can we close please?

@TaoChenOSU

Copy link
Copy Markdown
Contributor Author

Tao Chen (@TaoChenOSU) do we still need this? If not, can we close please?

Yes, will get this to a good state.

@giles17 Giles Odigwe (giles17) added the documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs label Jul 9, 2026
@TaoChenOSU
Tao Chen (TaoChenOSU) marked this pull request as ready for review July 9, 2026 19:39

@github-actions github-actions Bot 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.

Automated Code Review

Reviewers: 5 | Confidence: 92% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by TaoChenOSU's agents

@TaoChenOSU
Tao Chen (TaoChenOSU) added this pull request to the merge queue Jul 13, 2026
Merged via the queue into microsoft:main with commit 8e74360 Jul 13, 2026
37 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Agent Framework Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs observability Usage: [Issues, PRs], Target: observability related features python Usage: [Issues, PRs], Target: Python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants