Skip to content

Fix LogsCommand to sort results by timestamp#14645

Merged
JamesNK merged 2 commits into
release/13.2from
jamesnk/logscommand-timestamp-sorting
Feb 24, 2026
Merged

Fix LogsCommand to sort results by timestamp#14645
JamesNK merged 2 commits into
release/13.2from
jamesnk/logscommand-timestamp-sorting

Conversation

@JamesNK

@JamesNK JamesNK commented Feb 24, 2026

Copy link
Copy Markdown
Member

Description

Fixes #14646

Follow up to #14632. Logs for multiple resources weren't sorted by timestamp across resources

Changes:

  • Get logs for all resources in app host
  • Logs are fetched in parallel to improve performance
  • Add logs sorting in LogEntries collection in CLI
  • Refactored GetResourceLogsAsync to not be a mess of branches

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions

github-actions Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14645

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14645"

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

Updates the Aspire CLI logs command so that when aggregating logs from multiple resources, the output is sorted globally by timestamp (follow-up to #14632), and adjusts unit tests to validate the new ordering.

Changes:

  • Refactors LogsCommand to parse log lines into LogEntry objects and emit results sorted by timestamp.
  • Updates JSON and text output paths to use the parsed entries (including resolved resource prefixes).
  • Revises LogsCommandTests expectations and test data to verify cross-resource timestamp sorting.

Reviewed changes

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

File Description
src/Aspire.Cli/Commands/LogsCommand.cs Refactors log collection/output to sort entries by timestamp across resources.
tests/Aspire.Cli.Tests/Commands/LogsCommandTests.cs Updates tests and fixtures to assert the new timestamp-sorted behavior.

Comment thread src/Aspire.Cli/Commands/LogsCommand.cs
Comment thread tests/Aspire.Cli.Tests/Commands/LogsCommandTests.cs
Comment thread src/Aspire.Cli/Commands/LogsCommand.cs
@github-actions

github-actions Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit 887b903:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AgentInitCommand_WithMalformedMcpJson_ShowsErrorAndExitsNonZero ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateStartWaitAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording

📹 Recordings uploaded automatically from CI run #22346761059

@davidfowl

Copy link
Copy Markdown
Contributor

aspire logs still slow

@IEvangelist

Copy link
Copy Markdown
Member

aspire logs still slow

This recording seems to not have that 5+s delay you were seeing: https://asciinema.org/a/t1K6ivY4O0yOFyrL

@davidfowl

Copy link
Copy Markdown
Contributor

Hmmm, let me verify I am using the right one

@davidfowl

Copy link
Copy Markdown
Contributor

➜ aspire --version
13.3.0-pr.14645.g887b9030

@davidfowl

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-02-24.103754.mp4

@JamesNK

JamesNK commented Feb 24, 2026

Copy link
Copy Markdown
Member Author

It's much faster than it use to be for multiple resources. Now logs are fetched in parallel. 5 seconds vs 20+ seconds.

I think the delay at this point is coming from getting logs from DCP.

How about:

  1. I add a "getting logs" status in console UI so you see it doing something rather than a blank delay.
  2. DCP folks look at perf of getting logs.

@davidfowl @karolz-ms @danegsta

@davidfowl

Copy link
Copy Markdown
Contributor

Merge this PR, lets file a follow up.

@JamesNK
JamesNK merged commit 0b99806 into release/13.2 Feb 24, 2026
346 checks passed
@JamesNK
JamesNK deleted the jamesnk/logscommand-timestamp-sorting branch February 24, 2026 23:04
@dotnet-policy-service dotnet-policy-service Bot added this to the 13.2 milestone Feb 24, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants