Many telemetry commands improvements#14838
Merged
davidfowl merged 4 commits intorelease/13.2from Mar 2, 2026
Merged
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14838Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14838" |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the Aspire CLI telemetry commands’ console output (timestamps, resource naming/coloring, severity mapping, ordering) and adds targeted test coverage to keep the behavior stable across logs/spans/traces.
Changes:
- Updated CLI telemetry output formatting: local human-readable timestamps, consistent resource colors, replica-disambiguated resource names, severity derived from OTLP severity number, and chronological ordering for spans/traces.
- Refactored CLI telemetry output to consistently route through
IInteractionServiceand added new test suites forotel logs|spans|traces. - Shared infrastructure updates:
TimeProvider-based local-time formatting helpers, plus OTLP resource parsing support forservice.instance.id.
Reviewed changes
Copilot reviewed 35 out of 36 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Dashboard.Tests/TelemetryRepositoryTests/TelemetryRepositoryTests.cs | Adds test asserting spans are returned ordered by start time. |
| src/Aspire.Dashboard/Otlp/Storage/TelemetryRepository.Watchers.cs | Orders initial span snapshot chronologically in WatchSpansAsync. |
| tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs | Registers ResourceColorMap in CLI test DI. |
| src/Aspire.Cli/Program.cs | Registers ResourceColorMap in production DI. |
| src/Aspire.Cli/Commands/TelemetryLogsCommand.cs | Uses TimeProvider + severity-number labels + resource colors; outputs via IInteractionService. |
| src/Aspire.Cli/Commands/TelemetrySpansCommand.cs | Adds chronological ordering, local timestamps, resource colors; outputs via IInteractionService. |
| src/Aspire.Cli/Commands/TelemetryTracesCommand.cs | Changes trace table columns/content, sorts by time, resolves resource names (including replicas), colors resources. |
| src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs | Adds severity-number label mapping and resource-name resolution helpers; routes “no data” output through IInteractionService. |
| src/Aspire.Cli/Commands/LogsCommand.cs / src/Aspire.Cli/Commands/DescribeCommand.cs | Switches ResourceColorMap to DI-provided instance instead of per-command instantiation. |
| tests/Aspire.Cli.Tests/Commands/TelemetryLogsCommandTests.cs | New tests validating logs output formatting and replica naming. |
| tests/Aspire.Cli.Tests/Commands/TelemetrySpansCommandTests.cs | New tests validating spans output ordering/formatting and replica naming. |
| tests/Aspire.Cli.Tests/Commands/TelemetryTracesCommandTests.cs | New tests validating traces table columns/order and replica naming. |
| tests/Aspire.Cli.Tests/Commands/TelemetryTestHelper.cs | Adds shared telemetry test service setup (mock backchannel + mock HTTP). |
| tests/Aspire.Cli.Tests/Commands/TelemetryCommandTests.cs | Moves telemetry subcommand tests into dedicated suites; adds tests for new helper methods and time formatting. |
| src/Shared/FormatHelpers.cs | Adds FormatConsoleTime(TimeProvider, DateTime) and updates other format APIs to take TimeProvider. |
| src/Shared/TimeProviderExtensions.cs | Generalizes extensions from BrowserTimeProvider to TimeProvider. |
| src/Shared/Otlp/Serialization/OtlpResourceJson.cs | Adds GetServiceInstanceId() helper. |
| src/Shared/Otlp/OtlpHelpers.cs | Removes FormatNanoTimestamp (now replaced by console-time formatter). |
| src/Aspire.Cli/Resources/* (resx/xlf/designer) | Updates localized column headers for new traces table (Timestamp, Name). |
| src/Aspire.Cli/Aspire.Cli.csproj / src/Aspire.Dashboard/Aspire.Dashboard.csproj | Ensures shared FormatHelpers/TimeProviderExtensions are compiled into both projects. |
Files not reviewed (1)
- src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs: Language not supported
Comments suppressed due to low confidence (2)
src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs:269
- The XML doc on
GetSeverityTextsays 17-20=ERROR and 21-24=FATAL, but the method returns the abbreviationsFAILandCRITfor those ranges. Update the comment to reflect the actual output labels (and/or adjust the labels to match the documented names) so the documentation stays accurate.
/// <summary>
/// Gets abbreviated severity text for an OTLP severity number.
/// OTLP severity numbers: 1-4=TRACE, 5-8=DEBUG, 9-12=INFO, 13-16=WARN, 17-20=ERROR, 21-24=FATAL
/// </summary>
public static string GetSeverityText(int? severityNumber)
{
return severityNumber switch
{
>= 21 => "CRIT",
>= 17 => "FAIL",
>= 13 => "WARN",
>= 9 => "INFO",
>= 5 => "DBUG",
>= 1 => "TRCE",
_ => "-"
};
src/Aspire.Cli/Commands/TelemetryTracesCommand.cs:283
- When a trace ID is seen multiple times, the code updates
StartTimeNanoto the earliest span start time, but it does not update the associatedResource/FirstSpanName. This can produce rows where the displayed timestamp is for the earliest span, but the displayed name (resource + span name) comes from a different (later) span/resource. Consider updatingResourceandFirstSpanNamewhenever the earliest start time is replaced (or explicitly choose a consistent rule such as “root span name”).
if (traceInfos.TryGetValue(traceIdValue, out var info))
{
var maxDuration = info.Duration > duration ? info.Duration : duration;
// Track earliest start time across all spans in the trace
var earliestStart = info.StartTimeNano.HasValue && span.StartTimeUnixNano.HasValue
? (info.StartTimeNano.Value < span.StartTimeUnixNano.Value ? info.StartTimeNano : span.StartTimeUnixNano)
: info.StartTimeNano ?? span.StartTimeUnixNano;
traceInfos[traceIdValue] = (info.Resource, info.FirstSpanName, info.TraceId, earliestStart, maxDuration, info.SpanCount + 1, info.HasError || hasError);
}
else
{
traceInfos[traceIdValue] = (resourceName, span.Name ?? "", traceIdValue, span.StartTimeUnixNano, duration, 1, hasError);
Contributor
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22568125444 |
This was referenced Mar 2, 2026
davidfowl
approved these changes
Mar 2, 2026
mitchdenny
pushed a commit
that referenced
this pull request
Mar 5, 2026
* Many telemetry commands improvements * Clean up * Test cleanup * Test cleanup
Copilot AI
pushed a commit
that referenced
this pull request
Mar 10, 2026
* Many telemetry commands improvements * Clean up * Test cleanup * Test cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
HH:mm:ss.fff) instead of raw epoch values.INFO,WARN,FAIL, etc.) rather than relying on the sometimes-empty text field.TraceId | Resource | Duration | Spans | StatustoTimestamp | Name | Spans | Duration | Status, with Name combining resource, span name, and a short trace ID.IInteractionServiceinstead of directAnsiConsolecalls; new test suites added for all three telemetry commands.Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: