Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add one more metric to Spring Boot?

Spring Boot has preconfigured metrics. As I know it uses http://metrics.codahale.com/ library. How can I get MetricRegistry object to add my custom metrics?

like image 908
fedor.belov Avatar asked Oct 02 '22 02:10

fedor.belov


2 Answers

Spring boot now supports Codahale Metrics out of the box.

See http://docs.spring.io/spring-boot/docs/1.0.0.RC5/reference/htmlsingle/#production-ready-code-hale-metrics

like image 61
Newbie Avatar answered Oct 09 '22 00:10

Newbie


Spring Boot Does not use Codahale Metrics (yet). The plan is to support it as an option if it is on the classpath. If you prefer to do it that way then a MetricRegistry will be in the application context and you can simply @Autowire it and use it. You can see that work in progress on a branch in my fork.

The Boot interfaces for adding metrics are GaugeService and CounterService. You inject those and use them to record measurements. When Codahale gets support then this will be the recommended entry point for that as well, so you can get started using it now and add the Codahale stuff later if you want.

like image 43
Dave Syer Avatar answered Oct 09 '22 01:10

Dave Syer