mirror of
https://github.com/element-hq/synapse
synced 2024-08-19 05:40:58 +00:00
Export CPU usage metrics also under prometheus-standard metric name
This commit is contained in:
parent
b21b9dbc37
commit
03c2720940
1 changed files with 15 additions and 0 deletions
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue