mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-12 04:04:19 -05:00
Add metric to count lazy member sync requests
This commit is contained in:
parent
9eb1a79100
commit
bdc27d6716
@ -20,6 +20,8 @@ import logging
|
|||||||
|
|
||||||
from six import iteritems, itervalues
|
from six import iteritems, itervalues
|
||||||
|
|
||||||
|
from prometheus_client import Counter
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.api.constants import EventTypes, Membership
|
from synapse.api.constants import EventTypes, Membership
|
||||||
@ -36,6 +38,13 @@ from synapse.visibility import filter_events_for_client
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
# Counts the number of times we got asked for a lazy loaded sync. Type is one of
|
||||||
|
# initial_sync, full_sate_sync or incremental_sync
|
||||||
|
lazy_member_sync_counter = Counter(
|
||||||
|
"synapse_handlers_sync_lazy_member_sync", "", ["type"],
|
||||||
|
)
|
||||||
|
|
||||||
# Store the cache that tracks which lazy-loaded members have been sent to a given
|
# Store the cache that tracks which lazy-loaded members have been sent to a given
|
||||||
# client for no more than 30 minutes.
|
# client for no more than 30 minutes.
|
||||||
LAZY_LOADED_MEMBERS_CACHE_MAX_AGE = 30 * 60 * 1000
|
LAZY_LOADED_MEMBERS_CACHE_MAX_AGE = 30 * 60 * 1000
|
||||||
@ -227,14 +236,19 @@ class SyncHandler(object):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _wait_for_sync_for_user(self, sync_config, since_token, timeout,
|
def _wait_for_sync_for_user(self, sync_config, since_token, timeout,
|
||||||
full_state):
|
full_state):
|
||||||
|
if since_token is None:
|
||||||
|
sync_type = "initial_sync"
|
||||||
|
elif full_state:
|
||||||
|
sync_type = "full_state_sync"
|
||||||
|
else:
|
||||||
|
sync_type = "incremental_sync"
|
||||||
|
|
||||||
context = LoggingContext.current_context()
|
context = LoggingContext.current_context()
|
||||||
if context:
|
if context:
|
||||||
if since_token is None:
|
context.tag = sync_type
|
||||||
context.tag = "initial_sync"
|
|
||||||
elif full_state:
|
if sync_config.filter_collection.lazy_load_members():
|
||||||
context.tag = "full_state_sync"
|
lazy_member_sync_counter.labels(sync_type).inc()
|
||||||
else:
|
|
||||||
context.tag = "incremental_sync"
|
|
||||||
|
|
||||||
if timeout == 0 or since_token is None or full_state:
|
if timeout == 0 or since_token is None or full_state:
|
||||||
# we are going to return immediately, so don't bother calling
|
# we are going to return immediately, so don't bother calling
|
||||||
|
Loading…
Reference in New Issue
Block a user