summary refs log tree commit diff
path: root/synapse/storage/events.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-06-06 11:58:09 +0100
committerErik Johnston <erik@matrix.org>2016-06-06 11:58:09 +0100
commit7aa778fba9bb81087c3a1029e0a0d4ff55b1a065 (patch)
tree194a58be8c39fcf79cd56b40867e547701a0ef94 /synapse/storage/events.py
parentMerge pull request #836 from matrix-org/erikj/change_event_cache (diff)
downloadsynapse-7aa778fba9bb81087c3a1029e0a0d4ff55b1a065.tar.xz
Add metric counter for number of persisted events
Diffstat (limited to 'synapse/storage/events.py')
-rw-r--r--synapse/storage/events.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index 5db24e86f9..ff4f742f6a 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -27,6 +27,9 @@ from synapse.api.constants import EventTypes
 from canonicaljson import encode_canonical_json
 from collections import deque, namedtuple
 
+import synapse
+import synapse.metrics
+
 
 import logging
 import math
@@ -35,6 +38,10 @@ import ujson as json
 logger = logging.getLogger(__name__)
 
 
+metrics = synapse.metrics.get_metrics_for(__name__)
+persist_event_counter = metrics.register_counter("persisted_events")
+
+
 def encode_json(json_object):
     if USE_FROZEN_DICTS:
         # ujson doesn't like frozen_dicts
@@ -261,6 +268,7 @@ class EventsStore(SQLBaseStore):
                         events_and_contexts=chunk,
                         backfilled=backfilled,
                     )
+                    persist_event_counter.inc_by(len(chunk))
 
     @defer.inlineCallbacks
     @log_function
@@ -278,6 +286,7 @@ class EventsStore(SQLBaseStore):
                         current_state=current_state,
                         backfilled=backfilled,
                     )
+                    persist_event_counter.inc()
         except _RollbackButIsFineException:
             pass