Skip to content

Commit

Permalink
fix: fix parsing error for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Vihas Splunk committed Oct 16, 2023
1 parent 96d53a2 commit 9f461a3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions processor/resourcedetectionprocessor/internal/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,16 @@ func setHostCPUInfo(d *Detector, cpuInfo cpu.InfoStat) error {
}
d.rb.SetHostCPUFamily(family)

model, err := strconv.ParseInt(cpuInfo.Model, 10, 64)
if err != nil {
return fmt.Errorf("failed to convert cpuinfo model to integer: %w", err)
// For windows, this field is left blank. See https://github.com/shirou/gopsutil/blob/v3.23.9/cpu/cpu_windows.go#L113
// Skip setting modelId if the field is blank.
// ISSUE: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/27675
if cpuInfo.Model != "" {
model, err := strconv.ParseInt(cpuInfo.Model, 10, 64)
if err != nil {
return fmt.Errorf("failed to convert cpuinfo model to integer: %w", err)
}
d.rb.SetHostCPUModelID(model)
}
d.rb.SetHostCPUModelID(model)

d.rb.SetHostCPUModelName(cpuInfo.ModelName)
d.rb.SetHostCPUStepping(int64(cpuInfo.Stepping))
Expand Down

0 comments on commit 9f461a3

Please sign in to comment.