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

Fix some b'abcd' noise in logs and metrics #3892

Merged
merged 2 commits into from
Sep 17, 2018
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/3892.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix some b'abcd' noise in logs and metrics
5 changes: 4 additions & 1 deletion synapse/http/matrixfederationclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ def _request(self, destination, method, path,
request_deferred,
)

log_result = "%d %s" % (response.code, response.phrase,)
log_result = "%d %s" % (
response.code,
response.phrase.decode('ascii', errors='replace'),
)
break
except Exception as e:
if not retry_on_dns_fail and isinstance(e, DNSLookupError):
Expand Down
8 changes: 4 additions & 4 deletions synapse/http/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __repr__(self):
)

def get_request_id(self):
return "%s-%i" % (self.method, self.request_seq)
return "%s-%i" % (self.method.decode('ascii'), self.request_seq)

def get_redacted_uri(self):
uri = self.uri
Expand Down Expand Up @@ -119,7 +119,7 @@ def render(self, resrc):
# dispatching to the handler, so that the handler
# can update the servlet name in the request
# metrics
requests_counter.labels(self.method,
requests_counter.labels(self.method.decode('ascii'),
self.request_metrics.name).inc()

@contextlib.contextmanager
Expand Down Expand Up @@ -280,9 +280,9 @@ def _finished_processing(self):
int(usage.db_txn_count),
self.sentLength,
code,
self.method,
self.method.decode('ascii'),
self.get_redacted_uri(),
self.clientproto,
self.clientproto.decode('ascii', errors='replace'),
user_agent,
usage.evt_db_fetch_count,
)
Expand Down