Java Flight Recorder (JFR)

About

The jcmd utility is the traditional application to inquire diagnostic information from applications running on the JVM, also including the Java Flight Recorder (JFR).

Details

The Java Flight Recorder (JFR) is a profiling and event collection framework to gather detailed low-level information about how the Java Virtual Machine (JVM) and Java applications are behaving during execution.

Flight recordings can be started when the application is started or while the application is running. The data is recorded as time-stamped data points called events.

JFR is part of the JDK distribution, and it is integrated into the JVM.

Events:

JFR collects events that occur in the JVM when the Java application runs. The events are related to the state of the JVM itself or the state of the program. An event has a name, a timestamp, and additional information, like thread information, execution stack, and state of the heap.

Recording Types:

A time fixed recording, also known as a profiling recording, runs for a set amount of time, and then stops. A continuous recording is a recording that is always on and saves, for example, the last six hours of data into a circular buffer, discarding old data when the buffer fills up.

Performance:

The events that JFR collects contain a huge amount of data. For this reason, JFR is designed to affect the performance of a running application as little as possible.

JFR saves data about the events into a single output file. Because disk I/O operations are expensive, JFR uses various buffers to store collected data before flushing blocks of data to disk.

Synopsis

jcmd 1 JFR.start duration=60s filename=/data/recording1.jfr
jcmd 1 JFR.start duration=300s filename=/data/recording2.jfr settings=profile

Learn

Fundamentals

Java Flight Recorder » Basic Concepts and Usage

This tutorial examines Java Flight Recorder, its concepts, its basic commands, and how to use it.

https://www.baeldung.com/java-flight-recorder-monitoring#java-flight-recorder
Diagnose a Running JVM » JFR Command Options

A concise example how to generate a JFR file using the jcmd command.

https://www.baeldung.com/running-jvm-diagnose#7-jfr-command-options
Java SE Diagnostic Tools » Flight Recorder

The official documentation about JFR outlines its advantages, its event types grouped by recording templates, and its types of recordings. It also describes in detail how to produce flight recordings, what’s inside, and how to analyze them.

https://docs.oracle.com/en/java/javase/11/troubleshoot/diagnostic-tools.html#GUID-D38849B6-61C7-4ED6-A395-EA4BC32A9FD6

CrateDB

Use JFR with CrateDB on Docker

Learn why the standard way to run jcmd does not work when running CrateDB inside a container, for example when using Docker, and how to resolve that problem.

Java Flight Recorder (JFR)