Skip to content

Commit

Permalink
chore: do not attach pid tag for jstat when there is only one process
Browse files Browse the repository at this point in the history
  • Loading branch information
kongfei605 committed Dec 23, 2024
1 parent cdc1097 commit bd0c18b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion inputs/procstat/procstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,21 @@ func (ins *Instance) gatherLimit(slist *types.SampleList, procs map[PID]Process,
}

func (ins *Instance) gatherJvm(slist *types.SampleList, procs map[PID]Process, tags map[string]string) {
attachPid := false
if len(procs) > 1 {
attachPid = true
}
for pid := range procs {
jvmStat, err := execJstat(pid)
if err != nil {
log.Println("E! failed to exec jstat:", err)
continue
}

pidTag := map[string]string{"pid": fmt.Sprint(pid)}
pidTag := map[string]string{}
if attachPid {
pidTag["pid"] = fmt.Sprint(pid)
}
for k, v := range jvmStat {
slist.PushSample(inputName, "jvm_"+k, v, pidTag, ins.makeCmdlineLabelReggroupTag(procs[pid]), tags)
}
Expand Down

0 comments on commit bd0c18b

Please sign in to comment.