Skip to content

Commit

Permalink
Improve metrics logging for network io and nginx workers (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhurley authored Aug 22, 2022
1 parent 855e28d commit 9149ae8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/core/metrics/sources/net_io.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (nio *NetIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *pro
// collect net overflow. This is not easily obtained by gopsutil, so we exec netstat to get these values
overflows, err := nio.env.GetNetOverflow()
if err != nil {
log.Warnf("Error occurred getting network overflow metrics, %v", err)
log.Debugf("Error occurred getting network overflow metrics, %v", err)
}

if nio.netOverflows < 0 {
Expand Down
14 changes: 7 additions & 7 deletions src/core/metrics/sources/nginx_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,40 +183,40 @@ func (client *NginxWorkerClient) GetWorkerStats(childProcs []*proto.NginxDetails

pidAsInt, err := strconv.Atoi(nginxDetails.ProcessId)
if err != nil {
log.Warnf("failed to convert %s to int: %v", nginxDetails.ProcessId, err)
log.Debugf("failed to convert %s to int: %v", nginxDetails.ProcessId, err)
continue
}

proc, err := ps.NewProcess(int32(pidAsInt))
if err != nil {
log.Warnf("failed to retrieve process from pid %d: %v", pidAsInt, err)
log.Debugf("failed to retrieve process from pid %d: %v", pidAsInt, err)
continue
}

if times, err := proc.Times(); err == nil {
usr = usr + times.User
sys = sys + times.System
} else {
log.Warn("unable to get CPU times metrics")
log.Debug("unable to get CPU times metrics")
}

if memstat, err := proc.MemoryInfo(); err == nil {
memRss += float64(memstat.RSS)
memVms += float64(memstat.VMS)
} else {
log.Warn("unable to get memory info metrics")
log.Debug("unable to get memory info metrics")
}

if mempct, err := proc.MemoryPercent(); err == nil {
memPct += float64(mempct)
} else {
log.Warn("unable to get memory percentage metrics")
log.Debug("unable to get memory percentage metrics")
}

if fd, err := proc.NumFDs(); err == nil {
fdSum = fdSum + float64(fd)
} else {
log.Warn("unable to get number of file descriptors used metrics")
log.Debug("unable to get number of file descriptors used metrics")
}

if rlimit, err := proc.Rlimit(); err == nil {
Expand All @@ -228,7 +228,7 @@ func (client *NginxWorkerClient) GetWorkerStats(childProcs []*proto.NginxDetails
}
stats.Workers.RlimitNofile = float64(rlimitMax)
} else {
log.Warn("unable to get resource limit metrics")
log.Debug("unable to get resource limit metrics")
}

if ioc, err := proc.IOCounters(); err == nil {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9149ae8

Please sign in to comment.