Skip to content

Commit

Permalink
Fix process and thread name for pprof
Browse files Browse the repository at this point in the history
  • Loading branch information
javierhonduco committed Sep 6, 2024
1 parent 753bd59 commit 21cbdcb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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);
Expand Down

0 comments on commit 21cbdcb

Please sign in to comment.