Record Class MetricsSnapshot

java.lang.Object
java.lang.Record
cloud.opencode.base.rules.metric.MetricsSnapshot
Record Components:
ruleName - the rule name | 规则名称
evaluationCount - the number of times the rule was evaluated | 规则被评估的次数
fireCount - the number of times the rule fired | 规则被触发的次数
failCount - the number of times the rule failed | 规则失败的次数
totalDurationNanos - the total evaluation duration in nanoseconds | 总评估持续时间(纳秒)

public record MetricsSnapshot(String ruleName, long evaluationCount, long fireCount, long failCount, long totalDurationNanos) extends Record
Metrics Snapshot - Immutable Point-in-Time Snapshot of Rule Execution Metrics 指标快照 - 规则执行指标的不可变时间点快照

Captures per-rule evaluation counts, fire counts, failure counts, and total duration at the time the snapshot was taken.

捕获快照拍摄时每条规则的评估次数、触发次数、失败次数和总持续时间。

Since:
JDK 25, opencode-base-rules V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    MetricsSnapshot(String ruleName, long evaluationCount, long fireCount, long failCount, long totalDurationNanos)
    Creates an instance of a MetricsSnapshot record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Computes the average evaluation duration in nanoseconds 计算平均评估持续时间(纳秒)
    final boolean
    Indicates whether some other object is "equal to" this one.
    long
    Returns the value of the evaluationCount record component.
    long
    Returns the value of the failCount record component.
    long
    Returns the value of the fireCount record component.
    double
    Computes the fire rate (fireCount / evaluationCount) 计算触发率(触发次数 / 评估次数)
    final int
    Returns a hash code value for this object.
    Returns the value of the ruleName record component.
    final String
    Returns a string representation of this record class.
    long
    Returns the value of the totalDurationNanos record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MetricsSnapshot

      public MetricsSnapshot(String ruleName, long evaluationCount, long fireCount, long failCount, long totalDurationNanos)
      Creates an instance of a MetricsSnapshot record class.
      Parameters:
      ruleName - the value for the ruleName record component
      evaluationCount - the value for the evaluationCount record component
      fireCount - the value for the fireCount record component
      failCount - the value for the failCount record component
      totalDurationNanos - the value for the totalDurationNanos record component
  • Method Details

    • avgDurationNanos

      public double avgDurationNanos()
      Computes the average evaluation duration in nanoseconds 计算平均评估持续时间(纳秒)
      Returns:
      average duration, or 0 if no evaluations | 平均持续时间,如果没有评估则为0
    • fireRate

      public double fireRate()
      Computes the fire rate (fireCount / evaluationCount) 计算触发率(触发次数 / 评估次数)
      Returns:
      fire rate between 0.0 and 1.0, or 0 if no evaluations | 0.0到1.0之间的触发率,如果没有评估则为0
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • ruleName

      public String ruleName()
      Returns the value of the ruleName record component.
      Returns:
      the value of the ruleName record component
    • evaluationCount

      public long evaluationCount()
      Returns the value of the evaluationCount record component.
      Returns:
      the value of the evaluationCount record component
    • fireCount

      public long fireCount()
      Returns the value of the fireCount record component.
      Returns:
      the value of the fireCount record component
    • failCount

      public long failCount()
      Returns the value of the failCount record component.
      Returns:
      the value of the failCount record component
    • totalDurationNanos

      public long totalDurationNanos()
      Returns the value of the totalDurationNanos record component.
      Returns:
      the value of the totalDurationNanos record component