summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2022-05-10 18:20:52 +0100
committerStephen Finucane <sfinucan@redhat.com>2022-05-10 18:20:52 +0100
commit8aa5f89c2f595c2a65644475c6a3b782f1131afb (patch)
treeaf7532ded798fe9bfe470e629a2b79e192f91b8a
parenta7bedbde46ae2aec796837a7e69fbf35747f75cb (diff)
downloadtempest-8aa5f89c2f595c2a65644475c6a3b782f1131afb.tar.gz
Pass the global request ID as logging context
Change-Id: I63afbec5e3e5619e0ab1f0c504e56dee56ae88da Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
-rw-r--r--tempest/lib/common/rest_client.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tempest/lib/common/rest_client.py b/tempest/lib/common/rest_client.py
index ef14dfc1f..fc86914f6 100644
--- a/tempest/lib/common/rest_client.py
+++ b/tempest/lib/common/rest_client.py
@@ -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.