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

Copy link
Copy Markdown

Summary

Fixes #5806.

This makes Aspire traces available in the existing DevUI Traces tab. The aggregator now:

  • propagates a unique trace context to the selected agent service
  • captures the OpenAI response ID without changing the proxied response
  • retrieves the matching spans from the local Aspire Dashboard telemetry API
  • exposes those spans to the shared DevUI frontend
  • handles delayed span export, cancellation, dashboard failures, and concurrent responses

I also fixed three issues in the Aspire sample that prevented the current sample from starting cleanly: conflicting dashboard ports, AppHost target-framework discovery, and an Aspire Azure package-version mismatch.

Testing

  • 100/100 unit tests passed
  • Release package build passed with 0 warnings and 0 errors
  • Release AppHost sample build passed with 0 warnings and 0 errors
  • Frontend production build passed
  • Frontend lint completed with 0 errors
  • git diff --check passed

I tested streaming and non-streaming responses against a real Azure GPT-4.1 deployment. Both responses mapped to the correct four-span Aspire trace. I also verified that cancelling a response does not leave a stale trace mapping.

The live Azure deployment had capacity for one request, so the two-request live concurrency check was rate-limited. The regression suite covers 12 simultaneous responses and trace lookups, plus 100 parallel SSE response-ID captures.

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.

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

2 participants