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 Summary
ConstructorsConstructorDescriptionEventBusMetrics(long totalPublished, long totalDelivered, long totalErrors, long totalDeadEvents, int listenerCount) Creates an instance of aEventBusMetricsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of thelistenerCountrecord component.final StringtoString()Returns a string representation of this record class.longReturns the value of thetotalDeadEventsrecord component.longReturns the value of thetotalDeliveredrecord component.longReturns the value of thetotalErrorsrecord component.longReturns the value of thetotalPublishedrecord component.
-
Constructor Details
-
EventBusMetrics
public EventBusMetrics(long totalPublished, long totalDelivered, long totalErrors, long totalDeadEvents, int listenerCount) Creates an instance of aEventBusMetricsrecord class.- Parameters:
totalPublished- the value for thetotalPublishedrecord componenttotalDelivered- the value for thetotalDeliveredrecord componenttotalErrors- the value for thetotalErrorsrecord componenttotalDeadEvents- the value for thetotalDeadEventsrecord componentlistenerCount- the value for thelistenerCountrecord component
-
-
Method Details
-
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. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
totalPublished
public long totalPublished()Returns the value of thetotalPublishedrecord component.- Returns:
- the value of the
totalPublishedrecord component
-
totalDelivered
public long totalDelivered()Returns the value of thetotalDeliveredrecord component.- Returns:
- the value of the
totalDeliveredrecord component
-
totalErrors
public long totalErrors()Returns the value of thetotalErrorsrecord component.- Returns:
- the value of the
totalErrorsrecord component
-
totalDeadEvents
public long totalDeadEvents()Returns the value of thetotalDeadEventsrecord component.- Returns:
- the value of the
totalDeadEventsrecord component
-
listenerCount
public int listenerCount()Returns the value of thelistenerCountrecord component.- Returns:
- the value of the
listenerCountrecord component
-