mirror of
https://github.com/ceph/ceph
synced 2025-01-29 22:43:40 +00:00
prometheus: Use instance instead of inst variable
Signed-off-by: Boris Ranto <branto@redhat.com>
This commit is contained in:
parent
84241a2953
commit
0869351892
@ -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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user