Created
May 24, 2018 13:51
-
-
Save mykidong/991cc275b1b2c3f7d3c59e19643f8457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.codahale.metrics.ConsoleReporter; | |
import com.codahale.metrics.MetricRegistry; | |
import org.springframework.beans.factory.InitializingBean; | |
import java.util.concurrent.TimeUnit; | |
public class SystemOutReporter implements InitializingBean { | |
private MetricRegistry metricRegistry; | |
// metricRegistry injected. | |
public void setMetricRegistry(MetricRegistry metricRegistry) { | |
this.metricRegistry = metricRegistry; | |
} | |
@Override | |
public void afterPropertiesSet() throws Exception { | |
ConsoleReporter reporter = ConsoleReporter.forRegistry(this.metricRegistry) | |
.convertRatesTo(TimeUnit.SECONDS) | |
.convertDurationsTo(TimeUnit.MILLISECONDS) | |
.build(); | |
reporter.start(1, TimeUnit.SECONDS); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.