Log how long it takes to run a query when collecting metrics

Right now all elastic-recheck queries are using query_string queries
against ElasticRecheck, but if we ever support more options like
multi-line queries or regexp queries, it would be good to know how those
perform relative to the query_string queries, so log it at debug level
when running the CLI to dump metrics.

Change-Id: I8414205b84e347d3305ee8d7e6ac2d4ca18c9818
This commit is contained in:
Matt Riedemann 2014-01-08 10:54:24 -08:00
parent 63062df64e
commit bd4e1d8b9a

View File

@ -16,15 +16,18 @@
import argparse
import collections
import logging
import operator
import os
import re
import time
from launchpadlib import launchpad
import elastic_recheck.elasticRecheck as er
import elastic_recheck.results as er_results
LOG = logging.getLogger('recheckwatchbot')
LPCACHEDIR = os.path.expanduser('~/.launchpadlib/cache')
@ -165,7 +168,10 @@ def _failure_percentage(hits, fails):
def collect_metrics(classifier, fails):
data = {}
for q in classifier.queries:
start = time.time()
results = classifier.hits_by_query(q['query'], size=30000)
LOG.debug("Took %d seconds to run (uncached) query for bug %s" %
(time.time() - start, q['bug']))
hits = _status_count(results)
data[q['bug']] = {
'fails': _failure_count(hits),