Make osprofiler dependency really "soft"

In a37b5fe562 osprofiler was
changed to a soft requirement. However, if it is missing then
mistralclient will currently fail with:

AttributeError: 'NoneType' object has no attribute 'get_trace_id_headers'

This change checks to see if it was successfully imported before
it is used.

Depends-On: I1b61bd1de6811a5f65c2375dde956aafe33445b2
Change-Id: Ia742a4e55b35c5a787e4606ff2f91425dd156e5e
This commit is contained in:
Dougal Matthews
2016-09-01 13:38:46 +01:00
parent a37b5fe562
commit d655e010b8

View File

@@ -128,7 +128,8 @@ class HTTPClient(object):
if target_auth_uri:
headers['X-Target-Auth-Uri'] = target_auth_uri
# Add headers for osprofiler.
headers.update(osprofiler_web.get_trace_id_headers())
if osprofiler_web:
# Add headers for osprofiler.
headers.update(osprofiler_web.get_trace_id_headers())
return headers