use of org.apache.beam.runners.spark.aggregators.NamedAggregators in project beam by apache.
the class WithMetricsSupport method aggregatorMetricToGauges.
private Function<Map.Entry<String, Metric>, Map<String, Gauge>> aggregatorMetricToGauges() {
return new Function<Map.Entry<String, Metric>, Map<String, Gauge>>() {
@Override
public Map<String, Gauge> apply(final Map.Entry<String, Metric> entry) {
final NamedAggregators agg = ((AggregatorMetric) entry.getValue()).getNamedAggregators();
final String parentName = entry.getKey();
final Map<String, Gauge> gaugeMap = Maps.transformEntries(agg.renderAll(), toGauge());
final Map<String, Gauge> fullNameGaugeMap = Maps.newLinkedHashMap();
for (Map.Entry<String, Gauge> gaugeEntry : gaugeMap.entrySet()) {
fullNameGaugeMap.put(parentName + "." + gaugeEntry.getKey(), gaugeEntry.getValue());
}
return Maps.filterValues(fullNameGaugeMap, Predicates.notNull());
}
};
}
Aggregations