Codahale Metrics: using @Timed metrics annotation in plain Java

Long story short, you cannot use @Timed without some kind of AOP (be it Spring AOP or AspectJ).

A week or two ago, I also decided to add metrics to our project and chose AspectJ for this task (mostly because I used it in the past for similar purpose and because it allows for compile-time weaving while Spring allows only runtime via proxies).

You should be able to find all the necessary information and instructions here: https://github.com/astefanutti/metrics-aspectj.

As for Lombok, I guess they use built-in javac annotations processor:

Another point of contention is the implementation of both the code supporting IDE integration as well as the javac annotation processor. Both of these pieces of Project Lombok make use of non-public APIs to accomplish their sorcery. This means that there is a risk that Project Lombok will be broken with subsequent IDE or JDK releases.

Leave a Comment