Refactor CLI telemetry JSON output to match MCP tool format#16523
Refactor CLI telemetry JSON output to match MCP tool format#16523
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16523Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16523" |
There was a problem hiding this comment.
Pull request overview
Refactors the CLI telemetry --format json output to match the JSON shape produced by the dashboard MCP tools/AI helpers (camelCase properties, null stripping, full IDs, and simplified dashboardUrl), and consolidates the serialization logic into SharedAIHelpers so both surfaces stay aligned.
Changes:
- Centralized span/log/trace JSON serialization in
SharedAIHelpersand updated CLI commands to deserialize OTLP JSON and re-emit the shared DTO JSON. - Updated JSON schema details (camelCase,
dashboardUrlstring, fulltraceId/spanId, null property stripping) and adjusted MCP + CLI tests accordingly. - Added
PromptContext.ProcessValuesto disable token-saving/dedup processing for CLI JSON output.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/Mcp/ListTracesToolTests.cs | Updates assertions for camelCase + full IDs + dashboardUrl. |
| tests/Aspire.Cli.Tests/Mcp/ListStructuredLogsToolTests.cs | Updates assertions for camelCase fields and dashboardUrl. |
| tests/Aspire.Cli.Tests/Commands/TelemetryTracesCommandTests.cs | Adds/updates CLI JSON output validation for traces. |
| tests/Aspire.Cli.Tests/Commands/TelemetryTestHelper.cs | Adds shared JSON pretty-printing helper for tests. |
| tests/Aspire.Cli.Tests/Commands/TelemetrySpansCommandTests.cs | Adds/updates CLI JSON output validation for spans. |
| tests/Aspire.Cli.Tests/Commands/TelemetryLogsCommandTests.cs | Adds/updates CLI JSON output validation for logs. |
| src/Shared/ConsoleLogs/SharedAIHelpers.cs | Adds shared CLI-oriented JSON serialization helpers; switches to camelCase properties and strips nulls. |
| src/Shared/ConsoleLogs/PromptContext.cs | Adds ProcessValues flag so CLI can bypass value processing/dedup. |
| src/Aspire.Dashboard/Model/Assistant/AIHelpers.cs | Changes resource graph JSON to emit dashboardUrl instead of dashboard_link. |
| src/Aspire.Cli/Commands/TelemetryTracesCommand.cs | JSON mode now deserializes OTLP response and re-serializes via shared helpers. |
| src/Aspire.Cli/Commands/TelemetrySpansCommand.cs | Same as traces: JSON mode re-emits shared helper JSON. |
| src/Aspire.Cli/Commands/TelemetryLogsCommand.cs | Same approach for logs; threads “dashboardUrl” into streaming/snapshot JSON output. |
…RL for dashboardUrl links
mitchdenny
left a comment
There was a problem hiding this comment.
Reviewed 12 changed files. Found 1 issue (naming inconsistency).
mitchdenny
left a comment
There was a problem hiding this comment.
Reviewed 12 changed files. Found 1 naming inconsistency issue.
|
🎬 CLI E2E Test Recordings — 76 recordings uploaded (commit View all recordings
📹 Recordings uploaded automatically from CI run #25090901923 |
|
No documentation PR is required for this change. The existing The PR is an internal refactoring that aligns JSON serialization with the MCP tool format — a breaking change to the JSON shape, but with no prior documentation to revise.
|
Description
The current JSON format matches OTLP/JSON. But that JSON is very verbose, doesn't include all information, and doesn't have a way to represent traces. New JSON should work better with AI agents.
Refactor CLI telemetry JSON output to align with the MCP tool format used by the dashboard AI helpers. This is a breaking change to JSON returned from telemetry commands.
Changes
SerializeSpansToJson,SerializeLogsToJson,SerializeTracesToJson, andSerializeTraceToJsontoSharedAIHelpersso CLI commands produce identical JSON to MCP toolsPromptContext.ProcessValuesflag: Whenfalse,AddValuereturns input unchanged (CLI doesn't need AI token-limiting deduplication)StripNullPropertiesremoves null-valued properties from JSON objectsdashboardUrlsimplification: ReplaceddashboardLinkobject ({url, text}) with a directdashboardUrlstring in bothSharedAIHelpersandAIHelpersspanIdandtraceIdare no longer shortened viaToShortenedIdin JSON outputGetTraceDtoreusesGetSpanDto: Eliminated duplicated span conversion logic; inner trace spans retaintraceIdandtimestampFormatJsontoTelemetryTestHelper; added attributes to span/trace/log test dataChecklist