From f7b2be6d082a13e11b0f323e02edeb78e48aad64 Mon Sep 17 00:00:00 2001 From: Zhi Yan Liu Date: Fri, 26 Dec 2014 16:59:37 +0800 Subject: [PATCH] Add profiling support to Zaqar client To be able to create profiling traces for Zaqar, 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 end user calls Zaqar via OpenStack python client, if profiler is initialized, Zaqar client will add extra header, that will be parsed by special osprofiler middleware at server side) Don't worry no security issue here, trace information is signed by HMAC key that is setted in config file at server side. So only person that knows HMAC key is able to send proper header. Zaqar server patch is: I32565de6c447cd5e95a0ef54a9fbd4e571c2d820 Currently there are some projects are using osprofiler, like Glance, Cinder, Heat, and some others are working in progress, e.g. Trove. Implements: blueprint osprofiler Change-Id: I880c003511e9e4ef99806ba5b19d0ef6996be80b Co-Authored-By: wangxiyuan --- zaqarclient/transport/http.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zaqarclient/transport/http.py b/zaqarclient/transport/http.py index 0c61662a..e791d11a 100644 --- a/zaqarclient/transport/http.py +++ b/zaqarclient/transport/http.py @@ -16,10 +16,14 @@ from distutils import version import json +from oslo_utils import importutils + from zaqarclient.common import http from zaqarclient.transport import base from zaqarclient.transport import response +osprofiler_web = importutils.try_import("osprofiler.web") + class HttpTransport(base.Transport): @@ -82,6 +86,9 @@ class HttpTransport(base.Transport): else: headers['content-type'] = 'application/json' + if osprofiler_web: + headers.update(osprofiler_web.get_trace_id_headers()) + resp = self.client.request(method, url=url, params=request.params,