summary refs log tree commit diff
path: root/synapse/state/__init__.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-06-21 09:58:54 +0100
committerGitHub <noreply@github.com>2019-06-21 09:58:54 +0100
commit74566982413cd4d1d517053da601aeb89f585c9b (patch)
tree4edb527a5e340ee133c55459304a58a3b6122788 /synapse/state/__init__.py
parentImprove email notification logging (#5502) (diff)
parentBlack (diff)
downloadsynapse-74566982413cd4d1d517053da601aeb89f585c9b.tar.xz
Merge pull request #5476 from matrix-org/erikj/histogram_extremities
Add metrics for length of new extremities persisted.
Diffstat (limited to 'synapse/state/__init__.py')
-rw-r--r--synapse/state/__init__.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/synapse/state/__init__.py b/synapse/state/__init__.py
index fc20d1eaee..1b454a56a1 100644
--- a/synapse/state/__init__.py
+++ b/synapse/state/__init__.py
@@ -21,6 +21,7 @@ from six import iteritems, itervalues
 
 import attr
 from frozendict import frozendict
+from prometheus_client import Histogram
 
 from twisted.internet import defer
 
@@ -37,6 +38,14 @@ from synapse.util.metrics import Measure
 logger = logging.getLogger(__name__)
 
 
+# Metrics for number of state groups involved in a resolution.
+state_groups_histogram = Histogram(
+    "synapse_state_number_state_groups_in_resolution",
+    "Number of state groups used when performing a state resolution",
+    buckets=(1, 2, 3, 5, 7, 10, 15, 20, 50, 100, 200, 500, "+Inf"),
+)
+
+
 KeyStateTuple = namedtuple("KeyStateTuple", ("context", "type", "state_key"))
 
 
@@ -476,6 +485,8 @@ class StateResolutionHandler(object):
                 "Resolving state for %s with %d groups", room_id, len(state_groups_ids)
             )
 
+            state_groups_histogram.observe(len(state_groups_ids))
+
             # start by assuming we won't have any conflicted state, and build up the new
             # state map by iterating through the state groups. If we discover a conflict,
             # we give up and instead use `resolve_events_with_store`.