Class EventType
java.lang.Object
jdk.jfr.EventType
Describes an event, its fields, settings and annotations.
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();
}
- Since:
- 9
-
Method Summary
Modifier and TypeMethodDescription<A extends Annotation>
AgetAnnotation(Class<A> annotationClass) Returns the first annotation for the specified type if an annotation element with the same name is directly present, otherwisenull.Returns an immutable list of annotation elements for this event type.Returns the list of human-readable names that make up the categories for this event type (for example,"Java Application","Statistics").Returns a short sentence that describes the event class.static EventTypegetEventType(Class<? extends Event> eventClass) Returns the event type for an event class, ornullif it doesn't exist.Returns the field with the specified name, ornullif it doesn't exist.Returns an immutable list of descriptors that describe the event fields of this event type.longgetId()Returns a unique ID for this event type in the Java Virtual Machine (JVM).getLabel()Returns a human-readable name (for example,"CPU Load").getName()Returns an identifier for the event (for example,"jdk.CPULoad").Returns an immutable list of the setting descriptors that describe the available event settings for this event type.booleanReturnstrueif the event is enabled and at least one recording is running,falseotherwise.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Method Details
-
getFields
Returns an immutable list of descriptors that describe the event fields of this event type.- Returns:
- the list of field descriptors, not
null
-
getField
Returns the field with the specified name, ornullif it doesn't exist.It's possible to index into a nested field by using
"."(for instance"thread.group.parent.name").- Parameters:
name- of the field to get, notnull- Returns:
- a value descriptor that describes the field, or
nullif the field with the specified name doesn't exist
-
getName
-
getLabel
-
getId
public long getId()Returns a unique ID for this event type in the Java Virtual Machine (JVM).- Returns:
- the ID that is used in the JVM
-
getAnnotationElements
Returns an immutable list of annotation elements for this event type.- Returns:
- an immutable list of annotations or an empty list if no
annotations exists, not
null
-
isEnabled
public boolean isEnabled()Returnstrueif the event is enabled and at least one recording is running,falseotherwise.By default, the event is enabled. The event can be enabled or disabled by setting the enabled setting to
trueorfalse, programmatically or by using a configuration file. The event can also be disabled by annotating event with the@Enabled(false)annotation.- Returns:
- true if event is enabled, false otherwise
- See Also:
-
getDescription
Returns a short sentence that describes the event class.The description of an event class can be set with
Description.- Returns:
- the description, or
nullif no description exists - See Also:
-
getAnnotation
Returns the first annotation for the specified type if an annotation element with the same name is directly present, otherwisenull.- Type Parameters:
A- the type of the annotation to query for and return if present- Parameters:
annotationClass- theClassobject that corresponds to the annotation type, notnull- Returns:
- this element's annotation for the specified annotation type if
directly present, else
null
-
getEventType
Returns the event type for an event class, ornullif it doesn't exist.- Parameters:
eventClass- the event class, notnull- Returns:
- the event class, or null if class doesn't exist
- Throws:
IllegalArgumentException- ifeventClassis an abstract classIllegalStateException- if the class is annotated withRegistered(false), but not manually registered
-
getSettingDescriptors
Returns an immutable list of the setting descriptors that describe the available event settings for this event type.- Returns:
- the list of setting descriptors for this event type, not
null
-
getCategoryNames
-