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?
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.
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