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.
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.
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.
| 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.
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.
Should we set logsFlagSet as follows?
logs.AddFlags(logsFlagSet, logs.SkipLoggingConfigurationFlags())
|
Updated.Use default featuregate |
Thanks~, let me take a look. |
045961d to
8acfe9f
Compare
|
Thanks |
|
Looks good to me, but would you mind squashing the commits? https://karmada.io/docs/next/contributor/github-workflow/#squash-commits |
7fee772 to
c9555f9
Compare
|
@RainbowMango sure and sorry for the dely.updated now |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: zhoujinyu <2319109590@qq.com>
c9555f9 to
828acab
Compare
|
@RainbowMango lint has been fixed,i have tested it in my own repo and ci should pass now.a LGTM label is needed.Thanks for your review :) |
|
/lgtm |
|
/kind feature |




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?: