我在Spring启动REST服务中使用dropwizard指标,
<!--Dropwizard Metrics for Spring-->
<dependency>
<groupId>com.ryantenney.metrics</groupId>
<artifactId>metrics-spring</artifactId>
<version>3.1.3</version>
<exclusions>
<exclusion>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
</exclusion>
</exclusions>
</dependency>
// MetricsConfig.java
import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricRegistry;
import com.ryantenney.metrics.spring.config.annotation.EnableMetrics;
import com.ryantenney.metrics.spring.config.annotation.MetricsConfigurerAdapter;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.TimeUnit;
@Configuration
@EnableMetrics(proxyTargetClass = true)
public class MetricsConfig extends MetricsConfigurerAdapter {
@Override
public void configureReporters(MetricRegistry metricRegistry) {
// registerReporter allows the MetricsConfigurerAdapter to
// shut down the reporter when the Spring context is closed
registerReporter(ConsoleReporter
.forRegistry(metricRegistry)
.build())
.start(60, TimeUnit.MINUTES);
}
}
从上面的配置中,每小时dropwizard都会将指标吐出到控制台,同时,dropwizard指标会在哪里存储和捕获指标数据?是Java堆,还有那里的性能影响以及微调这一点的方法。
答案 0 :(得分:0)
信息存储在Java堆中,一旦服务器重新启动就会消失。
性能影响不应太大,通常应该超过拥有此类指标的好处