-
@Retention(RUNTIME) @Target(TYPE) public @interface MetadataDefinition
用于定义新类型的事件元数据的元注释。在以下示例中,使用两个用户定义的注释
@Severity
和@TransactionId
定义事务事件。@MetadataDefinition @Label("Severity") @Description("Value between 0 and 100 that indicates severity. 100 is most severe.") @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE }) public @interface @Severity { int value() default 50; } @MetadataDefinition @Label("Transaction Id") @Relational @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD }) public @interface @Severity { } @Severity(80) @Label("Transaction Blocked"); class TransactionBlocked extends Event { @TransactionId @Label("Transaction"); long transactionId; @TransactionId @Label("Transaction Blocker"); long transactionId; }
@MetadataDefinition
添加到@Severity
和@TransactionId
的声明中可确保Flight Recorder保存信息。- 从以下版本开始:
- 9