Search in sources :

Example 1 with NamedAggregators

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());
        }
    };
}
Also used : Function(com.google.common.base.Function) Metric(com.codahale.metrics.Metric) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) SortedMap(java.util.SortedMap) NamedAggregators(org.apache.beam.runners.spark.aggregators.NamedAggregators) Gauge(com.codahale.metrics.Gauge)

Aggregations

Gauge (com.codahale.metrics.Gauge)1 Metric (com.codahale.metrics.Metric)1 Function (com.google.common.base.Function)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 NamedAggregators (org.apache.beam.runners.spark.aggregators.NamedAggregators)1