Add standard process_start_time_seconds metric
parent
def63649df
commit
981f852d54
|
@ -119,6 +119,17 @@ rusage = None
|
|||
stats = None
|
||||
fd_counts = None
|
||||
|
||||
# In order to report process_start_time_seconds we need to know the machine's
|
||||
# boot time, because the value in /proc/self/stat is relative to this
|
||||
boot_time = None
|
||||
try:
|
||||
with open("/proc/stat") as _procstat:
|
||||
for line in _procstat:
|
||||
if line.startswith("btime "):
|
||||
boot_time = int(line.split()[1])
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
TYPES = {
|
||||
stat.S_IFSOCK: "SOCK",
|
||||
stat.S_IFLNK: "LNK",
|
||||
|
@ -218,6 +229,10 @@ process_metrics.register_callback(
|
|||
"max_fds", lambda: _get_max_fds()
|
||||
)
|
||||
|
||||
process_metrics.register_callback(
|
||||
"start_time_seconds", lambda: boot_time + int(stats[19]) / TICKS_PER_SEC
|
||||
)
|
||||
|
||||
reactor_metrics = get_metrics_for("reactor")
|
||||
tick_time = reactor_metrics.register_distribution("tick_time")
|
||||
pending_calls_metric = reactor_metrics.register_distribution("pending_calls")
|
||||
|
|
Loading…
Reference in New Issue