Monitoring timers
Valid as of Datafari 6.0.3
Functional feature
In order to monitor search method performances, we added a feature to monitor the time spent in various methods in the Search process. If enabled, this features adds logs in:
/opt/datafari/logs/datafari.logs
Enable the monitoring timers
To enable the monitoring, edit the datafari.properties file:
/opt/datafari/tomcat/conf/datafari.properties
And set this parameter to “true”:
# Monotoring timers
ENABLE_MONITORING_TIMER=true
It is not required to restart Datafari to apply the new configuration.
How to read the logs
This tool can produce two types of log. The first one is the “top”, the second one in the “stop”.
Top
The “top” indicates the time spend in the current method at a specific position in the code.
Example of “top” log:
In this specific example, the SearchAPI.search()
method is being monitored. In th code, position “8” occurs right after the execution. In the code, these logs are produced by lines that look like:
Stop
The “stop” log indicates the elapsed time of execution of the method.
It is calculated by subtracting the start time timer.start()
for the end time timer.stop()
. If you are running multiple queries simultaneously, you can distinguish logs using the thread number. Here, exec-8
.
The timer.stop()
method is meant to be called when exiting the monitored method.
Technical feature
This feature is provided by the new Timer util class. This method implements three methods.
Constructor
This class should be instantiated at the beginning of the method:
The first parameter is the name of the class. The second parameter is the name of the method.
start()
This method initiates the timer. It is called in the constructor, so you should not call it manually.
top()
Call this method to log the current timer at any given position in the code.
The parameter is the position. It can be any String, such as a number, or any explicit information.
stop()
This method should be called before any “return” or “throw” in the monitored method. It logs the total elapsed time of execution of the method.
timer.stop();