Return to site

Java mission control

· mashup,java
DEFINE: JDK Mission Control

Java Flight Recorder and JDK Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis.

Java Flight Recorder is a profiling and event collection framework built into the Oracle JDK.

It allows Java administrators and developers to gather detailed low level information about how the Java Virtual Machine (JVM) and the Java application are behaving.

JDK Mission Control is an advanced set of tools that enables efficient and detailed analysis of the extensive of data collected by Java Flight Recorder.

The tool chain enables developers and administrators to collect and analyze data from Java applications running locally or deployed in production environments.

DO: Monitoring Java Applications with Flight Recorder

There are three components:
  1. JFR: Java Flight Recorder, monitoring tool that collects information about the events in a Java Virtual Machine (JVM) during the execution of a Java application.
  2. jcmd, utility used to send diagnostic command requests to the JVM.
  3. JMC: Java Mission Control (JMC), which contains a plugin that allows us to visualize the data collected by JFR.
JFR has two main concepts: events and dataflow.
  • Events: JFR collects events that occur in the JVM when the Java application runs. An event has a name, a timestamp, and additional information.
  • Dataflow: data from the JVM and from the Java application. This data is stored in small thread-local buffers that are flushed to a global in-memory buffer.
Start Registering and visualize Data
java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder   -XX:StartFlightRecording=duration=200s,filename=flight.jfr   -cp ./out/ com.baeldung.flightrecorder.FlightRecorder
NEXT: JFR Event Streaming in Java 14

To consume the data today from JFR, a user must start a recording, stop it, dump the contents to disk and then parse the recording file.

This works well for application profiling, where typically at least a minute of data is being recorded at a time, but not for monitoring purposes.

With JEP 349, it is proposed to create an API, via which the data collected by the JFR can be used for the continuous monitoring of active and inactive applications.