2019-08-04 16:36:03 +00:00
|
|
|
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):
|
2019-08-04 16:36:03 +00:00
|
|
|
if band is None:
|
2019-08-11 09:37:45 +00:00
|
|
|
band = "unknown"
|
2019-08-04 16:36:03 +00:00
|
|
|
else:
|
|
|
|
band = band.getName()
|
|
|
|
|
|
|
|
if mode is None:
|
2019-08-11 09:37:45 +00:00
|
|
|
mode = "unknown"
|
2019-08-04 16:36:03 +00:00
|
|
|
|
|
|
|
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}
|
2019-08-04 16:36:03 +00:00
|
|
|
|
|
|
|
self.metrics[band][mode]["count"] += count
|
|
|
|
|
|
|
|
def getMetrics(self):
|
|
|
|
return self.metrics
|