Skip to main content

Module trace

Module trace 

Source
Expand description

Live match-trace channel — RFC 006 (in-process) + RFC 009 (transport).

§Architecture

 HTTP handler ──► TraceEmitter::emit()
                        │
             tokio::sync::broadcast (bounded, 1024)
                        │
          ┌─────────────┴──────────────┐
     in-process                  TraceTransport::accept_loop
     subscriber                  (UDS on Unix, TCP fallback)
                                       │
                                 up to 4 GUI connections
                                 (newline-delimited JSON)

§Transport variants

TraceTransportConfigPlatformNotes
Uds { path }Unix/macOSDefault when available
Tcp { addr }AllPortable fallback; addr = "127.0.0.1:0" assigns ephemeral port
DisabledAllNo out-of-process forwarding (default)

§Back-pressure

The broadcast channel is bounded by TRACE_CHANNEL_CAPACITY. When the channel is full, emit drops the event and increments an internal counter; the count is reported as dropped_count on the next event.

Slow out-of-process subscribers receive a RecvError::Lagged from the broadcast channel; the gap is reported in the next JSON line via dropped_count.

§Subscriber cap

At most MAX_SUBSCRIBERS out-of-process connections are accepted. A fifth connection receives {"error":"max_subscribers_reached"} and is then closed.

Structs§

MatchTraceEvent
A single request/response trace event.
RequestSummary
Key fields from the incoming HTTP request.
TraceConfig
Trace-channel behaviour configuration (RFC 023).
TraceEmitter
Shared handle to the trace broadcast channel.
TraceTransport

Enums§

Outcome
What the server decided to do with the request.
TraceTransportConfig
Configuration for the out-of-process transport layer.

Constants§

MAX_SUBSCRIBERS
Maximum concurrent out-of-process subscriber connections.
TRACE_CHANNEL_CAPACITY
Capacity of the broadcast channel (events).

Functions§

now_ms
Current Unix time in milliseconds.