Merge "Pass the global request ID as logging context"

This commit is contained in:
Zuul 2022-06-15 23:41:51 +00:00 committed by Gerrit Code Review
commit 2d04649e9a
1 changed files with 9 additions and 1 deletions

View File

@ -414,6 +414,11 @@ class RestClient(object):
return resp[i]
return ""
def _get_global_request_id(self, resp):
if 'x-openstack-request-id' in resp:
return resp['x-openstack-request-id']
return ''
def _safe_body(self, body, maxlen=4096):
# convert a structure into a string safely
try:
@ -461,7 +466,10 @@ class RestClient(object):
if req_headers is None:
req_headers = {}
# if we have the request id, put it in the right part of the log
extra = dict(request_id=self._get_request_id(resp))
extra = {
'request_id': self._get_request_id(resp),
'global_request_id': self._get_global_request_id(resp),
}
# NOTE(sdague): while we still have 6 callers to this function
# we're going to just provide work around on who is actually
# providing timings by gracefully adding no content if they don't.