Expand description
§crustrace-mermaid
A tracing_subscriber::Layer implementation that collects spans
and renders them as Mermaid flowcharts.
This crate is designed to pair with crustrace,
which automatically instruments entire modules. Together, you can
generate call graphs of your Rust program without hand-writing #[instrument].
§Example
use crustrace::instrument;
use crustrace_mermaid::{MermaidLayer, GroupingMode};
use tracing_subscriber::prelude::*;
#[instrument]
fn inner(x: i32) -> i32 { x + 1 }
#[instrument]
fn outer(y: i32) -> i32 {
inner(y) + inner(y * 2)
}
fn main() {
let layer = MermaidLayer::new().with_mode(GroupingMode::MergeByName);
tracing_subscriber::registry().with(layer).init();
outer(5);
// When the root span closes, a Mermaid diagram is printed to stdout
}By default, the layer flushes automatically when a root span finishes,
but you can disable this with MermaidLayer::without_auto_flush and
call MermaidLayer::flush manually.
Structs§
- Mermaid
Layer - A
tracing_subscriber::Layerthat collects function spans and renders them as a Mermaid flowchart.
Enums§
- Grouping
Mode - How to group multiple calls in the rendered Mermaid output.
- Param
Render Mode - How to render function parameters in Mermaid output.