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
This commit is contained in:
@@ -17,9 +17,11 @@ import six
|
|||||||
from six.moves import urllib
|
from six.moves import urllib
|
||||||
|
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
|
from keystoneclient.openstack.common import importutils
|
||||||
from keystoneclient.openstack.common import jsonutils
|
from keystoneclient.openstack.common import jsonutils
|
||||||
from keystoneclient import utils
|
from keystoneclient import utils
|
||||||
|
|
||||||
|
osprofiler_web = importutils.try_import("osprofiler.web")
|
||||||
|
|
||||||
USER_AGENT = 'python-keystoneclient'
|
USER_AGENT = 'python-keystoneclient'
|
||||||
|
|
||||||
@@ -189,6 +191,9 @@ class Session(object):
|
|||||||
|
|
||||||
headers['X-Auth-Token'] = token
|
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
|
# 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
|
# should ignore the filter. This will make it easier for clients who
|
||||||
# want to overrule the default endpoint_filter data added to all client
|
# want to overrule the default endpoint_filter data added to all client
|
||||||
|
Reference in New Issue
Block a user