Package com.tnsai.agents.groups
Record Class GroupMetrics
java.lang.Object
java.lang.Record
com.tnsai.agents.groups.GroupMetrics
- Record Components:
groupId- group IDmemberCount- current member counthealthyMemberCount- healthy member countlifecycle- current lifecycle statetasksCompleted- total tasks completedtasksFailed- total tasks failedmessagesExchanged- total messages exchangedaverageResponseTime- average scatter response timeuptime- time since group startedleaderElections- number of leader electionstimestamp- when metrics were captured
public record GroupMetrics(String groupId, int memberCount, int healthyMemberCount, GroupLifecycle lifecycle, long tasksCompleted, long tasksFailed, long messagesExchanged, Duration averageResponseTime, Duration uptime, int leaderElections, Instant timestamp)
extends Record
Metrics snapshot for an AgentGroup.
-
Constructor Summary
ConstructorsConstructorDescriptionGroupMetrics(String groupId, int memberCount, int healthyMemberCount, GroupLifecycle lifecycle, long tasksCompleted, long tasksFailed, long messagesExchanged, Duration averageResponseTime, Duration uptime, int leaderElections, Instant timestamp) Creates an instance of aGroupMetricsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theaverageResponseTimerecord component.static GroupMetricsCreates empty metrics for a new group.final booleanIndicates whether some other object is "equal to" this one.doubleGets healthy member percentage.doubleGets task success rate.groupId()Returns the value of thegroupIdrecord component.final inthashCode()Returns a hash code value for this object.intReturns the value of thehealthyMemberCountrecord component.booleanChecks if group is fully healthy.intReturns the value of theleaderElectionsrecord component.Returns the value of thelifecyclerecord component.intReturns the value of thememberCountrecord component.longReturns the value of themessagesExchangedrecord component.longReturns the value of thetasksCompletedrecord component.longReturns the value of thetasksFailedrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.uptime()Returns the value of theuptimerecord component.
-
Constructor Details
-
GroupMetrics
public GroupMetrics(String groupId, int memberCount, int healthyMemberCount, GroupLifecycle lifecycle, long tasksCompleted, long tasksFailed, long messagesExchanged, Duration averageResponseTime, Duration uptime, int leaderElections, Instant timestamp) Creates an instance of aGroupMetricsrecord class.- Parameters:
groupId- the value for thegroupIdrecord componentmemberCount- the value for thememberCountrecord componenthealthyMemberCount- the value for thehealthyMemberCountrecord componentlifecycle- the value for thelifecyclerecord componenttasksCompleted- the value for thetasksCompletedrecord componenttasksFailed- the value for thetasksFailedrecord componentmessagesExchanged- the value for themessagesExchangedrecord componentaverageResponseTime- the value for theaverageResponseTimerecord componentuptime- the value for theuptimerecord componentleaderElections- the value for theleaderElectionsrecord componenttimestamp- the value for thetimestamprecord component
-
-
Method Details
-
empty
Creates empty metrics for a new group.- Parameters:
groupId- group ID- Returns:
- empty metrics
-
getTaskSuccessRate
public double getTaskSuccessRate()Gets task success rate.- Returns:
- success rate (0.0 - 1.0)
-
getHealthyPercentage
public double getHealthyPercentage()Gets healthy member percentage.- Returns:
- healthy percentage (0.0 - 1.0)
-
isFullyHealthy
public boolean isFullyHealthy()Checks if group is fully healthy.- Returns:
- true if all members healthy
-
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. -
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. -
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 '=='. -
groupId
Returns the value of thegroupIdrecord component.- Returns:
- the value of the
groupIdrecord component
-
memberCount
public int memberCount()Returns the value of thememberCountrecord component.- Returns:
- the value of the
memberCountrecord component
-
healthyMemberCount
public int healthyMemberCount()Returns the value of thehealthyMemberCountrecord component.- Returns:
- the value of the
healthyMemberCountrecord component
-
lifecycle
Returns the value of thelifecyclerecord component.- Returns:
- the value of the
lifecyclerecord component
-
tasksCompleted
public long tasksCompleted()Returns the value of thetasksCompletedrecord component.- Returns:
- the value of the
tasksCompletedrecord component
-
tasksFailed
public long tasksFailed()Returns the value of thetasksFailedrecord component.- Returns:
- the value of the
tasksFailedrecord component
-
messagesExchanged
public long messagesExchanged()Returns the value of themessagesExchangedrecord component.- Returns:
- the value of the
messagesExchangedrecord component
-
averageResponseTime
Returns the value of theaverageResponseTimerecord component.- Returns:
- the value of the
averageResponseTimerecord component
-
uptime
Returns the value of theuptimerecord component.- Returns:
- the value of the
uptimerecord component
-
leaderElections
public int leaderElections()Returns the value of theleaderElectionsrecord component.- Returns:
- the value of the
leaderElectionsrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-