New version 1.1.0 of metracer was released: https://github.com/kocherovms/metracer/releases/tag/v1.1.0. There were many experiments, redesigns and code rewrites. Main changes are around tracing output – now it’s done via org.slf4j.Logger. (issue #8)
Decision to use org.slf4.Logger to output entry / exit tags was made because:
- org.slf4.Logger is one of the standards of logging for JavaEE which allows to interleave application logs and output of metracer in a natural way;
- System.out.println doesn’t suite well for JavaEE applications because output could be easily redirected at runtime.
Use of org.slf4.Logger made it necessary to redesign code a bit:
- new Runtime class was introduced which handles all the logic of logging. Instrumentation now only inserts callbacks to Runtime, there is no heavy logic in a generated code (see TracingCodeInjector class);
- to fight with the issues of ClassLoaders isolation (enforced e.g. by JBoss‘s ModuleClassLoader) patching of all encountered ClassLoaders was introduced – patching drills a direct hole to App ClassLoader where Runtime class of metracer lives (see TracingCodeInjector.injectDirectAccessToMetracerClasses);
- since not all instrumented classes have org.slf4.Logger inside a ‘context sensitive’ discovery method was introduced – we scan a stack trace and take a Logger for the very first class which has the Logger. If there is no such class on the way we fallback to default System.out.println.
Among the notable changes is a drop of support of annotations – issue #9. It turned out that there is too few benefits from the use of annotations – the same things could be achieved via some AOP in a more natural way.