mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Fix some b'abcd' noise in logs and metrics
Python 3 compatibility: make sure that we decode some byte sequences before we use them to create log lines and metrics labels.
This commit is contained in:
parent
c9c50284d7
commit
f00a9d2636
@ -244,7 +244,10 @@ class MatrixFederationHttpClient(object):
|
|||||||
request_deferred,
|
request_deferred,
|
||||||
)
|
)
|
||||||
|
|
||||||
log_result = "%d %s" % (response.code, response.phrase,)
|
log_result = "%d %s" % (
|
||||||
|
response.code,
|
||||||
|
response.phrase.decode('ascii', errors='replace'),
|
||||||
|
)
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not retry_on_dns_fail and isinstance(e, DNSLookupError):
|
if not retry_on_dns_fail and isinstance(e, DNSLookupError):
|
||||||
|
@ -82,7 +82,7 @@ class SynapseRequest(Request):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_request_id(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):
|
def get_redacted_uri(self):
|
||||||
uri = self.uri
|
uri = self.uri
|
||||||
@ -119,7 +119,7 @@ class SynapseRequest(Request):
|
|||||||
# dispatching to the handler, so that the handler
|
# dispatching to the handler, so that the handler
|
||||||
# can update the servlet name in the request
|
# can update the servlet name in the request
|
||||||
# metrics
|
# metrics
|
||||||
requests_counter.labels(self.method,
|
requests_counter.labels(self.method.decode('ascii'),
|
||||||
self.request_metrics.name).inc()
|
self.request_metrics.name).inc()
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
@ -280,9 +280,9 @@ class SynapseRequest(Request):
|
|||||||
int(usage.db_txn_count),
|
int(usage.db_txn_count),
|
||||||
self.sentLength,
|
self.sentLength,
|
||||||
code,
|
code,
|
||||||
self.method,
|
self.method.decode('ascii'),
|
||||||
self.get_redacted_uri(),
|
self.get_redacted_uri(),
|
||||||
self.clientproto,
|
self.clientproto.decode('ascii', errors='replace'),
|
||||||
user_agent,
|
user_agent,
|
||||||
usage.evt_db_fetch_count,
|
usage.evt_db_fetch_count,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user