- java.lang.Object
-
- jdk.jfr.EventSettings
-
public abstract class EventSettings extends Object
将事件设置应用于录制的便捷类。可以通过调用使用方法链接配置的
Recording.enable(String)方法来获取用于记录的EventSettings对象。以下示例显示如何使用
EventSettings类。Recording r = new Recording(); r.enable("jdk.CPULoad") .withPeriod(Duration.ofSeconds(1)); r.enable("jdk.FileWrite") .withoutStackTrace() .withThreshold(Duration.ofNanos(10)); r.start(); Thread.sleep(10_000); r.stop(); r.dump(Files.createTempFile("recording", ".jfr"));- 从以下版本开始:
- 9
-
-
方法摘要
所有方法 实例方法 抽象方法 具体的方法 变量和类型 方法 描述 abstract EventSettingswith(String name, String value)设置与此事件设置关联的事件的设置值。EventSettingswithoutStackTrace()禁用与此事件设置关联的事件的堆栈跟踪。EventSettingswithoutThreshold()指定不使用阈值。EventSettingswithPeriod(Duration duration)设置与此事件设置关联的事件的间隔。EventSettingswithStackTrace()为与此事件设置关联的事件启用堆栈跟踪。EventSettingswithThreshold(Duration duration)设置与此事件设置关联的事件的阈值。
-
-
-
方法详细信息
-
withStackTrace
public final EventSettings withStackTrace()
为与此事件设置关联的事件启用堆栈跟踪。相当于调用
with("stackTrace", "true")方法。- 结果
-
事件设置对象用于进一步配置,而不是
null
-
withoutStackTrace
public final EventSettings withoutStackTrace()
禁用与此事件设置关联的事件的堆栈跟踪。相当于调用
with("stackTrace", "false")方法。- 结果
-
事件设置对象用于进一步配置,而不是
null
-
withoutThreshold
public final EventSettings withoutThreshold()
指定不使用阈值。这是一种方便的方法,相当于调用
with("threshold", "0 s")方法。- 结果
-
事件设置对象用于进一步配置,而不是
null
-
withPeriod
public final EventSettings withPeriod(Duration duration)
设置与此事件设置关联的事件的间隔。- 参数
-
duration- 期限,而不是null - 结果
-
事件设置对象用于进一步配置,而不是
null
-
withThreshold
public final EventSettings withThreshold(Duration duration)
设置与此事件设置关联的事件的阈值。- 参数
-
duration- 持续时间,如果没有使用持续时间,null - 结果
-
事件设置对象进一步配置,而不是
null
-
with
public abstract EventSettings with(String name, String value)
设置与此事件设置关联的事件的设置值。- 参数
-
name- 设置的名称(例如,"threshold") -
value- 要设置的值(例如"20 ms"notnull) - 结果
-
事件设置对象用于进一步配置,而不是
null
-
-