summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--synapse/handlers/presence.py7
-rw-r--r--synapse/http/request_metrics.py15
-rw-r--r--synapse/replication/tcp/resource.py9
3 files changed, 12 insertions, 19 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index aca822c46a..4ee87d5714 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -142,8 +142,9 @@ class PresenceHandler(object):
         }
 
         LaterGauge(
-            "user_to_current_state_size", "", [], lambda: len(self.user_to_current_state)
-        ).register()
+            "synapse_handlers_presence_user_to_current_state_size", "", [],
+            lambda: len(self.user_to_current_state)
+        )
 
         now = self.clock.time_msec()
         for state in active_presence:
@@ -212,7 +213,7 @@ class PresenceHandler(object):
             60 * 1000,
         )
 
-        LaterGauge("wheel_timer_size", "", [], lambda: len(self.wheel_timer)).register()
+        LaterGauge("synapse_handlers_presence_wheel_timer_size", "", [], lambda: len(self.wheel_timer))
 
     @defer.inlineCallbacks
     def _on_shutdown(self):
diff --git a/synapse/http/request_metrics.py b/synapse/http/request_metrics.py
index 0984870e7e..e7f1bfc4ae 100644
--- a/synapse/http/request_metrics.py
+++ b/synapse/http/request_metrics.py
@@ -71,24 +71,14 @@ in_flight_requests_db_sched_duration = Counter("synapse_http_request_in_flight_r
 _in_flight_requests = set()
 
 
-def _collect_in_flight():
-    """Called just before metrics are collected, so we use it to update all
-    the in flight request metrics
-    """
-
-    for rm in _in_flight_requests:
-        rm.update_metrics()
-
-
-metrics.register_collector(_collect_in_flight)
-
-
 def _get_in_flight_counts():
     """Returns a count of all in flight requests by (method, server_name)
 
     Returns:
         dict[tuple[str, str], int]
     """
+    for rm in _in_flight_requests:
+        rm.update_metrics()
 
     # Map from (method, name) -> int, the number of in flight requests of that
     # type
@@ -99,6 +89,7 @@ def _get_in_flight_counts():
 
     return counts
 
+
 LaterGauge(
     "synapse_http_request_metrics_in_flight_requests_count", "",
     ["method", "servlet"],
diff --git a/synapse/replication/tcp/resource.py b/synapse/replication/tcp/resource.py
index ed251c79ac..1ca30bc31a 100644
--- a/synapse/replication/tcp/resource.py
+++ b/synapse/replication/tcp/resource.py
@@ -73,8 +73,8 @@ class ReplicationStreamer(object):
         # Current connections.
         self.connections = []
 
-        l = LaterGauge("synapse_replication_tcp_resource_total_connections", "", [], lambda: len(self.connections))
-        l.register()
+        LaterGauge("synapse_replication_tcp_resource_total_connections", "", [],
+                   lambda: len(self.connections))
 
         # List of streams that clients can subscribe to.
         # We only support federation stream if federation sending hase been
@@ -87,14 +87,15 @@ class ReplicationStreamer(object):
         self.streams_by_name = {stream.NAME: stream for stream in self.streams}
 
         LaterGauge(
-            "synapse_replication_tcp_resource_connections_per_stream", "", ["stream_name"],
+            "synapse_replication_tcp_resource_connections_per_stream", "",
+            ["stream_name"],
             lambda: {
                 (stream_name,): len([
                     conn for conn in self.connections
                     if stream_name in conn.replication_streams
                 ])
                 for stream_name in self.streams_by_name
-            }).register()
+            })
 
         self.federation_sender = None
         if not hs.config.send_federation: