Add metrics for len of new extremities persisted.
Of new events being persisted add metrics for total size of forward extremities and number of unchanged, "stale" extremities.
This commit is contained in:
parent
6840ebeef8
commit
499d4a32cd
|
@ -24,7 +24,7 @@ from six import iteritems, text_type
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
|
|
||||||
from canonicaljson import json
|
from canonicaljson import json
|
||||||
from prometheus_client import Counter
|
from prometheus_client import Counter, Histogram
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
|
@ -74,6 +74,19 @@ state_delta_reuse_delta_counter = Counter(
|
||||||
"synapse_storage_events_state_delta_reuse_delta", ""
|
"synapse_storage_events_state_delta_reuse_delta", ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# The number of forward extremities for each new event.
|
||||||
|
forward_extremities_counter = Histogram(
|
||||||
|
"synapse_storage_events_forward_extremities_persisted", "",
|
||||||
|
buckets=(1, 2, 3, 5, 7, 10, 15, 20, 50, 100, 200, 500, "+Inf")
|
||||||
|
)
|
||||||
|
|
||||||
|
# The number of stale forward extremities for each new event. Stale extremities
|
||||||
|
# are those that were in the previous set of extremities as well as the new.
|
||||||
|
stale_forward_extremities_counter = Histogram(
|
||||||
|
"synapse_storage_events_stale_forward_extremities_persisted", "",
|
||||||
|
buckets=(0, 1, 2, 3, 5, 7, 10, 15, 20, 50, 100, 200, 500, "+Inf")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def encode_json(json_object):
|
def encode_json(json_object):
|
||||||
"""
|
"""
|
||||||
|
@ -541,6 +554,8 @@ class EventsStore(
|
||||||
and not event.internal_metadata.is_soft_failed()
|
and not event.internal_metadata.is_soft_failed()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
latest_event_ids = set(latest_event_ids)
|
||||||
|
|
||||||
# start with the existing forward extremities
|
# start with the existing forward extremities
|
||||||
result = set(latest_event_ids)
|
result = set(latest_event_ids)
|
||||||
|
|
||||||
|
@ -564,6 +579,13 @@ class EventsStore(
|
||||||
)
|
)
|
||||||
result.difference_update(existing_prevs)
|
result.difference_update(existing_prevs)
|
||||||
|
|
||||||
|
# We only update metrics for events that change forward extremities
|
||||||
|
# (e.g. we ignore backfill/outliers/etc)
|
||||||
|
if result != latest_event_ids:
|
||||||
|
forward_extremities_counter.observe(len(result))
|
||||||
|
stale = set(latest_event_ids) & result
|
||||||
|
stale_forward_extremities_counter.observe(len(stale))
|
||||||
|
|
||||||
defer.returnValue(result)
|
defer.returnValue(result)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
Loading…
Reference in New Issue