[ 
https://issues.apache.org/jira/browse/STORM-1966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15376866#comment-15376866
 ] 

ASF GitHub Bot commented on STORM-1966:
---------------------------------------

Github user HeartSaVioR commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1560#discussion_r70800422
  
    --- 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) {
    +    if (!populateMapType) {
    +      return Collections.singletonList(dataPoint);
    +    }
    +
    +    List<IMetricsConsumer.DataPoint> dataPoints = new ArrayList<>();
    +
    +    if (dataPoint.value == null) {
    +      LOG.warn("Data point with name " + dataPoint.name + " is null. 
Discarding." + dataPoint.name);
    +    } else if (dataPoint.value instanceof Map) {
    +      Map<String, Object> dataMap = (Map<String, Object>) dataPoint.value;
    --- End diff --
    
    Yeah good point. Will address.


> Expand metric having Map type as value into multiple metrics based on entries
> -----------------------------------------------------------------------------
>
>                 Key: STORM-1966
>                 URL: https://issues.apache.org/jira/browse/STORM-1966
>             Project: Apache Storm
>          Issue Type: Improvement
>          Components: storm-core
>    Affects Versions: 2.0.0, 1.1.0
>            Reporter: Jungtaek Lim
>            Assignee: Jungtaek Lim
>
> We're introducing "metrics filter" (STORM-1700) into Storm 1.1.0, which can 
> give a control of volume and kinds of metrics to users.
> After playing with metrics, I found that most of built-in metrics in Storm 
> (core and storm-kafka) are having Map as value which have been expected to be 
> populated from Metrics Consumer. Since filter resides on metrics consumer 
> bolt (not injected to metrics consumer) filter cannot know how metrics are 
> populated, thus can't filter out some of populated metrics.
> For example, let's say we have metric which name is 'A' and value is \{"B": 
> 1, "C": 2\}. For now we can't filter out 'A.C' and keep only 'A.B' since 
> filter even doesn't know 'A' will be changed to 'A.B' and 'A.C'.
> Since well-known metrics consumer (like storm-graphite) already supports 
> populating metrics from one level map of value, I'd like to support this from 
> Storm side and apply filter to populated metrics.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to