| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e19ecd4 commit 82b48df
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,10 +189,19 @@ private void findNextElement() { | |||
| 189 | 189 | } | |
| 190 | 190 | ||
| 191 | 191 | private Collector.MetricFamilySamples filter(Collector.MetricFamilySamples next) { | |
| 192 | - if (includedNames.isEmpty() || includedNames.contains(next.name)) { | ||
| 192 | + if (includedNames.isEmpty()) { | ||
| 193 | 193 | return next; | |
| 194 | 194 | } else { | |
| 195 | - return null; | ||
| 195 | + Iterator<Collector.MetricFamilySamples.Sample> it = next.samples.iterator(); | ||
| 196 | + while (it.hasNext()) { | ||
| 197 | + if (!includedNames.contains(it.next().name)) { | ||
| 198 | + it.remove(); | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + if (next.samples.size() == 0) { | ||
| 202 | + return null; | ||
| 203 | + } | ||
| 204 | + return next; | ||
| 196 | 205 | } | |
| 197 | 206 | } | |
| 198 | 207 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,15 +80,20 @@ public void testMetricFamilySamples_filterNames() { | |||
| 80 | 80 | Collector ec = new EmptyCollector().register(registry); | |
| 81 | 81 | SkippedCollector sr = new SkippedCollector().register(registry); | |
| 82 | 82 | PartiallyFilterCollector pfr = new PartiallyFilterCollector().register(registry); | |
| 83 | - HashSet<String> names = new HashSet<String>(); | ||
| 83 | + HashSet<String> metrics = new HashSet<String>(); | ||
| 84 | + HashSet<String> series = new HashSet<String>(); | ||
| 84 | 85 | for (Collector.MetricFamilySamples metricFamilySamples : Collections.list(registry.filteredMetricFamilySamples( | |
| 85 | - new HashSet<String>(Arrays.asList("", "s", "c", "part_filter_a", "part_filter_c"))))) { | ||
| 86 | - names.add(metricFamilySamples.name); | ||
| 86 | + new HashSet<String>(Arrays.asList("", "s_sum", "c", "part_filter_a", "part_filter_c"))))) { | ||
| 87 | + metrics.add(metricFamilySamples.name); | ||
| 88 | + for (Collector.MetricFamilySamples.Sample sample : metricFamilySamples.samples) { | ||
| 89 | + series.add(sample.name); | ||
| 90 | + } | ||
| 87 | 91 | } | |
| 88 | 92 | ||
| 89 | 93 | assertEquals(1, sr.collectCallCount); | |
| 90 | 94 | assertEquals(2, pfr.collectCallCount); | |
| 91 | - assertEquals(new HashSet<String>(Arrays.asList("s", "c", "part_filter_a", "part_filter_c")), names); | ||
| 95 | + assertEquals(new HashSet<String>(Arrays.asList("s", "c", "part_filter_a", "part_filter_c")), metrics); | ||
| 96 | + assertEquals(new HashSet<String>(Arrays.asList("s_sum", "c", "part_filter_a", "part_filter_c")), series); | ||
| 92 | 97 | } | |
| 93 | 98 | ||
| 94 | 99 | @Test | |
| Back | FazBrowse Home | New Git URL |
0 commit comments