tracing-callgraph

A tracing library for generating call graphs in Graphviz dot representation.

CI License Cargo Documentation

Example

```rust use tracingcallgraph::GraphLayer; use tracingsubscriber::{prelude::*, registry::Registry};

fn setupglobalsubscriber() -> impl Drop { let (graphlayer, _guard) = GraphLayer::withfile("./output.dot").unwrap(); let subscriber = Registry::default().with(graph_layer);

tracing::subscriber::set_global_default(subscriber).expect("Could not set global default");
_guard

}

[tracing::instrument]

fn outer_a() { inner() }

[tracing::instrument]

fn outer_b() { inner() }

[tracing::instrument]

fn inner() {}

fn main() { let guard = setupglobalsubscriber(); outera(); outer_b(); } ```

Output

digraph { 0 [ label = "\"outer_a\"" ] 1 [ label = "\"inner\"" ] 2 [ label = "\"outer_b\"" ] 0 -> 1 [ label = "1" ] 2 -> 1 [ label = "1" ] }

Special Thanks

Special thanks to the authors of tracing-flame which this draws on heavily.