Skip to content

Expose disk size as size_bytes label on node_disk_info#7

Merged
anulika-asama merged 2 commits into
masterfrom
diskstats/size
Jun 23, 2026
Merged

Expose disk size as size_bytes label on node_disk_info#7
anulika-asama merged 2 commits into
masterfrom
diskstats/size

Conversation

@anulika-asama

@anulika-asama anulika-asama commented Jun 23, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Disk information metrics now include a size_bytes label, showing each device’s size in bytes (left empty when size information isn’t available).
  • Bug Fixes

    • Updated sysfs fixtures and test expectations to reflect the new disk size label and label ordering.
  • Documentation

    • Added Apache 2.0 license headers to the Linux kernel modules and systemd services collectors.
  • Chores

    • Minor formatting cleanup in the main entrypoint import block.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f0d16f97-0f2b-423b-9d66-eb9e92886536

📥 Commits

Reviewing files that changed from the base of the PR and between f86d343 and 459ebf2.

📒 Files selected for processing (3)
  • collector/kernelmodules_linux.go
  • collector/systemdservices_linux.go
  • node_exporter.go
✅ Files skipped from review due to trivial changes (3)
  • collector/kernelmodules_linux.go
  • node_exporter.go
  • collector/systemdservices_linux.go

Walkthrough

node_disk_info gains a new size_bytes label. The Update method reads per-device block size from sysfs via SysBlockDeviceSize, converts it to a decimal string (empty on missing entries), and passes it to the metric. Test expectations and sysfs fixtures are updated to match.

Changes

Add size_bytes label to node_disk_info

Layer / File(s) Summary
size_bytes label contract and implementation
collector/diskstats_linux.go
infoDesc label list gains size_bytes; Update calls c.fs.SysBlockDeviceSize(dev), logs debug on non-ENOENT errors, converts the result to a base-10 string, and passes it to MustNewConstMetric.
Fixture updates and test expectations
collector/fixtures/sys.ttar, collector/diskstats_linux_test.go
Adds sys/block/sda/size (1953525168) to the sysfs fixture, repositions NVMe entries (nvme0c0n0/size, serial, state) to correct archive order, and updates expected node_disk_info samples to include the size_bytes label.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐇 A bunny checked sysfs one fine afternoon,
Found block sizes hiding — reported them soon!
size_bytes now shines in the info metric bright,
Each disk's true dimensions brought into the light.
Hops of delight for each sector and byte! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a size_bytes label to the node_disk_info metric to expose disk size, which is the primary objective of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch diskstats/size

Comment @coderabbitai help to get the list of available commands.

@anulika-asama anulika-asama merged commit 6e3d3c1 into master Jun 23, 2026
19 of 21 checks passed
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.

Node-exporter bug - expose the size of the disk in node_disk_info metrics

1 participant