runzhiwang commented on a change in pull request #76:
URL: https://github.com/apache/incubator-ratis/pull/76#discussion_r418791782
##########
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 Hi, thanks for review. Even though I have removed
prometheus in ratis, but it exists in ozone. Such as the following code. ozone
call `CollectorRegistry.defaultRegistry.register` to register registry in
prometheus, and it also need call
`CollectorRegistry.defaultRegistry.unregister` to unregister it. There is no
close method for prometheus, and the unregister also need a parameter which
differs from Reporter::close.
```
MetricRegistries.global().addReporterRegistration(
registry -> CollectorRegistry.defaultRegistry.register(
new RatisDropwizardExports(
registry.getDropWizardMetricRegistry())),
registry -> CollectorRegistry.defaultRegistry.unregister(
new RatisDropwizardExports(
registry.getDropWizardMetricRegistry())));
```
----------------------------------------------------------------
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]