summary refs log tree commit diff
path: root/synapse/storage/events.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-05-03 09:46:40 +0100
committerErik Johnston <erik@matrix.org>2017-05-03 09:46:40 +0100
commit8346e6e696e6f0052bc0f68ee825c2b08da2387d (patch)
tree11969ca353dc86c798e3fa6fc094d6b4530ffc25 /synapse/storage/events.py
parentPrefill state caches (diff)
parentMerge pull request #2178 from matrix-org/erikj/message_metrics (diff)
downloadsynapse-8346e6e696e6f0052bc0f68ee825c2b08da2387d.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/prefill_state
Diffstat (limited to 'synapse/storage/events.py')
-rw-r--r--synapse/storage/events.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index a8d1b93d99..a37b7bad5a 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -29,6 +29,7 @@ from synapse.api.constants import EventTypes
 from synapse.api.errors import SynapseError
 from synapse.state import resolve_events
 from synapse.util.caches.descriptors import cached
+from synapse.types import get_domain_from_id
 
 from canonicaljson import encode_canonical_json
 from collections import deque, namedtuple, OrderedDict
@@ -49,6 +50,9 @@ logger = logging.getLogger(__name__)
 
 metrics = synapse.metrics.get_metrics_for(__name__)
 persist_event_counter = metrics.register_counter("persisted_events")
+event_counter = metrics.register_counter(
+    "persisted_events_sep", labels=["type", "origin_type", "origin_entity"]
+)
 
 
 def encode_json(json_object):
@@ -370,11 +374,25 @@ class EventsStore(SQLBaseStore):
                     new_forward_extremeties=new_forward_extremeties,
                 )
                 persist_event_counter.inc_by(len(chunk))
+
                 for room_id, (_, _, new_state) in current_state_for_room.iteritems():
                     self.get_current_state_ids.prefill(
                         (room_id, ), new_state
                     )
 
+                for event, context in chunk:
+                    if context.app_service:
+                        origin_type = "local"
+                        origin_entity = context.app_service.id
+                    elif self.hs.is_mine_id(event.sender):
+                        origin_type = "local"
+                        origin_entity = "*client*"
+                    else:
+                        origin_type = "remote"
+                        origin_entity = get_domain_from_id(event.sender)
+
+                    event_counter.inc(event.type, origin_type, origin_entity)
+
     @defer.inlineCallbacks
     def _calculate_new_extremeties(self, room_id, event_contexts, latest_event_ids):
         """Calculates the new forward extremeties for a room given events to