Run JMC tool rools programmatically

146 Views Asked by At

My goal is to write Java class that will analyze jfr dump and give warnings like JMC tool like in attached screenshot. For example: "There are long socket read pauses" or "The JVM was paused for 100 % during ..." etc.

I saw an example of org.openjdk.jmc.flightrecorder.rules.RuleRegistry. However it contains no rules. How can I export all rules that JMC tool runs on JFR dump and load them into my RuleRegistry?

        IItemCollection events = JfrLoaderToolkit.loadEvents(new File("abcd.jfr"));
        for (IRule rule : RuleRegistry.getRules())
        {
            RunnableFuture<Result> future = rule.evaluate(events, IPreferenceValueProvider.DEFAULT_VALUES); 
future.run(); 
            Result result = future.get(); 

enter image description here

1

There are 1 best solutions below

2
Hirt On

Just ensure that you have all the proper bundles on the classpath.

See https://github.com/thegreystone/jmc-jshell for an example.