From 086935189275d38c0bc6df674f6fc86aaa4de770 Mon Sep 17 00:00:00 2001 From: Boris Ranto Date: Thu, 12 Jul 2018 13:57:59 +0200 Subject: [PATCH] prometheus: Use instance instead of inst variable Signed-off-by: Boris Ranto --- src/pybind/mgr/prometheus/module.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index a465eaed256..71480c6d560 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -648,25 +648,25 @@ class Module(MgrModule): @cherrypy.expose def metrics(self): - inst = global_instance() + instance = global_instance() # Lock the function execution try: - inst.collect_lock.acquire() - return self._metrics(inst) + instance.collect_lock.acquire() + return self._metrics(instance) finally: - inst.collect_lock.release() + instance.collect_lock.release() - def _metrics(self, inst): + def _metrics(self, instance): # Return cached data if available and collected before the cache times out - if inst.collect_cache and time.time() - inst.collect_time < inst.collect_timeout: - return inst.collect_cache + if instance.collect_cache and time.time() - instance.collect_time < instance.collect_timeout: + return instance.collect_cache - if inst.have_mon_connection(): - metrics = inst.collect() + if instance.have_mon_connection(): + metrics = instance.collect() cherrypy.response.headers['Content-Type'] = 'text/plain' if metrics: - inst.collect_cache = self.format_metrics(metrics) - return inst.collect_cache + instance.collect_cache = self.format_metrics(metrics) + return instance.collect_cache else: raise cherrypy.HTTPError(503, 'No MON connection') -- 2.39.5