Add histogram buckets for totalhits_per_query metric.
@@ -78,6 +78,8 @@ public class StatisticsSearcher extends Searcher {
private final Counter emptyResults; // number of results containing no concrete hits
private final Value hitsPerQuery; // mean number of hits per query
private final Value hitsPerQueryBuckets;
+ private final Value totalHitsPerQuery;
+ private final Value totalHitsPerQueryBuckets;
private final PeakQpsReporter peakQpsReporter;
@@ -139,11 +141,13 @@ public class StatisticsSearcher extends Searcher {
peakQPS = new Value(PEAK_QPS_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMax(true).setNameExtension(false));
hitsPerQuery = new Value(HITS_PER_QUERY_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMean(true).setNameExtension(false));
hitsPerQueryBuckets = Value.buildValue(HITS_PER_QUERY_METRIC, manager, null);
+ totalHitsPerQuery = new Value(TOTALHITS_PER_QUERY_METRIC, manager, new Value.Parameters().setLogRaw(false).setLogMean(true).setNameExtension(false));
+ totalHitsPerQueryBuckets = Value.buildValue(TOTALHITS_PER_QUERY_METRIC, manager, null);
emptyResults = new Counter(EMPTY_RESULTS_METRIC, manager, false);
metricReceiver.declareGauge(QUERY_LATENCY_METRIC, Optional.empty(), new MetricSettings.Builder().histogram(true).build());
metricReceiver.declareGauge(HITS_PER_QUERY_METRIC, Optional.empty(), new MetricSettings.Builder().histogram(true).build());
-
+ metricReceiver.declareGauge(TOTALHITS_PER_QUERY_METRIC, Optional.empty(), new MetricSettings.Builder().histogram(true).build());
scheduler.schedule(peakQpsReporter, 1000, 1000);
}
@@ -275,7 +279,11 @@ public class StatisticsSearcher extends Searcher {
hitsPerQueryBuckets.put(hitCount);
metric.set(HITS_PER_QUERY_METRIC, (double) hitCount, metricContext);
- metric.set(TOTALHITS_PER_QUERY_METRIC, (double) result.getTotalHitCount(), metricContext);
+ long totalHitCount = result.getTotalHitCount();
+ totalHitsPerQuery.put(totalHitCount);
+ totalHitsPerQueryBuckets.put(totalHitCount);
+ metric.set(TOTALHITS_PER_QUERY_METRIC, (double) totalHitCount, metricContext);
+
metric.set(QUERY_OFFSET_METRIC, (double) (query.getHits() + query.getOffset()), metricContext);
if (hitCount == 0) {
emptyResults.increment();
