Pass the Metrics group into the process collector instead of having it find its own one; this avoids it needing to import from synapse.metrics
This commit is contained in:
parent
ccc1a3d54d
commit
aac13b1f9a
|
@ -338,7 +338,7 @@ def setup(config_options):
|
||||||
hs.get_replication_layer().start_get_pdu_cache()
|
hs.get_replication_layer().start_get_pdu_cache()
|
||||||
|
|
||||||
register_memory_metrics(hs)
|
register_memory_metrics(hs)
|
||||||
register_process_collector()
|
register_process_collector(get_metrics_for("process"))
|
||||||
|
|
||||||
reactor.callWhenRunning(start)
|
reactor.callWhenRunning(start)
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@ import os
|
||||||
import stat
|
import stat
|
||||||
from resource import getrusage, RUSAGE_SELF
|
from resource import getrusage, RUSAGE_SELF
|
||||||
|
|
||||||
from synapse.metrics import get_metrics_for
|
|
||||||
|
|
||||||
|
|
||||||
TICKS_PER_SEC = 100
|
TICKS_PER_SEC = 100
|
||||||
BYTES_PER_PAGE = 4096
|
BYTES_PER_PAGE = 4096
|
||||||
|
@ -111,10 +109,10 @@ def _process_fds():
|
||||||
return counts
|
return counts
|
||||||
|
|
||||||
|
|
||||||
def register_process_collector():
|
def register_process_collector(process_metrics):
|
||||||
# Legacy synapse-invented metric names
|
# Legacy synapse-invented metric names
|
||||||
|
|
||||||
resource_metrics = get_metrics_for("process.resource")
|
resource_metrics = process_metrics.make_subspace("resource")
|
||||||
|
|
||||||
resource_metrics.register_collector(update_resource_metrics)
|
resource_metrics.register_collector(update_resource_metrics)
|
||||||
|
|
||||||
|
@ -125,12 +123,10 @@ def register_process_collector():
|
||||||
# kilobytes
|
# kilobytes
|
||||||
resource_metrics.register_callback("maxrss", lambda: rusage.ru_maxrss * 1024)
|
resource_metrics.register_callback("maxrss", lambda: rusage.ru_maxrss * 1024)
|
||||||
|
|
||||||
get_metrics_for("process").register_callback("fds", _process_fds, labels=["type"])
|
process_metrics.register_callback("fds", _process_fds, labels=["type"])
|
||||||
|
|
||||||
# New prometheus-standard metric names
|
# New prometheus-standard metric names
|
||||||
|
|
||||||
process_metrics = get_metrics_for("process")
|
|
||||||
|
|
||||||
if HAVE_PROC_SELF_STAT:
|
if HAVE_PROC_SELF_STAT:
|
||||||
process_metrics.register_callback(
|
process_metrics.register_callback(
|
||||||
"cpu_user_seconds_total",
|
"cpu_user_seconds_total",
|
||||||
|
|
Loading…
Reference in New Issue