Class LatencyRecord

  • All Implemented Interfaces:
    Serializable

    public class LatencyRecord
    extends Object
    implements Serializable
    Contains latency measurements collected during KDC agent communication and processing.

    A latency record stores start and stop timestamps for the metrics associated with a LatencyContext. The context defines which metrics are recorded and their ordering.

    Timestamps are measured in nanoseconds using System.nanoTime().

    Advanced users may inspect the latency context and timestamp arrays to analyze individual stages of agent processing. The recording and management of timestamps are handled internally by KDC.

    Latency records may be serialized and transmitted with agents and replies.

    Depending on the communication context, some measurements may not be available until processing has completed. For synchronous operations, measurements may include both sending and receiving activities.

    A timestamp value of 0L indicates that a measurement has not been recorded. A start and stop timestamp pair of 1L indicates that the metric is not applicable.

    Author:
    Charles B. Kozoyed
    See Also:
    LatencyContext, LatencyMetric, Serialized Form
    • Constructor Detail

      • LatencyRecord

        public LatencyRecord()
        Constructs an empty latency record.

        This constructor is provided for serialization and deserialization. The record is not initialized for timing operations until its internal state is populated.

    • Method Detail

      • isComplete

        public boolean isComplete()
        Determines whether all metrics associated with this record have valid start and stop timestamps.
        Returns:
        true if all metrics have valid timestamps; false otherwise
      • getLatencyContext

        public LatencyContext getLatencyContext()
        Returns the latency context associated with this record.

        The context identifies the metrics represented by the timestamp arrays and their ordering.

        Returns:
        the latency context, or null if not initialized
        See Also:
        LatencyContext.getMetrics()
      • getStartTimeLine

        public long[] getStartTimeLine()
        Returns a copy of the recorded start timestamps.

        Array positions correspond to the ordered metrics returned by LatencyContext.getMetrics().

        Modifying the returned array does not affect this record. Returns a copy of the recorded start timestamps.

        Array positions correspond to the ordered metrics returned by LatencyContext.getMetrics().

        This method requires an initialized latency record. Calling it before the timestamp arrays have been populated may result in a NullPointerException.

        Returns:
        a defensive copy of the start timestamp array
      • getStopTimeLine

        public long[] getStopTimeLine()
        Returns a copy of the recorded stop timestamps.

        Array positions correspond to the ordered metrics returned by LatencyContext.getMetrics().

        Modifying the returned array does not affect this record.

        Array positions correspond to the ordered metrics returned by LatencyContext.getMetrics().

        This method requires an initialized latency record. Calling it before the timestamp arrays have been populated may result in a NullPointerException.

        Returns:
        a defensive copy of the stop timestamp array