{"id":463443,"date":"2025-06-15T15:10:31","date_gmt":"2025-06-15T15:10:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=463443"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=463443","title":{"rendered":"<span>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u00ab\u0437\u0434\u0435\u0441\u044c \u0438 \u0441\u0435\u0439\u0447\u0430\u0441\u00bb: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 JDK Flight Recorder<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/y4\/-w\/a9\/y4-wa9fxtdjzx4nyxgunlfmhvys.jpeg\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/y4\/-w\/a9\/y4-wa9fxtdjzx4nyxgunlfmhvys.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/y4\/-w\/a9\/y4-wa9fxtdjzx4nyxgunlfmhvys.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><br \/> JDK Flight Recorder (JFR) \u2014 \u044d\u0442\u043e \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0432 JVM. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 JFR \u043b\u0435\u0436\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438\u0434\u0435\u044f, \u043d\u043e \u0432\u043e\u043a\u0440\u0443\u0433 \u043d\u0435\u0435 \u0432\u044b\u0440\u043e\u0441\u043b\u0430 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u0430\u044f \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0440\u0435\u0448\u0430\u0442\u044c \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u0441\u043f\u0435\u043a\u0442\u0440 \u0437\u0430\u0434\u0430\u0447.<br \/> \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 JFR \u2014 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u041f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432 JDK 14 \u0432 \u0432\u0438\u0434\u0435 <a href=\"https:\/\/docs.oracle.com\/en\/java\/javase\/14\/jfapi\/monitor-events-flight-recorder-event-streaming-api.html\">Flight Recorder Event Streaming API<\/a> \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f JFR \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439. <a name=\"habracut\"><\/a>\u0414\u0430\u043b\u0435\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u0443\u0434\u0443 \u043f\u0438\u0441\u0430\u0442\u044c Streaming API \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438. <\/p>\n<p> <\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 JFR?<\/h2>\n<p> <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Streaming API, \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0440\u0430\u0431\u043e\u0442\u0435 JFR.<\/p>\n<p> <\/p>\n<p>\u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u2014 \u044d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u0432 \u043c\u0438\u0440\u0435 JFR. \u0415\u0441\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 (\u0437\u043e\u043d\u0434\u044b) \u2014 \u0447\u0430\u0441\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 JVM \u0438 \u0438\u0445 \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0442\u043d\u0438, \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0438 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u043a\u043e\u0434 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e\u0449\u0438\u0439 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <a href=\"https:\/\/docs.oracle.com\/en\/java\/javase\/14\/jfapi\/create-events.html\">API<\/a>.<br \/> \u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0441\u0445\u0435\u043c\u0443, \u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p> <\/p>\n<p>JFR \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0432\u0441\u0435\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432-\u0437\u043e\u043d\u0434\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044e (\u043f\u0440\u043e\u0444\u0438\u043b\u044c) \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u043e\u043d\u0434\u0443 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0441\u0431\u043e\u0440\u0430 \u0441\u044d\u043c\u043f\u043b\u043e\u0432 \u0434\u043b\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432).<\/p>\n<p> <\/p>\n<p>JFR \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u0435 \u0438 \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u0422\u0435, \u043a\u0442\u043e \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0440\u044f\u0434 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u0430\u043c\u043d\u0435\u0439. JFR \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u0442\u0440\u044e\u043a\u0438, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0431\u0443\u0444\u0435\u0440\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u0422\u0430\u043a\u0436\u0435 JFR \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0440\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u0432\u044b\u0442\u0435\u0441\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430 \u0434\u0438\u0441\u043a \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0438\u0445 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435.<br \/> \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 (API, jcmd, JMX). JFR \u0438\u043c\u0435\u0435\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<p> <\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d Streaming API?<\/h2>\n<p> <\/p>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 JFR \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u043b\u0430 \u0440\u0435\u0442\u0440\u043e\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u044b\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.<br \/> \u0422\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u0441\u0435\u0441\u0441\u0438\u044f \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0433\u043b\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p> <\/p>\n<ul>\n<li>\u0421\u0442\u0430\u0440\u0442 \u0441\u0435\u0441\u0441\u0438\u0439 JFR;<\/li>\n<li>\u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439;<\/li>\n<li>\u0412\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 JFR \u0432 \u0444\u0430\u0439\u043b;<\/li>\n<li>\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0435\u0441\u0441\u0438\u0438 (\u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f);<\/li>\n<li>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430 \u0432 Mission Control \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0435.<\/li>\n<\/ul>\n<p> <\/p>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u044f \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 JVM \u0438 \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u041d\u043e \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043d\u0430\u0434\u043e \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<p> <\/p>\n<p>\u0421 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u0440\u0430\u0441\u0442\u0451\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. JVM \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 JMX, \u043d\u043e JFR \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0434\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0438 \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p> <\/p>\n<p>\u041f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f Streaming API \u043e\u0442\u043a\u0440\u044b\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f JFR \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p> <\/p>\n<h2>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Streaming API<\/h2>\n<p> <\/p>\n<p>Streaming API \u0434\u0430\u0451\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f JFR \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043b\u0438\u0448\u043d\u0438\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438.<br \/> \u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u2014 \u043f\u0430\u0441\u0441\u0438\u0432\u043d\u044b\u0439 \u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439.<br \/> \u0412 \u043f\u0430\u0441\u0441\u0438\u0432\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0441\u0441\u0438\u0438 JFR, \u0441\u0431\u043e\u0440 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438.<\/p>\n<p> <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u043d\u0438\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0442\u0438\u043f\u0430 &#171;jdk.JavaMonitorEnter&#187; (\u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0430), \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u043c\u044b\u0435 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435, \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0438\u0445 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<p> <\/p>\n<pre><code class=\"java\">    try (EventStream stream = EventStream.openRepository()) {        stream.onEvent(\"jdk.JavaMonitorEnter\", System.out::println);        stream.start();     }<\/code><\/pre>\n<p> <\/p>\n<p>\u0422\u0430\u043a\u0443\u044e \u0436\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043f\u0443\u0442\u044c \u043a \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u043c\u0443 \u0431\u0443\u0444\u0435\u0440\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c\u0443 JFR.<\/p>\n<p> <\/p>\n<pre><code class=\"java\">    Path path = Path.of(\"\/tmp\/myjfr\/\");     try (EventStream stream = EventStream.openRepository(path)) {        stream.onEvent(\"jdk.JavaMonitorEnter\", System.out::println);        stream.start();     }<\/code><\/pre>\n<p> <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u0445\u043e\u0441\u0442\u0430. \u042d\u0442\u043e\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u043d\u0438\u0436\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 Kubernetes.<\/p>\n<p> <\/p>\n<p>\u0410\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u0437\u043e\u043d\u0434\u043e\u0432 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438. \u0412 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044e JFR \u0442\u0435\u043c \u0438\u043b\u0438 \u0438\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u043e\u043d\u0430 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u0430 \u043a \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435.<\/p>\n<p> <\/p>\n<pre><code class=\"java\">    try (RecordingStream stream = new RecordingStream()) {        stream.enable(\"jdk.JavaMonitorEnter\").withStackTrace();        stream.onEvent(\"jdk.JavaMonitorEnter\", System.out::println);        stream.start();     }<\/code><\/pre>\n<p> <\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0431\u044a\u0435\u043a\u0442 <code>RecordingStream<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0441 \u0441\u043e\u0431\u044b\u0442\u0438\u044f. \u0422\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u0435\u043d \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u0433\u0435\u043d\u0442\u043e\u0432, \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u044f JFR \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p> <\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>RecordingStream<\/code> \u0438 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a JVM, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0438\u0436\u0435.<\/p>\n<p> <\/p>\n<h2>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c JFR \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 micrometer, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Streaming API<\/h2>\n<p> <\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0443 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0432\u043e\u0437\u043d\u0438\u043a \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u0430 \u0437\u0430\u0447\u0435\u043c \u0432\u0441\u0451 \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432 \u043c\u043e\u0451\u043c Spring \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438? \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c.<\/p>\n<p> <\/p>\n<p>\u0412 JDK 21 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 (\u0442\u043e\u0447\u043d\u0435\u0435 JDK 21 \u2014 \u043f\u0435\u0440\u0432\u0430\u044f LTS \u0432\u0435\u0440\u0441\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b). \u041e\u0434\u0438\u043d \u0438\u0437 \u043d\u044e\u0430\u043d\u0441\u043e\u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0439 \u0432 JDK 24) \u2014 \u044d\u0442\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u0442\u043e\u043a\u0430-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f, \u0435\u0441\u043b\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0432\u043b\u0430\u0434\u0435\u0435\u0442 Java \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u043e\u043c (\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 synchronized \u0431\u043b\u043e\u043a\u0435). \u042d\u0442\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c \u0441 \u0438\u0441\u0447\u0435\u0440\u043f\u0430\u043d\u0438\u0435\u043c \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0435\u0439.<br \/> \u0412 JFR \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0435 \u0441 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u043f\u043e\u0442\u043e\u043a\u0430-\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044f. \u0410 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043c\u0435\u0442\u0440\u0438\u043a \u0432 Spring.<\/p>\n<p> <\/p>\n<p>\u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 JFR \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0440\u0435\u0435\u0441\u0442\u0440 \u043c\u0435\u0442\u0440\u0438\u043a Spring.<\/p>\n<p> <\/p>\n<h4 id=\"kontroler-otvechaet-za-zapusk-podpiski\">\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438<\/h4>\n<p> <\/p>\n<pre><code class=\"java\">    @Component     class JfrEventLifecycle implements SmartLifecycle {        private final AtomicBoolean running = new AtomicBoolean(false);        private final JfrVirtualThreadPinnedEventHandler virtualThreadPinnedEventHandler;        private RecordingStream recordingStream;        JfrEventLifecycle(JfrVirtualThreadPinnedEventHandler virtualThreadPinnedEventHandler) {            this.virtualThreadPinnedEventHandler = virtualThreadPinnedEventHandler;        }        @Override        public void start() {            if (!isRunning()) {                recordingStream = new RecordingStream();                recordingStream.enable(\"jdk.VirtualThreadPinned\").withStackTrace();                recordingStream.onEvent(\"jdk.VirtualThreadPinned\", virtualThreadPinnedEventHandler::handle);                \/\/ prevents memory leaks in long-running apps                recordingStream.setMaxAge(Duration.ofSeconds(10));                recordingStream.startAsync();                running.set(true);            }        }        @Override        public void stop() {            if (isRunning()) {                recordingStream.close();                running.set(false);            }        }        @Override        public boolean isRunning() {            return running.get();        }     }<\/code><\/pre>\n<p> <\/p>\n<h4 id=\"obrabotchik-propuskaet-cherez-sebya--sobytiya-i-obnovlyaet-metriku\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0431\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u0440\u0438\u043a\u0443<\/h4>\n<p> <\/p>\n<pre><code class=\"java\">    @Component     class JfrVirtualThreadPinnedEventHandler {        private static final int STACK_TRACE_MAX_DEPTH = 25;        private final Logger log = LoggerFactory.getLogger(JfrVirtualThreadPinnedEventHandler.class);        private final MeterRegistry meterRegistry;        JfrVirtualThreadPinnedEventHandler(MeterRegistry meterRegistry) {            this.meterRegistry = meterRegistry;        }        void handle(RecordedEvent event) {            \/\/ marked as nullable in Javadoc            var thread = event.getThread() != null ? event.getThread().getJavaName() : \"&lt;unknown&gt;\";            var duration = event.getDuration();            var startTime = LocalDateTime.ofInstant(event.getStartTime(), ZoneId.systemDefault());            var stackTrace = formatStackTrace(event.getStackTrace(), STACK_TRACE_MAX_DEPTH);            log.warn(                    \"Thread '{}' pinned for: {}ms at {}, stacktrace: \\n{}\",                    thread,                    duration.toMillis(),                    startTime,                    stackTrace            );            var timer = meterRegistry.timer(\"jfr.thread.pinning\");            timer.record(duration);        }         private String formatStackTrace(RecordedStackTrace stackTrace, int maxDepth) {            if (stackTrace == null) {                return \"\\t&lt;not available&gt;\";            }            String formatted = \"\\t\" + stackTrace.getFrames().stream()                    .limit(maxDepth)                    .map(JfrVirtualThreadPinnedEventHandler::formatStackTraceFrame)                    .collect(Collectors.joining(\"\\n\\t\"));            if (maxDepth &lt; stackTrace.getFrames().size()) {                return formatted + \"\\n\\t(...)\"; \/\/ truncated            }            return formatted;        }        private static String formatStackTraceFrame(RecordedFrame frame) {            return frame.getMethod().getType().getName() + \"#\" + frame.getMethod().getName() + \": \" + frame.getLineNumber();        }     }<\/code><\/pre>\n<p> <\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u2014 <a href=\"https:\/\/github.com\/mikemybytes\/jfr-thread-pinning-spring-boot\">https:\/\/github.com\/mikemybytes\/jfr-thread-pinning-spring-boot<\/a><\/p>\n<p> <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c &#171;\u043f\u043e\u0434\u0446\u0435\u043f\u0438\u0442\u044c&#187; \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u0438 JFR \u0438 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0435\u0441\u0442\u0440 \u043c\u0435\u0442\u0440\u0438\u043a Spring. \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0441\u0442\u044d\u043a \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Prometheus + Grafana, \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0430\u0440\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430.<\/p>\n<p> <\/p>\n<p>\u042f \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Streaming API \u0432 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435.<br \/> \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0432 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u043d\u0430\u043c \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c &#171;jfr-starter&#187; \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u041d\u043e \u0443\u0432\u044b, \u0442\u0430\u043a\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0435\u0449\u0451 \u043d\u0438\u043a\u0435\u043c \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d. Streaming API \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u043f\u043e\u0439\u0442\u0438 \u0438 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u0438 \u0441\u0435\u0439\u0447\u0430\u0441. \u0418 \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442, \u043c\u043e\u0436\u0435\u0442, \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f &#171;jfr-stater&#187;.<\/p>\n<p> <\/p>\n<h2>\u041a\u0430\u043a \u0435\u0449\u0451 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Streaming API?<\/h2>\n<p> <\/p>\n<p>\u0421\u0447\u0438\u0442\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 JFR \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u2014 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Streaming API. \u041d\u043e \u043c\u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u043e, \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435, \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u2014 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u043d\u0435\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p> <\/p>\n<p>jfrunit \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 JFR \u0432 JUnit \u0442\u0435\u0441\u0442\u0430\u0445.<\/p>\n<p> <\/p>\n<p>\u041a\u0442\u043e-\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e JUnit \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u043d\u0435\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f, \u0438 \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0434\u0430 \u2026<br \/> \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0442\u0430\u043a\u0438\u0435 \u0442\u0435\u0441\u0442\u044b \u043d\u0443\u0436\u043d\u044b, \u0438 \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JUnit, \u0442\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438 \u043d\u0435\u0442.<br \/> \u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u2014 \u0442\u0435\u0441\u0442 \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043f\u0440\u0438 \u043e\u0442\u043c\u0435\u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u0441\u0442\u0430 \u043d\u0430 jfrunit.<\/p>\n<p> <\/p>\n<pre><code class=\"java\">    @JfrEventTest     public class JfrUnitTest {          public JfrEvents jfrEvents = new JfrEvents();      private JfrEventType eVirtualThreadStart = new JfrEventType(\"jdk.VirtualThreadStart\") {};     private JfrEventType eVirtualThreadEnd = new JfrEventType(\"jdk.VirtualThreadEnd\") {};      @EnableEvent(\"jdk.VirtualThreadStart\")     @EnableEvent(\"jdk.VirtualThreadEnd\")     @Test     public void test_no_thread_leak() throws InterruptedException {         \/\/ \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b         CompletableFuture&lt;Object&gt; heavyTask = startHeavyTask();         Thread.sleep(10);          \/\/ \u043e\u0442\u043c\u0435\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0437\u0430\u0434\u0430\u0447         heavyTask.cancel(true);          Assertions.assertThatThrownBy(() -&gt; heavyTask.join())         .isExactlyInstanceOf(CancellationException.class);          jfrEvents.awaitEvents();          var started = jfrEvents.filter(eVirtualThreadStart).count();         var ended = jfrEvents.filter(eVirtualThreadEnd).count();          \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u044b         Assertions.assertThat(ended)             .as(\"VirtualThreadEnd events %d should be equal to VirtualThreadStart events %d\", ended, started)             .isEqualTo(started);     }       \u2026<\/code><\/pre>\n<p> <\/p>\n<p>\u0410\u0432\u0442\u043e\u0440\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 jfrunit \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0440\u043e\u0432\u043e\u0434\u044f\u0442 \u0442\u0435\u0441\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e SQL \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<p> <\/p>\n<pre><code class=\"java\">    @SpringBootTest     @JfrEventTest     public class SpringJooqGradleApplicationTests {        @Autowired        public TestUserService testUserService;        public JfrEvents jfrEvents = new JfrEvents();        @Test        public void createUser() {            boolean success = testUserService.createUser(String.valueOf(ThreadLocalRandom.current().nextLong()),                ThreadLocalRandom.current().nextInt());            Assertions.assertThat(success).isTrue();            jfrEvents.awaitEvents();            Assertions.assertThat(jfrEvents.events().filter(this::isQueryEvent).count()).isEqualTo(1);        }     }<\/code><\/pre>\n<p> <\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u2014 <a href=\"https:\/\/github.com\/moditect\/jfrunit-examples\/tree\/main\/spring-jooq-gradle\">https:\/\/github.com\/moditect\/jfrunit-examples\/tree\/main\/spring-jooq-gradle<\/a><\/p>\n<p> <\/p>\n<p>\u042d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u0442\u0435\u043c, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/github.com\/openjdk\/jmc\/blob\/master\/agent\/README.md\">JMC Agent<\/a> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0441\u043e\u0431\u044b\u0442\u0438\u0439 JFR \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 JOOQ \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p> <\/p>\n<h2>\u0423\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a Streaming API<\/h2>\n<p> <\/p>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f \u043a Streaming API \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e JVM \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<br \/> \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c JVM \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b JMX. \u041e\u043d \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u044f\u0432\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<br \/> \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u043d\u0438\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>RecordingStream<\/code> \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0439 JVM \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u043f\u043e JMX.<\/p>\n<p> <\/p>\n<pre><code class=\"java\">    String host = \"com.example\";     int port = 7091;     String url = \"service:jmx:rmi:\/\/\/jndi\/rmi:\/\/\" + host + \":\" + port + \"\/jmxrmi\";     JMXServiceURL u = new JMXServiceURL(url);     JMXConnector c = JMXConnectorFactory.connect(u);     MBeanServerConnection connection = c.getMBeanServerConnection();     try (RemoteRecordingStream stream = new RemoteRecordingStream(connection)) {        stream.enabled(\"jdk.JavaMonitorEnter\").withStackTrace();        stream.onEvent(\"jdk.JavaMonitorEnter\", System.out::println),        stream.start();     }<\/code><\/pre>\n<p> <\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c <code>RemoteRecordingStream<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 poll \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e, \u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<p> <\/p>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f JFR \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. <\/p>\n<p> <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0430\u0433\u0435\u043d\u0442\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 Kubernetes \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c &#171;side car&#187;.<\/p>\n<p> <\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c POD, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0430\u0433\u0435\u043d\u0442 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043a\u0430\u043a \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 (\u044d\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0430\u0436\u043d\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043e\u0431\u0440\u0430\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f). \u0414\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0431\u043e\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u0449\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u0432 \u0434\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0442\u043e\u043c (volume) \u0442\u0438\u043f\u0430 &#171;dir&#187; \u0438 \u043f\u0440\u0438\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u0435\u0433\u043e \u043a \u043e\u0431\u043e\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c. <\/p>\n<p> <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/kh\/7l\/kk\/kh7lkkl9hijpl9xb0g6m5dyyby8.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/kh\/7l\/kk\/kh7lkkl9hijpl9xb0g6m5dyyby8.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/kh\/7l\/kk\/kh7lkkl9hijpl9xb0g6m5dyyby8.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p> <\/p>\n<p>\u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438<\/p>\n<p> <\/p>\n<pre><code class=\"plaintext\">java \\  -XX:StartFlightRecording \\ -XX:FlightRecorderOptions:repository=\/var\/jfr\/repo \\ \u2026<\/code><\/pre>\n<p> <\/p>\n<p>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u044b\u0448\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442 JFR \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 \u0434\u043b\u044f \u201c\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u201d \u2014 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e JFR \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.<br \/> \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0443\u0442\u044c <code>\/var\/jfr\/repo<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0435\u0441\u0442\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u043e\u0431\u043e\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435.<br \/> \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u0430\u0433\u0435\u043d\u0442\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<p> <\/p>\n<pre><code class=\"java\">    Path path = Path.of(\"\/var\/jfr\/repo\/\");     try (EventStream stream = EventStream.openRepository(path)) {        stream.onEvent(System.out::println);        stream.start();     }<\/code><\/pre>\n<p> <\/p>\n<p>\u041a\u043e\u0434 \u0432\u044b\u0448\u0435 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0434 \u0430\u0433\u0435\u043d\u0442\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u0432\u0430\u0448\u0443 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430.<br \/> \u0415\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441 JMX, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u0440\u043e\u0449\u0435 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0438 \u043c\u0435\u043d\u0435\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u0430 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0412\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<p> <\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p> <\/p>\n<p>\u041f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 Streaming API \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f JFR \u0432 JDK 14 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<br \/> \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044f Streaming API \u2014 \u044d\u0442\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0430\u0432\u0442\u043e\u0440\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u043e\u0432\u044b\u0445 \u0430\u0433\u0435\u043d\u0442\u043e\u0432 \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438, \u043e\u043d \u0431\u0435\u0437 \u0442\u0440\u0443\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u201c\u0437\u0434\u0435\u0441\u044c \u0438 \u0441\u0435\u0439\u0447\u0430\u0441\u201d, \u043d\u0435 \u0434\u043e\u0436\u0438\u0434\u0430\u044f\u0441\u044c, \u043f\u043e\u043a\u0430 \u043d\u0443\u0436\u043d\u044b\u0435 \u0432\u0430\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u0445\/\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Streaming API \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u0432 \u0441\u0432\u043e\u0451\u043c \u043a\u043e\u0434\u0435 \u2014 \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043d\u043e.<br \/> \u0422\u0430\u043a\u0436\u0435 jfrunit \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u043c \u043a\u0440\u0435\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f Streaming API, \u043d\u0435\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0435 \u0441 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u043e\u043c.<\/p>\n<p> <\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0430\u044f \u0432\u043e\u043a\u0440\u0443\u0433 JFR, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u0441\u043f\u0435\u0432\u0430\u0435\u0442 \u0437\u0430 \u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c, \u0438 \u044f \u043e\u0436\u0438\u0434\u0430\u044e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 API JFR, \u0432\u043a\u043b\u044e\u0447\u0430\u044f Streaming API, \u0432 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/917766\/\"> https:\/\/habr.com\/ru\/articles\/917766\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/y4\/-w\/a9\/y4-wa9fxtdjzx4nyxgunlfmhvys.jpeg\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/y4\/-w\/a9\/y4-wa9fxtdjzx4nyxgunlfmhvys.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/y4\/-w\/a9\/y4-wa9fxtdjzx4nyxgunlfmhvys.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><br \/> JDK Flight Recorder (JFR) \u2014 \u044d\u0442\u043e \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0432 JVM. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 JFR \u043b\u0435\u0436\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438\u0434\u0435\u044f, \u043d\u043e \u0432\u043e\u043a\u0440\u0443\u0433 \u043d\u0435\u0435 \u0432\u044b\u0440\u043e\u0441\u043b\u0430 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u0430\u044f \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0440\u0435\u0448\u0430\u0442\u044c \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u0441\u043f\u0435\u043a\u0442\u0440 \u0437\u0430\u0434\u0430\u0447.<br \/> \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 JFR \u2014 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u041f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432 JDK 14 \u0432 \u0432\u0438\u0434\u0435 <a href=\"https:\/\/docs.oracle.com\/en\/java\/javase\/14\/jfapi\/monitor-events-flight-recorder-event-streaming-api.html\">Flight Recorder Event Streaming API<\/a> \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f JFR \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-463443","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=463443"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463443\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=463443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=463443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=463443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}