OSprofiler initialization method
Added init_from_conf method, that takes service configuration and initializes notifier. This allows initialization to be handled in osprofiler instead of projects/services. Added oslo.messaging dependency. Change-Id: I77d0d3b5e9e725507916724dcd28d5fbc6f7f5c7
This commit is contained in:
parent
10f48b9cc8
commit
aca7aeb133
|
@ -0,0 +1,42 @@
|
|||
# Copyright 2016 Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import oslo_messaging
|
||||
|
||||
from osprofiler import notifier
|
||||
from osprofiler import web
|
||||
|
||||
|
||||
def init_from_conf(conf, context, project, service, host):
|
||||
"""Initialize notifier from service configuration
|
||||
|
||||
:param conf: service configuration
|
||||
:param context: request context
|
||||
:param project: project name (keystone, cinder etc.)
|
||||
:param service: service name that will be profiled
|
||||
:param host: hostname or host IP address that the service will be
|
||||
running on.
|
||||
"""
|
||||
connection_str = conf.profiler.connection_string
|
||||
_notifier = notifier.create(
|
||||
connection_str,
|
||||
messaging=oslo_messaging,
|
||||
context=context,
|
||||
transport=oslo_messaging.get_transport(conf),
|
||||
project=project,
|
||||
service=service,
|
||||
host=host)
|
||||
notifier.set(_notifier)
|
||||
web.enable(conf.profiler.hmac_keys)
|
|
@ -1,3 +1,4 @@
|
|||
six>=1.9.0 # MIT
|
||||
oslo.messaging>=5.2.0 # Apache-2.0
|
||||
oslo.utils>=3.4.0 # Apache-2.0
|
||||
WebOb>=1.2.3 # MIT
|
||||
|
|
Loading…
Reference in New Issue