diff --git a/doc/source/contributor/osprofiler-support.rst b/doc/source/contributor/osprofiler-support.rst index 7cf298f439..3ce1a6559d 100644 --- a/doc/source/contributor/osprofiler-support.rst +++ b/doc/source/contributor/osprofiler-support.rst @@ -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 --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 diff --git a/ironic/common/profiler.py b/ironic/common/profiler.py index 90ca35c755..3a2956661e 100644 --- a/ironic/common/profiler.py +++ b/ironic/common/profiler.py @@ -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