Diskstats/size bytes ci fix#9
Conversation
Add the standard Apache license block to kernelmodules and systemdservices collectors, and separate the local module import group in node_exporter.go. Co-authored-by: Cursor <cursoragent@cursor.com>
WalkthroughThe PR adds a Changesdiskstats size_bytes label
kernelmodules collector
Sequence Diagram(s)sequenceDiagram
participant Prometheus
participant kernelModulesCollector
participant procModules as /proc/modules
Prometheus->>kernelModulesCollector: Update(ch)
kernelModulesCollector->>procModules: Open and scan lines
loop per module line
procModules-->>kernelModulesCollector: name, size, refcount, state fields
kernelModulesCollector->>kernelModulesCollector: parse size/refcount, map state string→numeric
kernelModulesCollector->>Prometheus: emit state gauge (module label)
kernelModulesCollector->>Prometheus: emit size_bytes gauge (module label)
kernelModulesCollector->>Prometheus: emit refcount gauge (module label)
end
kernelModulesCollector-->>Prometheus: return scanner.Err()
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
collector/kernelmodules_linux.go (1)
79-80: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winIncrease scanner token limit to avoid scrape-time failure on long
/proc/moduleslines.
bufio.Scanneruses a 64 KiB token cap by default. If a module line exceeds that, scanning aborts andUpdatereturns an error (collector scrape failure). Set a larger buffer explicitly at scanner initialization.Suggested patch
scanner := bufio.NewScanner(file) + // /proc/modules lines are typically short, but raise the token limit defensively + // so one oversized line doesn't fail the entire collector scrape. + scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024) for scanner.Scan() {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@collector/kernelmodules_linux.go` around lines 79 - 80, The bufio.Scanner at the scanner initialization point in kernelmodules_linux.go uses the default 64 KiB token limit, which can cause scanning to fail if lines in /proc/modules exceed this size and result in collector scrape errors. After creating the scanner with bufio.NewScanner, call the scanner.Buffer method to set a larger maximum token size to accommodate longer module lines and prevent scrape-time failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@collector/kernelmodules_linux.go`:
- Around line 79-80: The bufio.Scanner at the scanner initialization point in
kernelmodules_linux.go uses the default 64 KiB token limit, which can cause
scanning to fail if lines in /proc/modules exceed this size and result in
collector scrape errors. After creating the scanner with bufio.NewScanner, call
the scanner.Buffer method to set a larger maximum token size to accommodate
longer module lines and prevent scrape-time failures.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 95fd258c-62a1-4aed-8584-285e6bbd47a7
📒 Files selected for processing (6)
collector/diskstats_linux.gocollector/diskstats_linux_test.gocollector/fixtures/sys.ttarcollector/kernelmodules_linux.gocollector/systemdservices_linux.gonode_exporter.go
👮 Files not reviewed due to content moderation or server errors (1)
- collector/fixtures/sys.ttar
Summary by CodeRabbit
size_byteslabel for block devices.