8256156: JFR: Allow 'jfr' tool to show metadata without a recording #1904
8256156: JFR: Allow 'jfr' tool to show metadata without a recording #1904y1yang0 wants to merge 8 commits intoopenjdk:masterfrom
Conversation
|
Hi @kelthuzadx, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user kelthuzadx" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
|
/covered |
|
Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
|
/signed |
|
You are already a known contributor! |
|
/label add hotspot-jfr |
|
@kelthuzadx |
|
/label add ready |
Webrevs
|
|
@kelthuzadx The label
|
|
Mailing list message from Yang Yi on hotspot-jfr-dev: Happy New Year. Can anyone help reviewing this patch? ;) ------------- ------------------------------------------------------------------ Hi all, May I please have a review for this minor patch? It simplifies the use of subcommand `metadata` of jfr tool. Recording ------------- Commit messages: Changes: https://git.openjdk.java.net/jdk/pull/1904/files PR: https://git.openjdk.java.net/jdk/pull/1904 |
| } catch (IOException ioe) { | ||
| couldNotReadError(file, ioe); | ||
| } | ||
| } catch (Exception e) { |
There was a problem hiding this comment.
This error handling seems inadequate. If there is IOException, it still makes sense to get proper message, and not a stack trace
| continue; | ||
| } | ||
| if (foundEventFilter) { | ||
| if (acceptedEvents.contains(type.getName())) { |
There was a problem hiding this comment.
I would expect filtering for the metadata command to work like the 'print' command (accepting acronyms, wildcards etc.)
| if (categoryAnno != null) { | ||
| String[] categories = categoryAnno.value(); | ||
| for (String category : categories) { | ||
| if (categoryNames.contains(category)) { |
There was a problem hiding this comment.
I would expect filtering for the metadata command to work like the 'print' command (wildcards etc.)
| options.removeLast(); | ||
| return tmp; | ||
| } catch (Exception e) { | ||
| // ignored since recording file for jfr metadata is optional |
There was a problem hiding this comment.
Inadequate error handling. If there is something wrong with the file (permission etc) I like to know it, and not get the event types for the current JVM.
There was a problem hiding this comment.
It would not swallow the exception now.
| eventNames.add(line.substring(7, line.indexOf("\"", 7))); | ||
| } | ||
| } | ||
| List<Type> eventTypes = TypeLibrary.getInstance().getTypes(); |
There was a problem hiding this comment.
I think it would be better to use public API (FlightRecorder.getEventTypes()) instead of calling internals.
| @@ -99,7 +106,11 @@ public String getName() { | |||
|
|
|||
| @Override | |||
There was a problem hiding this comment.
I think ine would like to get similar help as for the ''print' command when it comes to filtering.
|
/csr |
|
@egahlin has indicated that a compatibility and specification (CSR) request is needed for this pull request. |
ca42a73 to
ad96ede
Compare
ad96ede to
b3c2ea5
Compare
|
It still doesn't work the same way as when you specify a file. Here is a patch I think it will fix the functionality. Not tested or formatted. |
|
Hi Erik, I have updated this patch according to your diff content. I'm fine with changes about force initialization. But it looks like the changes in |
egahlin
left a comment
There was a problem hiding this comment.
I think it is easier to grasp what the code does without the continue statement.
| for (EventType eventType : eventTypes) { | ||
| expectedNames.add(eventType.getName()); | ||
| } | ||
| Asserts.assertGTE(eventNames.size(), expectedNames.size()); |
There was a problem hiding this comment.
Seems something like this would be sufficient:
public void testNumberOfEventTypes() {
int count = 0;
for (String line : output.asLines()) {
if (line.contains("extends jdk.jfr.Event")) {
count++;
}
Assert.assertEquals(count, FlightRecorder.getFlightRecorder().getEventTypes().size());
}
≈
| testWildcardAndAcronym(); | ||
| } | ||
|
|
||
| static void testBasic() throws Throwable { |
There was a problem hiding this comment.
Perhaps change the name of the method to testUnfiltered() to make it more clear what the test does and create a separate method for the --wrongOption, i.e. testIllegalOption()
| Asserts.assertGTE(eventNames.size(), expectedNames.size()); | ||
| } | ||
|
|
||
| static void testDeterministic() throws Throwable { |
There was a problem hiding this comment.
Change name of the method to testEventFilter().
| List<String> lines = output.asLines(); | ||
|
|
||
| for (String line : lines) { | ||
| if (line.startsWith("@Name(\"")) { |
There was a problem hiding this comment.
Use contains "extends jdk.jfr.Event" as it is more stable
|
|
||
| for (String line : lines) { | ||
| if (line.startsWith("@Name(\"")) { | ||
| eventNames.add(line.substring(7, line.indexOf("\"", 7))); |
There was a problem hiding this comment.
Should be easy to check if the event is correct, not just the number.
if (line.contains("XXZQZYY.") {
event1 = true;
}
if (line.contains("ZQZPP") {
event2 = true;
}
Regarding events names, see following comment.
| } | ||
|
|
||
| static void testWildcardAndAcronym() throws Throwable { | ||
| OutputAnalyzer output = ExecuteHelper.jfr("metadata", "--events", "Thread*"); |
There was a problem hiding this comment.
Instead of depending on name of existing JVM events (which may change, be removed or interfere with wildcard expansion done by the OS) it would be better to create two custom Java events with an unlikely name pattern, i.e. com.example.XXZQZYY and com.stuff.ZQZPP, and then filter on "ZQZ".
To make sure they are registered, you can do:
FlightRecorder.register(XXZQZYY.class);
FlightRecorder.register(ZQZPP.class);
in static initializer so it is executed before calling ExecuteHelper.jfr("metadata", "--events", "ZQZ*");
There was a problem hiding this comment.
Make sense, I re-implement the test, using customized events.
| Asserts.assertGTE(eventNames.size(), 2); | ||
| } | ||
|
|
||
| static void testWildcardAndAcronym() throws Throwable { |
There was a problem hiding this comment.
The name of the seems misleading since it doesn't test acronyms, testWildcard() shuld be sufficient.
690f422 to
ff13850
Compare
egahlin
left a comment
There was a problem hiding this comment.
Looks good.
I still think the name of the test method should be called testWildcard() instead of testWildcardAndAcronym() since it is not testing acronyms, i.e using "GC" instead of "GarbageCollection", which is fine, but the name of the method should be appropriate.
|
@kelthuzadx This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 996 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@egahlin) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
Thank Erik for your patient and reviews. Your naming suggestion makes sense, I forgot to rename that method in the previous commit. Now it has been corrected. /integrate |
|
@kelthuzadx |
a2cedbf to
c401df4
Compare
|
/sponsor |
|
@egahlin The PR has been updated since the change author (@kelthuzadx) issued the |
|
/integrate |
|
@kelthuzadx |
|
/sponsor |
|
@egahlin @kelthuzadx Since your change was applied there have been 997 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 86e4c75. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi all,
May I please have a review for this minor patch?
It simplifies the use of subcommand
metadataof jfr tool. Recordingfile is no longer mandatory, users can directly use
jfr metadatatooutput JDK builtin meta information. As JDK-8256156 mentioned, it also
supports events and categories filters:
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/1904/head:pull/1904$ git checkout pull/1904