Merge "Remove ceilometer from osprofile backend"
This commit is contained in:
commit
1aba8b2471
|
@ -642,7 +642,7 @@ in that dictionary are:
|
||||||
feature from older versions of osprofiler when OpenStack components could use
|
feature from older versions of osprofiler when OpenStack components could use
|
||||||
oslo.messaging for notifications and the trace client used ceilometer as a
|
oslo.messaging for notifications and the trace client used ceilometer as a
|
||||||
receiver backend. By default Horizon uses the same URL pointing to a MongoDB
|
receiver backend. By default Horizon uses the same URL pointing to a MongoDB
|
||||||
cluster for both purposes, since ceilometer was too slow for using with UI.
|
cluster for both purposes.
|
||||||
Example: ``"receiver_connection_string": "mongodb://%s" % OPENSTACK_HOST``.
|
Example: ``"receiver_connection_string": "mongodb://%s" % OPENSTACK_HOST``.
|
||||||
|
|
||||||
.. _osprofiler documentation: https://docs.openstack.org/osprofiler/latest/user/integration.html#how-to-initialize-profiler-to-get-one-trace-across-all-services
|
.. _osprofiler documentation: https://docs.openstack.org/osprofiler/latest/user/integration.html#how-to-initialize-profiler-to-get-one-trace-across-all-services
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import json
|
import json
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from osprofiler import _utils as utils
|
from osprofiler import _utils as utils
|
||||||
from osprofiler.drivers.base import get_driver as profiler_get_driver
|
from osprofiler.drivers.base import get_driver as profiler_get_driver
|
||||||
from osprofiler import notifier
|
from osprofiler import notifier
|
||||||
|
@ -50,35 +48,14 @@ def traced(request, name, info=None):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
def _get_engine_kwargs(request, connection_str):
|
def _get_engine():
|
||||||
from openstack_dashboard.api import base
|
|
||||||
engines_kwargs = {
|
|
||||||
# NOTE(tsufiev): actually Horizon doesn't use ceilometer backend (too
|
|
||||||
# slow for UI), but since osprofiler still supports it (due to API
|
|
||||||
# deprecation cycle limitations), Horizon also should support this
|
|
||||||
# option
|
|
||||||
'ceilometer': lambda req: {
|
|
||||||
'endpoint': base.url_for(req, 'metering'),
|
|
||||||
'insecure': settings.OPENSTACK_SSL_NO_VERIFY,
|
|
||||||
'cacert': settings.OPENSTACK_SSL_CACERT,
|
|
||||||
'token': (lambda: req.user.token.id),
|
|
||||||
'ceilometer_api_version': '2'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
engine = urlparse(connection_str).scheme
|
|
||||||
return engines_kwargs.get(engine, lambda req: {})(request)
|
|
||||||
|
|
||||||
|
|
||||||
def _get_engine(request):
|
|
||||||
connection_str = horizon_settings.get_dict_config(
|
connection_str = horizon_settings.get_dict_config(
|
||||||
'OPENSTACK_PROFILER', 'receiver_connection_string')
|
'OPENSTACK_PROFILER', 'receiver_connection_string')
|
||||||
kwargs = _get_engine_kwargs(request, connection_str)
|
return profiler_get_driver(connection_str)
|
||||||
return profiler_get_driver(connection_str, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def list_traces(request):
|
def list_traces():
|
||||||
engine = _get_engine(request)
|
engine = _get_engine()
|
||||||
fields = ['base_id', 'timestamp', 'info.request.path', 'info']
|
fields = ['base_id', 'timestamp', 'info.request.path', 'info']
|
||||||
traces = engine.list_traces(fields)
|
traces = engine.list_traces(fields)
|
||||||
return [{'id': trace['base_id'],
|
return [{'id': trace['base_id'],
|
||||||
|
@ -86,7 +63,7 @@ def list_traces(request):
|
||||||
'origin': trace['info']['request']['path']} for trace in traces]
|
'origin': trace['info']['request']['path']} for trace in traces]
|
||||||
|
|
||||||
|
|
||||||
def get_trace(request, trace_id):
|
def get_trace(trace_id):
|
||||||
def rec(_data, level=0):
|
def rec(_data, level=0):
|
||||||
_data['level'] = level
|
_data['level'] = level
|
||||||
_data['is_leaf'] = not _data['children']
|
_data['is_leaf'] = not _data['children']
|
||||||
|
@ -103,7 +80,7 @@ def get_trace(request, trace_id):
|
||||||
finished = child_finished
|
finished = child_finished
|
||||||
return _data, finished
|
return _data, finished
|
||||||
|
|
||||||
engine = _get_engine(request)
|
engine = _get_engine()
|
||||||
trace = engine.get_report(trace_id)
|
trace = engine.get_report(trace_id)
|
||||||
data, max_finished = rec(trace)
|
data, max_finished = rec(trace)
|
||||||
data['info']['max_finished'] = max_finished
|
data['info']['max_finished'] = max_finished
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Traces(generic.View):
|
||||||
|
|
||||||
@utils.ajax()
|
@utils.ajax()
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
return api.list_traces(request)
|
return api.list_traces()
|
||||||
|
|
||||||
|
|
||||||
@urls.register
|
@urls.register
|
||||||
|
@ -46,4 +46,4 @@ class Trace(generic.View):
|
||||||
|
|
||||||
@utils.ajax()
|
@utils.ajax()
|
||||||
def get(self, request, trace_id):
|
def get(self, request, trace_id):
|
||||||
return api.get_trace(request, trace_id)
|
return api.get_trace(trace_id)
|
||||||
|
|
Loading…
Reference in New Issue