runzhiwang commented on a change in pull request #76:
URL: https://github.com/apache/incubator-ratis/pull/76#discussion_r418216518



##########
File path: 
ratis-metrics/src/main/java/org/apache/ratis/metrics/MetricsReporting.java
##########
@@ -34,17 +34,41 @@ private MetricsReporting() {
   }
 
   public static Consumer<RatisMetricRegistry> consoleReporter(TimeDuration 
rate) {
-    return ratisMetricRegistry -> 
ConsoleReporter.forRegistry(ratisMetricRegistry.getDropWizardMetricRegistry())
-        
.convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build()
-        .start(rate.getDuration(), rate.getUnit());
+    return ratisMetricRegistry -> {
+      ConsoleReporter reporter = 
ConsoleReporter.forRegistry(ratisMetricRegistry.getDropWizardMetricRegistry())
+          
.convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
+      reporter.start(rate.getDuration(), rate.getUnit());
+      ratisMetricRegistry.setConsoleReporter(reporter);
+    };
+  }
+
+  public static Consumer<RatisMetricRegistry> stopConsoleReporter() {

Review comment:
       @avijayanhwx Yes, we can close() JmxReporter and ConsoleReporter. But 
for prometheus, it only has unregister, and also need a parameter 
i.e.collector. I think prometheus make the problem complicated.The following 
code copy from ozone related PR: 
https://github.com/apache/hadoop-ozone/pull/885.
   
   
![image](https://user-images.githubusercontent.com/51938049/80747058-66b76f00-8b55-11ea-8402-5f60ecb03ed2.png)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to