Record Class FlowTimings

java.lang.Object
java.lang.Record
org.microproxy.FlowTimings
Record Components:
startEpochMillis - wall-clock time when the request started arriving; 0 for NONE
dnsStartNanos - the DNS lookup start offset in nanoseconds, or -1 if absent
dnsEndNanos - the DNS lookup end offset in nanoseconds, or -1 if absent
connectStartNanos - the TCP connect start offset in nanoseconds, or -1 if absent
connectEndNanos - the TCP connect end offset in nanoseconds, or -1 if absent
tlsStartNanos - the upstream TLS start offset in nanoseconds, or -1 if absent
tlsEndNanos - the upstream TLS end offset in nanoseconds, or -1 if absent
requestSentNanos - the completed request-send offset in nanoseconds, or -1 if absent
firstResponseByteNanos - the first upstream response-byte offset in nanoseconds, or -1 if absent
responseCompleteNanos - the completed client-response offset in nanoseconds, or -1 if absent
clientTlsHandshakeNanos - the client TLS handshake duration in nanoseconds, or -1 if absent

public record FlowTimings(long startEpochMillis, long dnsStartNanos, long dnsEndNanos, long connectStartNanos, long connectEndNanos, long tlsStartNanos, long tlsEndNanos, long requestSentNanos, long firstResponseByteNanos, long responseCompleteNanos, long clientTlsHandshakeNanos) extends Record
When the phases of one request/response exchange happened, from FlowContext.timings().

Every ...Nanos component except clientTlsHandshakeNanos is an offset in nanoseconds (System.nanoTime()) from the moment the first byte of the request arrived, or -1 when that phase did not happen (yet). A request on a reused keep-alive or pooled server connection has no DNS, connect or TLS phase; a request answered by the proxy or a filter has no server phases at all. When several connection attempts were made (falling back from one chained proxy to the next), a phase starts with the first attempt and ends with the last.

Phases with the server:

  • DNS: resolving the server's name (or a chained proxy's), unless a filter supplied an address;
  • connect: the TCP connection to the server or first chained proxy;
  • TLS: handshakes towards the server: with a TLS chained proxy, and with the origin when intercepting (CONNECT with a MitmManager, where it is part of the CONNECT exchange, not of the requests inside the session);
  • request sent: the request head and body have been written;
  • first response byte: the first byte of the server's response (including a 1xx);
  • response complete: the last byte of the response to the client has been written, whoever made the response.

clientTlsHandshakeNanos is the duration of the TLS handshake with the client (the proxy's TLS listener, or the intercepted session) on which the request arrived, or -1.

  • Field Details

    • NONE

      public static final FlowTimings NONE
      No exchange recorded, e.g. for a context made outside the proxy.
  • Constructor Details

    • FlowTimings

      public FlowTimings(long startEpochMillis, long dnsStartNanos, long dnsEndNanos, long connectStartNanos, long connectEndNanos, long tlsStartNanos, long tlsEndNanos, long requestSentNanos, long firstResponseByteNanos, long responseCompleteNanos, long clientTlsHandshakeNanos)
      Creates an instance of a FlowTimings record class.
      Parameters:
      startEpochMillis - the value for the startEpochMillis record component
      dnsStartNanos - the value for the dnsStartNanos record component
      dnsEndNanos - the value for the dnsEndNanos record component
      connectStartNanos - the value for the connectStartNanos record component
      connectEndNanos - the value for the connectEndNanos record component
      tlsStartNanos - the value for the tlsStartNanos record component
      tlsEndNanos - the value for the tlsEndNanos record component
      requestSentNanos - the value for the requestSentNanos record component
      firstResponseByteNanos - the value for the firstResponseByteNanos record component
      responseCompleteNanos - the value for the responseCompleteNanos record component
      clientTlsHandshakeNanos - the value for the clientTlsHandshakeNanos record component
  • Method Details

    • start

      public Optional<Instant> start()
      When the request started arriving (wall clock).
      Returns:
      the request start instant, or empty if no exchange was recorded
    • dnsLookup

      public Optional<Duration> dnsLookup()
      How long resolving the server's name took.
      Returns:
      the DNS lookup duration, or empty if the phase was not recorded
    • connect

      public Optional<Duration> connect()
      How long the TCP connect took.
      Returns:
      the TCP connect duration, or empty if the phase was not recorded
    • tlsHandshake

      public Optional<Duration> tlsHandshake()
      How long the TLS handshakes towards the server took.
      Returns:
      the upstream TLS duration, or empty if the phase was not recorded
    • clientTlsHandshake

      public Optional<Duration> clientTlsHandshake()
      How long the TLS handshake with the client took.
      Returns:
      the client TLS duration, or empty if the phase was not recorded
    • timeToFirstByte

      public Optional<Duration> timeToFirstByte()
      From the start of the request to the first byte of the server's response: everything the client waited for that the proxy did not decide alone (lookup, connect, sending, the server).
      Returns:
      the time to the first upstream byte, or empty if none was recorded
    • total

      public Optional<Duration> total()
      From the start of the request to the end of the response sent to the client.
      Returns:
      the full exchange duration, or empty until the response completes
    • 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. All components in this record class 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.
    • startEpochMillis

      public long startEpochMillis()
      Returns the value of the startEpochMillis record component.
      Returns:
      the value of the startEpochMillis record component
    • dnsStartNanos

      public long dnsStartNanos()
      Returns the value of the dnsStartNanos record component.
      Returns:
      the value of the dnsStartNanos record component
    • dnsEndNanos

      public long dnsEndNanos()
      Returns the value of the dnsEndNanos record component.
      Returns:
      the value of the dnsEndNanos record component
    • connectStartNanos

      public long connectStartNanos()
      Returns the value of the connectStartNanos record component.
      Returns:
      the value of the connectStartNanos record component
    • connectEndNanos

      public long connectEndNanos()
      Returns the value of the connectEndNanos record component.
      Returns:
      the value of the connectEndNanos record component
    • tlsStartNanos

      public long tlsStartNanos()
      Returns the value of the tlsStartNanos record component.
      Returns:
      the value of the tlsStartNanos record component
    • tlsEndNanos

      public long tlsEndNanos()
      Returns the value of the tlsEndNanos record component.
      Returns:
      the value of the tlsEndNanos record component
    • requestSentNanos

      public long requestSentNanos()
      Returns the value of the requestSentNanos record component.
      Returns:
      the value of the requestSentNanos record component
    • firstResponseByteNanos

      public long firstResponseByteNanos()
      Returns the value of the firstResponseByteNanos record component.
      Returns:
      the value of the firstResponseByteNanos record component
    • responseCompleteNanos

      public long responseCompleteNanos()
      Returns the value of the responseCompleteNanos record component.
      Returns:
      the value of the responseCompleteNanos record component
    • clientTlsHandshakeNanos

      public long clientTlsHandshakeNanos()
      Returns the value of the clientTlsHandshakeNanos record component.
      Returns:
      the value of the clientTlsHandshakeNanos record component