[release/8.0] Dashboard should request log streams only when the user gestures to display them #3343
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.
Customer Impact
Currently the dashboard requests log streams for all application resources at the startup or shortly after. This is not efficient, especially for Containers, where each log stream is associated with a separate container orchestrator (CLI) running in the background.
If you have many projects and containers running in your app, these unnecessary background processes use resources on your machine.
Testing
I manually tested launching an app, switching between console logs. Ensuring that after no longer viewing a container's console logs, the docker logs process goes away.
Existing tests pass. Added new unit tests.
Risk
Medium-low. This changes how console logs are streamed from DCP to the AppHost to the Dashboard.
Change the AppHost to only subscribe to DCP's logs when there is a subscriber for the logs.
Fix #2789
Show logs
Remove the "StreamingLogger" because that causes subsequent subscribers to not see what was already written.
Fix duplicate logs issue by clearing out the backlog when the last subscriber leaves.
Fix existing tests for new functionality and add an additional test.
Only clear the backlog on containers and executables.
Move lock out of async iterator.
async IAsyncEnumerable
methods.Employ a 2nd loop that listens for both "has subscribers" and "logs available".
Simplify ResourceNotificationService.WatchAsync.
Fix test build
Address PR feedback
Microsoft Reviewers: Open in CodeFlow