java.lang.Object
jdk.jfr.EventSettings
将事件设置应用于录音的便利类。
可以通过调用使用方法链接配置的 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 EventSettings为与此事件设置关联的事件设置设置值。final EventSettings禁用与此事件设置关联的事件的堆栈跟踪。final EventSettings指定不使用阈值。final EventSettingswithPeriod(Duration duration) 设置与此事件设置关联的事件的间隔。final EventSettings为与此事件设置关联的事件启用堆栈跟踪。final EventSettingswithThreshold(Duration duration) 为与此事件设置关联的事件设置阈值。
-
方法详情
-
withStackTrace
为与此事件设置关联的事件启用堆栈跟踪。相当于调用
with("stackTrace", "true")方法。- 返回:
-
用于进一步配置的事件设置对象,而不是
null
-
withoutStackTrace
禁用与此事件设置关联的事件的堆栈跟踪。相当于调用
with("stackTrace", "false")方法。- 返回:
-
用于进一步配置的事件设置对象,而不是
null
-
withoutThreshold
指定不使用阈值。这是一个方便的方法,相当于调用
with("threshold", "0 s")方法。- 返回:
-
用于进一步配置的事件设置对象,而不是
null
-
withPeriod
设置与此事件设置关联的事件的间隔。- 参数:
duration- 持续时间,而不是null- 返回:
-
用于进一步配置的事件设置对象,而不是
null
-
withThreshold
为与此事件设置关联的事件设置阈值。- 参数:
duration- 持续时间,或者null如果没有使用持续时间- 返回:
-
用于进一步配置的事件设置对象,而不是
null
-
with
为与此事件设置关联的事件设置设置值。- 参数:
name- 设置的名称(例如,"threshold")value- 要设置的值(例如"20 ms"而不是null)- 返回:
-
用于进一步配置的事件设置对象,而不是
null
-