Skip to content

Commit

Permalink
Wrap error returns in proccesses collector
Browse files Browse the repository at this point in the history
Wrap error returns so that the user can know more about what failed.
Returns from getAllocatedThreads() are errors anyway.

Related to #2110

Signed-off-by: Ben Kochie <superq@gmail.com>
  • Loading branch information
SuperQ committed Aug 5, 2021
1 parent 7fc5c60 commit 0ae3c07
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions collector/processes_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (c *processCollector) Update(ch chan<- prometheus.Metric) error {
func (c *processCollector) getAllocatedThreads() (int, map[string]int32, int, error) {
p, err := c.fs.AllProcs()
if err != nil {
return 0, nil, 0, err
return 0, nil, 0, fmt.Errorf("unable to list all processes: %w", err)
}
pids := 0
thread := 0
Expand All @@ -119,7 +119,7 @@ func (c *processCollector) getAllocatedThreads() (int, map[string]int32, int, er
continue
}
level.Debug(c.logger).Log("msg", "error reading stat for pid", "pid", pid, "err", err)
return 0, nil, 0, err
return 0, nil, 0, fmt.Errorf("error reading stat for pid %d: %w", pid, err)
}
pids++
procStates[stat.State]++
Expand Down

0 comments on commit 0ae3c07

Please sign in to comment.