Merge "x-openstack-request-id logged twice in logs"
This commit is contained in:
commit
e0d50479ad
@ -46,18 +46,6 @@ from novaclient import utils
|
||||
extensions_ignored_name = ["__init__"]
|
||||
|
||||
|
||||
def _log_request_id(logger, resp, service_name):
|
||||
request_id = (resp.headers.get('x-openstack-request-id') or
|
||||
resp.headers.get('x-compute-request-id'))
|
||||
if request_id:
|
||||
logger.debug('%(method)s call to %(service_name)s for %(url)s '
|
||||
'used request id %(response_request_id)s',
|
||||
{'method': resp.request.method,
|
||||
'service_name': service_name,
|
||||
'url': resp.url,
|
||||
'response_request_id': request_id})
|
||||
|
||||
|
||||
class SessionClient(adapter.LegacyJsonAdapter):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -85,10 +73,6 @@ class SessionClient(adapter.LegacyJsonAdapter):
|
||||
raise_exc=False,
|
||||
**kwargs)
|
||||
|
||||
# if service name is None then use service_type for logging
|
||||
service = self.service_name or self.service_type
|
||||
_log_request_id(self.logger, resp, service)
|
||||
|
||||
# TODO(andreykurilin): uncomment this line, when we will be able to
|
||||
# check only nova-related calls
|
||||
# api_versions.check_headers(resp, self.api_version)
|
||||
|
@ -51,8 +51,7 @@ class ClientTest(utils.TestCase):
|
||||
|
||||
class SessionClientTest(utils.TestCase):
|
||||
|
||||
@mock.patch.object(novaclient.client, '_log_request_id')
|
||||
def test_timings(self, mock_log_request_id):
|
||||
def test_timings(self):
|
||||
self.requests_mock.get('http://no.where')
|
||||
|
||||
client = novaclient.client.SessionClient(session=session.Session())
|
||||
@ -75,15 +74,6 @@ class SessionClientTest(utils.TestCase):
|
||||
cs.reset_timings()
|
||||
self.assertEqual(0, len(cs.get_timings()))
|
||||
|
||||
@mock.patch.object(novaclient.client, '_log_request_id')
|
||||
def test_log_request_id(self, mock_log_request_id):
|
||||
self.requests_mock.get('http://no.where')
|
||||
client = novaclient.client.SessionClient(session=session.Session(),
|
||||
service_name='compute')
|
||||
client.request("http://no.where", 'GET')
|
||||
mock_log_request_id.assert_called_once_with(client.logger, mock.ANY,
|
||||
'compute')
|
||||
|
||||
|
||||
class ClientsUtilsTest(utils.TestCase):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user