Skip to content

Reduce AppHost log noise for CLI connections and readiness checks - #20542

Merged
James Newton-King (JamesNK) merged 12 commits into
mainfrom
fix/quiet-auxiliary-backchannel-logging
Oct 3, 2026
Merged

James Newton-King (JamesNK) merged 12 commits into
mainfrom
fix/quiet-auxiliary-backchannel-logging

Conversation

@JamesNK

@JamesNK James Newton-King (JamesNK) commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Description

Reduce routine AppHost diagnostic noise produced by CLI connections and repeated dashboard readiness checks:

  • Move expected auxiliary backchannel connections, disconnects, and shutdown cancellations from Debug to Trace. Expected connection resets no longer attach exception stack traces; unexpected failures still log as errors.
  • Avoid emitting wait/finished Debug messages when a resource is already healthy and its ready event has completed. Pending waits and cancellation retain their behavior. Keep WatchAsync snapshot replay inside its try/finally so early disposal unsubscribes.
  • Filter routine Debug-level Microsoft.Extensions.Http.DefaultHttpClientFactory logs in all AppHost logging providers, including the CLI backchannel. Information, Warning, and Error logs remain visible to those providers and are still forwarded to the CLI.

No new dependencies or public API changes.

Related: #20552 tracks the separately investigated accumulation of aspire ps --follow processes and their dashboard URL requests; this PR reduces log noise but does not reduce those calls.

Validation

  • Focused ResourceNotificationTests and DistributedApplicationBuilderTests: 137 passed, one Unix-only test skipped on Windows. The HTTP-client test verifies that Debug entries are filtered globally while Information and higher remain available to both the backchannel and another logging provider.
  • Focused auxiliary backchannel shutdown/disconnect tests passed (2/2). The disconnect test accepts both expected EOF and connection-reset outcomes; it does not require a reset-specific path.
  • Started TestShop and exercised CLI resource restart, status, and log commands. The AppHost CLI log no longer contained routine auxiliary disconnect/cancellation entries; after five minutes idle the latest run produced no additional diagnostic log data. Four subsequent aspire describe calls produced four dashboard-URL RPC entries and no resource-readiness wait/finished entries.

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

@github-actions

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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20542

Or

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

@github-actions

This comment has been minimized.

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.

Copilot review overview

🟢 Approval recommended

The targeted logging changes match the stated intent and have focused regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Reduces routine auxiliary backchannel logging noise while preserving errors for unexpected failures.

Changes:

  • Moves expected connection lifecycle logs from Debug to Trace.
  • Omits exception details for expected connection resets.
  • Adds focused logging assertions.
File Description
src/​Aspire.Hosting/​Backchannel/​AuxiliaryBackchannelService.cs Lowers expected lifecycle logging verbosity.
tests/​Aspire.Hosting.Tests/​Backchannel/​AuxiliaryBackchannelTests.cs Verifies Trace-level cancellation and reset logs.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

This comment has been minimized.

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.

Copilot review overview

🟡 Changes recommended

The reset test can take the normal EOF path and therefore does not reliably verify exception-free connection-reset logging.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

Comment thread tests/Aspire.Hosting.Tests/Backchannel/AuxiliaryBackchannelTests.cs
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot September 28, 2026 10:25
@JamesNK James Newton-King (JamesNK) changed the title Reduce routine auxiliary backchannel log noise Reduce AppHost log noise for CLI connections and readiness checks Sep 28, 2026
@github-actions

This comment has been minimized.

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.

Copilot review overview

🟡 Changes recommended

The HTTP log filter is global and uses the wrong threshold, contradicting the intended provider-local suppression.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread src/Aspire.Hosting/DistributedApplicationBuilder.cs
@github-actions

This comment has been minimized.

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.

Copilot review overview

🟢 Approval recommended

The behavior changes are focused, consistent with the description, and supported by targeted regression tests.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@github-actions

This comment has been minimized.

Move routine client lifecycle events to Trace and avoid logging stack traces for expected connection resets. Assert the shutdown and disconnect log levels in focused tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
An abrupt socket close can complete StreamJsonRpc normally or surface as a connection reset. Check both disconnect paths stay at Trace without exceptions while ensuring no error is logged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep concise Debug messages when AppHost connections close during ps info and dashboard lookups, while retaining exception details for unexpected failures.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Ignore expected AppHost disconnects while continuing to watch remaining AppHosts. Keep Debug exceptions for unexpected RPC failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Propagate connection loss from legacy resource log streaming so follow commands report a stopped AppHost instead of treating disconnect as a successful end of logs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the existing GetResourceLogsAsync fallback behavior and remove its dedicated propagation test. Retain the shared backchannel disconnect classifier.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Share socket connection-reset classification between CLI telemetry followers and the Hosting auxiliary backchannel. Preserve error handling for invalid telemetry and unexpected transport failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

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.

Copilot review overview

🟡 Changes recommended

The documented telemetry-follow shutdown contract lacks coverage through the real CLI and HTTP transport path.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Files not reviewed (1)
  • src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs: Generated file

Comment thread src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs Outdated
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@mitchdenny Mitch Denny (mitchdenny) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, a few non blocking comments.

Comment thread src/Aspire.Cli/Commands/TelemetryLogsCommand.cs Outdated
Comment thread src/Aspire.Cli/README.md Outdated
Comment thread src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs
Add an optional error-handler overload and a disconnect-aware wrapper, update telemetry follow commands and tests, and remove unnecessary README detail.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Tests selector

51 / 98 PR test projects · 4 PR jobs, from 40 changed files.

Selected PR test projects (51 / 98)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Provisioning.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 45 of the 51 selected test projects come from a single change — src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs.

🔧 src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs (changed source)
→ 45 via the project graph

show 45

Aspire.Hosting.Analyzers.Tests (2 hops), Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.Azure.Kusto.Tests (2 hops), Aspire.Hosting.Azure.Provisioning.Tests (3 hops), Aspire.Hosting.Azure.Tests, Aspire.Hosting.Browsers.Tests (2 hops), Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests (2 hops), Aspire.Hosting.DevTunnels.Tests (2 hops), Aspire.Hosting.Docker.Tests (2 hops), Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.EntityFrameworkCore.Tests (2 hops), Aspire.Hosting.Foundry.Tests (2 hops), Aspire.Hosting.Garnet.Tests (2 hops), Aspire.Hosting.Go.Tests (2 hops), Aspire.Hosting.Java.Tests (2 hops), Aspire.Hosting.JavaScript.Tests (2 hops), Aspire.Hosting.Kafka.Tests (2 hops), Aspire.Hosting.Keycloak.Tests (2 hops), Aspire.Hosting.Kubernetes.Tests (2 hops), Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests (2 hops), Aspire.Hosting.MongoDB.Tests (2 hops), Aspire.Hosting.MySql.Tests (2 hops), Aspire.Hosting.Nats.Tests (2 hops), Aspire.Hosting.OpenAI.Tests (2 hops), Aspire.Hosting.Oracle.Tests (2 hops), Aspire.Hosting.Orleans.Tests (2 hops), Aspire.Hosting.PostgreSQL.Tests (2 hops), Aspire.Hosting.Python.Tests (2 hops), Aspire.Hosting.Qdrant.Tests (2 hops), Aspire.Hosting.RabbitMQ.Tests (2 hops), Aspire.Hosting.Redis.Tests (2 hops), Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests (2 hops), Aspire.Hosting.Seq.Tests (2 hops), Aspire.Hosting.SqlServer.Tests (2 hops), Aspire.Hosting.Testing.Tests (2 hops), Aspire.Hosting.Valkey.Tests (2 hops), Aspire.Hosting.Yarp.Tests (2 hops), Aspire.Playground.Tests

🧪 tests/Aspire.Hosting.Tests/Backchannel/AuxiliaryBackchannelTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests
→ 3 via the project graph: Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.Radius.Tests

📦 affected project Aspire.Cli
→ 1 test: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.Tests/Backchannel/BackchannelDisconnectHelpersTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Commands/PsCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Commands/TelemetryFollowTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/TestServices/FaultingReadStream.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/TestServices/TestAppHostAuxiliaryBackchannel.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Hosting.Tests/DistributedApplicationBuilderTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

🧪 tests/Aspire.Hosting.Tests/ResourceNotificationTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

🧪 tests/Aspire.Hosting.Tests/Utils/SocketExceptionHelpersTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Cli
extension-e2e • src/Aspire.Cli/Aspire.Cli.csproj, src/Aspire.Cli/Backchannel/AppHostCliBackchannel.cs, src/Aspire.Cli/Backchannel/BackchannelDisconnectHelpers.cs, src/Aspire.Cli/Commands/AppHostFollowDisconnectHelpers.cs, src/Aspire.Cli/Commands/DescribeCommand.cs, src/Aspire.Cli/Commands/LogsCommand.cs, src/Aspire.Cli/Commands/PsCommand.cs, src/Aspire.Cli/Commands/RunCommand.cs, src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs, src/Aspire.Cli/Commands/TelemetryLogsCommand.cs, src/Aspire.Cli/Commands/TelemetrySpansCommand.cs, src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs, src/Aspire.Cli/Resources/TelemetryCommandStrings.resx, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.cs.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.de.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.es.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.fr.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.it.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.ja.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.ko.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.pl.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.pt-BR.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.ru.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.tr.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.zh-Hans.xlf, src/Aspire.Cli/Resources/xlf/TelemetryCommandStrings.zh-Hant.xlf, src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs, src/Aspire.Hosting/Aspire.Hosting.csproj, src/Aspire.Hosting/Backchannel/AuxiliaryBackchannelService.cs, src/Aspire.Hosting/DistributedApplicationBuilder.cs
• affected project Aspire.Cli
polyglot • affected project Aspire.Cli
• affected project Aspire.Hosting.Azure.Provisioning
typescript-api-compat affected project Aspire.Cli

Selection computed for commit 41faba7.

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.

Copilot review overview

🟢 Approval recommended

Source review found no blocking issues, and focused regression coverage addresses the changed behavior.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Files not reviewed (1)
  • src/Aspire.Cli/Resources/TelemetryCommandStrings.Designer.cs: Generated file

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@JamesNK
James Newton-King (JamesNK) merged commit 9c2163a into main Oct 3, 2026
587 of 591 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Oct 3, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #1819

Generated by PR Documentation Check · copilot · auto · 91.2 AIC · ⌖ 15.7 AIC · ⊞ 20.3K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1819 targeting release/17.0.

Triggered signals: cli_command_file_changed (DescribeCommand.cs, LogsCommand.cs, PsCommand.cs, RunCommand.cs, TelemetryLogsCommand.cs, TelemetrySpansCommand.cs all changed), cli_resource_strings_changed (TelemetryCommandStrings.resx adds DashboardConnectionLost), pr_body_has_cli_flag_mention (PR body references aspire ps --follow). The diff adds a new user-visible behavior to aspire otel logs --follow and aspire otel spans --follow: when the dashboard connection closes mid-stream (expected disconnect), the command now prints "The connection to the dashboard was lost." to stderr and exits successfully instead of surfacing a raw I/O error, per TelemetryCommandHelpers.ReadLinesWithDisconnectHandlingAsync and TelemetryFollowTests. Updated --follow option descriptions in aspire-otel-logs.mdx and aspire-otel-spans.mdx to document this message and exit behavior. No doc changes were needed for aspire ps/aspire describe/aspire run since their changes only reduce internal log noise on already-silent code paths (no new user-facing strings or options there).

Note

This draft PR needs human review before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants