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

    https://github.com/apache/storm/pull/2763#discussion_r205515487
  
    --- Diff: 
storm-server/src/main/java/org/apache/storm/metric/StormMetricsRegistry.java ---
    @@ -27,52 +28,67 @@
     
     @SuppressWarnings("unchecked")
     public class StormMetricsRegistry {
    -    public static final MetricRegistry DEFAULT_REGISTRY = new 
MetricRegistry();
    +    private static final MetricRegistry DEFAULT_REGISTRY = new 
MetricRegistry();
         private static final Logger LOG = 
LoggerFactory.getLogger(StormMetricsRegistry.class);
     
    -    public static Meter registerMeter(String name) {
    -        Meter meter = new Meter();
    -        return register(name, meter);
    +    public static Meter registerMeter(final String name) {
    +        return register(name, new Meter());
         }
     
    -    // TODO: should replace Callable to Gauge<Integer> when nimbus.clj is 
translated to java
    -    public static Gauge<Integer> registerGauge(final String name, final 
Callable fn) {
    -        Gauge<Integer> gauge = new Gauge<Integer>() {
    -            @Override
    -            public Integer getValue() {
    -                try {
    -                    return (Integer) fn.call();
    -                } catch (Exception e) {
    -                    LOG.error("Error getting gauge value for {}", name, e);
    -                }
    -                return 0;
    +    /**
    +     * Register a gauge with provided callback. This swallows all 
exceptions
    +     * thrown from the callback, consider using {@link 
#registerProvidedGauge(String, Gauge)}
    +     * if no exceptions will be thrown by the callable.
    +     *
    +     * @param name name of the gauge
    +     * @param fn callback that measures
    +     * @param <V> type of measurement the callback returns, also the type 
of gauge
    +     * @return registered gauge
    +     */
    +    public static <V> Gauge<V> registerGauge(final String name, final 
Callable<V> fn) {
    --- End diff --
    
    Could we just change this to take a guage instead?
    
    ```
    public static <V> Gauge<V> registerGauge(final String name, final Gauge<V> 
gauge) {
        return register(name, gauge);
    }
    ```
    We are not calling this from clojure anymore so we didn't need the Callable 
any more, and for the most part there are no code changes to make this happen.


---

Reply via email to