summary refs log tree commit diff
path: root/synapse/federation/federation_server.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/federation/federation_server.py')
-rw-r--r--synapse/federation/federation_server.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py
index 3216fca95f..25c0014f97 100644
--- a/synapse/federation/federation_server.py
+++ b/synapse/federation/federation_server.py
@@ -33,7 +33,14 @@ import logging
 
 logger = logging.getLogger(__name__)
 
-metrics = synapse.metrics.get_metrics_for(__name__)
+# synapse.federation.federation_server is a silly name
+metrics = synapse.metrics.get_metrics_for("synapse.federation.server")
+
+received_pdus_counter = metrics.register_counter("received_pdus")
+
+received_edus_counter = metrics.register_counter("received_edus")
+
+received_queries_counter = metrics.register_counter("received_queries", labels=["type"])
 
 
 class FederationServer(FederationBase):
@@ -75,7 +82,6 @@ class FederationServer(FederationBase):
 
     @defer.inlineCallbacks
     @log_function
-    @metrics.counted
     def on_backfill_request(self, origin, room_id, versions, limit):
         pdus = yield self.handler.on_backfill_request(
             origin, room_id, versions, limit
@@ -85,10 +91,11 @@ class FederationServer(FederationBase):
 
     @defer.inlineCallbacks
     @log_function
-    @metrics.counted
     def on_incoming_transaction(self, transaction_data):
         transaction = Transaction(**transaction_data)
 
+        received_pdus_counter.inc_by(len(transaction.pdus))
+
         for p in transaction.pdus:
             if "unsigned" in p:
                 unsigned = p["unsigned"]
@@ -158,6 +165,8 @@ class FederationServer(FederationBase):
         defer.returnValue((200, response))
 
     def received_edu(self, origin, edu_type, content):
+        received_edus_counter.inc()
+
         if edu_type in self.edu_handlers:
             self.edu_handlers[edu_type](origin, content)
         else:
@@ -165,7 +174,6 @@ class FederationServer(FederationBase):
 
     @defer.inlineCallbacks
     @log_function
-    @metrics.counted
     def on_context_state_request(self, origin, room_id, event_id):
         if event_id:
             pdus = yield self.handler.get_state_for_pdu(
@@ -193,7 +201,6 @@ class FederationServer(FederationBase):
 
     @defer.inlineCallbacks
     @log_function
-    @metrics.counted
     def on_pdu_request(self, origin, event_id):
         pdu = yield self._get_persisted_pdu(origin, event_id)
 
@@ -206,13 +213,13 @@ class FederationServer(FederationBase):
 
     @defer.inlineCallbacks
     @log_function
-    @metrics.counted
     def on_pull_request(self, origin, versions):
         raise NotImplementedError("Pull transactions not implemented")
 
     @defer.inlineCallbacks
-    @metrics.counted
     def on_query_request(self, query_type, args):
+        received_queries_counter.inc(query_type)
+
         if query_type in self.query_handlers:
             response = yield self.query_handlers[query_type](args)
             defer.returnValue((200, response))
@@ -222,14 +229,12 @@ class FederationServer(FederationBase):
             )
 
     @defer.inlineCallbacks
-    @metrics.counted
     def on_make_join_request(self, room_id, user_id):
         pdu = yield self.handler.on_make_join_request(room_id, user_id)
         time_now = self._clock.time_msec()
         defer.returnValue({"event": pdu.get_pdu_json(time_now)})
 
     @defer.inlineCallbacks
-    @metrics.counted
     def on_invite_request(self, origin, content):
         pdu = self.event_from_pdu_json(content)
         ret_pdu = yield self.handler.on_invite_request(origin, pdu)
@@ -237,7 +242,6 @@ class FederationServer(FederationBase):
         defer.returnValue((200, {"event": ret_pdu.get_pdu_json(time_now)}))
 
     @defer.inlineCallbacks
-    @metrics.counted
     def on_send_join_request(self, origin, content):
         logger.debug("on_send_join_request: content: %s", content)
         pdu = self.event_from_pdu_json(content)
@@ -252,7 +256,6 @@ class FederationServer(FederationBase):
         }))
 
     @defer.inlineCallbacks
-    @metrics.counted
     def on_event_auth(self, origin, room_id, event_id):
         time_now = self._clock.time_msec()
         auth_pdus = yield self.handler.on_event_auth(event_id)
@@ -261,7 +264,6 @@ class FederationServer(FederationBase):
         }))
 
     @defer.inlineCallbacks
-    @metrics.counted
     def on_query_auth_request(self, origin, content, event_id):
         """
         Content is a dict with keys::