don't log service catalog in every token response

The whole service catalog is embedded in every token, and by default
all token responses are logged at DEBUG. This adds a huge amount of
basically const data into system logs, over and over and over again.

We should not log the service catalog by default on every token
response. The following replaces the service catalog with the token
<removed>.

This reduces the compressed logs of API services by about 1/3.

Change-Id: I95832d0f13ca93c4618784da9d1eb9ca166cae53
This commit is contained in:
Sean Dague
2015-01-07 10:59:34 -05:00
parent 260f54dad7
commit 453e926322

View File

@@ -53,6 +53,21 @@ def request(url, method='GET', **kwargs):
return Session().request(url, method=method, **kwargs)
def remove_service_catalog(body):
try:
data = jsonutils.loads(body)
except ValueError:
return body
try:
if 'catalog' in data['token']:
data['token']['catalog'] = '<removed>'
return jsonutils.dumps(data)
else:
return body
except KeyError:
return body
class Session(object):
"""Maintains client communication state and common functionality.
@@ -182,7 +197,7 @@ class Session(object):
if not headers:
headers = response.headers
if not text:
text = response.text
text = remove_service_catalog(response.text)
if json:
text = jsonutils.dumps(json)