From 471952e2771b2af1e0d12ac41a71d0e0adf1e49a Mon Sep 17 00:00:00 2001 From: Matthew Davis Date: Thu, 24 Aug 2023 08:56:15 -0400 Subject: [PATCH] add label to log if a label is provided --- .../federator/QueryRequestFederator.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/zulia-server/src/main/java/io/zulia/server/index/federator/QueryRequestFederator.java b/zulia-server/src/main/java/io/zulia/server/index/federator/QueryRequestFederator.java index 175cc152..1e87505d 100644 --- a/zulia-server/src/main/java/io/zulia/server/index/federator/QueryRequestFederator.java +++ b/zulia-server/src/main/java/io/zulia/server/index/federator/QueryRequestFederator.java @@ -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 results = send(request); @@ -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; } @@ -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"; @@ -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"); + } } }