Package com.tnsai.llm.observability
Record Class StreamMetrics
java.lang.Object
java.lang.Record
com.tnsai.llm.observability.StreamMetrics
- Record Components:
firstChunkAt- when the first chunk arrivedtimeToFirstToken-firstChunkAt - call.startedAt— stored separately so consumers don't need the call's start time to compute itchunkCount- total chunks receivedinterChunkP50- median inter-chunk delayinterChunkP99- 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 Summary
ConstructorsConstructorDescriptionStreamMetrics(Instant firstChunkAt, Duration timeToFirstToken, long chunkCount, Duration interChunkP50, Duration interChunkP99) Creates an instance of aStreamMetricsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of thechunkCountrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefirstChunkAtrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of theinterChunkP50record component.Returns the value of theinterChunkP99record component.Returns the value of thetimeToFirstTokenrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
StreamMetrics
public StreamMetrics(Instant firstChunkAt, Duration timeToFirstToken, long chunkCount, Duration interChunkP50, Duration interChunkP99) Creates an instance of aStreamMetricsrecord class.- Parameters:
firstChunkAt- the value for thefirstChunkAtrecord componenttimeToFirstToken- the value for thetimeToFirstTokenrecord componentchunkCount- the value for thechunkCountrecord componentinterChunkP50- the value for theinterChunkP50record componentinterChunkP99- the value for theinterChunkP99record component
-
-
Method Details
-
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 '=='. -
firstChunkAt
Returns the value of thefirstChunkAtrecord component.- Returns:
- the value of the
firstChunkAtrecord component
-
timeToFirstToken
Returns the value of thetimeToFirstTokenrecord component.- Returns:
- the value of the
timeToFirstTokenrecord component
-
chunkCount
public long chunkCount()Returns the value of thechunkCountrecord component.- Returns:
- the value of the
chunkCountrecord component
-
interChunkP50
Returns the value of theinterChunkP50record component.- Returns:
- the value of the
interChunkP50record component
-
interChunkP99
Returns the value of theinterChunkP99record component.- Returns:
- the value of the
interChunkP99record component
-