8365815: JFR: Update metadata.xml with 'jfr query' examples

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin
2025-08-25 15:10:50 +00:00
parent 45726a1f8b
commit d24449f696
2 changed files with 29 additions and 4 deletions

View File

@@ -922,8 +922,10 @@ public class GenerateJfrFiles {
}
out.write(" using JfrEvent<Event" + event.name
+ ">::commit; // else commit() is hidden by overloaded versions in this class");
printConstructor2(out, event, empty);
printCommitMethod(out, event, empty);
if (!event.fields.isEmpty()) {
printConstructor2(out, event, empty);
printCommitMethod(out, event, empty);
}
if (!empty) {
printVerify(out, event.fields);
}

View File

@@ -40,16 +40,39 @@
event.commit();
}
void baz(char* text) {
EventText event;
event.set_text(text);
event.commit();
}
$ make images
$ java -XX:StartFlightRecording:settings=none,filename=dump.jfr ...
$ jfr view Text dump.jfr
Time Event Thread Text
======== ======================================== ==========================
21:54:29 Attach Listener hello
21:54:29 Attach Listener world
...
$ jfr print dump.jfr
$ jfr query 'SELECT text, COUNT(text) FROM Text GROUP BY text ORDER BY text ASC' dump.jfr
Text Count
=================== ===================
hello 622
world 37
$ jfr query 'SELECT COUNT(duration), AVG(duration), MEDIAN(duration), P90(duration),
P99(duration), P999(duration) FROM Duration' dump.jfr
The 'jfr query' command is only available in debug builds, but recordings with internal
events can be generated by product builds.
Programmatic access:
try (var rf = new RecordingFile(Path.of("dump.jfr"))) {
while (rf.hasMoreEvents()) {
RecordedEvent e = rf.readEvent();
System.out.println(e.getName() + " " + e.getDuration());
EventType et = e.getEventType();
System.out.println(et.getName() + " " + e.getDuration() + " " + e.getValue("text"));
}
};
!-->