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
ConstructorsConstructorDescriptionMetricsSnapshot(String ruleName, long evaluationCount, long fireCount, long failCount, long totalDurationNanos) Creates an instance of aMetricsSnapshotrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleComputes the average evaluation duration in nanoseconds 计算平均评估持续时间(纳秒)final booleanIndicates whether some other object is "equal to" this one.longReturns the value of theevaluationCountrecord component.longReturns the value of thefailCountrecord component.longReturns the value of thefireCountrecord component.doublefireRate()Computes the fire rate (fireCount / evaluationCount) 计算触发率(触发次数 / 评估次数)final inthashCode()Returns a hash code value for this object.ruleName()Returns the value of theruleNamerecord component.final StringtoString()Returns a string representation of this record class.longReturns the value of thetotalDurationNanosrecord component.
-
Constructor Details
-
MetricsSnapshot
public MetricsSnapshot(String ruleName, long evaluationCount, long fireCount, long failCount, long totalDurationNanos) Creates an instance of aMetricsSnapshotrecord class.- Parameters:
ruleName- the value for theruleNamerecord componentevaluationCount- the value for theevaluationCountrecord componentfireCount- the value for thefireCountrecord componentfailCount- the value for thefailCountrecord componenttotalDurationNanos- the value for thetotalDurationNanosrecord 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
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
ruleName
-
evaluationCount
public long evaluationCount()Returns the value of theevaluationCountrecord component.- Returns:
- the value of the
evaluationCountrecord component
-
fireCount
-
failCount
-
totalDurationNanos
public long totalDurationNanos()Returns the value of thetotalDurationNanosrecord component.- Returns:
- the value of the
totalDurationNanosrecord component
-