10 Enable and Disable Events
You can enable and disable events with the @Enabled annotation. The example EnablementSample.java
demonstrates this.
import jdk.jfr.Enabled;
import jdk.jfr.Event;
import jdk.jfr.Label;
import jdk.jfr.Name;
public class EnablementSample {
@Name("com.oracle.WontSeeMe")
@Label("Won't See Me")
@Enabled(false)
static class WontSeeMe extends Event {
}
@Name("com.oracle.WillSeeMe")
@Label("Will See Me")
@Enabled(true)
static class WillSeeMe extends Event {
}
public static void main(String... args) throws Exception {
WontSeeMe event1 = new WontSeeMe();
event1.commit();
WillSeeMe event2 = new WillSeeMe();
event2.commit();
}
}