user3364192
user3364192

Reputation: 3933

Custom JFR Java mission control events

I would like to emit custom events in jmc -I've came across the blog post about jfr custom events - http://hirt.se/blog/?p=444 . The author however stressed that this feature may be depracted in the future. Since the jmc is not open source I am unable to check it. Is the information in the blogpost still up to date?

Upvotes: 2

Views: 881

Answers (2)

Kire Haglin
Kire Haglin

Reputation: 7069

JDK 9 has been released and it contains a supported API to create custom events. Example,

@Label("Hello World!")
class HelloWorld extends jdk.jfr.Event {
  @Label("Message")
  String message;
}

class App {
  public static void main(String... args) {
    HelloWorld e = new HelloWorld();
    e.message = "hello, world!";
    e.commit();
  }
}

Upvotes: 4

Hirt
Hirt

Reputation: 1774

The Blogposter here! :) I've started hacking together a few small plug-ins for JFR during the Hackergarten meetings in Luzern, to showcase how these APIs can be used. I've open sourced them here:

https://github.com/thegreystone

When JDK 9 is released, I will submit updates that will make them support both JDK7/8 and JDK 9 transparently, to showcase how it can be done. Note that using the JDK7/8 JFR API is NOT supported, and never will be. That said, it's nevertheless pretty useful. ;)

Upvotes: 2

Related Questions