Github user zd-project commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2771#discussion_r207599113
  
    --- Diff: 
storm-server/src/main/java/org/apache/storm/metric/StormMetricsRegistry.java ---
    @@ -12,28 +12,30 @@
     
     package org.apache.storm.metric;
     
    +import com.codahale.metrics.ExponentiallyDecayingReservoir;
     import com.codahale.metrics.Gauge;
     import com.codahale.metrics.Histogram;
     import com.codahale.metrics.Meter;
     import com.codahale.metrics.Metric;
     import com.codahale.metrics.MetricRegistry;
     import com.codahale.metrics.MetricSet;
     import com.codahale.metrics.Reservoir;
    +
     import java.util.Map;
     import java.util.concurrent.Callable;
    +
    +import com.codahale.metrics.Timer;
    +import org.apache.commons.lang.StringUtils;
     import org.apache.storm.daemon.metrics.MetricsUtils;
     import org.apache.storm.daemon.metrics.reporters.PreparableReporter;
     import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;
     
    -@SuppressWarnings("unchecked")
    -public class StormMetricsRegistry {
    -    private static final MetricRegistry DEFAULT_REGISTRY = new 
MetricRegistry();
    +public class StormMetricsRegistry extends MetricRegistry {
    --- End diff --
    
    The reason I changed the `static register()` to instance `register()` 
method is stated here. Also I should point out that because 
StormMetricsRegistry is a static singleton, it will persist throughout each 
UnitTest. So if a UnitTest class has multiple tests in it, all metrics will 
actually be registered multiple times. We either have to change all unit tests 
to have set up and tear down, or we have to completely revamp the 
StormMetricsRegistry class to make it non-static. As I don't have that much 
time to do either of them, I came up with this walkaround. @srdo @revans2 
@Ethanlm 


---

Reply via email to