test-span 0.1.0

macro and utilities to do snapshot tests on tracing spans
Documentation

the test span library provides you with two functions:

get_logs() that returns [prelude::Records]

get_span() that returns a [prelude::Span], Which can be serialized and used with insta for snapshot tests. Refer to the tests.rs file to see how it behaves.

Example:

#[test_span]
async fn test_it_works() {
futures::join!(do_stuff(), do_stuff())
}

#[tracing::instrument(name = "do_stuff", level = "info")]
async fn do_stuff() -> u8 {
// ...
do_stuff2().await;
}

#[tracing::instrument(
name = "do_stuff2",
target = "my_crate::an_other_target",
level = "info"
)]
async fn do_stuff_2(number: u8) -> u8 {
// ...
}
`get_span()` will provide you with:

┌──────┐
│ root │
└──┬───┘
│
┌───────┴───────┐
▼               ▼
┌──────────┐   ┌──────────┐
│ do_stuff │   │ do_stuff │
└────┬─────┘   └─────┬────┘
│               │
│               │
▼               ▼
┌───────────┐   ┌───────────┐
│ do_stuff2 │   │ do_stuff2 │
└───────────┘   └───────────┘