Github user srdo commented on a diff in the pull request:
https://github.com/apache/storm/pull/2763#discussion_r203723640
--- Diff:
storm-server/src/main/java/org/apache/storm/metric/StormMetricsRegistry.java ---
@@ -27,52 +28,63 @@
@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.
--- End diff --
Nit: Consider adding a note that this handles exceptions thrown from the
callback.
---