JMC parser for Java JFR dumps using Jrockit

耗尽温柔 提交于 2019-12-11 11:32:25

问题


I got to know that parsing JFR into Java can be done by unsupported parsers like JMC parser using jrockit from this. Also I figured during the flight recording there will be lot of events captured.

If I want to retrieve data values from various events such as Stack trace under Events tab, Hot method under Code tab, Call tree under Code tab etc etc. How do I filter? Example image

for example I was able to filter Call tree using following code as mentioned in jfr-flame-graph.

final String EVENT_TYPE = "Method Profiling Sample";
IView view = recording.createView();
for(IEvent event : view){
if(EVENT_TYPE.equals(event.getEventType().getName())){
  FLRStackTrace flrStackTrace = (FLRStackTrace) event.getValue("(stackTrace)");

Here, Event type - Method Profiling Sample ; Identifier - (stacktrace);

So If I want to retrieve stacktrace/hot methods/etc what are the events/identifiers that I need to capture? Is there any documentations for this?


回答1:


There isn't any documentation for this. If you want to extract stacktraces, the jfr-flame-graph is a very good example. The difference between Events/Stack trace and Code/Hot Methods is just that the Hot Methods tab only uses the Method Profiling Sample event, the Events tabs are more general and will show the event types you have selected in the Event Types view. The Code/Call Tree is the same as Hot Methods, but "upside down".

To see which other events that are available, you can use the JMC UI. There is feature in there called Designer view (Click Window/Show View/Designer). If you have a recording open, you can use the red stop button to go into design mode of the tab that you are interested in, then right-click the interesting component to see which event types and attributes it uses.




回答2:


JDK 9 has a supported parser API.

Path p = Paths.get("recording.jfr");
for (RecordedEvent event: RecordingFile.readAllEvents(p)) {
  System.out.println(event);
}

For a more complete example, see Javadoc http://docs.oracle.com/javase/9/docs/api/jdk/jfr/consumer/package-summary.html



来源:https://stackoverflow.com/questions/37322738/jmc-parser-for-java-jfr-dumps-using-jrockit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!