Export Spring Boot Drive Performance with Dropwizard for Jmx or Graphite

I want to use Spring Boot MetricsWriterto write / export data from my Spring Boot application to a data source of my choice (say - Jmx / Graphite). I can use JmxReporter/ GraphiteReporter, but I believe Spring abstraction Writer/ Exportercan play a vital role in terms of changing the data source later.

REST endpoint annotated with Dropwizard annotations

@Timed(absolute=true, name="invokeEndpoint")
public ResponseEntity<Object> callSomeApi() {
   ...
}

My configuration class is as follows:

@Configuration
public class SpringBootMetrics {

    @Bean
    @ExportMetricReader
    public MetricReader metricReader() {
        return new MetricRegistryMetricReader(metricRegistry());
    }   

    public MetricRegistry metricRegistry() {
        final MetricRegistry metricRegistry = new MetricRegistry();
        return metricRegistry;
    }

    @Bean
    @ExportMetricWriter
    MetricWriter metricWriter(MBeanExporter exporter) {
        return new JmxMetricWriter(exporter);
    }
}

I don't see any metrics for calling the endpoint being collected in Jmx via jconsole. What am I missing?

+6
1

org.springframework.boot.actuate.endpoint.MetricsEndpointMetricReader Spring, , :

   @Bean
   MetricsEndpointMetricReader metricsEndpointMetricReader(MetricsEndpoint metricsEndpoint) {
      return new MetricsEndpointMetricReader(metricsEndpoint);
   }
+2

Source: https://habr.com/ru/post/1017053/


All Articles