add CPU throttling metrics from cgroup cpu.stat#112
Draft
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 1 file
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="process_metrics_linux.go">
<violation number="1" location="process_metrics_linux.go:474">
P2: writeProcessCpuThrottleMetrics dereferences ctms without guarding against the nil return from getCgroupCpuStats, which can panic when no cgroup CPU stats are available.</violation>
<violation number="2" location="process_metrics_linux.go:476">
P2: `process_cgroup_cpu_throttled_seconds_total` reports non-second units (micro/milliseconds). Convert throttled_time to seconds (or store microseconds consistently and divide by 1e6 when writing) to avoid unit mismatch.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| } | ||
| WriteGaugeUint64(w, "process_cgroup_cpu_periods_total", ctms.nrPeriods) | ||
| WriteGaugeUint64(w, "process_cgroup_cpu_throttled_periods_total", ctms.nrThrottled) | ||
| WriteGaugeUint64(w, "process_cgroup_cpu_throttled_seconds_total", ctms.throttledTime) |
Contributor
There was a problem hiding this comment.
P2: process_cgroup_cpu_throttled_seconds_total reports non-second units (micro/milliseconds). Convert throttled_time to seconds (or store microseconds consistently and divide by 1e6 when writing) to avoid unit mismatch.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At process_metrics_linux.go, line 476:
<comment>`process_cgroup_cpu_throttled_seconds_total` reports non-second units (micro/milliseconds). Convert throttled_time to seconds (or store microseconds consistently and divide by 1e6 when writing) to avoid unit mismatch.</comment>
<file context>
@@ -403,6 +420,62 @@ func readPSITotals(cgroupPath, statsName string) (uint64, uint64, error) {
+ }
+ WriteGaugeUint64(w, "process_cgroup_cpu_periods_total", ctms.nrPeriods)
+ WriteGaugeUint64(w, "process_cgroup_cpu_throttled_periods_total", ctms.nrThrottled)
+ WriteGaugeUint64(w, "process_cgroup_cpu_throttled_seconds_total", ctms.throttledTime)
+}
+
</file context>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #112 +/- ##
==========================================
- Coverage 88.68% 87.02% -1.67%
==========================================
Files 12 12
Lines 1388 1449 +61
==========================================
+ Hits 1231 1261 +30
- Misses 106 132 +26
- Partials 51 56 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix VictoriaMetrics/VictoriaMetrics#10430
Summary by cubic
Expose CPU throttling metrics from cgroup cpu.stat for the current process. Works with cgroup v1 and v2 and only emits metrics when the cgroup CPU controller is enabled (addresses #10430).
Written for commit 085d533. Summary will update on new commits.