Record Class StreamMetrics

java.lang.Object
java.lang.Record
com.tnsai.llm.observability.StreamMetrics
Record Components:
firstChunkAt - when the first chunk arrived
timeToFirstToken - firstChunkAt - call.startedAt — stored separately so consumers don't need the call's start time to compute it
chunkCount - total chunks received
interChunkP50 - median inter-chunk delay
interChunkP99 - 99th percentile inter-chunk delay

public record StreamMetrics(Instant firstChunkAt, Duration timeToFirstToken, long chunkCount, Duration interChunkP50, Duration interChunkP99) extends Record
Streaming-specific timing metrics for one LLM call (issue #79).

Time-to-first-token (TTFT) is the operator's headline streaming metric; inter-chunk percentiles surface stalls (a stream can have fast TTFT but stutter mid-response). For non-streaming calls the enclosing LLMCallLog.streamMetrics() is empty.

Since:
0.5.0 (issue #79)
  • Constructor Details

    • StreamMetrics

      public StreamMetrics(Instant firstChunkAt, Duration timeToFirstToken, long chunkCount, Duration interChunkP50, Duration interChunkP99)
      Creates an instance of a StreamMetrics record class.
      Parameters:
      firstChunkAt - the value for the firstChunkAt record component
      timeToFirstToken - the value for the timeToFirstToken record component
      chunkCount - the value for the chunkCount record component
      interChunkP50 - the value for the interChunkP50 record component
      interChunkP99 - the value for the interChunkP99 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. 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.
    • firstChunkAt

      public Instant firstChunkAt()
      Returns the value of the firstChunkAt record component.
      Returns:
      the value of the firstChunkAt record component
    • timeToFirstToken

      public Duration timeToFirstToken()
      Returns the value of the timeToFirstToken record component.
      Returns:
      the value of the timeToFirstToken record component
    • chunkCount

      public long chunkCount()
      Returns the value of the chunkCount record component.
      Returns:
      the value of the chunkCount record component
    • interChunkP50

      public Duration interChunkP50()
      Returns the value of the interChunkP50 record component.
      Returns:
      the value of the interChunkP50 record component
    • interChunkP99

      public Duration interChunkP99()
      Returns the value of the interChunkP99 record component.
      Returns:
      the value of the interChunkP99 record component