Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add metric counter for number of persisted events
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Jun 6, 2016
1 parent 3210f4c commit 7aa778f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
from canonicaljson import encode_canonical_json
from collections import deque, namedtuple

import synapse
import synapse.metrics


import logging
import math
Expand All @@ -35,6 +38,10 @@
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
Expand Down Expand Up @@ -261,6 +268,7 @@ def _persist_events(self, events_and_contexts, backfilled=False):
events_and_contexts=chunk,
backfilled=backfilled,
)
persist_event_counter.inc_by(len(chunk))

@defer.inlineCallbacks
@log_function
Expand All @@ -278,6 +286,7 @@ def _persist_event(self, event, context, current_state=None, backfilled=False):
current_state=current_state,
backfilled=backfilled,
)
persist_event_counter.inc()
except _RollbackButIsFineException:
pass

Expand Down

0 comments on commit 7aa778f

Please sign in to comment.