mirror of
https://mau.dev/maunium/synapse.git
synced 2025-01-05 23:14:01 +01:00
add a last seen metric (#3396)
This commit is contained in:
parent
a61738b316
commit
f116f32ace
1 changed files with 21 additions and 0 deletions
|
@ -190,6 +190,22 @@ event_processing_last_ts = Gauge("synapse_event_processing_last_ts", "", ["name"
|
||||||
# finished being processed.
|
# finished being processed.
|
||||||
event_processing_lag = Gauge("synapse_event_processing_lag", "", ["name"])
|
event_processing_lag = Gauge("synapse_event_processing_lag", "", ["name"])
|
||||||
|
|
||||||
|
last_ticked = time.time()
|
||||||
|
|
||||||
|
|
||||||
|
class ReactorLastSeenMetric(object):
|
||||||
|
|
||||||
|
def collect(self):
|
||||||
|
cm = GaugeMetricFamily(
|
||||||
|
"python_twisted_reactor_last_seen",
|
||||||
|
"Seconds since the Twisted reactor was last seen",
|
||||||
|
)
|
||||||
|
cm.add_metric([], time.time() - last_ticked)
|
||||||
|
yield cm
|
||||||
|
|
||||||
|
|
||||||
|
REGISTRY.register(ReactorLastSeenMetric())
|
||||||
|
|
||||||
|
|
||||||
def runUntilCurrentTimer(func):
|
def runUntilCurrentTimer(func):
|
||||||
|
|
||||||
|
@ -222,6 +238,11 @@ def runUntilCurrentTimer(func):
|
||||||
tick_time.observe(end - start)
|
tick_time.observe(end - start)
|
||||||
pending_calls_metric.observe(num_pending)
|
pending_calls_metric.observe(num_pending)
|
||||||
|
|
||||||
|
# Update the time we last ticked, for the metric to test whether
|
||||||
|
# Synapse's reactor has frozen
|
||||||
|
global last_ticked
|
||||||
|
last_ticked = end
|
||||||
|
|
||||||
if running_on_pypy:
|
if running_on_pypy:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue