2017-03-03 54 views
0

我使用dropwizard指標在春季啓動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會吐out控制檯的指標,同時,dropwizard指標在哪裏存儲和捕獲指標數據?它是Java堆,以及那裏的性能影響和微調的方式。

回答

0

信息存儲在Java堆中,一旦服務器重新啓動就會消失。

性能影響不應該太大,通常應該超過獲得這樣的指標的好處