Merge "Enable OSProfiler support in Ironic - follow-up"

This commit is contained in:
Jenkins 2017-08-19 04:39:48 +00:00 committed by Gerrit Code Review
commit 7f96d578a1
2 changed files with 20 additions and 11 deletions

View File

@ -70,6 +70,7 @@ profiler options and restart ironic services::
[profiler]
enabled = True
hmac_keys = SECRET_KEY # default value used across several OpenStack projects
trace_sqlalchemy = True
In order to trace ironic using OSProfiler, use openstackclient to run
@ -95,6 +96,10 @@ The trace results can be saved in a file with ``--out file-name`` option::
$ osprofiler trace show --html <trace-id> --out trace.html
The trace results show the time spent in ironic-api, ironic-conductor, and db
calls. More detailed db tracing is enabled if ``trace_sqlalchemy``
is set to true.
Sample Trace:
.. figure:: ../images/sample_trace.svg
@ -103,6 +108,8 @@ Sample Trace:
:alt: Sample Trace
Each trace has embedded trace point details as shown below:
.. figure:: ../images/sample_trace_details.svg
:width: 660px
:align: left

View File

@ -32,16 +32,18 @@ def setup(name, host='0.0.0.0'):
a notifier backend, which is set in
osprofiler.initializer.init_from_conf.
"""
if CONF.profiler.enabled:
admin_context = context.get_admin_context()
initializer.init_from_conf(conf=CONF,
context=admin_context.to_dict(),
project="ironic",
service=name,
host=host)
LOG.info("OSProfiler is enabled. Trace is generated using "
"[profiler]/hmac_keys specified in ironic.conf. "
"To disable, set [profiler]/enabled=false")
if not CONF.profiler.enabled:
return
admin_context = context.get_admin_context()
initializer.init_from_conf(conf=CONF,
context=admin_context.to_dict(),
project="ironic",
service=name,
host=host)
LOG.info("OSProfiler is enabled. Trace is generated using "
"[profiler]/hmac_keys specified in ironic.conf. "
"To disable, set [profiler]/enabled=false")
def trace_cls(name, **kwargs):
@ -54,7 +56,7 @@ def trace_cls(name, **kwargs):
:param kwargs: Any other keyword args used by profiler.trace_cls
"""
def decorator(cls):
if profiler and 'profiler' in CONF and CONF.profiler.enabled:
if CONF.profiler.enabled:
trace_decorator = profiler.trace_cls(name, kwargs)
return trace_decorator(cls)
return cls