Merge pull request #3892 from matrix-org/rav/decode_bytes_in_request_logs

Fix some b'abcd' noise in logs and metrics
pull/14/head
Richard van der Hoff 6 years ago committed by GitHub
commit c7131baefc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      changelog.d/3892.bugfix
  2. 5
      synapse/http/matrixfederationclient.py
  3. 8
      synapse/http/site.py

@ -0,0 +1 @@
Fix some b'abcd' noise in logs and metrics

@ -244,7 +244,10 @@ class MatrixFederationHttpClient(object):
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):

@ -82,7 +82,7 @@ class SynapseRequest(Request):
)
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
@ -119,7 +119,7 @@ class SynapseRequest(Request):
# 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
@ -280,9 +280,9 @@ class SynapseRequest(Request):
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,
)

Loading…
Cancel
Save