summary refs log tree commit diff
path: root/synapse/metrics/__init__.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2016-10-19 13:56:06 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2016-10-19 15:05:21 +0100
commit03c2720940ed730dad11996020c180e592fd64a9 (patch)
tree705d361cbb7a1e04cb2330f0249400cd099949d0 /synapse/metrics/__init__.py
parentCallback metric values might not just be integers - allow floats (diff)
downloadsynapse-03c2720940ed730dad11996020c180e592fd64a9.tar.xz
Export CPU usage metrics also under prometheus-standard metric name
Diffstat (limited to 'synapse/metrics/__init__.py')
-rw-r--r--synapse/metrics/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py
index 76d5998d75..e4dd4c61e2 100644
--- a/synapse/metrics/__init__.py
+++ b/synapse/metrics/__init__.py
@@ -119,6 +119,8 @@ def update_resource_metrics():
     global rusage
     rusage = getrusage(RUSAGE_SELF)
 
+## Legacy synapse-invented metric names
+
 resource_metrics = get_metrics_for("process.resource")
 
 # msecs
@@ -165,6 +167,19 @@ def _process_fds():
 
 get_metrics_for("process").register_callback("fds", _process_fds, labels=["type"])
 
+## New prometheus-standard metric names
+process_metrics = get_metrics_for("process");
+
+process_metrics.register_callback(
+    "cpu_user_seconds_total", lambda: rusage.ru_utime
+)
+process_metrics.register_callback(
+    "cpu_system_seconds_total", lambda: rusage.ru_stime
+)
+process_metrics.register_callback(
+    "cpu_seconds_total", lambda: rusage.ru_utime + rusage.ru_stime
+)
+
 reactor_metrics = get_metrics_for("reactor")
 tick_time = reactor_metrics.register_distribution("tick_time")
 pending_calls_metric = reactor_metrics.register_distribution("pending_calls")