Custom Instrumentation Using Java Annotations
Using Java annotations, APM Insight provides an easier way to custom instrument your application classes and methods. Usage of Java annotation enables you to define custom names for the transaction and also assign a custom component.
Configuration Steps for Java Agent
- As a prerequisite, apminsight-javaagent.zip needs to be downloaded from your Site24x7 account. It comprises of agent jar with its associated files and the apminsight-javaagent-api.jar
- Include the apminsight-javaagent-api.jar file to the project build path and also ensure this file is exported along with other libraries of the application.
- Java agent API library provides two annotations which can be used in your application to track the performance of your custom classes and methods.
- @ApmTracker: Can be used upon any classes and methods, which will be instrumented and included in the traces.
- @ApmRootTracker: Can be used only on methods, which are likely to be the entry point method of the transaction(background).
@ApmTracker
Attributes:
- component - Optional attribute
Defines the custom component for annotated classes/methods.
- name - Optional attribute
A custom name for the annotated element, which will be prepended to actual method name.
Method parameters can be used for custom name by mentioning the argument index(starts at 1) with prefix '$'.
The instrumented methods and its custom names can be viewed under Traces.
@ApmRootTracker
Attributes
- component - Optional attribute
Defines the custom component for annotated methods.
- name - Optional attribute
A custom name for the annotated element, which will be prepended to actual method name.
Method parameters can be used for custom name by mentioning the argument index(starts at 1) with prefix '$'.
- txnName - Mandatory
Defines the name for the background transaction, only if the method is the entry point of the transaction else it will be tracked as generic method and added to the traces.
The transaction is named according to the value specified for the attribute txnName.