summary refs log tree commit diff
path: root/synapse/metrics
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2016-10-19 14:23:40 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2016-10-19 15:05:21 +0100
commit95fc70216d7c9f2142466c298b0b8fa456afd399 (patch)
tree8cb02e1b9d875031c4c4d366d647ea9c8af79516 /synapse/metrics
parentUse /proc/self/stat to generate the new process_cpu_*_seconds_total metrics (diff)
downloadsynapse-95fc70216d7c9f2142466c298b0b8fa456afd399.tar.xz
Add standard process_*_memory_bytes metrics
Diffstat (limited to 'synapse/metrics')
-rw-r--r--synapse/metrics/__init__.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py
index 434e7535cc..106458e104 100644
--- a/synapse/metrics/__init__.py
+++ b/synapse/metrics/__init__.py
@@ -113,6 +113,7 @@ def render_all():
 # process resource usage
 
 TICKS_PER_SEC = 100
+BYTES_PER_PAGE = 4096
 
 rusage = None
 stats = None
@@ -188,6 +189,13 @@ process_metrics.register_callback(
     "cpu_seconds_total", lambda: (float(stats[11]) + float(stats[12])) / TICKS_PER_SEC
 )
 
+process_metrics.register_callback(
+    "virtual_memory_bytes", lambda: int(stats[20])
+)
+process_metrics.register_callback(
+    "resident_memory_bytes", lambda: int(stats[21]) * BYTES_PER_PAGE
+)
+
 reactor_metrics = get_metrics_for("reactor")
 tick_time = reactor_metrics.register_distribution("tick_time")
 pending_calls_metric = reactor_metrics.register_distribution("pending_calls")