Skip to content

Commit

Permalink
feat: Use eventracker in api.py instead of logging
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnuon committed Dec 20, 2023
1 parent 2a54da3 commit c56745e
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions search/api.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
""" search business logic implementations """

from datetime import datetime
import logging
import time

from django.conf import settings

from eventtracking import tracker as track
from .filter_generator import SearchFilterGenerator
from .search_engine_base import SearchEngine
from .result_processor import SearchResultProcessor
from .utils import DateRange

log = logging.getLogger(__name__)

# Default filters that we support, override using COURSE_DISCOVERY_FILTERS setting if desired
DEFAULT_FILTER_FIELDS = ["org", "modes", "language"]

Expand Down Expand Up @@ -104,19 +102,12 @@ def perform_search(
search_time_in_seconds = search_time['end'] - search_time['start']
filter_generation_time_in_seconds = filter_generation_time['end'] - filter_generation_time['start']

timing_results = {
"name": "edx_search.search_timings",
"cluster_query_time_in_ms": results["took"],
eventtracking.track("edx.course.search.executed", {
"search_term": search_term,
"processing_time_in_seconds": processing_time_in_seconds,
"search_time_in_seconds": search_time_in_seconds,
"filter_generation_time_in_seconds": filter_generation_time_in_seconds,
}

log.info(f"edx-search search timings {timing_results}")

results["processing_time_in_seconds"] = processing_time_in_seconds
results["search_time_in_seconds"] = search_time_in_seconds
results["filter_generation_time_in_seconds"] = filter_generation_time_in_seconds
})
return results


Expand Down

0 comments on commit c56745e

Please sign in to comment.