summary refs log tree commit diff
path: root/synapse/federation/transaction_queue.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2018-04-12 12:18:57 +0100
committerGitHub <noreply@github.com>2018-04-12 12:18:57 +0100
commit0f13f30fcadc0aec3230435f1e5e8df4f4e6eac7 (patch)
tree1f52b177c8ca278ed84d568652f892484ef2dc33 /synapse/federation/transaction_queue.py
parentMerge pull request #3059 from matrix-org/rav/doc_response_cache (diff)
parentFormat docstring (diff)
downloadsynapse-0f13f30fcadc0aec3230435f1e5e8df4f4e6eac7.tar.xz
Merge pull request #3090 from matrix-org/erikj/processed_event_lag
Add metrics for event processing lag
Diffstat (limited to 'synapse/federation/transaction_queue.py')
-rw-r--r--synapse/federation/transaction_queue.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/synapse/federation/transaction_queue.py b/synapse/federation/transaction_queue.py
index 5b0b798e57..963d938edd 100644
--- a/synapse/federation/transaction_queue.py
+++ b/synapse/federation/transaction_queue.py
@@ -233,12 +233,27 @@ class TransactionQueue(object):
                     consumeErrors=True
                 ))
 
-                events_processed_counter.inc_by(len(events))
-
                 yield self.store.update_federation_out_pos(
                     "events", next_token
                 )
 
+                if events:
+                    now = self.clock.time_msec()
+                    ts = yield self.store.get_received_ts(events[-1].event_id)
+
+                    synapse.metrics.event_processing_lag.set(
+                        now - ts, "federation_sender",
+                    )
+                    synapse.metrics.event_processing_last_ts.set(
+                        ts, "federation_sender",
+                    )
+
+                events_processed_counter.inc_by(len(events))
+
+                synapse.metrics.event_processing_positions.set(
+                    next_token, "federation_sender",
+                )
+
         finally:
             self._is_processing = False