Monitoring

Atoti Limits contains the JfrService, which allows you to record Java Flight Recordings (JFRs) for troubleshooting purposes.

Record a JFR via REST

The JfrController provides REST endpoints for starting and stopping JFR recordings. You can use these endpoints to record JFRs on a running application. This REST API is useful for recording JFRs that capture a manual action or a set of actions that you want to analyze. The easiest way to send the requests is by using the Swagger UI.

To start a JFR recording, send a POST request to the monitoring/jfr/start/{name} endpoint with the name of the recording:

JFR Controller Start

warning

Failing to stop a JFR recording can lead to high disk usage and memory consumption. Always stop a recording after you have finished collecting data. By default, the JFR recording will stop after 60 minutes.

To stop the recording, send a POST request to the monitoring/jfr/stop/{name} endpoint with the name of the recording:

JFR Controller Stop

The JFR file will be returned in the response body and can be downloaded from the Swagger UI:

JFR Controller Stop

You can also send a GET request to the monitoring/jfr/list endpoint to list all currently running JFR recordings:

{"MyFirstRecording", "MySecondRecording"}

Record a JFR from code

The JfrService can be used internally in the application to record JFRs that start/stop at specified points in the code. This is useful when debugging a specific issue, such as isolating a bottleneck. JfrService is a Spring service, so you can use it by injecting it into your components:

@Autowired private JfrService jfrService;

OR

@RequiredArgsConstructor
@Component
public class MyComponent {
    private final JfrService jfrService;
}

To start a JFR recording, call the startRecording method with a name for the recording:

jfrService.startRecording("MyRecording");

warning

Failing to stop a JFR recording can lead to high disk usage and memory consumption. Always stop a recording after you have finished collecting data. By default, the JFR recording will stop after 60 minutes.

To stop the recording, call the stopRecording method with the name of the recording:

jfrService.stopRecording("MyRecording");

The JFR will be saved in the jfr directory with the name MyRecording.jfr.