Skip to content

Commit

Permalink
Add some sampling log in BTD supertd events
Browse files Browse the repository at this point in the history
Summary: Requested [in post](https://fb.workplace.com/groups/targetdeterminator/permalink/4335581330001657/?comment_id=4335606786665778&reply_comment_id=4336232649936525) . Adding such sampling in log to help analysis

Differential Revision: D60321384

fbshipit-source-id: 84ef0ad41f5d56c810b1abcd315536ac433e34ea
  • Loading branch information
Xiang Gao authored and facebook-github-bot committed Jul 29, 2024
1 parent 88cfa58 commit 5fec8bd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions btd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,18 @@ pub fn main(args: Args) -> anyhow::Result<()> {
step(&format!(
"finish with {immediate_changes} immediate changes, {total_changes} total changes"
));
// Sample 5 of the immediate changes for logging
let immediate_change_samples: Vec<String> = immediate
.iter()
.take(5)
.map(|x| x.0.label().as_str().to_owned())
.collect();
// Sample 5 of code changes for logging
let changeset_samples: Vec<String> = changes
.cell_paths()
.take(5)
.map(|x| x.as_str().to_owned())
.collect();
// BTreeMap so that reasons are consistently ordered in logs
let mut reason_counts: BTreeMap<RootImpactKind, u64> = BTreeMap::new();
for (_, reason) in recursive.iter().flatten() {
Expand All @@ -298,7 +310,9 @@ pub fn main(args: Args) -> anyhow::Result<()> {
event: BTD_SUCCESS,
duration: t.elapsed(),
data: json!({
"changeset_samples": changeset_samples,
"immediate_changes": immediate_changes,
"immediate_change_samples": immediate_change_samples,
"total_changes": total_changes,
"reason_counts": reason_counts,
})
Expand Down

0 comments on commit 5fec8bd

Please sign in to comment.