Search code examples
javametricsmicrometerstatsd

How to use micrometer @Timed in not spring application


I've an app, which implemented in pure java + apache kafka streams (not spring app). I need to add micrometer and custom metrics. How to do that? Can I use @Timed annotation on the methods?

What about TimedAspect class? how I can use it?

I'm using micrometer-registry-statsd.

I've registered meter registry as follow Metrics.addRegistry(new StatsMeterRegistry(HereStatsdConfig))


Solution

  • Finally I figured out it. It can be done using Metrics.counter or Metrics.timer or other methods of micrometer.io library. Metrics class should be used in applications which don't have DI.