-
Notifications
You must be signed in to change notification settings - Fork 13
Add idle time in cpu utilization attributes, revise cpu utilization check, add some helpers to Counter #294
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?
Conversation
- log error explanations before returning default values in cpu utilization - WIP: wait during the cpu utilization check if the gathered points are not enough apart for the range. now the checks will return a valid value instead of zeros, causing problems rn
- add counter.GetFirst() to get the oldest value of the counter - add counter.checkRetenton() to see if the designed counter retention time is adequate - fix counter.AvgForDuration function possibly including the latest value twice in its calculation - add tests for the new counter functions - check_cpu_utilization -> check ahread if the counter can fit the requested period - check_cpu_utlization -> print logs if the counter is not filled up enough for the requested period - check_cpu_utilization -> print logs about after looking for a value in the past according to the requested period
sni
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.
looks good, i have only some minor notes
| // round retention time to a multiple of interval | ||
| retention := int64(math.Ceil(float64(retentionMilli)/float64(intervalMilli))) * intervalMilli | ||
| size := retention / intervalMilli | ||
| // round retentionMili time to a multiple of interval |
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.
typo Milli
| for seen := int64(0); seen <= c.size; seen++ { | ||
|
|
||
| //nolint:intrange // tracking the seen elements is easier | ||
| for seen := int64(0); seen < c.size; seen++ { |
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.
what the linter suggested here is:
for range c.size {
which is simpler and cleaner.
| if val.UnixMilli < useAfterUnix { | ||
| return last | ||
| var previouslyComparedValue *Value | ||
| for valuesSeen := int64(0); valuesSeen <= c.size; valuesSeen++ { |
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 simple for range c.size should work here as well.
| } | ||
|
|
||
| if err = counter.CheckRetention(time.Second*time.Duration(scanLookBack64), 0); err != nil { | ||
| log.Tracef("cpuinfo counter cant hold the query range: %s", err.Error()) |
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.
typo: cant
| } | ||
|
|
||
| if err = counter.CheckRetention(time.Second*time.Duration(scanLookBack64), 100); err != nil { | ||
| log.Warnf("cpuinfo counter cant hold the query range even when extended: %s", err.Error()) |
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.
same
The cpu utilization check will always return the default value, if it cannot get proper values from the cpuinfo counter.
It will complain to the logs better.
By default I set the acceptablePercentage to %50. If there is a check of 100s, and the values I get from the counter is currently < 50s apart, it will complain differently to the log. It will still return the calculated values for that <50s period though. If its above >50s it is deemed representative.