mirror of
https://github.com/searxng/searxng.git
synced 2025-08-19 18:26:48 +02:00
[enh] settings.yml: implement general.enable_metrics
* allow not to record metrics (response time, etc...) * this commit doesn't change the UI. If the metrics are disabled /stats and /stats/errors will return empty response. in /preferences, the columns response time and reliability will be empty.
This commit is contained in:
parent
a7199bc085
commit
2134703b4b
8 changed files with 35 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue