{"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\"><img decoding=\"async\" class=\"aligncenter wp-image-228063 size-full\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2021\/04\/jfr-streaming-code-snippet.png\" alt=\"Image jfr streaming code snippet\" width=\"936\" height=\"400\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2021\/04\/jfr-streaming-code-snippet.png 936w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2021\/04\/jfr-streaming-code-snippet-300x128.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2021\/04\/jfr-streaming-code-snippet-768x328.png 768w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/a><\/p>\n<p>To learn more, experiment with the library, or contribute, visit the <a href=\"https:\/\/github.com\/microsoft\/jfr-streaming\">jfr-streaming<\/a> project on GitHub. The library is also available on Maven Central.<\/p>\n<p>If you have <a href=\"https:\/\/jbang.dev\/\">jbang<\/a> installed, you can also try it right now with this:<\/p>\n<pre style=\"padding-left: 40px;\">$ jbang <a href=\"https:\/\/raw.githubusercontent.com\/microsoft\/jfr-streaming\/main\/samples\/jbang\/Sample.java\">https:\/\/raw.githubusercontent.com\/microsoft\/jfr-streaming\/main\/samples\/jbang\/Sample.java<\/a><\/pre>\n<p>Happy coding, folks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":9452,"featured_media":228063,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,8],"tags":[248,26],"class_list":["post-228062","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-open-source","tag-java","tag-performance"],"acf":[],"blog_post_summary":"<p>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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/228062","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/users\/9452"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/comments?post=228062"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/228062\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media\/228063"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media?parent=228062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/categories?post=228062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/tags?post=228062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}