From 21cbdcb0bda6204dd5eeb78135a06476193391e1 Mon Sep 17 00:00:00 2001 From: Francisco Javier Honduvilla Coto Date: Thu, 5 Sep 2024 11:23:35 +0100 Subject: [PATCH] Fix process and thread name for pprof --- src/profile.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/profile.rs b/src/profile.rs index b9f5549..525c7a2 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -96,6 +96,8 @@ pub fn to_pprof( } } + let task_and_process_names = TaskName::for_task(sample.tid).unwrap_or(TaskName::errored()); + let labels = vec![ pprof.new_label( "pid", @@ -105,8 +107,14 @@ pub fn to_pprof( "pid", LabelStringOrNumber::Number(sample.tid.into(), "task-id".into()), ), - // TODO: add real thread name / comm. - pprof.new_label("comm", LabelStringOrNumber::String("fake-comm".into())), + pprof.new_label( + "process-name", + LabelStringOrNumber::String(task_and_process_names.main_thread), + ), + pprof.new_label( + "thread-name", + LabelStringOrNumber::String(task_and_process_names.current_thread), + ), ]; pprof.add_sample(location_ids, sample.count as i64, labels);