Search code examples
springspring-bootcodahale-metrics

Using Coda Hale Meter in Spring Boot application


The documentation says that

Users can create Coda Hale metrics by prefixing their metric names with the appropriate type (e.g. histogram., meter.).

I am taking this to mean that I can use either a Counter or Guage with a metric name of the form "meter.*" and this will work as a meter. I have tried

counterService.increment("meter.si.invoice.processing");

but when I visit /manage/metrics I just see the count and not the metered rate. What is the correct way to use a Coda Hale Meter in Spring Boot. The documentation is not very clear on how the integration works.


Solution

  • The metrics endpoint is not aware of Codahale stuff. Once you send your metrics there you need to use Codahale tools to extract them (a meter for example doesn't map directly onto Spring Boot metric types, so there's no obvious way to expose them in the way you tried).