Main

JFR Event Stream Stop

JDK Flight Recorder received several updates with JDK 20, including a significant update to the Event Stream API. Let's take a look! More info ➱ https://inside.java/sip/75 Tags: #Java #jfr #JDK20 #java20

Java

10 months ago

Hey Java Developers! JDK Flight Recorder, JFR, received a number of updates with jDK 20 Including a big one to their streams API, let's take a look Three new events were added to JFR InitialSecurityProperty SecurityProviderService and JITRestart Bringing the number of pre-defined events to 177 And helping in the areas of security and performance monitoring However the biggest update to JFR was the addition of stop() to the event streaming API The JFR event streaming API Added in JDK 14 provides
several useful features The API provides programmatic access to JFR Events The streams also provide a near real-time view into the JVM and application internals Which is very helpful in the area of observability However a helpful side-effect of the Event Stream API was it allowed JFR to be used in automated tests The addition of stop() in JDK 20 greatly improves this story Prior to JDK 20 to close a stream typically required a special event to call close on the stream Like in this example here T
his added complexity, visual noise, and time, as events were only flushed once a second which could in, aggregate, add significant time to the execution of a test suite if JFR was being used significantly The new stream stop() method immediately flushes and then stops a stream Removing the requirement of a special event to close a stream significantly reducing the complexity of a test while reducing the run time as well Happy coding!

Comments