Spring 引导中的 Dropwizard 指标性能开销

Dropwizard Metrics Performance overhead in Spring Boot

我在 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每小时都会向控制台吐出metrics,那么同时,dropwizard metrics在哪里存储和捕获metrics数据呢?它是 Java 堆吗?它对性能有何影响以及对此进行微调的方法。

信息存储在 Java 堆中,一旦服务器重新启动就会消失。

对性能的影响应该不会太大,通常应该超过拥有此类指标的好处