Today we are happy to share the first release of our JFR Streaming library. With this library, developers can easily manage Java Flight Recordings programmatically. It includes commonly expected features such as starting and stopping a flight recording on a local or remote JVM and reading the recorded file as an InputStream.
Azure Application Insights is a production-ready, and detailed Application Performance Monitoring solution that covers Java workloads. In integrating Java Flight Recorder, we can provide deeper insights into the inner works of applications in the JVM.
Before deciding to create this library, we evaluated three options:
- Use jcmd to manage JFR recordings.
- Use the existing code that is part of the Java Mission Control project.
- Create a new library to allow managing recordings programmatically.
The tool jcmd and other diagnostic tools are part of the JDK and are not typically available on Java runtimes. JDK’s jcmd is a handy tool for a variety of things, but it would have required us to manage to get access to all the underlying infrastructure where JVMs may be running. jcmd was not designed for this use case. It would have required the development of a solution that would have been difficult to scale.
The JMC libraries were also considered, but because it would have brought over a large dependency footprint unnecessary for our use case, we’ve decided to skip this solution.
What we really needed was a standalone, lightweight library for this purpose, so after we reviewed these two first options, we went for option 3. It supports Java 8 and later versions with zero external dependencies. Developers can use it on various use cases, from Java agent APM development to desktop Java.
To learn more, experiment with the library, or contribute, visit the jfr-streaming project on GitHub. The library is also available on Maven Central.
If you have jbang installed, you can also try it right now with this:
$ jbang https://raw.githubusercontent.com/microsoft/jfr-streaming/main/samples/jbang/Sample.java
Happy coding, folks!
0 comments