Monitor can record the execution of a given project either online or offline. The offline version uses a prerecorded
JFR recording file, whereas the online version uses the temporary data recorded and saved inside the /tmp
folder. The
offline version is more suited to generate a report based on the test execution, and the online version to generate a
report based on the field executions.
Monitor uses the Java Flight Recorder (JFR) to capture runtime data. It can record 10 types of accesses or capabilities (to be refined).
- ClassLoad
- Deserialization
- FileForce
- FileRead
- FileWrite
- Native Library Access
- Network Access
- Process Start
- Socket Read
- Socket Write
When one of these events is observed by the JFR, the monitor will get its stack trace and check if it has been called by a third party library. If so, it will record it.
Executing the preprocessor first is mandatory for the Monitor.
To run the offline version,
-
Package the monitor.
mvn clean package
-
Run the test suite of the target project using the following command.
mvn test -DargLine=\"-XX:StartFlightRecording=name=<name>,settings=<path_to_settings.jfc>,filename=<path_to_save_the_JFR_recording>\"
Alternatively, set an environment variable and run the tests.
export MAVEN_OPTS=\"-XX:StartFlightRecording=name=name,settings=<path_to_settings.jfc>,filename=<path_to_save_the_JFR_recording>\" mvn test unset MAVEN_OPTS
The
name
can be any string. The defaultsettings.jfc
file can be found in the root folder of Theo. Thefilename
is the path where you want to save the JFR report. -
Execute the Monitor.
mvn exec:java -Dexec.args="track-offline -j <path_to_jfr_recording> -l <path_to_lockfile> -r <report_path>"
The
report_path
is optional. The default value istest-report.json
.
To run the online version,
- Package the monitor.
mvn clean package
- Execute the Monitor.
The
mvn exec:java -Dexec.args="track-online -j <repository_path> -l <path_to_lockfile> -r <report_path>"
<repository_path>
and thereport_path
are optional. The default values are/tmp
andprod-report.json
respectively. However, if you are on a Windows machine, the default value of therepository_path
will not work. Therefore, it is mandatory to define a custom path. - Run the target project with a workload using the following command.
The
java -XX:StartFlightRecording=name=<name>,settings=<path_to_the_settings.jfc_file>,filename=<path_to_save_the_JFR_recording> -XX:FlightRecorderOptions=repository=tmp -jar <path_to_the_jar>
name
can be any string. The defaultsettings.jfc
file can be found in the root folder of Theo. Thefilename
is the path where you want to save the JFR report. Therepository
should be the same value as what you used previously for the<repository_path>
.
- Refine the access categories and their sub-fields.
- Add more comprehensive tests.
- Has to use mvn execute command (instead of an executable jar) as we need the dependency information of the loaded classes. Potentially, we can overcome this by using the classport.