-
Notifications
You must be signed in to change notification settings - Fork 7
feat:structured logging #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat:structured logging #29
Conversation
|
Welcome @FAUST-BENCHOU! It looks like this is your first PR to karmada-io/multicluster-cloud-provider 🎉 |
Summary of ChangesHello @FAUST-BENCHOU, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully adds support for structured logging by integrating the k8s.io/component-base/logs package. The implementation correctly introduces the necessary options, command-line flags, and initialization logic to enable formats like JSON, which is a significant improvement for observability.
To fully capitalize on this new feature, I recommend a follow-up effort to refactor existing logging statements. For instance, calls like klog.Infof and klog.Errorf could be converted to their structured counterparts, klog.InfoS and klog.ErrorS. A good example is the version logging in app/manager.go, which could be changed from klog.Infof("multicluster-controller-manager version: %s", version.Get()) to klog.InfoS("multicluster-controller-manager version", "version", version.Get()). This would log the version details as a structured object, making the logs much easier to parse and query automatically. Adopting this pattern throughout the codebase would greatly enhance the utility of the structured logging feature you've introduced.
|
Thanks~ |
XiShanYongYe-Chang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @FAUST-BENCHOU
I noticed a few differences compared to the changes made in the Karmada main repository. I want to confirm whether these also need to be modified.
flush log in the main function:
// Ensure any buffered log entries are flushed
logs.FlushLogs()and other questions in the comments.
app/manager.go
Outdated
| func Run(ctx context.Context, opts *options.MultiClusterControllerManagerOptions, cloudProvider multiclusterprovider.Interface) error { | ||
| // Apply structured logging configuration | ||
| // This must be called as early as possible to apply the logging format | ||
| if err := logsapi.ValidateAndApply(opts.Logging, nil); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValidateAndApply has been added to the PersistentPreRunE function under cmd, and some feature gates have been included. Do we also need the same setup and provide these feature gates?
| // Set logging flags | ||
| logsFlagSet := fss.FlagSet("logs") | ||
| klogflag.Add(logsFlagSet) | ||
| // Add logging configuration flags including --logging-format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we set logsFlagSet as follows?
logs.AddFlags(logsFlagSet, logs.SkipLoggingConfigurationFlags())
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Updated.Use default featuregate |
Thanks~, let me take a look. |
Signed-off-by: zhoujinyu <[email protected]>
045961d to
8acfe9f
Compare
Signed-off-by: zhoujinyu <[email protected]>
|
Thanks |
RainbowMango
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/assign




What type of PR is this?
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #26
Special notes for your reviewer:
You can use logging-format like below
Does this PR introduce a user-facing change?: