summaryrefslogtreecommitdiff
path: root/searx/results.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-04-14 17:23:15 +0200
committerAlexandre Flament <alex@al-f.net>2021-04-21 16:24:46 +0200
commit7acd7ffc02d14d175ec2a99ba984e47d8cb65d7d (patch)
tree000b6e4b0038ed627bb114f8a2de83681bbf7ad4 /searx/results.py
parentaae7830d14242ac1f98232f428654c5d2c9c5eb2 (diff)
[enh] rewrite and enhance metrics
Diffstat (limited to 'searx/results.py')
-rw-r--r--searx/results.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/searx/results.py b/searx/results.py
index c1a1819d..41c15080 100644
--- a/searx/results.py
+++ b/searx/results.py
@@ -5,7 +5,7 @@ from threading import RLock
from urllib.parse import urlparse, unquote
from searx import logger
from searx.engines import engines
-from searx.metrology.error_recorder import record_error
+from searx.metrics import histogram_observe, counter_add, count_error
CONTENT_LEN_IGNORED_CHARS_REGEX = re.compile(r'[,;:!?\./\\\\ ()-_]', re.M | re.U)
@@ -196,12 +196,10 @@ class ResultContainer:
if len(error_msgs) > 0:
for msg in error_msgs:
- record_error(engine_name, 'some results are invalids: ' + msg)
+ count_error(engine_name, 'some results are invalids: ' + msg)
if engine_name in engines:
- with RLock():
- engines[engine_name].stats['search_count'] += 1
- engines[engine_name].stats['result_count'] += standard_result_count
+ histogram_observe(standard_result_count, 'engine', engine_name, 'result', 'count')
if not self.paging and standard_result_count > 0 and engine_name in engines\
and engines[engine_name].paging:
@@ -301,9 +299,8 @@ class ResultContainer:
for result in self._merged_results:
score = result_score(result)
result['score'] = score
- with RLock():
- for result_engine in result['engines']:
- engines[result_engine].stats['score_count'] += score
+ for result_engine in result['engines']:
+ counter_add(score, 'engine', result_engine, 'score')
results = sorted(self._merged_results, key=itemgetter('score'), reverse=True)