-
Notifications
You must be signed in to change notification settings - Fork 182
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
Fixed Consistent Log Levelling #1490
Conversation
🤖 SeineSailor Here is a concise summary of the pull request changes: Summary: This pull request primarily focuses on improving logging and error handling in the codebase. The key modifications include:
Impact: These changes improve the overall logging experience, providing more informative messages without affecting the external interface or behavior of the code. Observations:
Suggestions for improvement:
|
d8849d7
to
14c8f70
Compare
1400dc5
to
77d4005
Compare
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.
A few things in the rebase to fix up.
I've left some comments for small changes.
I think it's mostly when we're using InfoS
(not preceeded by V(n)
) with err
as one of the values that we'd be better off using ErrorS
.
That and some small changes to grammar or messages.
cmd/exporter/exporter.go
Outdated
func finalizing() { | ||
stack := "exit stack: \n" + string(debug.Stack()) | ||
klog.InfoS(stack) | ||
exitCode := 10 | ||
klog.Infoln(finishingMsg) | ||
klog.FlushAndExit(klog.ExitFlushTimeout, exitCode) | ||
} | ||
|
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.
This can go. It was removed in #1503
cmd/exporter/exporter.go
Outdated
klog.Infoln(finishingMsg) | ||
klog.FlushAndExit(klog.ExitFlushTimeout, exitCode) | ||
} | ||
|
||
func main() { | ||
start := time.Now() | ||
klog.InitFlags(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.
This registers the flags - you can see this from running kepler -help
cmd/exporter/exporter.go
Outdated
// for log debugging issues | ||
flag.Set("logtostderr", "false") | ||
flag.Set("alsologtostderr", "true") | ||
flag.Set("log_dir", "/root/kepler/kepler_prime/kepler_debug/logs1.txt") |
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.
I don't think it's safe to assume this directory exists everywhere.
I'd probably remove it.
cmd/exporter/exporter.go
Outdated
func main() { | ||
start := time.Now() | ||
klog.InitFlags(nil) | ||
|
||
// for log debugging issues |
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.
Is this setting defaults that are different to what klog provides?
cmd/exporter/exporter.go
Outdated
flag.Set("alsologtostderr", "true") | ||
flag.Set("log_dir", "/root/kepler/kepler_prime/kepler_debug/logs1.txt") | ||
flag.Set("v", "2") | ||
|
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.
Have you tested that the log level can still be correctly overridden?
@@ -0,0 +1,59 @@ | |||
/* |
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.
I believe this file was also deleted
@@ -66,3 +66,15 @@ func (c *ContainerStats) String() string { | |||
c.ContainerID, | |||
) + c.Stats.String() | |||
} | |||
|
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.
As was this function
pkg/collector/stats/utils.go
Outdated
} | ||
|
||
// cgroup metric are deprecated and will be removed later |
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.
This was also removed in a recent PR
pkg/collector/stats/utils.go
Outdated
@@ -104,7 +110,7 @@ func GetNodeName() string { | |||
func getCPUArch() string { | |||
arch, err := getCPUArchitecture() | |||
if err == nil { | |||
klog.V(3).Infof("Current CPU architecture: %s", arch) | |||
klog.V(3).InfoS("Current CPU architecture:", "arch", arch) |
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.
klog.V(3).InfoS("Current CPU architecture:", "arch", arch) | |
klog.V(3).InfoS("Discovered CPU architecture", "arch", arch) |
pkg/config/config.go
Outdated
klog.V(5).InfoS("Configuration value", "ENABLE_EBPF_CGROUPID", EnabledEBPFCgroupID) | ||
klog.V(5).InfoS("Configuration value", "ENABLE_GPU", EnabledGPU) | ||
klog.V(5).InfoS("Configuration value", "ENABLE_QAT", EnabledQAT) | ||
klog.V(5).InfoS("Configuration value", "ENABLE_PROCESS_METRICS", EnableProcessStats) | ||
klog.V(5).InfoS("Configuration value", "EXPOSE_HW_COUNTER_METRICS", ExposeHardwareCounterMetrics) | ||
klog.V(5).InfoS("Configuration value", "EXPOSE_CGROUP_METRICS", ExposeCgroupMetrics) | ||
klog.V(5).InfoS("Configuration value", "EXPOSE_IRQ_COUNTER_METRICS", ExposeIRQCounterMetrics) |
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.
You can make this all one line:
klog.V(5).InfoS("Configuration value", "ENABLE_EBPF_CGROUPID", EnabledEBPFCgroupID) | |
klog.V(5).InfoS("Configuration value", "ENABLE_GPU", EnabledGPU) | |
klog.V(5).InfoS("Configuration value", "ENABLE_QAT", EnabledQAT) | |
klog.V(5).InfoS("Configuration value", "ENABLE_PROCESS_METRICS", EnableProcessStats) | |
klog.V(5).InfoS("Configuration value", "EXPOSE_HW_COUNTER_METRICS", ExposeHardwareCounterMetrics) | |
klog.V(5).InfoS("Configuration value", "EXPOSE_CGROUP_METRICS", ExposeCgroupMetrics) | |
klog.V(5).InfoS("Configuration value", "EXPOSE_IRQ_COUNTER_METRICS", ExposeIRQCounterMetrics) | |
klog.V(5).InfoS("Configuration values", "ENABLE_EBPF_CGROUPID", EnabledEBPFCgroupID, "ENABLE_GPU", EnabledGPU, "ENABLE_QAT", EnabledQAT,"ENABLE_PROCESS_METRICS", EnableProcessStats, "EXPOSE_HW_COUNTER_METRICS", ExposeHardwareCounterMetrics, "EXPOSE_CGROUP_METRICS", ExposeCgroupMetrics, "EXPOSE_IRQ_COUNTER_METRICS", ExposeIRQCounterMetrics) |
@PalmPalm7 when you've fixed the issues with the rebase, you might want to run |
Thank you for the Review Dave, I'll make changes to ensure they are properly formatted. |
Edit: Have finished consistent log leveling issue.
Made changes to exisisting codebase with structured logs from format logs. Github issue ref.
Added logging kepler with klog section on dev/README.md, see here.