mirror of
https://github.com/searxng/searxng.git
synced 2025-08-03 02:22:22 +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
|
@ -9,7 +9,7 @@ from timeit import default_timer
|
|||
from operator import itemgetter
|
||||
|
||||
from searx.engines import engines
|
||||
from .models import HistogramStorage, CounterStorage
|
||||
from .models import HistogramStorage, CounterStorage, VoidHistogram, VoidCounterStorage
|
||||
from .error_recorder import count_error, count_exception, errors_per_engines
|
||||
|
||||
__all__ = [
|
||||
|
@ -69,14 +69,18 @@ def counter(*args):
|
|||
return counter_storage.get(*args)
|
||||
|
||||
|
||||
def initialize(engine_names=None):
|
||||
def initialize(engine_names=None, enabled=True):
|
||||
"""
|
||||
Initialize metrics
|
||||
"""
|
||||
global counter_storage, histogram_storage # pylint: disable=global-statement
|
||||
|
||||
counter_storage = CounterStorage()
|
||||
histogram_storage = HistogramStorage()
|
||||
if enabled:
|
||||
counter_storage = CounterStorage()
|
||||
histogram_storage = HistogramStorage()
|
||||
else:
|
||||
counter_storage = VoidCounterStorage()
|
||||
histogram_storage = HistogramStorage(histogram_class=VoidHistogram)
|
||||
|
||||
# max_timeout = max of all the engine.timeout
|
||||
max_timeout = 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue