1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Span-tracing primitives gated behind the `profiling` Cargo feature.
//!
//! Off by default. When enabled, every [`crate::profile_span!`] call enters a
//! `tracing::trace_span!` whose guard drops on scope exit — so spans
//! nest exactly the way Rust scopes nest, which is what
//! `tracing-chrome` / perfetto need to draw a clean flame chart.
//!
//! When the feature is off there is no `tracing` dependency at all; the
//! macro expands to a `let _: () = ();` binding and disappears in any
//! optimization pass. Release builds without `--features profiling`
//! pay zero CPU and zero binary size for instrumented call sites.
//!
//! ## Usage
//!
//! ```ignore
//! use aetna_core::profile_span;
//!
//! fn layout_pass() {
//! profile_span!("layout");
//! // ... work ...
//! }
//! ```
//!
//! ## Host wiring
//!
//! Subscribers live in the host binary, not here. The showcase wires up
//! `tracing-chrome` behind a `--profile <output.json>` flag. Other apps
//! can attach `tracing-subscriber::fmt` for live console output, or any
//! other subscriber from the `tracing` ecosystem.
//!
//! ## Naming
//!
//! Span names are short stable strings using `phase::sub` shape so the
//! flame chart reads top-down. Examples: `frame::build`,
//! `prepare::layout`, `paint::text::shape`. Prefer adding a new span
//! name over reusing an existing one for a different call site —
//! flame-chart readers identify hotspots by name.
/// Enter a span for the rest of the current scope. No-op unless the
/// `profiling` feature is enabled. Pass a `&'static str` literal — the
/// macro forwards it to `tracing::trace_span!` (or to a `()` binding
/// when off).
///
/// ```ignore
/// fn layout(...) {
/// profile_span!("layout");
/// // ... work ...
/// }
/// ```