Skip to content

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

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

Python: .NET: Show Aspire traces in DevUI#7874
Saibernard wants to merge 13 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
@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
@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 Outdated
@Saibernard

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@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 dotnet/src/Aspire.Hosting.AgentFramework.DevUI/DevUIAggregatorHostedService.cs Outdated
Comment thread python/packages/devui/frontend/src/components/layout/debug-panel.tsx Outdated
@Saibernard

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@moonbox3

Copy link
Copy Markdown
Contributor

Saibernard please help fix the current file conflict. thanks.

Comment thread python/packages/devui/frontend/src/services/api.ts Outdated
Comment thread dotnet/src/Aspire.Hosting.AgentFramework.DevUI/DevUIAggregatorHostedService.cs Outdated
Comment thread dotnet/src/Aspire.Hosting.AgentFramework.DevUI/DevUIAggregatorHostedService.cs Outdated
Comment thread python/packages/devui/frontend/src/App.tsx Outdated
@moonbox3

Copy link
Copy Markdown
Contributor

Please re-open when PR feedback is addressed and file conflicts are addressed. Thanks.

Merge current main, preserve the full trace polling window, stream bounded JSON response capture, and use the current trace retrieval capability. Add regression coverage for delayed spans and response copying.
@Saibernard

Copy link
Copy Markdown
Author

Evan Mattson (@moonbox3) The review feedback has been addressed and the branch is merged with current main with the conflicts resolved (ffe3c15). All review threads are resolved.

GitHub does not let me reopen this PR from my side since it was closed by a maintainer. Could you please reopen it? If you would rather I open a fresh PR instead, let me know and I will do that.

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

Trace polling can discard accumulated spans after transient failures and remain active far beyond its documented window.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

python/packages/devui/frontend/src/services/api.ts:261

  • A transient fetch or JSON-decoding failure discards every span merged by earlier polls, so one bad snapshot can turn a partially recovered trace into an empty result. Keep the accumulated map and allow the remaining attempts to recover; only abort errors should terminate polling.
      } catch (error) {
        if (isAbortError(error)) throw error;
        return [];
  • Files reviewed: 19/21 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread python/packages/devui/frontend/src/services/api.ts Outdated
Comment thread python/packages/devui/frontend/src/services/api.ts Outdated
Keep collected spans across transient failures and enforce a six-second deadline across requests, response bodies, and delays. Move frontend tests out of Python test discovery and format the regenerated bundle for the required hooks.
@Saibernard
Saibernard deployed to github-app-auth September 11, 2026 00:21 — with GitHub Actions Active
@Saibernard
Saibernard deployed to github-app-auth September 11, 2026 00:30 — 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

4 participants