feat(agent): add structured zap logging to metal agent#164
Merged
Defilan merged 4 commits intodefilantech:mainfrom Feb 26, 2026
Merged
feat(agent): add structured zap logging to metal agent#164Defilan merged 4 commits intodefilantech:mainfrom
Defilan merged 4 commits intodefilantech:mainfrom
Conversation
Defilan
requested changes
Feb 22, 2026
Member
Defilan
left a comment
There was a problem hiding this comment.
Thanks for this, Matias! Structured logging for the Metal Agent is overdue. Really appreciate the fix. A couple of things before merge:
- Remove LogLevel from MetalAgentConfig as it's never read inside the agent package (level is consumed in main.go before injection)
- Please add a table-driven test for parseLogLevel()
- Optional: consider making logger a required param instead of variadic. Update tests to pass zap.NewNop().Sugar()
We'll squash-merge so the lint-fix commit folds in automatically.
305851e to
094ede8
Compare
Signed-off-by: Matías Insaurralde <matias@insaurral.de>
Signed-off-by: Matías Insaurralde <matias@insaurral.de>
094ede8 to
6d48448
Compare
This was referenced Feb 25, 2026
Merged
Closed
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.
What
fmt.Printflogging with structured zap logs in startup, runtime, and shutdown paths.--log-levelparsing and production zap logger initialization incmd/metal-agent/main.go.watcher,executor,registry) with no-op fallbacks for optional constructor usage.component,subsystem, namespace/name/port/pid/error) to improve observability and troubleshooting.Why
Metal agent logs were previously plain text and inconsistent across components. This change standardizes logging, enables configurable verbosity, and improves operational debugging with structured context.
How
cmd/metal-agent/main.govia a smallnewLogger(level)helper.parseLogLevelto map--log-level(debug|info|warn|error) into zapcore levels, defaulting toinfo.fmt.Printfstartup/runtime/shutdown logs with structuredSugaredLoggercalls (Infow,Warnw,Errorw,Debugw) and contextual fields.MetalAgentConfigto accept an injected logger and propagated scoped child loggers intowatcher,executor, andregistry(component/subsystemfields).zap.NewNop().Sugar()fallback when none is provided.cmd/metal-agent/main.goto wire this logger into controller-runtime (ctrl.SetLogger) so controller-runtime/client logs use the same config.Checklist
make testpasses locallymake lintpasses locallygit commit -s) per DCO