public final class EventType extends Object
The following example shows how the EventType
class can be used to print metadata about an event.
for (EventType eventType : FlightRecorder.getFlightRecorder().getEventTypes()) {
System.out.println("Event Type: " + eventType.getName());
if (eventType.getLabel() != null) {
System.out.println("Label: " + eventType.getLabel());
}
if (eventType.getDescription() != null) {
System.out.println("Description: " + eventType.getDescription());
}
StringJoiner s = new StringJoiner(" / ");
for (String category : eventType.getCategoryNames()) {
s.add(category);
}
System.out.println("Category: " + s);
System.out.println("Fields: " + eventType.getFields().size());
System.out.println("Annotations: " + eventType.getAnnotationElements().size());
System.out.println("Settings: " + eventType.getSettingDescriptors().size());
System.out.println("Enabled: " + eventType.isEnabled());
System.out.println();
}
Modifier and Type | Method | Description |
---|---|---|
<A extends Annotation> |
getAnnotation |
Returns the first annotation for the specified type if an annotation element with the same name is directly present, otherwise null . |
List |
getAnnotationElements() |
Returns an immutable list of annotation elements for this event type. |
List |
getCategoryNames() |
Returns the list of human-readable names that makes up the categories for this event type (for example, "Java Application" , "Statistics" ). |
String |
getDescription() |
Returns a short sentence that describes the event class. |
static EventType |
getEventType |
Returns the event type for an event class, or null if it doesn't exist. |
ValueDescriptor |
getField |
Returns the field with the specified name, or null if it doesn't exist. |
List |
getFields() |
Returns an immutable list of descriptors that describe the event fields of this event type. |
long |
getId() |
Returns a unique ID for this event type in the Java Virtual Machine (JVM). |
String |
getLabel() |
Returns a human-readable name (for example, "CPU Load" ). |
String |
getName() |
Returns an identifier for the event (for example, "jdk.CPULoad" ). |
List |
getSettingDescriptors() |
Returns an immutable list of the setting descriptors that describe the available event settings for this event type. |
boolean |
isEnabled() |
Returns true if the event is enabled and at least one recording is running, false otherwise. |
public List<ValueDescriptor> getFields()
null
public ValueDescriptor getField(String name)
null
if it doesn't exist. It's possible to index into a nested field by using "."
(for instance "thread.group.parent.name
").
name
- of the field to get, not null
null
if the field with the specified name doesn't existpublic String getName()
"jdk.CPULoad"
). The identifier is the fully qualified name of the event class, if not set using the Name
annotation.
null
public String getLabel()
"CPU Load"
). The label of an event class can be set with Label
.
null
if a label is not setpublic long getId()
public List<AnnotationElement> getAnnotationElements()
null
public boolean isEnabled()
true
if the event is enabled and at least one recording is running, false
otherwise. By default, the event is enabled. The event can be enabled or disabled by setting the enabled setting to true
or false
, programmatically or by using a configuration file. The event can also be disabled by annotating event with the @Enabled(false)
annotation.
public String getDescription()
The description of an event class can be set with Description
.
null
if no description existspublic <A extends Annotation> A getAnnotation(Class<A> annotationClass)
null
.A
- the type of the annotation to query for and return if presentannotationClass
- the Class
object that corresponds to the annotation type, not null
null
public static EventType getEventType(Class<? extends Event> eventClass)
null
if it doesn't exist.eventClass
- the event class, not null
IllegalArgumentException
- if eventClass
is an abstract classIllegalStateException
- if the class is annotated with Registered(false)
, but not manually registeredpublic List<SettingDescriptor> getSettingDescriptors()
null
public List<String> getCategoryNames()
"Java Application"
, "Statistics"
)."Uncategorized"
if no category is set
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jfr/jdk/jfr/EventType.html