[DB-2137] Report disk usage metrics for index and log drives#5640
[DB-2137] Report disk usage metrics for index and log drives#5640timothycoleman wants to merge 1 commit into
Conversation
The sys-disk metric only reported total/used bytes for the database drive. Extend it to also report the index and log drives when they live on different physical drives. CreateDiskMetric now takes a list of paths and a drive-info resolver. It resolves each path to its drive and registers one total/used pair per distinct drive, deduplicating by disk name so paths sharing a mount (the common default layout) don't emit duplicate (kind, disk) series. When everything is on one drive the output is unchanged. The index-path expression is computed once in ClusterVNode and reused. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code Review by Qodo
1. Drive dedupe locks-in fallback
|
PR Summary by QodoReport disk usage metrics for index and log drives WalkthroughsDescription• Extends *-sys-disk metric to report total/used bytes for index and log drives in addition to the database drive, enabling visibility for split-disk layouts. • CreateDiskMetric now accepts a list of paths and a getDriveInfo resolver; it deduplicates by disk name so paths sharing a mount point don't emit duplicate metric series. • indexPath is computed once in ClusterVNode and passed through MetricsBootstrapper.Bootstrap alongside the new logPath parameter. • Adds two new unit tests: one verifying deduplication when all paths share a drive, and one verifying separate series are emitted per distinct drive. Diagramgraph TD
A["ClusterVNode"] -->|"indexPath, logPath"| B["MetricsBootstrapper"]
B -->|"[dbPath, indexPath, logPath]"| C["SystemMetrics"]
C -->|"per distinct drive"| D["ObservableGauge\n*-sys-disk-bytes"]
C -->|"resolve path"| E["DriveStats.GetDriveInfo"]
E --> F[("DriveData\n(DiskName, Total, Available)")]
F --> C
subgraph Legend
direction LR
_svc["Service/Class"] ~~~ _db[("Data Record")] ~~~ _metric["Metric Output"]
end
High-Level AssessmentThe approach is optimal. Injecting the drive-info resolver as a File ChangesEnhancement (2)
Refactor (1)
Tests (1)
|
There was a problem hiding this comment.
Pull request overview
This PR extends the *-sys-disk Prometheus metric so it can report disk total/used bytes for the DB, index, and log locations (deduplicated when multiple paths map to the same underlying drive), improving observability for split-disk deployments.
Changes:
- Extend metrics bootstrapping to pass DB/index/log paths into disk metrics registration.
- Refactor
SystemMetrics.CreateDiskMetricto accept multiple paths plus an injected drive-info resolver and deduplicate by resolved drive. - Add unit tests validating drive deduplication and multi-drive emission behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/KurrentDB.Core/MetricsBootstrapper.cs |
Pass DB/index/log paths into system disk metrics registration. |
src/KurrentDB.Core/Metrics/SystemMetrics.cs |
Generalize disk metric creation to multiple paths and dedupe per distinct drive. |
src/KurrentDB.Core/ClusterVNode.cs |
Wire index/log paths into metrics bootstrap and reuse the computed index path. |
src/KurrentDB.Core.XUnit.Tests/Metrics/SystemMetricsTests.cs |
Add coverage for deduplication and multi-drive metric series behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public void CreateDiskMetric(string metricName, IReadOnlyList<string> paths, Func<string, DriveData> getDriveInfo, Dictionary<SystemTracker, string> dimNames) { | ||
| var dims = new Dimensions<SystemTracker, long>(config, dimNames, tag => new()); |
The *-sys-disk metric (exposed on /metrics) previously reported total/used bytes only for the database drive. This PR extends it to also report the index and log drives when they live on different physical drives, so operators running a split-disk layout get free/used visibility for all three.