Interface FlowTracer

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
Telemetry

public interface FlowTracer extends AutoCloseable
Traces the proxy's exchanges and flows: given with HttpProxyServerBootstrap.withTracer(org.microproxy.FlowTracer), it is asked for a FlowTrace when each request head arrives, and handed each exchange's and flow's FlowRecord when it is over. The optional microproxy-otel module implements it with OpenTelemetry's W3C Trace Context, B3 and Jaeger propagation and OTLP export; the core only calls it.

Calls run on the exchange's thread and should be quick. NOOP, the default, costs nothing: the proxy checks for it before calling.

  • Field Details

    • NOOP

      static final FlowTracer NOOP
      Traces nothing.
  • Method Details

    • startExchange

      FlowTrace startExchange(FlowContext flow, HttpRequest request)
      Called when a request head arrives from the client, before trackers, authentication and filters see it, so that headers the tracer adds (an X-Request-Id) are seen by all of them and the access log. The request may also be a CONNECT (real, or made up for a SOCKS client or a transparent connection), which opens a tunnel or a flow.
      Parameters:
      flow - the exchange's context
      request - the request head, which may be changed in place
      Returns:
      the exchange's trace, or FlowTrace.NONE to trace nothing
    • flowEnded

      default void flowEnded(FlowRecord record)
      Called once per finished exchange or flow, with the record ActivityTracker.flowEnded(org.microproxy.FlowRecord) gets: FlowRecord.trace() is the trace startExchange(org.microproxy.FlowContext, org.microproxy.http.HttpRequest) made, or FlowTrace.NONE for a flow that had no request of its own (a relayed transparent QUIC flow, a request a transport answered itself).
      Parameters:
      record - the finished exchange or flow
    • proxyStarted

      default void proxyStarted(HttpProxyServer server)
      Called once a proxy that uses this tracer has started, for instance to read its stats.
      Parameters:
      server - the running proxy
    • close

      default void close()
      Called once the proxy has stopped, after its exchanges ended: a last chance to flush.
      Specified by:
      close in interface AutoCloseable