Skip to content

Commit

Permalink
feat: Add search timings to segment events
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnuon committed Dec 19, 2023
1 parent 966e1e1 commit aaa4372
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,23 @@ def perform_search(

# post-process the result
start = time.time()
q

for result in results["results"]:
result["data"] = SearchResultProcessor.process_result(result["data"], search_term, user)

results["access_denied_count"] = len([r for r in results["results"] if r["data"] is None])
results["results"] = [r for r in results["results"] if r["data"] is not None]

end = time.time()
filtering_time_in_seconds = end - start

log.info("ES result timings: %s", {
'es_query_time_in_ms': results['took'],
'filtering_time_in_seconds': end - start,
'filtering_time_in_seconds': filtering_time_in_seconds,
'es_has_timed_out': results['timed_out'],
})

results['filtering_time_in_seconds'] = filtering_time_in_seconds
return results


Expand Down
1 change: 1 addition & 0 deletions search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def do_search(request, course_id=None):
"page_size": size,
"page_number": page,
"results_count": results["total"],
"filtering_time_in_seconds": results["filtering_time_in_seconds"],
}
)

Expand Down

0 comments on commit aaa4372

Please sign in to comment.