This class provides the methods necessary for creating, starting, stopping, and destroying recordings.
Modifier and Type | Field and Description |
---|---|
private static volatile boolean | |
private final PlatformRecorder | |
private static volatile FlightRecorder |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public static void | addListener(FlightRecorderListener
the listener to add, not changeListener)null Adds a recorder listener and captures the |
public static void | addPeriodicEvent(Class<? extends Event>
the class that the hook should run for, not eventClass, Runnable null the hook, not hook)null Adds a hook for a periodic event. |
public List | Returns: list of events, notnull Returns an immutable list that contains all currently registered events. |
public static FlightRecorder | Returns: a Flight Recorder instance, notnull Returns the Flight Recorder for the platform. |
pack-priv PlatformRecorder | |
public List | Returns: a list of recordings, notnull Returns an immutable list of the available recordings. |
public static boolean | Returns: true , if Flight Recorder is available, false
otherwiseReturns |
public static boolean | Returns: true , if Flight Recorder is initialized,
false otherwiseReturns |
public static void | |
public static boolean | Returns: true , if the listener could be removed, false
otherwiselistener to remove, not changeListener)null Removes a recorder listener. |
public static boolean | Returns: true if hook is removed, false otherwisethe hook to remove, not hook)null Removes a hook for a periodic event. |
public Recording | Returns: a snapshot of all available recording data, notnull Creates a snapshot of all available recorded data. |
public static void | unregister(Class<? extends Event>
the event class to unregistered, not eventClass)null Unregisters an event class. |
initialized | back to summary |
---|---|
private static volatile boolean initialized |
internal | back to summary |
---|---|
private final PlatformRecorder internal |
platformRecorder | back to summary |
---|---|
private static volatile FlightRecorder platformRecorder |
FlightRecorder | back to summary |
---|---|
private FlightRecorder(PlatformRecorder internal) |
addListener | back to summary |
---|---|
public static void addListener(FlightRecorderListener changeListener) Adds a recorder listener and captures the
If Flight Recorder is already initialized when the listener is added, then the method
|
addPeriodicEvent | back to summary |
---|---|
public static void addPeriodicEvent(Class<? extends Event> eventClass, Runnable hook) throws SecurityException Adds a hook for a periodic event.
The implementation of the hook should return as soon as possible, to
avoid blocking other Flight Recorder operations. The hook should emit
one or more events of the specified type. When a hook is added, the
interval at which the call is invoked is configurable using the
|
getEventTypes | back to summary |
---|---|
public List Returns an immutable list that contains all currently registered events.
By default, events are registered when they are first used, typically
when an event object is allocated. To ensure an event is visible early,
registration can be triggered by invoking the
|
getFlightRecorder | back to summary |
---|---|
public static FlightRecorder getFlightRecorder() throws IllegalStateException, SecurityException Returns the Flight Recorder for the platform.
|
getInternal | back to summary |
---|---|
pack-priv PlatformRecorder getInternal() |
getRecordings | back to summary |
---|---|
public List Returns an immutable list of the available recordings.
A recording becomes available when it is created. It becomes unavailable when it
is in the |
isAvailable | back to summary |
---|---|
public static boolean isAvailable() Returns This method can quickly check whether Flight Recorder can be initialized, without actually doing the initialization work. The value may change during runtime and it is not safe to cache it.
|
isInitialized | back to summary |
---|---|
public static boolean isInitialized() Returns
|
register | back to summary |
---|---|
public static void register(Class<? extends Event> eventClass) Registers an event class. If the event class is already registered, then the invocation of this method is ignored.
|
removeListener | back to summary |
---|---|
public static boolean removeListener(FlightRecorderListener changeListener) Removes a recorder listener. If the same listener is added multiple times, only one instance is removed.
|
removePeriodicEvent | back to summary |
---|---|
public static boolean removePeriodicEvent(Runnable hook) throws SecurityException Removes a hook for a periodic event.
|
takeSnapshot | back to summary |
---|---|
public Recording takeSnapshot() Creates a snapshot of all available recorded data.
A snapshot is a synthesized recording in a A snapshot provides stable access to data for later operations (for example, operations to change the interval or to reduce the data size). The following example shows how to create a snapshot and write a subset of the data to a file. try (Recording snapshot = FlightRecorder.getFlightRecorder().takeSnapshot()) { if (snapshot.getSize() > 0) { snapshot.setMaxSize(100_000_000); snapshot.setMaxAge(Duration.ofMinutes(5)); snapshot.dump(Paths.get("snapshot.jfr")); } }
|
unregister | back to summary |
---|---|
public static void unregister(Class<? extends Event> eventClass) Unregisters an event class. If the event class is not registered, then the invocation of this method is ignored.
|