From 2f21463af9b824d3e5742af47ed8c313751d100e Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Sat, 28 Jun 2014 23:37:05 +0400 Subject: [PATCH] Add profiling support to keystoneclient To be able to create profiling traces for Keystone, client should be able to send special HTTP header that contains trace info. This patch is as well important to be able to make cross project traces. (Typical case nova calls keystone via python client, if profiler is initialized in nova, keystone client will add extra header, that will be parsed by special osprofiler middleware in keystone api) Don't worry no security issue here, trace information is signed by HMAC key that is setted in api-paste.ini. So only person that knows HMAC key is able to send proper header. Change-Id: Ide6fe268613bb0cc9d9ec6fae2957cc570e9f851 --- keystoneclient/session.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/keystoneclient/session.py b/keystoneclient/session.py index 743c22672..ddfe089d1 100644 --- a/keystoneclient/session.py +++ b/keystoneclient/session.py @@ -17,9 +17,11 @@ import six from six.moves import urllib from keystoneclient import exceptions +from keystoneclient.openstack.common import importutils from keystoneclient.openstack.common import jsonutils from keystoneclient import utils +osprofiler_web = importutils.try_import("osprofiler.web") USER_AGENT = 'python-keystoneclient' @@ -189,6 +191,9 @@ class Session(object): headers['X-Auth-Token'] = token + if osprofiler_web: + headers.update(osprofiler_web.get_trace_id_headers()) + # if we are passed a fully qualified URL and an endpoint_filter we # should ignore the filter. This will make it easier for clients who # want to overrule the default endpoint_filter data added to all client