Set<MetricEvent> () { if (REPORT_AGGREGATED_STATS_TO_FUS) { final Set<MetricEvent> allKeysLookupStats = allKeysLookupDurationsMsByIndexId.entrySet().stream().map(e -> { final IndexId<?, ?> indexId = e.getKey(); final Recorder recorderForIndex = e.getValue(); final Histogram recordedValuesHistogram = recorderForIndex.getIntervalHistogram(); return EVENT_INDEX_ALL_KEYS_LOOKUP.metric( FIELD_INDEX_ID.with(indexId.getName()), FIELD_LOOKUPS_TOTAL.with((int)recordedValuesHistogram.getTotalCount()), //TODO FIELD_LOOKUPS_FAILED.with( -1 ), FIELD_LOOKUP_DURATION_MEAN.with(recordedValuesHistogram.getMean()), FIELD_LOOKUP_DURATION_90P.with((int)recordedValuesHistogram.getValueAtPercentile(90)), FIELD_LOOKUP_DURATION_95P.with((int)recordedValuesHistogram.getValueAtPercentile(95)), FIELD_LOOKUP_DURATION_99P.with((int)recordedValuesHistogram.getValueAtPercentile(99)), FIELD_LOOKUP_DURATION_MAX.with((int)recordedValuesHistogram.getMaxValue() ) ); }).collect(toSet()); final Set<MetricEvent> entriesLookupStats = entriesLookupDurationsMsByIndexId.entrySet().stream().map(e -> { final IndexId<?, ?> indexId = e.getKey(); final Recorder recorderForIndex = e.getValue(); final Histogram recordedValuesHistogram = recorderForIndex.getIntervalHistogram(); return EVENT_INDEX_ENTRIES_LOOKUP.metric( FIELD_INDEX_ID.with(indexId.getName()), FIELD_LOOKUPS_TOTAL.with((int)recordedValuesHistogram.getTotalCount()), //TODO FIELD_LOOKUPS_FAILED.with( -1 ), FIELD_LOOKUP_DURATION_MEAN.with(recordedValuesHistogram.getMean()), FIELD_LOOKUP_DURATION_90P.with((int)recordedValuesHistogram.getValueAtPercentile(90)), FIELD_LOOKUP_DURATION_95P.with((int)recordedValuesHistogram.getValueAtPercentile(95)), FIELD_LOOKUP_DURATION_99P.with((int)recordedValuesHistogram.getValueAtPercentile(99)), FIELD_LOOKUP_DURATION_MAX.with((int)recordedValuesHistogram.getMaxValue() ) ); }).collect(toSet()); final Set<MetricEvent> stubEntriesLookupStats = stubEntriesLookupDurationsMsByIndexId.entrySet().stream().map(e -> { final IndexId<?, ?> indexId = e.getKey(); final Recorder recorderForIndex = e.getValue(); final Histogram recordedValuesHistogram = recorderForIndex.getIntervalHistogram(); return EVENT_STUB_INDEX_ENTRIES_LOOKUP.metric( FIELD_INDEX_ID.with(indexId.getName()), FIELD_LOOKUPS_TOTAL.with((int)recordedValuesHistogram.getTotalCount()), //TODO FIELD_LOOKUPS_FAILED.with( -1 ), FIELD_LOOKUP_DURATION_MEAN.with(recordedValuesHistogram.getMean()), FIELD_LOOKUP_DURATION_90P.with((int)recordedValuesHistogram.getValueAtPercentile(90)), FIELD_LOOKUP_DURATION_95P.with((int)recordedValuesHistogram.getValueAtPercentile(95)), FIELD_LOOKUP_DURATION_99P.with((int)recordedValuesHistogram.getValueAtPercentile(99)), FIELD_LOOKUP_DURATION_MAX.with((int)recordedValuesHistogram.getMaxValue() ) ); }).collect(toSet()); final HashSet<MetricEvent> all = new HashSet<>(); all.addAll(allKeysLookupStats); all.addAll(entriesLookupStats); all.addAll(stubEntriesLookupStats); return all; } else { return Set.of( EVENT_INDEX_ALL_KEYS_LOOKUP.metric(FIELD_INDEX_ID.with("")) ); } }