2
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3
# not use this file except in compliance with the License. You may obtain
4
# a copy of the License at
6
# http://www.apache.org/licenses/LICENSE-2.0
8
# Unless required by applicable law or agreed to in writing, software
9
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11
# License for the specific language governing permissions and limitations
14
from oslo.config import cfg
15
from oslo import messaging
16
import osprofiler.profiler
19
from heat.common import context
20
from heat.common.i18n import _LW
21
from heat.common import messaging as rpc_messaging
22
from heat.openstack.common import log as logging
24
cfg.CONF.import_opt('profiler_enabled', 'heat.common.config', group='profiler')
26
LOG = logging.getLogger(__name__)
29
def setup(binary, host):
30
if cfg.CONF.profiler.profiler_enabled:
31
_notifier = osprofiler.notifier.create(
32
"Messaging", messaging, context.get_admin_context().to_dict(),
33
rpc_messaging.TRANSPORT, "heat", binary, host)
34
osprofiler.notifier.set(_notifier)
35
LOG.warning(_LW("OSProfiler is enabled.\nIt means that person who "
36
"knows any of hmac_keys that are specified in "
37
"/etc/heat/api-paste.ini can trace his requests. \n"
38
"In real life only operator can read this file so "
39
"there is no security issue. Note that even if person "
40
"can trigger profiler, only admin user can retrieve "
41
"trace information.\n"
42
"To disable OSprofiler set in heat.conf:\n"
43
"[profiler]\nenabled=false"))
45
osprofiler.web.disable()