you likely want a standalone AOP solution like AspectJ
j
Joe
02/07/2019, 3:22 PM
Ok, am I right in thinking annotation processors can create new classes, but not modify existing ones? so another option could be to generated Timed$class and use that everywhere? but probably an AOP solution is what I'll end up doing
b
bdawg.io
02/07/2019, 4:57 PM
annotation processors can create new classes, but not modify existing ones
correct
s
shane
01/20/2020, 3:16 AM
Maybe you could use ByteBuddy, and have a custom Guice binder that wraps all your dependencies with a dynamic proxy version
https://bytebuddy.net/#/
Hibernate uses ByteBuddy to generate DB entity proxy subclasses that can lazy load joins with SQL
Your dependency classes could get bound to a provider that generates the proxy subclass with hooks that record metrics.
You might need open classes + protected methods for this to work tho. You could use the all open plugin and sed s/private fun/protected fun/g.