trace-tally
A tracing layer for rendering hierarchical task trees to the terminal.

Usage
Using trace-tally requires implementing two traits to control how your data is processed and displayed:
- [
TraceMapper]: Extracts the relevant data fromspansandevents. - [
Renderer]: Dictates exactly how that extracted data is formatted and printed to the terminal.
Complete Example
use Write;
use *;
// Define how to display spans and events
;
// Define how to extract data from tracing primitives
;
;
// Setup render loop
Channel vs Inline
trace-tally provides two layer constructors:
- [
inline_layer] renders synchronously on every span/event. No background thread needed. Best for short-lived CLI tools where simplicity matters. - [
channel_layer] sends actions over anmpscchannel to a separate render loop. This decouples tracing from rendering, enabling timed redraws and spinner animations.
The complete example above uses [inline_layer]. See examples/render_loop.rs for a [channel_layer] setup with animated output.
Both require that the TraceMapper associated types match the Renderer associated types (TaskData and EventData). A mismatch produces a compile error on the [inline_layer] / [channel_layer] call.
[channel_layer] accepts any [ActionTransport] implementation, not just [std::sync::mpsc::Sender]. Implement [ActionTransport] to use crossbeam, tokio, or other channel backends.
Customizing Rendering
Override [Renderer::render_task] to change how the task tree is walked. The default renders the task line, then buffered events (skipped for completed tasks), then recurses into subtasks:
API
| Type | Role |
|---|---|
[Renderer] |
Trait — define TaskData/EventData types and rendering callbacks. |
[TraceMapper] |
Trait — extract custom data from tracing spans and events. |
[TaskRenderer] |
Receives Actions, manages the task tree state, and drives rendering. |
[FrameWriter] |
Terminal writer with ANSI cursor control for frame clearing. |
[TaskView] / [EventView] |
Read-only views passed to renderer callbacks to access underlying data. |
[Action] |
Enum representing state changes: TaskStart, Event, TaskEnd, CancelAll. |
[ActionTransport] |
Trait for channel backends — implemented for mpsc::Sender by default. |