From 52e9ef4a4112ac5d4108b10c43472b384425a187 Mon Sep 17 00:00:00 2001 From: kpdev Date: Tue, 2 Feb 2021 07:37:43 +0100 Subject: [PATCH] Add profiling support to designateclient To be able to create profiling traces for Designate, client should be able to send special HTTP header that contains trace info. 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. Main patch (in Designate) is: https://review.opendev.org/c/openstack/designate/+/773574 Change-Id: I4b84ac1a5d4f84da3a38e4e0cb0990a54c6044ef --- designateclient/v2/client.py | 6 ++++++ lower-constraints.txt | 1 + 2 files changed, 7 insertions(+) diff --git a/designateclient/v2/client.py b/designateclient/v2/client.py index b9a42afd..05085359 100644 --- a/designateclient/v2/client.py +++ b/designateclient/v2/client.py @@ -31,6 +31,9 @@ from designateclient.v2.zones import ZoneExportsController from designateclient.v2.zones import ZoneImportsController from designateclient.v2.zones import ZoneTransfersController from designateclient import version +from oslo_utils import importutils + +osprofiler_web = importutils.try_import("osprofiler.web") class DesignateAdapter(adapter.LegacyJsonAdapter): @@ -78,6 +81,9 @@ class DesignateAdapter(adapter.LegacyJsonAdapter): kwargs['headers'].setdefault( 'Content-Type', 'application/json') + if osprofiler_web: + kwargs['headers'].update(osprofiler_web.get_trace_id_headers()) + response, body = super(self.__class__, self).request(*args, **kwargs) # Decode is response, if possible diff --git a/lower-constraints.txt b/lower-constraints.txt index 91454f73..b569a286 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -41,6 +41,7 @@ oslo.log==3.36.0 oslo.serialization==2.18.0 oslo.utils==3.33.0 oslotest==3.2.0 +osprofiler==3.4.0 paramiko==2.0.0 pbr==2.0.0 prettytable==0.7.2