@Test public void reportsAllMetricsIfNotPerformingFiltering() { Timer timer = taggedMetricRegistry.timer(METRIC_NAME_1); FilteredTaggedMetricSet filteredTaggedMetricSet = new FilteredTaggedMetricSet( taggedMetricRegistry, $ -> false, Refreshable.only(false)); assertThat(filteredTaggedMetricSet.getMetrics()).containsExactlyInAnyOrderEntriesOf( ImmutableMap.of(METRIC_NAME_1, timer)); }
@Override public Map<MetricName, Metric> getMetrics() { if (performFiltering.get()) { return KeyedStream.stream(unfiltered.getMetrics()) .filterKeys(metricNameFilter) .collectToMap(); } return unfiltered.getMetrics(); }
FilteredTaggedMetricSet implements TaggedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { if (performFiltering.get()) { return KeyedStream.stream(unfiltered.getMetrics()) .filterKeys(metricNameFilter) .collectToMap(); } return unfiltered.getMetrics(); } }
FilteredTaggedMetricSet implements TaggedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { if (performFiltering.get()) { return KeyedStream.stream(unfiltered.getMetrics()) .filterKeys(metricNameFilter) .collectToMap(); } return unfiltered.getMetrics(); } FilteredTaggedMetricSet(
            TaggedMetricSet unfiltered,
            Predicate<MetricName> metricNameFilter,
            Refreshable<Boolean> performFiltering); }
FilteredTaggedMetricSet implements TaggedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { if (performFiltering.get()) { return KeyedStream.stream(unfiltered.getMetrics()) .filterKeys(metricNameFilter) .collectToMap(); } return unfiltered.getMetrics(); } FilteredTaggedMetricSet(
            TaggedMetricSet unfiltered,
            Predicate<MetricName> metricNameFilter,
            Refreshable<Boolean> performFiltering); @Override Map<MetricName, Metric> getMetrics(); @Override void forEachMetric(BiConsumer<MetricName, Metric> consumer); }
FilteredTaggedMetricSet implements TaggedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { if (performFiltering.get()) { return KeyedStream.stream(unfiltered.getMetrics()) .filterKeys(metricNameFilter) .collectToMap(); } return unfiltered.getMetrics(); } FilteredTaggedMetricSet(
            TaggedMetricSet unfiltered,
            Predicate<MetricName> metricNameFilter,
            Refreshable<Boolean> performFiltering); @Override Map<MetricName, Metric> getMetrics(); @Override void forEachMetric(BiConsumer<MetricName, Metric> consumer);  }