summaryrefslogtreecommitdiff
path: root/searx/metrics/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/metrics/models.py')
-rw-r--r--searx/metrics/models.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/searx/metrics/models.py b/searx/metrics/models.py
index d42569b7f..900a7fa93 100644
--- a/searx/metrics/models.py
+++ b/searx/metrics/models.py
@@ -102,16 +102,17 @@ class Histogram:
class HistogramStorage:
- __slots__ = 'measures'
+ __slots__ = 'measures', 'histogram_class'
- def __init__(self):
+ def __init__(self, histogram_class=Histogram):
self.clear()
+ self.histogram_class = histogram_class
def clear(self):
self.measures = {}
def configure(self, width, size, *args):
- measure = Histogram(width, size)
+ measure = self.histogram_class(width, size)
self.measures[args] = measure
return measure
@@ -154,3 +155,13 @@ class CounterStorage:
logger.debug("Counters:")
for k in ks:
logger.debug("- %-60s %s", '|'.join(k), self.counters[k])
+
+
+class VoidHistogram(Histogram):
+ def observe(self, value):
+ pass
+
+
+class VoidCounterStorage(CounterStorage):
+ def add(self, value, *args):
+ pass