Use OSprofiler options consolidated in lib itself

Starting with 1.0.0 osprofiler release options needed for
its workability are consolidated inside osprofiler itself.
Let's use them.

UpgradeImpact
DocImpact
Change-Id: Ie20e827f26c9be6867c233afdea9e05e2869d6e1
This commit is contained in:
Dina Belova 2016-02-09 15:58:14 -08:00
parent 4504fdfa75
commit 16660696f9
4 changed files with 10 additions and 19 deletions

View File

@ -84,7 +84,7 @@ def _create_facade_lazily():
# which requires db.sqlalchemy.api, which requires service which
# requires objects.base
CONF.import_group("profiler", "cinder.service")
if CONF.profiler.profiler_enabled:
if CONF.profiler.enabled:
if CONF.profiler.trace_sqlalchemy:
osprofiler_sqlalchemy.add_tracing(sqlalchemy,
_FACADE.get_engine(),

View File

@ -333,10 +333,6 @@ def list_opts():
cinder_volume_drivers_vzstorage.vzstorage_opts,
cinder_volume_drivers_nfs.nfs_opts,
)),
('PROFILER',
itertools.chain(
cinder_service.profiler_opts,
)),
('BRCD_FABRIC_EXAMPLE',
itertools.chain(
cinder_zonemanager_drivers_brocade_brcdfabricopts.

View File

@ -34,6 +34,7 @@ from oslo_utils import importutils
osprofiler_notifier = importutils.try_import('osprofiler.notifier')
profiler = importutils.try_import('osprofiler.profiler')
osprofiler_web = importutils.try_import('osprofiler.web')
profiler_opts = importutils.try_import('osprofiler.opts')
from cinder import context
from cinder import exception
@ -69,28 +70,22 @@ service_opts = [
help='Number of workers for OpenStack Volume API service. '
'The default is equal to the number of CPUs available.'), ]
profiler_opts = [
cfg.BoolOpt("profiler_enabled", default=False,
help=_('If False fully disable profiling feature.')),
cfg.BoolOpt("trace_sqlalchemy", default=False,
help=_("If False doesn't trace SQL requests.")),
cfg.StrOpt("hmac_keys", default="SECRET_KEY",
help=_("Secret key to use to sign tracing messages."))
]
CONF = cfg.CONF
CONF.register_opts(service_opts)
CONF.register_opts(profiler_opts, group="profiler")
if profiler_opts:
profiler_opts.set_defaults(CONF)
def setup_profiler(binary, host):
if (osprofiler_notifier is None or
profiler is None or
osprofiler_web is None):
osprofiler_web is None or
profiler_opts is None):
LOG.debug('osprofiler is not present')
return
if CONF.profiler.profiler_enabled:
if CONF.profiler.enabled:
_notifier = osprofiler_notifier.create(
"Messaging", messaging, context.get_admin_context().to_dict(),
rpc.TRANSPORT, "cinder", binary, host)
@ -105,7 +100,7 @@ def setup_profiler(binary, host):
"trigger profiler, only admin user can retrieve trace "
"information.\n"
"To disable OSprofiler set in cinder.conf:\n"
"[profiler]\nprofiler_enabled=false"))
"[profiler]\nenabled=false"))
else:
osprofiler_web.disable()
@ -131,7 +126,7 @@ class Service(service.Service):
self.topic = topic
self.manager_class_name = manager
manager_class = importutils.import_class(self.manager_class_name)
if CONF.profiler.profiler_enabled:
if CONF.profiler.enabled:
manager_class = profiler.trace_cls("rpc")(manager_class)
self.manager = manager_class(host=self.host,

View File

@ -264,7 +264,7 @@ class VolumeManager(manager.SchedulerDependentManager):
is_vol_db_empty=vol_db_empty,
active_backend_id=curr_active_backend_id)
if CONF.profiler.profiler_enabled and profiler is not None:
if CONF.profiler.enabled and profiler is not None:
self.driver = profiler.trace_cls("driver")(self.driver)
try:
self.extra_capabilities = jsonutils.loads(