Skip to content

add CPU throttling metrics from cgroup cpu.stat#112

Draft
JayiceZ wants to merge 10 commits into
masterfrom
issue-10430
Draft

add CPU throttling metrics from cgroup cpu.stat#112
JayiceZ wants to merge 10 commits into
masterfrom
issue-10430

Conversation

@JayiceZ

@JayiceZ JayiceZ commented Feb 16, 2026

Copy link
Copy Markdown

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).

  • New Features
    • Added metrics: process_cgroup_cpu_periods_total, process_cgroup_cpu_throttled_periods_total, process_cgroup_cpu_throttled_seconds_total.
    • Auto-detects v1/v2 cpu.stat and parses nr_periods, nr_throttled, and throttled time; converts to seconds and skips metrics if the CPU controller isn’t enabled.

Written for commit 085d533. Summary will update on new commits.

@JayiceZ
JayiceZ marked this pull request as draft February 16, 2026 06:18

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread process_metrics_linux.go Outdated
Comment thread process_metrics_linux.go Outdated
@codecov

codecov Bot commented Feb 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.26437% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.00%. Comparing base (e60b57c) to head (84e7c97).

Files with missing lines Patch % Lines
process_metrics_linux.go 71.26% 18 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #112      +/-   ##
==========================================
- Coverage   87.96%   87.00%   -0.96%     
==========================================
  Files          12       12              
  Lines        1437     1524      +87     
==========================================
+ Hits         1264     1326      +62     
- Misses        119      137      +18     
- Partials       54       61       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JayiceZ
JayiceZ marked this pull request as ready for review March 2, 2026 05:27

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@JayiceZ
JayiceZ marked this pull request as draft March 2, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CPU throttling metrics from cgroup cpu.stat (quota throttling proof)

1 participant