Created
September 6, 2020 17:02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JfrPeriodicEventHandler | |
// register a periodic JFR event and assing its handler to this method; the periodicity is defined in the Event itself via 'jdk.jfr.Period' annotation | |
public static void handleSimplePeriodic(SimplePeriodicEvent event) { | |
// the handler code will be called periodically by the JFR infrastructure | |
if (event.shouldCommit()) { | |
// if the event type is enabled and there is an ongoing recording set up the valued and commit the event | |
event.setValue(10); | |
event.commit(); | |
} | |
} | |
@JfrBlock(SimpleEvent.class) | |
// create a block containing JFR event calls; all the event types enumerated in the annotation will be automatically registered | |
public static void emitEvent(long bytesRead) { | |
// instantiate the event | |
SimpleEvent event = new SimpleEvent(); | |
if (event.shouldCommit()) { | |
// if the event type is enabled and there is an ongoing recording set up the valued and commit the event | |
event.setValue(bytesRead); | |
event.commit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment