-
Notifications
You must be signed in to change notification settings - Fork 372
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
don't report CPU metrics if it's negative value #2538
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,9 @@ def is_active(self): | |
|
||
def get_tracked_metrics(self, **_): | ||
""" | ||
Retrieves the current value of the metrics tracked for this cgroup and returns them as an array | ||
Retrieves the current value of the metrics tracked for this cgroup and returns them as an array. | ||
|
||
Note: Agent won't track the metrics if the current cpu ticks less than previous value and returns empty array. | ||
""" | ||
raise NotImplementedError() | ||
|
||
|
@@ -241,11 +243,16 @@ def get_throttled_time(self): | |
return float(self._current_throttled_time - self._previous_throttled_time) / 1E9 | ||
|
||
def get_tracked_metrics(self, **kwargs): | ||
tracked = [ | ||
MetricValue(MetricsCategory.CPU_CATEGORY, MetricsCounter.PROCESSOR_PERCENT_TIME, self.name, self.get_cpu_usage()), | ||
] | ||
tracked = [] | ||
cpu_usage = self.get_cpu_usage() | ||
if cpu_usage >= float(0): | ||
tracked.append(MetricValue(MetricsCategory.CPU_CATEGORY, MetricsCounter.PROCESSOR_PERCENT_TIME, self.name, cpu_usage)) | ||
|
||
if 'track_throttled_time' in kwargs and kwargs['track_throttled_time']: | ||
tracked.append(MetricValue(MetricsCategory.CPU_CATEGORY, MetricsCounter.THROTTLED_TIME, self.name, self.get_throttled_time())) | ||
throttled_time = self.get_throttled_time() | ||
if cpu_usage >= float(0) and throttled_time >= float(0): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, very likely throttled time could have wrong value too. So, I decided not to report both. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we do not need to check for the 2 conditions, if the single condition cpu_usage < 0 is true, we should not report the 2 metrics There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, if cpu_usage < 0 is true then it won't check second condition. I added second condition for rare case. |
||
tracked.append(MetricValue(MetricsCategory.CPU_CATEGORY, MetricsCounter.THROTTLED_TIME, self.name, throttled_time)) | ||
|
||
return tracked | ||
|
||
|
||
|
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.
updating previous/current values happens inside these get functions on every poll, so no explicit logic needed to reset the values.