pub struct TraceEmitter {
pub config: Arc<TraceConfig>,
/* private fields */
}Expand description
Shared handle to the trace broadcast channel.
Clone freely — each clone refers to the same underlying channel.
Fields§
§config: Arc<TraceConfig>Behaviour settings (body capture, etc.).
Implementations§
Source§impl TraceEmitter
impl TraceEmitter
pub fn new() -> Self
pub fn with_config(config: TraceConfig) -> Self
Sourcepub fn subscribe(&self) -> Receiver<MatchTraceEvent>
pub fn subscribe(&self) -> Receiver<MatchTraceEvent>
Subscribe to the event stream (in-process).
§A direct subscriber owns its own lag accounting
This is a plain tokio::sync::broadcast::Receiver — if this
caller’s own recv() loop falls behind by more than
TRACE_CHANNEL_CAPACITY events, it gets RecvError::Lagged(n)
the same way TraceTransport::forward_events does internally
for the UDS/TCP transport. This crate cannot fold that n into
dropped_count on this caller’s behalf — an event is broadcast
once and already in flight to every receiver by the time any one
of them lags, so nothing can retroactively patch the copy this
receiver eventually reads. A caller that wants an honest
dropped_count (rather than a stale one from a rarer, shared
counter — see this module’s own doc comment on back-pressure)
should accumulate n itself across Lagged and account for it
however it reports events onward, the same way forward_events
does for its own two transports.
Sourcepub fn enrich_with_body(
&self,
summary: &mut RequestSummary,
body_json: Option<&Value>,
)
pub fn enrich_with_body( &self, summary: &mut RequestSummary, body_json: Option<&Value>, )
Attach body JSON to a RequestSummary according to this emitter’s
TraceConfig. Call before emit when the request body is available.
§RFC 073 S-05: the captured body is redacted, not raw
This is the trace channel’s own body capture — it reaches out-of-process subscribers over the UDS/TCP transport, not just a local terminal, so leaving it unredacted here would be at least as serious a leak as the verbose-console-log one this RFC also fixes. Redaction runs before the size check, so the size cap applies to what is actually stored (post-redaction), not to the original.
Sourcepub fn emit(
&self,
received_at_ms: u64,
duration_ms: u32,
request: RequestSummary,
outcome: Outcome,
)
pub fn emit( &self, received_at_ms: u64, duration_ms: u32, request: RequestSummary, outcome: Outcome, )
Emit one event. If the channel is full, the event is dropped and the internal drop counter incremented.
Sourcepub fn has_subscribers(&self) -> bool
pub fn has_subscribers(&self) -> bool
Returns true iff at least one receiver is currently active.
Trait Implementations§
Source§impl Clone for TraceEmitter
impl Clone for TraceEmitter
Source§fn clone(&self) -> TraceEmitter
fn clone(&self) -> TraceEmitter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more