Skip to content

Python: Require Azure Monitor 1.8.10 for Foundry trace propagation - #8512

Merged
Jose Alvarez (jpalvarezl) merged 17 commits into
microsoft:mainfrom
jpalvarezl:jpalvarezl/fix/7492_python_telemetry
Sep 18, 2026
Merged

Jose Alvarez (jpalvarezl) merged 17 commits into
microsoft:mainfrom
jpalvarezl:jpalvarezl/fix/7492_python_telemetry

Conversation

@jpalvarezl

@jpalvarezl Jose Alvarez (jpalvarezl) commented Sep 18, 2026

Copy link
Copy Markdown
Member

Motivation & Context

Foundry agent calls can export client spans to Application Insights while the agent's Foundry Traces view shows only server spans. With Azure Monitor OpenTelemetry 1.8.9, the OpenAI HTTP transport is not automatically instrumented, so requests can lack a W3C traceparent header and the service starts a separate trace.

Azure Monitor OpenTelemetry 1.8.10 adds HTTPX/HTTPX2 auto-instrumentation. Using it connects the client and service spans in the existing agent's trace list and waterfall without custom project attribution or changes to agent identity and response handling.

Description & Review Guide

  • What are the major changes? Require azure-monitor-opentelemetry>=1.8.10,<2 in the workspace test dependency group and tracing samples. Add an existing-agent tracing sample supporting streaming and non-streaming calls, and update Foundry helper installation hints and tracing documentation.
  • What is the impact of these changes? The documented Azure Monitor setup propagates trace context through the OpenAI transport so client and Foundry service spans form one connected trace. Azure Monitor remains optional; applications with an existing installation must upgrade it separately. No project ARM ID override, response-ID copying, or new runtime attribution API is introduced.
  • What do you want reviewers to focus on? The dependency floor and related lockfile updates, the existing-agent sample, and the guidance for inspecting connected traces under Build > Agents > your agent > Traces, including agent version and time-range selection.

Related Issue

Fixes #7492

Supersedes the experimental attribution approach from the closed #7981. The earlier ARM-ID discovery and response-ID retention changes are not part of this fix.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after a language prefix) — a workflow keeps the label and the title prefix in sync automatically.

The build and test confirmations cover the affected scope: the Foundry wheel and source distribution build cleanly; all Foundry unit tests and the core observability suite report 706 passed, 14 skipped, and 26 integration tests deselected. Four experimental/deprecation warnings remain in the test run. The full repository suite was not run; dependency-owned propagation tests are intentionally not added.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5641780c-318a-4def-8692-710b2b061c60
Separate per-agent project identity from exporter configuration, preserve export on optional discovery failures, and capture response identity from the owned chat result. Consolidate invocation telemetry state and document both setup paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bfc650ea-638e-4c20-aae6-f63cca98462e
Replace the experimental project-attribution and response-ID workaround with Azure Monitor 1.8.10 transport auto-instrumentation. Update the tracing samples, setup guidance and workspace lock, and cover W3C propagation through both Foundry helpers without network calls.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the tracing dependency and documentation fix without testing behavior owned by Azure Monitor.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve main's refreshed dependency resolution and Python 3.15 compatibility while retaining the Azure Monitor 1.8.10 minimum for tracing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

Prompt-agent setup documentation incorrectly presents the required agent version as optional.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Updates Foundry tracing guidance and dependencies so client and service spans share a trace.

Changes:

  • Requires Azure Monitor OpenTelemetry 1.8.10+.
  • Adds an existing-agent tracing sample with streaming support.
  • Updates helper documentation and installation guidance.
File summaries
File Description
python/uv.lock Records the Azure Monitor dependency constraint.
python/pyproject.toml Raises the test dependency floor.
python/packages/foundry/README.md Documents connected tracing setup.
python/packages/foundry/agent_framework_foundry/_agent.py Updates helper guidance and installation error.
python/packages/foundry/agent_framework_foundry/_chat_client.py Updates helper guidance and installation error.
python/samples/02-agents/observability/README.md Adds setup and trace-inspection instructions.
python/samples/02-agents/observability/foundry_agent_tracing.py Adds the existing-agent tracing sample.
python/samples/02-agents/observability/foundry_tracing.py Updates dependency and cross-reference guidance.
python/samples/02-agents/providers/foundry/README.md Links the new sample.
Review details
  • Files reviewed: 8/9 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/samples/02-agents/observability/README.md Outdated
Comment thread python/samples/02-agents/observability/foundry_agent_tracing.py Outdated

@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.

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (15 commit(s)): c133e29bf466, 2ac21147e0b5, c46ff52fccb4, 7180c5893298, 79db80942428, 7695b7ffd6d9, a3eeaee0c3b8, 807a12a7d750, 4f3b8b1b053f, 51f07df0a239, 394f0e74e941, 39279585c608, 3640474dd39c, c6781acdd17b, 3e972fa18801
Model: gpt-5.6-sol-fast

Overview

The PR consistently raises the optional Azure Monitor dependency floor to the version that instruments the OpenAI SDK's HTTPX transport, and adds an existing-agent sample that configures telemetry before either streaming or non-streaming invocation. Existing helper tests cover destination lookup, provider configuration, custom resources, missing dependencies, and missing Application Insights resources, while the sample preserves telemetry opt-out and sensitive-data defaults. No Critical, High, or Medium defect was established.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

@jpalvarezl Jose Alvarez (jpalvarezl) changed the title Python: client traces attribution for MS Foundry Python: Require Azure Monitor 1.8.10 for Foundry trace propagation Sep 18, 2026
Document FOUNDRY_AGENT_VERSION as required for PromptAgents and optional for HostedAgents, preserving runtime behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the package README focused on installation, the setup helper and the sample link. Retain sample prerequisites and run instructions without repeating the telemetry investigation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jpalvarezl
Jose Alvarez (jpalvarezl) added this pull request to the merge queue Sep 18, 2026
Merged via the queue into microsoft:main with commit 4f41eab Sep 18, 2026
93 of 104 checks passed
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 python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Foundry Prompt Agent client spans are not showing up in Foundry tracing UI

3 participants