summaryrefslogtreecommitdiff
path: root/searx/results.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-04-22 08:34:17 +0200
committerGitHub <noreply@github.com>2021-04-22 08:34:17 +0200
commitc6d5605d272c963b075bf17eba7407d0a700cd2a (patch)
tree799ef589f587465f1b8d323fc1f569b1c7590f2a /searx/results.py
parentb7848e342273526192a3392dcfd8c291196506ac (diff)
parentbaff1cbbab8a72155823c3186971a5f56d7a92f2 (diff)
Merge pull request #7 from searxng/metrics
Metrics
Diffstat (limited to 'searx/results.py')
-rw-r--r--searx/results.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/searx/results.py b/searx/results.py
index b3b874118..a1c1d8527 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, secondary=True)
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)
@@ -369,9 +366,9 @@ class ResultContainer:
return 0
return resultnum_sum / len(self._number_of_results)
- def add_unresponsive_engine(self, engine_name, error_type, error_message=None):
+ def add_unresponsive_engine(self, engine_name, error_type, error_message=None, suspended=False):
if engines[engine_name].display_error_messages:
- self.unresponsive_engines.add((engine_name, error_type, error_message))
+ self.unresponsive_engines.add((engine_name, error_type, error_message, suspended))
def add_timing(self, engine_name, engine_time, page_load_time):
self.timings.append({