Many frameworks use annotations for designating important classes and entry points that could be turned into transactions in perfino. With the "Annotated invocations" transaction type you can let perfino do this work for you.
Method and class annotations
An annotation transaction definition takes the fully qualified class name of the annotation that you are interested in. Annotations can be either used on classes or on methods. Before proceeding with the configuration, you have to tell perfino for which target the selected annotation is used.
For an annotated method, each method invocation becomes a transaction in perfino. Annotations on classes create transactions for all calls into public instance methods.
The second choice is whether derived classes should be considered as well. For methods, it can be important to capture the time in an overridden method. For example, if a framework creates an implementing proxy class and overrides the annotated method in order to add database transactions, you want to intercept the method in the proxy class, and not only the annotated method.
For annotated classes, the "Method selection" options determine which methods are selected to generate transactions:
Implementing methods onlyIf the annotation is placed on an interface that already defines all operations of interest with its methods, you should select this option.
All public methodsIf the derived classes have their own methods of interest that do not implement or override the methods in the annotated class, use this option to create transactions from all public methods.
When you use annotations on classes with the setting for intercepting public methods in derived classes, the question remains what class name should be used in the transaction naming.
By default, a naming element of type "Class name" adds the name of the class where the intercepted method is defined. If you want to add the name of the annotated super class instead, select the "Use annotated class name for filter and naming" check box in the "Annotation" step of the wizard.
If you want to go the other way and add the class name of the actual instance on which the method was called, use the "Instance class name" naming element instead.
Even more specific, the "Instance name" naming element adds the
toString() invocation on the
object where the transaction method was called.
This naming element can also apply a getter chain to this object and append the
invocation on the result to the transaction name instead.
For example, if the instance class has a
getVerbose() method that returns the desired text,
set the getter chain to
getVerbose(). You can mix public field accesses and parameter-less
invocations of public methods like this:
If you use the
getClass() method to append a class name, there are two special fields that are
provided by perfino to simulate the abbreviated and simple class name modes that are available for the
"Class name" and "Instance class name" naming elements:
getClass().simpleName, the name of the class without its package is added. For example,
getClass().abbrevName, the abbreviated package names are added. For example,
Note that the "Instance name" naming element generates a far higher overhead than the "Instance class name" or "Class name" naming elements, since it always involves actual method calls.