Skip to content

Commit d41e9ea

Browse files
thomasywangfacebook-github-bot
authored andcommitted
Create a Perfetto Sink (#2169)
Summary: Create a TraceDispatcherSink that writes perfetto traces in their native protobuf format directly to local files The advantages include: - No row limits (vs 400k for a scuba query) - Zero ingestion latency (Traces are available immediately) - No json -> protobuf conversion needed and very compact - Compatibility with distributed file systems like OILFS - Faster execution of expanse: No more querying scuba and conversion of scuba -> perfetto protobuf Reviewed By: moonli Differential Revision: D89403329
1 parent 95e137f commit d41e9ea

File tree

4 files changed

+678
-0
lines changed

4 files changed

+678
-0
lines changed

hyperactor_telemetry/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ lazy_static = "1.5"
3131
libc = "0.2.139"
3232
opentelemetry = "0.29"
3333
opentelemetry_sdk = { version = "0.29.0", features = ["rt-tokio"] }
34+
prost = { version = "0.13.4", default-features = false }
3435
rand = { version = "0.8", features = ["small_rng"] }
3536
rusqlite = { version = "0.37.0", features = ["backup", "blob", "bundled", "column_decltype", "functions", "limits", "modern_sqlite", "serde_json"] }
3637
scuba = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
@@ -43,6 +44,7 @@ tracing = { version = "0.1.41", features = ["attributes", "valuable"] }
4344
tracing-appender = "0.2.3"
4445
tracing-core = { version = "0.1.33", features = ["valuable"] }
4546
tracing-glog = { version = "0.4.1", features = ["ansi", "tracing-log"] }
47+
tracing-perfetto-sdk-schema = "0.12.0"
4648
tracing-subscriber = { version = "0.3.20", features = ["chrono", "env-filter", "json", "local-time", "parking_lot", "registry"] }
4749
urlencoding = "2.1.0"
4850
whoami = "1.5"

hyperactor_telemetry/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,27 @@ fn initialize_logging_with_log_prefix_impl(
704704
}
705705
}
706706

707+
if hyperactor_config::global::get(sinks::perfetto::PERFETTO_TRACE_MODE)
708+
!= sinks::perfetto::PerfettoTraceMode::Off
709+
{
710+
let exec_id = env::execution_id();
711+
let process_name = std::env::var("HYPERACTOR_PROCESS_NAME")
712+
.unwrap_or_else(|_| "client".to_string());
713+
match sinks::perfetto::PerfettoFileSink::new(
714+
sinks::perfetto::default_trace_dir(),
715+
&exec_id,
716+
&process_name,
717+
) {
718+
Ok(sink) => {
719+
max_level = Some(tracing::level_filters::LevelFilter::TRACE);
720+
sinks.push(Box::new(sink));
721+
}
722+
Err(e) => {
723+
tracing::warn!("failed to create PerfettoFileSink: {}", e);
724+
}
725+
}
726+
}
727+
707728
{
708729
if hyperactor_config::global::get(ENABLE_OTEL_TRACING) {
709730
use crate::meta;

hyperactor_telemetry/src/sinks/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
//! writing events to a specific backend (SQLite, Scuba, glog, etc).
1212
1313
pub mod glog;
14+
pub mod perfetto;
1415
pub mod sqlite;

0 commit comments

Comments
 (0)