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, extended by RFC 040).
TraceEmitter
Shared handle to the trace broadcast channel.
TraceTransport

Enums§

HeaderRedactionMode
Which request headers get redacted before a trace event is built (RFC 040 Q1).
Outcome
What the server decided to do with the request.
TraceTransportConfig
Configuration for the out-of-process transport layer.

Constants§

DEFAULT_HEADER_DENYLIST
Built-in denylist of well-known credential-bearing request headers, applied by default (RFC 040 Q1). Compared case-insensitively.
MAX_SUBSCRIBERS
Maximum concurrent out-of-process subscriber connections.
REDACTED_HEADER_VALUE
Placeholder value substituted for a redacted header (RFC 040 Goal 4). The header name is kept so a consumer can tell “redacted” from “the request never sent this header” — only the value differs.
TRACE_CHANNEL_CAPACITY
Capacity of the broadcast channel (events).

Functions§

now_ms
Current Unix time in milliseconds.