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

Commit

Permalink
Merge pull request #3892 from matrix-org/rav/decode_bytes_in_request_…
Browse files Browse the repository at this point in the history
…logs

Fix some b'abcd' noise in logs and metrics
  • Loading branch information
richvdh authored Sep 17, 2018
2 parents c9c5028 + 0cb7aff commit c7131ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
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

0 comments on commit c7131ba

Please sign in to comment.