Record Class GroupMetrics

java.lang.Object
java.lang.Record
com.tnsai.agents.groups.GroupMetrics
Record Components:
groupId - group ID
memberCount - current member count
healthyMemberCount - healthy member count
lifecycle - current lifecycle state
tasksCompleted - total tasks completed
tasksFailed - total tasks failed
messagesExchanged - total messages exchanged
averageResponseTime - average scatter response time
uptime - time since group started
leaderElections - number of leader elections
timestamp - 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 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 a GroupMetrics record class.
      Parameters:
      groupId - the value for the groupId record component
      memberCount - the value for the memberCount record component
      healthyMemberCount - the value for the healthyMemberCount record component
      lifecycle - the value for the lifecycle record component
      tasksCompleted - the value for the tasksCompleted record component
      tasksFailed - the value for the tasksFailed record component
      messagesExchanged - the value for the messagesExchanged record component
      averageResponseTime - the value for the averageResponseTime record component
      uptime - the value for the uptime record component
      leaderElections - the value for the leaderElections record component
      timestamp - the value for the timestamp record component
  • Method Details

    • empty

      public static GroupMetrics empty(String groupId)
      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

      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 '=='.
      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.
    • groupId

      public String groupId()
      Returns the value of the groupId record component.
      Returns:
      the value of the groupId record component
    • memberCount

      public int memberCount()
      Returns the value of the memberCount record component.
      Returns:
      the value of the memberCount record component
    • healthyMemberCount

      public int healthyMemberCount()
      Returns the value of the healthyMemberCount record component.
      Returns:
      the value of the healthyMemberCount record component
    • lifecycle

      public GroupLifecycle lifecycle()
      Returns the value of the lifecycle record component.
      Returns:
      the value of the lifecycle record component
    • tasksCompleted

      public long tasksCompleted()
      Returns the value of the tasksCompleted record component.
      Returns:
      the value of the tasksCompleted record component
    • tasksFailed

      public long tasksFailed()
      Returns the value of the tasksFailed record component.
      Returns:
      the value of the tasksFailed record component
    • messagesExchanged

      public long messagesExchanged()
      Returns the value of the messagesExchanged record component.
      Returns:
      the value of the messagesExchanged record component
    • averageResponseTime

      public Duration averageResponseTime()
      Returns the value of the averageResponseTime record component.
      Returns:
      the value of the averageResponseTime record component
    • uptime

      public Duration uptime()
      Returns the value of the uptime record component.
      Returns:
      the value of the uptime record component
    • leaderElections

      public int leaderElections()
      Returns the value of the leaderElections record component.
      Returns:
      the value of the leaderElections record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component