Merge pull request #555 from matrix-org/erikj/logcontext

Allowing tagging log contexts
This commit is contained in:
Erik Johnston 2016-02-03 15:20:00 +00:00
commit c8e4d5de7f
3 changed files with 42 additions and 16 deletions

View file

@ -18,6 +18,7 @@ from ._base import BaseHandler
from synapse.streams.config import PaginationConfig
from synapse.api.constants import Membership, EventTypes
from synapse.util import unwrapFirstError
from synapse.util.logcontext import LoggingContext
from twisted.internet import defer
@ -140,6 +141,15 @@ class SyncHandler(BaseHandler):
A Deferred SyncResult.
"""
context = LoggingContext.current_context()
if context:
if since_token is None:
context.tag = "initial_sync"
elif full_state:
context.tag = "full_state_sync"
else:
context.tag = "incremental_sync"
if timeout == 0 or since_token is None or full_state:
# we are going to return immediately, so don't bother calling
# notifier.wait_for_events.