forked from MirrorHub/synapse
Add standard process_start_time_seconds metric
This commit is contained in:
parent
def63649df
commit
981f852d54
1 changed files with 15 additions and 0 deletions
|
@ -119,6 +119,17 @@ rusage = None
|
||||||
stats = None
|
stats = None
|
||||||
fd_counts = 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 = {
|
TYPES = {
|
||||||
stat.S_IFSOCK: "SOCK",
|
stat.S_IFSOCK: "SOCK",
|
||||||
stat.S_IFLNK: "LNK",
|
stat.S_IFLNK: "LNK",
|
||||||
|
@ -218,6 +229,10 @@ process_metrics.register_callback(
|
||||||
"max_fds", lambda: _get_max_fds()
|
"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")
|
reactor_metrics = get_metrics_for("reactor")
|
||||||
tick_time = reactor_metrics.register_distribution("tick_time")
|
tick_time = reactor_metrics.register_distribution("tick_time")
|
||||||
pending_calls_metric = reactor_metrics.register_distribution("pending_calls")
|
pending_calls_metric = reactor_metrics.register_distribution("pending_calls")
|
||||||
|
|
Loading…
Reference in a new issue