I’ve been looking at various java performance monitoring tools.
I worked out a solution that uses perf4j + aspectj, so that I can define which classes to monitor with an aspectj pointcut expression. However aspectj also (AFAIK), does not allow you to change the pointcut expression at runtime. So if I need to monitor new classes I would have to change the aop.xml and recompile (or atleast restart the app if using AspectJ load time weaving).
I have not found anything so far that can instrument classes at runtime without needing a restart of the application. Is there a tool/technology out there which can do that?
Found a perfect little library BTrace, which does exactly what I needed. It works by manipulating the byte code of the instrumented class at runtime, no need to restart your application. Check out the user guide to see how easy it is to set it up.
Another thing worth mentioning about Btrace is that, the authors have made a lot effort to make it safe to work in a production environment.