{"id":228062,"date":"2021-04-12T15:48:33","date_gmt":"2021-04-12T22:48:33","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/java\/?p=228062"},"modified":"2021-04-13T10:18:26","modified_gmt":"2021-04-13T17:18:26","slug":"microsoft-jfr-streaming","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/java\/microsoft-jfr-streaming\/","title":{"rendered":"Microsoft JFR Streaming Library for Java Flight Recorder"},"content":{"rendered":"<p>Today we are happy to share the first release of our <a href=\"https:\/\/github.com\/microsoft\/jfr-streaming\">JFR Streaming library<\/a>. 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.<\/p>\n<p>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.<\/p>\n<p>Before deciding to create this library, we evaluated three options:<\/p>\n<ol>\n<li>Use <em>jcmd<\/em> to manage JFR recordings.<\/li>\n<li>Use the existing code that is part of the Java Mission Control project.<\/li>\n<li>Create a new library to allow managing recordings programmatically.<\/li>\n<\/ol>\n<p>The tool <em>jcmd<\/em> and other diagnostic tools are part of the JDK and are not typically available on Java runtimes. JDK\u2019s\u00a0<em>jcmd <\/em>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. <em>jcmd <\/em>was not designed for this use case. It would have required the development of a solution that would have been difficult to scale.<\/p>\n<p>The JMC libraries were also considered, but because it would have brought over a large dependency footprint unnecessary for our use case, we\u2019ve decided to skip this solution.<\/p>\n<p>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.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2021\/04\/jfr-streaming-code-snippet.png\">