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

Reduce debug logging overhead #6251

Merged
merged 5 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6251.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce impact of debug logging.
6 changes: 4 additions & 2 deletions synapse/crypto/event_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ def compute_event_signature(event_dict, signature_name, signing_key):
redact_json = prune_event_dict(event_dict)
redact_json.pop("age_ts", None)
redact_json.pop("unsigned", None)
logger.debug("Signing event: %s", encode_canonical_json(redact_json))
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Signing event: %s", encode_canonical_json(redact_json))
redact_json = sign_json(redact_json, signature_name, signing_key)
logger.debug("Signed event: %s", encode_canonical_json(redact_json))
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Signed event: %s", encode_canonical_json(redact_json))
return redact_json["signatures"]


Expand Down
2 changes: 1 addition & 1 deletion synapse/federation/federation_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def backfill(self, dest, room_id, limit, extremities):
dest, room_id, extremities, limit
)

logger.debug("backfill transaction_data=%s", repr(transaction_data))
logger.debug("backfill transaction_data=%r", transaction_data)

room_version = yield self.store.get_room_version(room_id)
format_ver = room_version_to_event_format(room_version)
Expand Down
4 changes: 2 additions & 2 deletions synapse/federation/transport/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ def backfill(self, destination, room_id, event_tuples, limit):
Deferred: Results in a dict received from the remote homeserver.
"""
logger.debug(
"backfill dest=%s, room_id=%s, event_tuples=%s, limit=%s",
"backfill dest=%s, room_id=%s, event_tuples=%r, limit=%s",
destination,
room_id,
repr(event_tuples),
event_tuples,
str(limit),
)

Expand Down
11 changes: 8 additions & 3 deletions synapse/rest/client/v2_alpha/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,14 @@ def on_GET(self, request):
full_state = parse_boolean(request, "full_state", default=False)

logger.debug(
"/sync: user=%r, timeout=%r, since=%r,"
" set_presence=%r, filter_id=%r, device_id=%r"
% (user, timeout, since, set_presence, filter_id, device_id)
"/sync: user=%r, timeout=%r, since=%r, "
"set_presence=%r, filter_id=%r, device_id=%r",
user,
timeout,
since,
set_presence,
filter_id,
device_id,
)

request_key = (user, timeout, since, filter_id, full_state, device_id)
Expand Down
14 changes: 8 additions & 6 deletions synapse/rest/media/v1/preview_url_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ async def _async_render_GET(self, request):
pattern = entry[attrib]
value = getattr(url_tuple, attrib)
logger.debug(
("Matching attrib '%s' with value '%s' against" " pattern '%s'")
% (attrib, value, pattern)
"Matching attrib '%s' with value '%s' against" " pattern '%s'",
attrib,
value,
pattern,
)

if value is None:
Expand Down Expand Up @@ -186,7 +188,7 @@ def _do_preview(self, url, user, ts):

media_info = yield self._download_url(url, user)

logger.debug("got media_info of '%s'" % media_info)
logger.debug("got media_info of '%s'", media_info)

if _is_media(media_info["media_type"]):
file_id = media_info["filesystem_id"]
Expand Down Expand Up @@ -254,7 +256,7 @@ def _do_preview(self, url, user, ts):
og["og:image:width"] = dims["width"]
og["og:image:height"] = dims["height"]
else:
logger.warn("Couldn't get dims for %s" % og["og:image"])
logger.warn("Couldn't get dims for %s", og["og:image"])

og["og:image"] = "mxc://%s/%s" % (
self.server_name,
Expand All @@ -268,7 +270,7 @@ def _do_preview(self, url, user, ts):
logger.warn("Failed to find any OG data in %s", url)
og = {}

logger.debug("Calculated OG for %s as %s" % (url, og))
logger.debug("Calculated OG for %s as %s", url, og)

jsonog = json.dumps(og)

Expand Down Expand Up @@ -297,7 +299,7 @@ def _download_url(self, url, user):

with self.media_storage.store_into_file(file_info) as (f, fname, finish):
try:
logger.debug("Trying to get url '%s'" % url)
logger.debug("Trying to get url '%s'", url)
length, headers, uri, code = yield self.client.get_file(
url, output_stream=f, max_size=self.max_spider_size
)
Expand Down
4 changes: 1 addition & 3 deletions synapse/storage/data_stores/main/event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,7 @@ def get_backfill_events(self, room_id, event_list, limit):
)

def _get_backfill_events(self, txn, room_id, event_list, limit):
logger.debug(
"_get_backfill_events: %s, %s, %s", room_id, repr(event_list), limit
)
logger.debug("_get_backfill_events: %s, %r, %s", room_id, event_list, limit)

event_results = set()

Expand Down