Skip to content

Commit

Permalink
Fix CmdLine generation and caching
Browse files Browse the repository at this point in the history
When collecting process metrics the generation of `cmdLine` field and
its caching were happening in the wrong place. This commit fixes it.
  • Loading branch information
belimawr committed Nov 6, 2023
1 parent eb68005 commit b8a54bb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions metric/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ func (procStats *Stats) pidFill(pid int, filter bool) (ProcState, bool, error) {
if procStats.skipExtended {
return status, true, nil
}
status = procStats.cacheCmdLine(status)

// Filter based on user-supplied func
if filter {
Expand All @@ -236,9 +235,7 @@ func (procStats *Stats) pidFill(pid int, filter bool) (ProcState, bool, error) {
if err != nil {
return status, true, fmt.Errorf("FillPidMetrics: %w", err)
}
if len(status.Args) > 0 && status.Cmdline == "" {
status.Cmdline = strings.Join(status.Args, " ")
}

if status.CPU.Total.Ticks.Exists() {
status.CPU.Total.Value = opt.FloatWith(metric.Round(float64(status.CPU.Total.Ticks.ValueOr(0))))
}
Expand Down Expand Up @@ -266,6 +263,11 @@ func (procStats *Stats) pidFill(pid int, filter bool) (ProcState, bool, error) {
return status, true, fmt.Errorf("FillMetricsRequiringMoreAccess: %w", err)
}

if len(status.Args) > 0 && status.Cmdline == "" {
status.Cmdline = strings.Join(status.Args, " ")
}
status = procStats.cacheCmdLine(status)

// network data
if procStats.EnableNetwork {
procHandle, err := sysinfo.Process(pid)
Expand Down

0 comments on commit b8a54bb

Please sign in to comment.