Skip to content

Commit

Permalink
test: Set physical cores to logical when not found
Browse files Browse the repository at this point in the history
* All other archs apart from Intel's physical and logical cores should be same

Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed Apr 14, 2024
1 parent 63cb060 commit 4a42382
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/collector/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ func NewCPUCollector(logger log.Logger) (Collector, error) {
physicalCores += cores
}

// On ARM and some other architectures there is no CPUCores variable in the info.
// As HT/SMT is Intel's properitiary stuff, we can safely set
// physicalCores = logicalCores when physicalCores == 0 on other architectures
if physicalCores == 0 {
physicalCores = logicalCores
}

// In tests, the expected output is 4
if *emptyHostnameLabel {
physicalCores = 4
}
return &cpuCollector{
fs: fs,
cpu: prometheus.NewDesc(
Expand Down

0 comments on commit 4a42382

Please sign in to comment.