#tracing #perfetto #profiling #events #back-end

sys tracing-profile-perfetto-sys

Low-level bindings to Perfetto, optionally used by the tracing-profile crate

2 unstable releases

0.9.0 Dec 4, 2024
0.7.0 Sep 16, 2024

#8 in #perfetto

Download history 172/week @ 2024-09-16 19/week @ 2024-09-23 18/week @ 2024-09-30 215/week @ 2024-12-02 87/week @ 2024-12-09

302 downloads per month
Used in tracing-profile

Apache-2.0

2.5MB
43K SLoC

C++ 43K SLoC // 0.2% comments Rust 343 SLoC // 0.0% comments Forge Config 58 SLoC

Perfetto-sys

This crate wraps the perfetto sdk. Use it as follows:

Create a PerfettoGuard which will live for the duration of the tracing session via PerfettoGuard::new. Two types of backend are supported:

  • BackendConfig::InProcess will record only the trace data from the current process.
  • BackendConfig::System will also record system data. To do this kind of tracing the perfetto tools binaries must be available. Note that the PerfettoGuard creation and dropping will take some additional time to launch and stop the perfetto processes. See the perfetto documentation for the details.

To create a span, create a TraceEvent via TraceEvent::new. The event will persist until the TraceEvent is dropped. Using custom track event arguments, track id and flow id are supported.

To update a counter value use set_counter_u64 and set_counter_f64 methods.

Resources:

Dependencies

~2–10MB
~133K SLoC