private Stream<Entry<MatchedName, MetricValue>> filterMetricsInTsv(TimeSeriesValue tsv) { return tsv.getMetrics().entrySet().stream() .filter(entry -> match(entry.getKey())) .map(metricEntry -> SimpleMapEntry.create(new MatchedName(tsv, metricEntry.getKey()), metricEntry.getValue())); } }
@Override public Stream<Consumer<MutableContext>> map(Stream<Consumer<MutableContext>> in, Context ctx) { final Map<IdentifierPair, List<Map.Entry<MetricMatcher.MatchedName, MetricValue>>> metricMapping = matchers.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, mmEntry -> mmEntry.getValue().filter(ctx).collect(Collectors.toList()))); for (final Map.Entry<IdentifierPair, List<Map.Entry<MetricMatcher.MatchedName, MetricValue>>> mm : metricMapping.entrySet()) { final String groupIdentifier = mm.getKey().getGroup(); final String metricIdentifier = mm.getKey().getMetric(); final List<Consumer<MutableContext>> applications = mm.getValue().stream() .map(matchedMetric -> { Consumer<MutableContext> application = (nestedCtx) -> { nestedCtx.putGroupAliasByName(groupIdentifier, matchedMetric.getKey().getMatchedGroup()::getGroup); nestedCtx.putMetricAliasByName(metricIdentifier, matchedMetric.getKey().getMatchedGroup()::getGroup, matchedMetric.getKey()::getMetric); }; return application; }) .collect(Collectors.toList()); in = in.flatMap(inApplication -> applications.stream().map(inApplication::andThen)); } return in; } };
.map(named_entry -> SimpleMapEntry.create(named_entry.getKey().getTags(), named_entry.getValue())) .collect(Collectors.toList());
public Tags getTags() { return getGroup().getTags(); } }