Back to Perfetto

tracing-perfetto-sdk

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

56.01.6 KB
Original Source

tracing-perfetto-sdk

A tracing-subscriber Layer that emits Perfetto track events via the perfetto-sdk crate.

This bridges the Rust tracing ecosystem with Perfetto's native tracing infrastructure. Spans become duration slices and events become instant events, with full support for debug annotations, source locations, and integration with the Perfetto tracing service.

Quick start

rust,no_run
use tracing_subscriber::prelude::*;

tracing_perfetto_sdk::init();
tracing_subscriber::registry()
    .with(tracing_perfetto_sdk::PerfettoLayer::new())
    .init();

let span = tracing::info_span!("my_function", arg = 42);
let _guard = span.enter();
tracing::info!("hello from Perfetto");

Features

  • Zero-cost when disabled — category enable check is a single atomic load
  • Debug annotations — span and event fields are captured as Perfetto debug annotations
  • Source locations — file and line number are attached to every event
  • Service integration — works with both in-process tracing and the system tracing service

Crate features

FeatureDefaultDescription
vendoredyesStatically links the bundled Perfetto C library
CrateDescription
perfetto-sdkThe underlying Perfetto SDK bindings
tracingThe Rust tracing facade
tracing-subscriberComposable tracing subscriber layers