Skip to content

[Draft] Python telemetry attribution fix - #2

Draft
jpalvarezl wants to merge 17 commits into
mainfrom
jpalvarezl/fix/7492_python_telemetry
Draft

jpalvarezl wants to merge 17 commits into
mainfrom
jpalvarezl/fix/7492_python_telemetry

Conversation

@jpalvarezl

@jpalvarezl jpalvarezl commented Sep 9, 2026

Copy link
Copy Markdown
Owner

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; update the lockfile and compatible OpenTelemetry dependencies. 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 microsoft#7492

Supersedes the experimental attribution approach from the closed microsoft#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.

jpalvarezl and others added 11 commits September 1, 2026 10:04
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
jpalvarezl pushed a commit that referenced this pull request Sep 18, 2026
…8150) (microsoft#8163)

* Python: include checkpoint_id on AG-UI interrupt metadata (microsoft#8150)

Attach the pause workflow checkpoint id to RUN_FINISHED interrupt
metadata.agent_framework so multi-worker clients can resume via
forwardedProps.checkpoint_id without a side channel.

* Python: Prefer runner pause checkpoint over shared get_latest (microsoft#8150)

* Python: Fix ag-ui lint and ty ignores for microsoft#8150 tests

* Python: Core resolve_pause_checkpoint_id for AG-UI (microsoft#8150)

Move pause-checkpoint selection into Workflow and require a run-scoped
baseline so leftover runner ids are not advertised across runs.

* fix(python): resolve pyright failures in pause checkpoint lookup

Unblocks Package Checks / merge-gatekeeper on PR microsoft#8163.

* fix(ag-ui): address microsoft#8163 review on pause checkpoint ownership (#2)

- Workflow captures run baseline / restored id inside run(); resolve uses them
  so callers need not thread baseline_checkpoint_id.
- Exclude restored checkpoint from pause candidates after resume.
- Drop issue reference in docstring; emit RUN_FINISHED via existing
  _build_run_finished_event after attaching pause id.
- Move core pause-resolve coverage into test_workflow.py (no new test file).

* fix(ag-ui): resume builder-storage pause IDs without AG-UI storage

When checkpoint_id+resume is supplied, load pending requests from the workflow's effective builder/runtime storage if AG-UI was not given an explicit checkpoint_storage, so emitted pause IDs remain round-trippable.

* fix(ag-ui): silence ty invalid-argument-type on builder-storage resume test

Match existing yield_output ignore markers so Test Typing Checks accept the new resume round-trip coverage.

* fix(ag-ui): resume builder storage via AgentFrameworkWorkflow.run()

Allow forwardedProps.checkpoint_id when only WorkflowBuilder storage is configured, so wrapper/endpoint hosts round-trip pause ids without duplicating checkpoint_storage.

---------

Co-authored-by: minelhi <3417378192@qq.com>
Co-authored-by: LI <2484593937@qq.com>
Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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

1 participant