feat(log): add component supervision logging#16499
Draft
bartsmykla wants to merge 2 commits into
Draft
Conversation
Signed-off-by: Bart Smykla <bartek@smykla.com>
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.
Motivation
When a component exits with an error or panics, the logs say nothing useful: no component name, no stack trace, no indication of whether the process is still running. On-call has to read the code to figure out which goroutine died.
Implementation information
Added
runComponent, a supervision wrapper called from all three goroutine launch sites (non-leader start, runtime add, leader start). It:component startingandcomponent stoppedas bookend info lineserrChsuppressedcount so the operator can tell one crash from a cascadeerrChto avoid goroutine leaks aftermanager.Startreturns;errChis now buffered by 1 so the first error is never dropped even if a component panics beforeStartreaches its selectAdded
NamedComponentinterface so components can provide a stable log name; falls back to%Totherwise.The panic log level is
Error(not double-logged at the manager level since the error is returned fromStart). Normal exit errors are logged atInfofor the same reason - the error is also returned fromStart.