summaryrefslogtreecommitdiff
path: root/nova/service.py
diff options
context:
space:
mode:
authorDina Belova <dbelova@mirantis.com>2015-12-08 14:32:10 +0300
committerTovin Seven <vinhnt@vn.fujitsu.com>2017-01-18 15:00:14 +0700
commitecc8de8d6cccb06d7f4c8ecc144d37612ae1e9cc (patch)
tree03345e2b6d7afd801b78aab134473698fdf8fa1d /nova/service.py
parent045f08ab8a57b90b00e4777ca71a20b5603c296c (diff)
downloadnova-ecc8de8d6cccb06d7f4c8ecc144d37612ae1e9cc.tar.gz
Integrate OSProfiler and Nova
* Add osprofiler wsgi middleware. This middleware is used for 2 things: 1) It checks that person who want to trace is trusted and knows secret HMAC key. 2) It starts tracing in case of proper trace headers and adds the first wsgi trace point with info about the HTTP request * Add initialization of osprofiler on start of a service Currently that includes oslo.messaging notifier instance creation to send Ceilometer backend notifications. oslo-spec: https://review.openstack.org/#/c/103825/ python-novaclient change: https://review.openstack.org/#/c/254699/ based on: https://review.openstack.org/#/c/105096/ Co-Authored-By: Boris Pavlovic <boris@pavlovic.me> Co-Authored-By: Munoz, Obed N <obed.n.munoz@intel.com> Co-Authored-By: Roman Podoliaka <rpodolyaka@mirantis.com> Co-Authored-By: Tovin Seven <vinhnt@vn.fujitsu.com> Implements: blueprint osprofiler-support-in-nova Change-Id: I82d2badc8c1fcec27c3fce7c3c20e0f3b76414f1
Diffstat (limited to 'nova/service.py')
-rw-r--r--nova/service.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/nova/service.py b/nova/service.py
index d2b622a32a..5a15cd95a1 100644
--- a/nova/service.py
+++ b/nova/service.py
@@ -43,6 +43,10 @@ from nova import utils
from nova import version
from nova import wsgi
+osprofiler = importutils.try_import("osprofiler")
+osprofiler_initializer = importutils.try_import("osprofiler.initializer")
+
+
LOG = logging.getLogger(__name__)
CONF = nova.conf.CONF
@@ -81,6 +85,17 @@ def _update_service_ref(service):
service.save()
+def setup_profiler(binary, host):
+ if osprofiler and CONF.profiler.enabled:
+ osprofiler.initializer.init_from_conf(
+ conf=CONF,
+ context=context.get_admin_context().to_dict(),
+ project="nova",
+ service=binary,
+ host=host)
+ LOG.info(_LI("OSProfiler is enabled."))
+
+
class Service(service.Service):
"""Service object for binaries running on hosts.
@@ -110,6 +125,7 @@ class Service(service.Service):
if objects_base.NovaObject.indirection_api:
conductor_api = conductor.API()
conductor_api.wait_until_ready(context.get_admin_context())
+ setup_profiler(binary, self.host)
def __repr__(self):
return "<%(cls_name)s: host=%(host)s, binary=%(binary)s, " \
@@ -319,6 +335,7 @@ class WSGIService(service.Service):
# Pull back actual port used
self.port = self.server.port
self.backdoor_port = None
+ setup_profiler(name, self.host)
def reset(self):
"""Reset server greenpool size to default and service version cache.