Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Valid as of Datafari 6.X ?

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

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:

 INFO 2024-06-07T08:23:15Z (ajp-nio-127.0.0.1-8009-exec-8) - Tomcat|Datafari|datafari.utils.Timer|Monitoring class com.francelabs.datafari.api.SearchAPI. Execution of method search in progress. Top for position 8: 317 ms

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:

timer.top(“8”);

Stop

The “stop” log indicates the elapsed time of execution of the method.

INFO 2024-06-07T08:23:15Z (ajp-nio-127.0.0.1-8009-exec-8) - Tomcat|Datafari|datafari.utils.Timer|Monitoring class com.francelabs.datafari.rest.v2_0.search.Search2. Execution of method perfomSearch took 817 ms

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:

Timer timer = new Timer(SearchAggregator.class.getName(), "doGetSearch");

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.

timer.top(“1”);

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();

  • No labels