Skip to content

Instantly share code, notes, and snippets.

@ivanursul
Last active August 13, 2016 17:59
Show Gist options
  • Save ivanursul/2c056cfa657db78412a3aa6cfb6279fa to your computer and use it in GitHub Desktop.
Save ivanursul/2c056cfa657db78412a3aa6cfb6279fa to your computer and use it in GitHub Desktop.
package org.startup.queue.config;
import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.health.HealthCheckRegistry;
import com.codahale.metrics.servlets.AdminServlet;
import com.ryantenney.metrics.spring.config.annotation.EnableMetrics;
import com.ryantenney.metrics.spring.config.annotation.MetricsConfigurerAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.startup.queue.metrics.MetricsServletContextListener;
import javax.annotation.PostConstruct;
@Configuration
@EnableMetrics
public class MonitoringConfiguration extends MetricsConfigurerAdapter {
@Autowired
private MetricRegistry metricRegistry;
@Autowired
private HealthCheckRegistry healthCheckRegistry;
@PostConstruct
public void init() {
configureReporters(metricRegistry);
}
@Bean
public MetricsServletContextListener metricsServletContextListener(MetricRegistry metricRegistry, HealthCheckRegistry healthCheckRegistry) {
return new MetricsServletContextListener(metricRegistry, healthCheckRegistry);
}
@Bean
public ServletRegistrationBean servletRegistrationBean(){
return new ServletRegistrationBean(new AdminServlet(),"/dropwizard/*");
}
@Override
public void configureReporters(MetricRegistry metricRegistry) {
registerReporter(JmxReporter.forRegistry(metricRegistry).build()).start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment