JEP 349: JFR Event Streaming

OwnerErik Gahlin
Componenthotspot / jfr
Discussionhotspot dash jfr dash dev at openjdk dot java dot net
Reviewed byKaren Kinnear, Mikael Vidstedt
Endorsed byMikael Vidstedt
Created2017/07/11 19:20
Updated2019/08/15 13:59


Expose JDK Flight Recorder data for continuous monitoring.




The HotSpot VM emits more than 500 data points using JFR, most of them not available through other means besides parsing log files.

To consume the data today, 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. An example of monitoring usage is a dashboard which displays dynamic updates to the data.

There is overhead associated with creating a recording, such as:

If there were a way to read data being recorded from the disk repository without creating a new recording file, much of this overhead could be avoided.


Define an API by which users can subscribe to events asynchronously.

The following code illustrates how the API can be used. It shows how to print all classes on which threads have blocked for more than 10 ms. If a consumer is not able to keep up, events will be dropped after 600 seconds.

try (RecordingStream rs = new RecordingStream()) {
    rs.onEvent(e -> System.out.println(e.getClass("monitorClass")));

This creates a recording and at a given interval, perhaps once every two seconds, flushes events stored in memory and thread-local buffers to the disk repository. A separate thread parses the most recent file, up to the point in which data has been written, and pushes the events to the consumers.


JMX notifications provide a means for the JDK and third-party applications to expose information for continuous monitoring. There are, however, drawbacks that make JMX unsuited for the purpose of this JEP.


Risks and Assumptions