模块 jdk.jfr
 jdk.jfr

类 EventSettings

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
  • 方法详情

    • 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" 而不是 null
      返回:
      用于进一步配置的事件设置对象,而不是null