Closed pavelmash closed 3 years ago
@pavelmash After reading the man page for proc it's not directly clear to me that we'd want to include the the process time of the children of the target process. Can you provide some clarification for this PR?
The problem is what without this PR we include ONLY the process time of the children of the target process ( cutime + cstime). This is why prom_process_cpu_seconds_total
metric is always 0 for /example/example
.
I propose to include not only the the process time of the children but also a process time of the current process (a process libprom.so is loaded into) by adding utime
+ stime
Or, if you want to include only current process CPU usage, this metric can be calculated as utime + stime (but not cutime + cstime). See for example rust implementation
Ah yes. This was a mistake. I much prefer that we only include utime + stime. Thank you for noticing this!
@pavelmash What are your thoughts? Do you agree that it makes sense to only use (utime + stime) / sysconf(_SC_CLK_TCK)
? See time.h
Yes, I agree - changed by [c96154f]
Thanks!
Hey, @pavelmash - Thanks a ton for this sweet PR! 😄
Would you please shoot me an email when you get a chance? mcowley at digitalocean dot com 🎉
Calculate
process_cpu_seconds_total
asutime + stime + cutime + cstime
instead ofcutime + cstime
.This include an amount of time that this process has been scheduled in user and kernel modes (utime + stime) in addition to an amount of time that this process's waited-for children have been scheduled in user and kernel modes modes (cutime + cstime)