1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
Descriptiont: Fix osprofiler usage in horizon
This patch fixes usage of osprofiler in horizon which is not
working now. Redis driver is not using oslo_config, and this patch
is removing it as it removed in mongo driver already. As clients
are calling osprofiler.initializer.init_from_conf, this patch
is not affecting services. Only fixing osprofiler dashboard usage.
Author: Michal Arbet <michal.arbet@ultimum.io>
Date: Fri, 11 Jan 2019 16:38:21 +0100
Change-Id: Id4f3a5c31167b2edae839f82a56d431900aba33e
Bug-Ubuntu: https://bugs.launchpad.net/osprofiler/+bug/1811260
Origin: upstream, https://review.openstack.org/#/c/630298/
Last-Update: 2019-01-11
diff --git a/osprofiler/drivers/redis_driver.py b/osprofiler/drivers/redis_driver.py
index 250a81c..4da451a 100644
--- a/osprofiler/drivers/redis_driver.py
+++ b/osprofiler/drivers/redis_driver.py
@@ -16,7 +16,6 @@
from debtcollector import removals
-from oslo_config import cfg
from oslo_serialization import jsonutils
import six.moves.urllib.parse as parser
@@ -30,12 +29,11 @@
"Please specify 'db' in "
"'connection_string' instead.")
def __init__(self, connection_str, db=0, project=None,
- service=None, host=None, conf=cfg.CONF, **kwargs):
+ service=None, host=None, **kwargs):
"""Redis driver for OSProfiler."""
super(Redis, self).__init__(connection_str, project=project,
- service=service, host=host,
- conf=conf, **kwargs)
+ service=service, host=host, **kwargs)
try:
from redis import StrictRedis
except ImportError:
@@ -157,12 +155,12 @@
"Please specify 'db' in "
"'connection_string' instead.")
def __init__(self, connection_str, db=0, project=None,
- service=None, host=None, conf=cfg.CONF, **kwargs):
+ service=None, host=None, **kwargs):
"""Redis driver for OSProfiler."""
super(RedisSentinel, self).__init__(connection_str, project=project,
service=service, host=host,
- conf=conf, **kwargs)
+ **kwargs)
try:
from redis.sentinel import Sentinel
except ImportError:
@@ -171,13 +169,12 @@
"'redis' manually. Use command:\n "
"'pip install redis'.")
- self.conf = conf
- socket_timeout = self.conf.profiler.socket_timeout
+ socket_timeout = 0.1
parsed_url = parser.urlparse(self.connection_str)
sentinel = Sentinel([(parsed_url.hostname, int(parsed_url.port))],
password=parsed_url.password,
socket_timeout=socket_timeout)
- self.db = sentinel.master_for(self.conf.profiler.sentinel_service_name,
+ self.db = sentinel.master_for(parsed_url.path.replace("/", ""),
socket_timeout=socket_timeout)
@classmethod
|