tracing-texray
tracing-texray
is a tracing layer to introspect spans and events in plain text. By examine
-ing a specific
span, a full tree will be output when that span exits. Using code like the following (actual program elided):
You would see the following output printed to stderr:
load_data 52ms ├────────────────────────────────┤
download_results{uri: www.crates.io} 11ms ├─────┤
>URI resolved ┼
>connected ┼
compute_stats 10ms ├─────┤
render_response 6ms ├──┤
In cases where a more powerful solution like tracing-chrome is not required,
tracing-texray
can render lightweight timeline of what happened when.
Usage
tracing-texray
combines two pieces: a global subscriber, and local span examination. By default, tracing-texray
won't
print anything—it just sits in the background. But: once a span is examine
'd, tracing-texray
will track the
span and all of its children. When the span exits, span diagnostics will be printed to stderr (or another impl io::Write
as configured).
First, the layer must be installed globally:
use Duration;
use TeXRayLayer;
use ;
Next, wrap any spans you want to track with examine
:
use info_span;
use examine;
When the do_a_thing
span exits, output like the following will be printed:
do_a_thing 509μs ├───────────────────────────────────────────────────┤
inner_task{id: 0} 92μs ├────────┤
>buzz ┼
inner_task{id: 1} 36μs ├──┤
>buzz ┼
inner_task{id: 2} 35μs ├──┤
>buzz ┼
inner_task{id: 3} 36μs ├──┤
>buzz ┼
inner_task{id: 4} 35μs ├──┤
>buzz ┼