openwebrx-clone/owrx/metrics.py

31 lines
758 B
Python
Raw Normal View History

class Metrics(object):
sharedInstance = None
@staticmethod
def getSharedInstance():
if Metrics.sharedInstance is None:
Metrics.sharedInstance = Metrics()
return Metrics.sharedInstance
def __init__(self):
self.metrics = {}
2019-08-11 09:37:45 +00:00
def pushDecodes(self, band, mode, count=1):
if band is None:
2019-08-11 09:37:45 +00:00
band = "unknown"
else:
band = band.getName()
if mode is None:
2019-08-11 09:37:45 +00:00
mode = "unknown"
if not band in self.metrics:
self.metrics[band] = {}
if not mode in self.metrics[band]:
2019-08-11 09:37:45 +00:00
self.metrics[band][mode] = {"count": 0}
self.metrics[band][mode]["count"] += count
def getMetrics(self):
return self.metrics