Record Class EventBusMetrics

java.lang.Object
java.lang.Record
cloud.opencode.base.event.monitor.EventBusMetrics
Record Components:
totalPublished - total number of events published | 总发布事件数
totalDelivered - total number of listener invocations | 总监听器调用次数
totalErrors - total number of listener errors | 总监听器错误数
totalDeadEvents - total number of dead events (no listeners) | 总死事件数(无监听器)
listenerCount - current number of registered listeners | 当前注册监听器数

public record EventBusMetrics(long totalPublished, long totalDelivered, long totalErrors, long totalDeadEvents, int listenerCount) extends Record
Event Bus Metrics - Snapshot of event bus statistics 事件总线指标 - 事件总线统计快照

Immutable snapshot of event bus operational metrics, including event counts, error rates, and listener statistics.

事件总线运行指标的不可变快照,包括事件计数、错误率和监听器统计。

Features | 主要功能:

  • Total published/delivered/error counts - 总发布/投递/错误计数
  • Dead event tracking - 死事件跟踪
  • Listener count - 监听器计数

Usage Examples | 使用示例:

EventBusMetrics metrics = eventBus.getMetrics();
System.out.println("Published: " + metrics.totalPublished());
System.out.println("Dead events: " + metrics.totalDeadEvents());

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
Since:
JDK 25, opencode-base-event V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • EventBusMetrics

      public EventBusMetrics(long totalPublished, long totalDelivered, long totalErrors, long totalDeadEvents, int listenerCount)
      Creates an instance of a EventBusMetrics record class.
      Parameters:
      totalPublished - the value for the totalPublished record component
      totalDelivered - the value for the totalDelivered record component
      totalErrors - the value for the totalErrors record component
      totalDeadEvents - the value for the totalDeadEvents record component
      listenerCount - the value for the listenerCount record component
  • Method Details

    • 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. All components in this record class 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.
    • totalPublished

      public long totalPublished()
      Returns the value of the totalPublished record component.
      Returns:
      the value of the totalPublished record component
    • totalDelivered

      public long totalDelivered()
      Returns the value of the totalDelivered record component.
      Returns:
      the value of the totalDelivered record component
    • totalErrors

      public long totalErrors()
      Returns the value of the totalErrors record component.
      Returns:
      the value of the totalErrors record component
    • totalDeadEvents

      public long totalDeadEvents()
      Returns the value of the totalDeadEvents record component.
      Returns:
      the value of the totalDeadEvents record component
    • listenerCount

      public int listenerCount()
      Returns the value of the listenerCount record component.
      Returns:
      the value of the listenerCount record component