Github user HeartSaVioR commented on a diff in the pull request:
https://github.com/apache/storm/pull/1560#discussion_r70800325
--- Diff:
storm-core/src/jvm/org/apache/storm/metric/util/DataPointPopulator.java ---
@@ -0,0 +1,61 @@
+package org.apache.storm.metric.util;
+
+import org.apache.storm.metric.api.IMetricsConsumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class DataPointPopulator implements Serializable {
+ public static final Logger LOG =
LoggerFactory.getLogger(DataPointPopulator.class);
+
+ private final boolean populateMapType;
+ private final String metricNameSeparator;
+
+ public DataPointPopulator(boolean populateMapType, String
metricNameSeparator) {
+ this.populateMapType = populateMapType;
+ this.metricNameSeparator = metricNameSeparator;
+ }
+
+ public Collection<IMetricsConsumer.DataPoint>
populateDataPoints(Collection<IMetricsConsumer.DataPoint> dataPoints) {
+ if (!populateMapType) {
+ return dataPoints;
+ }
+
+ List<IMetricsConsumer.DataPoint> populatedDataPoints = new
ArrayList<>();
+
+ for (IMetricsConsumer.DataPoint dataPoint : dataPoints) {
+ populatedDataPoints.addAll(populateDataPoint(dataPoint));
+ }
+
+ return populatedDataPoints;
+ }
+
+ public Collection<IMetricsConsumer.DataPoint>
populateDataPoint(IMetricsConsumer.DataPoint dataPoint) {
--- End diff --
At least built-in metrics have at most one depth Map, but no more (I mean
no nested Map). The reason we would want to have such kind of logic is to
handle built-in metrics. In normal, having Map as value is not recommended
(which is what Bobby said too flexible).
For example, some metrics consumers take care of nested map, some of others
only take care one depth map, the others don't take care of map. Users
shouldn't rely on them.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---