Expand description

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 │
 └───────────┘   └───────────┘

Modules

Structs

A Vec of log entries.

A tree which is effectively a Tree containing all the spans

Enums

Functions

Unlike its get_logs counterpart provided by the trace_span macro, get_all_logs will return all of the module’s tests logs.

Returns Records, which is a Vec, containing all entries recorded by children of root_id.

Returns a Span, a Tree containing all the spans that are children of root_id.

Returns both the output of get_spans_for_root and get_logs_for_root

init_default is the default way to call with_targets, it sets up Level::INFO and looks for environment variables to filter spans.

Type Definitions