Conversation
Signed-off-by: Jain Johny <jj@asama.ai>
Signed-off-by: Jain Johny <jj@asama.ai>
WalkthroughAdds a NUMA node metric for PCI devices to the pcidevice collector and updates fixtures. The collector now emits node_pcidevice_numa_node, defaulting to -1 when NUMA info is absent. E2E and names fixtures are expanded to include entries for a new PCI device on bus 45 and NUMA node samples. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant P as Prometheus
participant NE as node_exporter
participant PC as pcidevice collector
participant SYS as sysfs/PCI
P->>NE: /metrics scrape
NE->>PC: Collect()
PC->>SYS: Enumerate PCI devices
SYS-->>PC: Device info (incl. optional NUMA)
alt NUMA node present
PC->>NE: node_pcidevice_numa_node{labels}=<numa_id>
else NUMA node absent
PC->>NE: node_pcidevice_numa_node{labels}=-1
end
PC->>NE: Other pcidevice metrics (existing + bus 45 entries)
NE-->>P: Expose metrics
note over PC,NE: New metric emitted with same label set as other PCI metrics
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
collector/pcidevice_linux.go (1)
237-241: Bug: nil PowerState reports as D0 (should be Unknown)When
device.PowerStateis nil,powerStatestays 0, contradicting the HELP (-1=Unknown). Default to -1.- var powerState float64 + powerState := -1.0 if device.PowerState != nil { powerState = parsePowerStateFromEnum(*device.PowerState) }
🧹 Nitpick comments (1)
collector/pcidevice_linux.go (1)
300-314: Order & count verified — optional: convert to explicit per-descriptor sendsc.descs (11 entries — collector/pcidevice_linux.go:164–176) matches the values slice (11 values — collector/pcidevice_linux.go:300–314); emission order is correct. Optional: replace the index-coupled for-loop with explicit ch <- c.descs[...].mustNewConstMetric(...) sends to reduce fragility when adding metrics.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
collector/fixtures/e2e-output.txt(1 hunks)collector/fixtures/pcidevice-names-output.txt(1 hunks)collector/pcidevice_linux.go(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (go)
🔇 Additional comments (5)
collector/pcidevice_linux.go (3)
103-108: NUMA node metric descriptor looks correctName, labels, and HELP text align with the rest of the collector.
277-284: Nil-safe NUMA handling is consistentUsing -1 as the unknown sentinel matches the HELP and other fields’ conventions.
175-176: Descriptor ordering preservedAppending pcideviceNumaNodeDesc at the end keeps index-based emissions stable. node_pcidevice_numa_node is present in collector/fixtures/pcidevice-names-output.txt and collector/fixtures/e2e-output.txt.
collector/fixtures/pcidevice-names-output.txt (1)
33-37: Names fixture updated for NUMA: OKHELP/TYPE and samples align with code (-1 unknown, 0 for known node).
collector/fixtures/e2e-output.txt (1)
2861-2916: E2E fixture extended (bus 45 + NUMA): OKBoth fixtures expose node_pcidevice_numa_node and counts look sane — e2e: bus=45 -> 0 (NUMA 0), bus=00/01 -> -1 (unknown). Files: collector/fixtures/pcidevice-names-output.txt:34, collector/fixtures/e2e-output.txt:2878.
* add numa_node and missing test output file Signed-off-by: Jain Johny <jj@asama.ai>
* add numa_node and missing test output file Signed-off-by: Jain Johny <jj@asama.ai>
Summary by CodeRabbit
New Features
Tests