Java Flight Recorder provides simple APIs to detect if it's available (FlightRecorder.isAvailable()) or initialized (FlightRecorder.isInitialized()). But there's no obvious API to detect if it's actually recording. Maybe I could check FlightRecorder.getFlightRecorder().getRecordings().isEmpty(), but I'm not sure it would be accurate. Is there an obvious API I'm missing?
How can I programmatically check if JFR is recording?
79 views Asked by stiemannkj1 At
1
To see if a recording is running, you must iterate all recordings and check their state.
I added the initialization check to prevent JFR to initialize when FlightRecorder.getFlightRecorder() is called.
If you want to detect when a recording starts, you can use the FlightRecorderListener.