diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2018-09-17 17:07:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-17 17:07:10 +0100 |
commit | c7131baefc743aa664860dec08a0574df5f0e5be (patch) | |
tree | 60a8ecf8e0936ab55c7b2cee21ec7c91ac0743a7 | |
parent | README: run python_dependencies with -m (diff) | |
parent | changelog (diff) | |
download | synapse-c7131baefc743aa664860dec08a0574df5f0e5be.tar.xz |
Merge pull request #3892 from matrix-org/rav/decode_bytes_in_request_logs
Fix some b'abcd' noise in logs and metrics
-rw-r--r-- | changelog.d/3892.bugfix | 1 | ||||
-rw-r--r-- | synapse/http/matrixfederationclient.py | 5 | ||||
-rw-r--r-- | synapse/http/site.py | 8 |
3 files changed, 9 insertions, 5 deletions
diff --git a/changelog.d/3892.bugfix b/changelog.d/3892.bugfix new file mode 100644 index 0000000000..8b30afab04 --- /dev/null +++ b/changelog.d/3892.bugfix @@ -0,0 +1 @@ +Fix some b'abcd' noise in logs and metrics diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py index 13b19f7626..083484a687 100644 --- a/synapse/http/matrixfederationclient.py +++ b/synapse/http/matrixfederationclient.py @@ -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): diff --git a/synapse/http/site.py b/synapse/http/site.py index e1e53e8ae5..2191de9836 100644 --- a/synapse/http/site.py +++ b/synapse/http/site.py @@ -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, ) |