RFR: 7033: Allow overriding the id (name) of the event type

Marcus Hirt hirt at openjdk.java.net
Thu Dec 3 10:25:05 UTC 2020


On Wed, 2 Dec 2020 21:25:58 GMT, Gunnar Morling <github.com+28612+gunnarmorling at openjdk.org> wrote:

>> I was always a bit hesitant to changing to using "name" for the annotation for the event type IDs, and for an XML grammar it makes sense to have the ID be an attribute (IMHO). "Name" is not required metadata, and it will simply use the class name as event name if not specified (IIRC). Perhaps we should add tests and ensure that this is indeed the default behaviour if not defining id?
>
>> and it will simply use the class name as event name if not specified (IIRC)
> 
> Yes, that's what was (is) doing before this PR. I don't think it's a good idea though, as the event type is located in the package of the instrumented code, and thus this event name also would be related to that, which I think is confusing.
> 
> So I changed it to base the event name of the name given in the XML file (which you just renamed to "label", which makes sense to me). So I could see us doing either what I propose here, or derive the name from the id given in the XML (makes more sense to me now in the light of that renaming you did). And perhaps even make id mandatory in the XSD?

Yes - the name should be derived from the id, if set (that's why I fixed it up in those other PRs - so that you could use it here properly). :)

IMHO, ID should not be mandatory in the XSD - the default should be the default in JFR, which is to just use the class name - which admittedly will be a bit bonkers if generated by the agent. But if you don't care at all about the class name, because you're just doing a one off, throwaway, kinda thing, getting the generated one is fine, at least to me. The labels is all you care about then anyways. Now, if you are to be a good citizen, you'll provide an ID, and all our examples should have them. 

We may also want to validate that all registered IDs are unique, and warn and exit if we find duplicates.

-------------

PR: https://git.openjdk.java.net/jmc/pull/170


More information about the jmc-dev mailing list