Skip to main content

Module tracing_capture

Module tracing_capture 

Source
Expand description

In-process tracing capture for tests.

Install a temporary subscriber that writes events into an in-memory buffer, run code that emits tracing events, then assert on the captured output. Use this to lock down a structured-logging contract (e.g. that every action dispatch logs surface, action, and outcome) so it cannot silently regress.

Tracing’s default subscriber is thread-local, so concurrent capturing tests would clobber each other. tracing_test_lock serializes them: hold the guard for the whole capture. Pair with #[tokio::test(flavor = "current_thread")] so awaits stay on the thread whose default you set.

Structs§

SharedBuf
A shared, in-memory buffer a tracing subscriber can write into.
SharedWriter
Write handle for a SharedBuf; implements io::Write and MakeWriter.

Functions§

tracing_test_lock
Process-wide lock serializing tracing-capture tests. Hold the returned guard for the entire capture so another test’s subscriber cannot interleave.