on master help sign in
[fix] error_recorder: record code and lineno about the engine

since the PR #2225 , code and lineno were sometimes meaningless see /stats/errors

commitca76f3119a4d66cb8aa74829ca5f0a0a72f0f96b authorAlexandre Flament <alex@al-f.net> dateSun 17 Jan 2021, 16:11 (6 years ago) parent80d7411
1 file changed+5−8
searx/metrology/error_recorder.py+5−8
searx/metrology/error_recorder.py+5−8
@@ -51,15 +51,12 @@ def add_error_context(engine_name: str, error_context: ErrorContext) -> None:
5151
5252
5353def get_trace(traces):
54− previous_trace = traces[-1]
5554 for trace in reversed(traces):
56− if trace.filename.endswith('searx/search.py'):
57− if previous_trace.filename.endswith('searx/poolrequests.py'):
58− return trace
59− if previous_trace.filename.endswith('requests/models.py'):
60− return trace
61− return previous_trace
62− previous_trace = trace
55+ split_filename = trace.filename.split('/')
56+ if len(split_filename) > 3 and '/'.join(split_filename[-3:-1]) == 'searx/engines':
57+ return trace
58+ if len(split_filename) > 3 and '/'.join(split_filename[-4:-1]) == 'searx/search/processors':
59+ return trace
6360 return traces[-1]
6461
6562