Back to Perfetto

perfetto-sdk-derive

contrib/rust-sdk/perfetto-derive/README.md

56.0964 B
Original Source

perfetto-sdk-derive

Procedural macros for the Perfetto Rust SDK.

This crate provides the #[tracefn] attribute macro for automatically instrumenting functions with Perfetto track events. When applied to a function, it emits a trace event spanning the function's execution and optionally captures input parameters as event arguments.

Usage

rust,ignore
use perfetto_sdk::track_event::*;

perfetto_sdk::track_event_categories! {
    pub mod my_categories {
        ("rendering", "Rendering events", []),
    }
}
use my_categories as perfetto_te_ns;

#[perfetto_sdk_derive::tracefn("rendering")]
fn draw_frame(width: u32, height: u32) {
    // A "draw_frame" trace event is emitted automatically,
    // capturing width and height as arguments.
}
CrateDescription
perfetto-sdkMain SDK with tracing session and track event APIs