Skip to content

Commit

Permalink
add label to log if a label is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavis95 committed Aug 24, 2023
1 parent 0217434 commit 471952e
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ public QueryResponse getResponse(QueryRequest request) throws Exception {
long start = System.currentTimeMillis();

String queryJson = JsonFormat.printer().print(request);
LOG.info("Running id <" + queryId + "> query <" + queryJson + ">");

String searchLabel = request.getSearchLabel();
if (searchLabel.isEmpty()) {
LOG.info("Running id <" + queryId + "> query <" + queryJson + ">");
}
else {
LOG.info("Running id <" + queryId + "> with label <" + searchLabel + "> query <" + queryJson + ">");
}

List<InternalQueryResponse> results = send(request);

Expand All @@ -80,7 +87,7 @@ public QueryResponse getResponse(QueryRequest request) throws Exception {
QueryResponse qr = queryCombiner.getQueryResponse();

long end = System.currentTimeMillis();
handleLog(queryId, qr, end - start);
handleLog(queryId, searchLabel, qr, end - start);
if (!queryCombiner.isShort()) {
return qr;
}
Expand All @@ -94,7 +101,7 @@ public QueryResponse getResponse(QueryRequest request) throws Exception {

}

private static void handleLog(long queryId, QueryResponse qr, long time) {
private static void handleLog(long queryId, String searchLabel, QueryResponse qr, long time) {
String prefix = "Finished query";
if (qr.getShardsQueried() == qr.getShardsPinned()) {
prefix = "Finished query from pinned cache";
Expand All @@ -103,6 +110,13 @@ else if (qr.getShardsQueried() == qr.getShardsCached()) {
prefix = "Finished query from cache";
}

LOG.info(prefix + " id <" + queryId + "> with result size " + String.format("%.2f", (qr.getSerializedSize() / 1024.0)) + "KB in " + time + "ms");
String resultSize = String.format("%.2f", (qr.getSerializedSize() / 1024.0));

if (searchLabel.isEmpty()) {
LOG.info(prefix + " id <" + queryId + "> with result size " + resultSize + "KB in " + time + "ms");
}
else {
LOG.info(prefix + " id <" + queryId + "> with label <" + searchLabel + "> with result size " + resultSize + "KB in " + time + "ms");
}
}
}

0 comments on commit 471952e

Please sign in to comment.