Register osprofiler options before setting engine hook

The patch makes the module to not assume the options are registered by
some other code, that may never be executed, f.e. when it's part of a
single test case execution.

Change-Id: I7eefb32e6f34d732bda681919b434a96b8ad36da
Closes-Bug: #1640782
This commit is contained in:
Ihar Hrachyshka 2016-11-08 19:54:04 +00:00
parent f562750d6b
commit e727b92d3d
1 changed files with 7 additions and 0 deletions

View File

@ -24,6 +24,7 @@ from oslo_db import exception as db_exc
from oslo_db.sqlalchemy import enginefacade
from oslo_log import log as logging
from oslo_utils import excutils
from osprofiler import opts as profiler_opts
import osprofiler.sqlalchemy
from pecan import util as p_util
import six
@ -42,6 +43,12 @@ def set_hook(engine):
context_manager = enginefacade.transaction_context()
context_manager.configure(sqlite_fk=True)
# TODO(ihrachys) the hook assumes options defined by osprofiler, and the only
# public function that is provided by osprofiler that will register them is
# set_defaults, that's why we call it here even though we don't need to change
# defaults
profiler_opts.set_defaults(cfg.CONF)
context_manager.append_on_engine_create(set_hook)