Class FlowRecord.Builder

java.lang.Object
org.microproxy.FlowRecord.Builder
Enclosing class:
FlowRecord

public static final class FlowRecord.Builder extends Object
Builds a FlowRecord; unset values are unknown.
  • Method Details

    • request

      public FlowRecord.Builder request(HttpRequest request)
      Sets the client's request.
      Parameters:
      request - the request head, or null
      Returns:
      this builder
    • response

      public FlowRecord.Builder response(HttpResponse response, ResponseSource source)
      Sets the response the client got, and where it came from.
      Parameters:
      response - the response head, or null
      source - where it came from, or null
      Returns:
      this builder
    • trailers

      public FlowRecord.Builder trailers(HttpHeaders trailers)
      Sets the response's trailers.
      Parameters:
      trailers - the trailers, or null
      Returns:
      this builder
    • time

      public FlowRecord.Builder time(long startEpochMillis, long durationNanos)
      Sets when the exchange started and how long it lasted.
      Parameters:
      startEpochMillis - the wall-clock start, in epoch milliseconds
      durationNanos - the duration in nanoseconds, or -1 when unknown
      Returns:
      this builder
    • timings

      public FlowRecord.Builder timings(FlowTimings timings)
      Sets the phase timings.
      Parameters:
      timings - the timings
      Returns:
      this builder
    • bytes

      public FlowRecord.Builder bytes(long received, long sent)
      Sets the bytes exchanged with the client.
      Parameters:
      received - bytes received from the client, or -1
      sent - bytes sent to the client, or -1
      Returns:
      this builder
    • upstreamBytes

      public FlowRecord.Builder upstreamBytes(long sent, long received)
      Sets the bytes exchanged with the server, on the wire.
      Parameters:
      sent - bytes written to the server, or -1
      received - bytes read from the server, or -1
      Returns:
      this builder
    • upstream

      public FlowRecord.Builder upstream(InetSocketAddress address, InetSocketAddress localAddress, String cluster, SSLSession session)
      Sets what the exchange was connected to.
      Parameters:
      address - the server or chained proxy, or null
      localAddress - the proxy's end of that connection, or null
      cluster - the chained proxy's or server's name, or null
      session - the TLS session with it, or null
      Returns:
      this builder
    • upstreamProtocol

      public FlowRecord.Builder upstreamProtocol(String protocol)
      Sets the protocol spoken to the upstream (FlowRecord.upstreamProtocol()).
      Parameters:
      protocol - HTTP/1.1, HTTP/2, HTTP/3, SOCKS4 or SOCKS5, or null
      Returns:
      this builder
    • upstreamTransportFailureReason

      public FlowRecord.Builder upstreamTransportFailureReason(String reason)
      Sets why the TLS handshake with the server failed.
      Parameters:
      reason - the reason, or null
      Returns:
      this builder
    • downstreamLocalAddress

      public FlowRecord.Builder downstreamLocalAddress(InetSocketAddress address)
      Sets the proxy's local address on the client connection.
      Parameters:
      address - the address, or null
      Returns:
      this builder
    • outcome

      public FlowRecord.Builder outcome(Set<ResponseFlag> flags, ProxyFailure failure, String details)
      Sets the outcome: flags, failure and details.
      Parameters:
      flags - the response flags
      failure - the failure, or null
      details - the response code details, or null
      Returns:
      this builder
    • trace

      public FlowRecord.Builder trace(FlowTrace trace)
      Sets the exchange's distributed trace.
      Parameters:
      trace - the trace, FlowTrace.NONE for none
      Returns:
      this builder
    • uniqueId

      public FlowRecord.Builder uniqueId(String uniqueId)
      Fixes the unique id instead of making a random one when asked.
      Parameters:
      uniqueId - the id
      Returns:
      this builder
    • build

      public FlowRecord build()
      Returns the record.
      Returns:
      the record