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§
- Shared
Buf - A shared, in-memory buffer a tracing subscriber can write into.
- Shared
Writer - Write handle for a
SharedBuf; implementsio::WriteandMakeWriter.
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.