Skip to content

Python: .NET: Show Aspire traces in DevUI - #7874

Open
Saibernard wants to merge 9 commits into
microsoft:mainfrom
Saibernard:issue-5806-aspire-devui-tracing
Open

Python: .NET: Show Aspire traces in DevUI#7874
Saibernard wants to merge 9 commits into
microsoft:mainfrom
Saibernard:issue-5806-aspire-devui-tracing

Conversation

@Saibernard

@Saibernard Saibernard commented Aug 26, 2026

Copy link
Copy Markdown

Motivation & Context

The Aspire integration currently forwards events and tool activity to DevUI, but it does not populate the Traces tab. Aspire-hosted .NET agent applications therefore cannot inspect their traces in DevUI even though the spans are available through the local Aspire Dashboard.

This change connects those spans to the corresponding DevUI response while preserving the existing proxy behavior.

Description & Review Guide

  • What are the major changes?

    • Propagates a unique trace context to the selected agent service.
    • Captures response IDs from streaming SSE and non-streaming JSON responses using bounded parsing.
    • Handles gzip and Brotli response compression without changing unrelated proxy traffic.
    • Retrieves matching spans through the Aspire Dashboard trace-by-ID API and rejects incomplete responses.
    • Merges span snapshots by span ID and waits for the trace to stabilize before displaying it.
    • Cleans up trace mappings during cancellation and failure paths.
    • Updates the Aspire sample to resolve dashboard port conflicts, target-framework discovery, and package-version compatibility.
  • What is the impact of these changes?

    • Aspire-hosted .NET agents can display their OpenTelemetry trace tree in the existing DevUI Traces tab.
    • Streaming and non-streaming responses map to the correct trace.
    • Non-Aspire servers continue using the existing behavior.
    • This does not introduce a breaking API change.
  • What do you want reviewers to focus on?

    • Trace correlation across the proxy, agent service, and Aspire Dashboard.
    • Response ID capture for fragmented, compressed, malformed, and oversized responses.
    • Trace completeness and frontend snapshot stabilization.
    • Cancellation, cleanup, and concurrent response handling.

Validation

  • Aspire DevUI tests: 110 passed
  • Five repeated full-suite runs: passed
  • Release package build: 0 warnings, 0 errors
  • Aspire integration sample Release build: 0 warnings, 0 errors
  • Frontend production build: passed
  • Frontend lint: 0 errors
  • Streaming and non-streaming compression coverage for gzip and Brotli: passed
  • Live Azure GPT-4.1 validation: both response modes mapped to the correct four-span Aspire trace
  • Cancellation and concurrent response regression coverage: passed
  • dotnet format: 0 files changed
  • git diff --check: passed

Live validation screenshots and sanitized evidence

Related Issue

Fixes #5806

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.

Copilot AI balanced review requested due to automatic review settings August 26, 2026 03:30
@Saibernard
Saibernard deployed to github-app-auth August 26, 2026 03:30 — with GitHub Actions Active
@Saibernard
Saibernard deployed to github-app-auth August 26, 2026 03:30 — with GitHub Actions Active
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python .NET Usage: [Issues, PRs], Target: .Net labels Aug 26, 2026
@Saibernard
Saibernard deployed to github-app-auth August 26, 2026 03:30 — with GitHub Actions Active
@github-actions github-actions Bot changed the title .NET: Show Aspire traces in DevUI Python: .NET: Show Aspire traces in DevUI Aug 26, 2026
@Saibernard

Saibernard commented Aug 26, 2026

Copy link
Copy Markdown
Author

Here are the screenshots from the live validation run.

The first one shows the successful streaming response and the four Aspire spans that DevUI retrieved for it.

DevUI showing the Aspire trace tree

The second one shows the matching trace ID, successful status, and the redacted Azure HTTP span.

DevUI showing the trace details

I replayed the captured live response and trace payload through the built DevUI so the screenshots are reproducible.

Full validation log | Sanitized trace payload

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 Aspire Dashboard trace retrieval to the shared DevUI frontend for .NET agent services.

Changes:

  • Correlates responses with Aspire OpenTelemetry traces.
  • Adds cancellable frontend trace polling and runtime-specific guidance.
  • Fixes Aspire sample configuration and package mismatches.

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/packages/devui/frontend/src/types/index.ts Adds tracing capabilities.
python/packages/devui/frontend/src/services/api.ts Polls trace endpoints.
python/packages/devui/frontend/src/components/layout/debug-panel.tsx Updates .NET trace guidance.
python/packages/devui/frontend/src/components/features/agent/context-inspector.tsx Updates context guidance.
python/packages/devui/frontend/src/components/features/agent/agent-view.tsx Starts and cancels trace polling.
python/packages/devui/frontend/src/App.tsx Configures tracing from metadata.
python/packages/devui/agent_framework_devui/ui/assets/index.css Regenerates frontend CSS.
dotnet/tests/Aspire.Hosting.AgentFramework.DevUI.UnitTests/AspireDashboardTracingTests.cs Tests trace correlation and failures.
dotnet/src/Aspire.Hosting.AgentFramework.DevUI/SseResponseIdCapture.cs Extracts response IDs from SSE.
dotnet/src/Aspire.Hosting.AgentFramework.DevUI/README.md Documents Aspire tracing.
dotnet/src/Aspire.Hosting.AgentFramework.DevUI/DevUIAggregatorHostedService.cs Implements trace propagation and retrieval.
dotnet/src/Aspire.Hosting.AgentFramework.DevUI/AspireDashboardTraceClient.cs Converts Dashboard spans for DevUI.
dotnet/src/Aspire.Hosting.AgentFramework.DevUI/AgentFrameworkBuilderExtensions.cs Supplies AppHost configuration.
dotnet/samples/05-end-to-end/DevUIAspireIntegration/DevUIIntegration.AppHost/Properties/launchSettings.json Resolves dashboard port conflicts.
dotnet/samples/05-end-to-end/DevUIAspireIntegration/DevUIIntegration.AppHost/DevUIIntegration.AppHost.csproj Fixes framework and Azure references.
dotnet/Directory.Packages.props Pins the Aspire Azure package.

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

Comment thread dotnet/src/Aspire.Hosting.AgentFramework.DevUI/AspireDashboardTraceClient.cs Outdated
Comment thread dotnet/src/Aspire.Hosting.AgentFramework.DevUI/AspireDashboardTraceClient.cs Outdated
Comment thread python/packages/devui/frontend/src/services/api.ts
@Saibernard

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@Saibernard
Saibernard deployed to github-app-auth August 26, 2026 03:48 — with GitHub Actions Active
@Saibernard

Copy link
Copy Markdown
Author

Addressed all three review findings in b74e546d.

What changed:

  • Unset OTLP statuses now match the frontend contract.
  • Trace retrieval now uses Aspire’s trace-by-ID endpoint and rejects count mismatches.
  • The frontend merges snapshots by span ID and waits for three identical merged snapshots before publishing.

Validation:

  • Aspire DevUI tests: 102 passed, 0 failed
  • Frontend lint: 0 errors, 13 existing warnings in unrelated files
  • Frontend production build: passed
  • Aspire package Release build for net10.0: 0 warnings, 0 errors
  • DevUI Aspire integration sample Release build for net10.0: 0 warnings, 0 errors
  • dotnet format: 0 files changed
  • git diff --check: passed

The existing screenshots are still representative because these changes affect trace completeness and status handling, not the layout.

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

Copilot reviewed 15 out of 17 changed files in this pull request and generated 3 comments.

Comment thread python/packages/devui/frontend/src/components/layout/debug-panel.tsx Outdated
@Saibernard

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@Saibernard
Saibernard deployed to github-app-auth August 26, 2026 22:21 — with GitHub Actions Active
@Saibernard

Copy link
Copy Markdown
Author

Addressed the latest review feedback in 269d2cbc and revalidated the change locally.

  • Aspire tracing tests: 103 passed, 0 failed
  • Cancellation regression: passed 5 consecutive runs
  • Frontend lint: 0 errors, with the same 13 existing warnings
  • Frontend production build: passed
  • Aspire package Release build: 0 warnings, 0 errors
  • Aspire integration sample Release build: 0 warnings, 0 errors
  • dotnet format: 0 files changed
  • git diff --check: passed

The existing Aspire screenshots are still representative. This revision changes the empty-state guidance for non-Aspire .NET servers and adds cancellation coverage. It does not change the Aspire trace layout or the successful trace display.

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

Copilot reviewed 16 out of 18 changed files in this pull request and generated no new comments.

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

Copilot reviewed 16 out of 18 changed files in this pull request and generated 1 comment.

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

Copilot reviewed 16 out of 18 changed files in this pull request and generated no new comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

dotnet/src/Aspire.Hosting.AgentFramework.DevUI/SseResponseIdCapture.cs:63

  • The 64 KiB cap can discard valid response IDs. This repository's StreamingResponseCreated serializes a full Response, including request instructions and tool definitions (Microsoft.Agents.AI.Hosting.OpenAI/Responses/AgentResponseUpdateExtensions.cs:242-272), so a valid data: line can exceed this limit. Once that happens, this parser drops the entire line; the later lifecycle response events can carry the same large response payload, leaving ResponseId null and preventing any trace mapping. Keep memory bounded while extracting response.id without requiring the complete line to fit in 64 KiB, and add coverage with an oversized response.created event.
            if (this._lineBuffer.WrittenCount >= MaxLineLength)
            {
                this._lineBuffer.Clear();
                this._discardingOversizedLine = true;
                continue;

@Saibernard
Saibernard deployed to github-app-auth August 27, 2026 01:20 — with GitHub Actions Active
@Saibernard

Saibernard commented Aug 27, 2026

Copy link
Copy Markdown
Author

Fixed the oversized SSE case in 3a97a67d and preserved the existing response ID precedence in df8a439d. Response ID capture now parses the entire bounded JSON prefix, so large valid response.created payloads still map to traces without removing the 64 KiB memory limit, while malformed prefixes are rejected. Added fragmented coverage with an event over 80 KiB, plus malformed JSON and precedence coverage. All 110 tracing tests pass, including five repeated full-suite runs.

@Saibernard
Saibernard deployed to github-app-auth August 27, 2026 01:26 — with GitHub Actions Active
@Saibernard
Saibernard requested a balanced review from Copilot August 27, 2026 01:36

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

Copilot reviewed 16 out of 18 changed files in this pull request and generated no new comments.

@eavanvalkenburg

Copy link
Copy Markdown
Member

Please make sure to use the regular PR template Saibernard

@Saibernard

Copy link
Copy Markdown
Author

Updated the PR description to use the repository standard template. Thanks for the reminder, Eduard van Valkenburg (@eavanvalkenburg).

@Saibernard
Saibernard deployed to github-app-auth August 27, 2026 18:36 — with GitHub Actions Active
@Saibernard
Saibernard deployed to github-app-auth August 27, 2026 18:37 — with GitHub Actions Active
@Saibernard
Saibernard deployed to github-app-auth August 27, 2026 18:37 — with GitHub Actions Active
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 .NET Usage: [Issues, PRs], Target: .Net python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: DevUI integration in Aspire does not have OpenTelemetry visibility

3 participants