Skip to content

Commit ab44474

Browse files
KarthikNedunchezhiyandianpopa
authored andcommitted
logger: increase metrics count if lock poisoned
Signed-off-by: karthik nedunchezhiyan <[email protected]>
1 parent 48a51ad commit ab44474

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/logger/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,8 @@ impl Logger {
547547
METRICS.logger.missed_log_count.inc();
548548
}
549549
} else {
550-
panic!("Failed to write to the provided metrics destination due to poisoned lock");
550+
METRICS.logger.missed_log_count.inc();
551+
panic!("Failed to write to the provided log destination due to poisoned lock");
551552
}
552553
} else if msg_level <= Level::Warn {
553554
eprintln!("{}", msg);
@@ -566,13 +567,15 @@ impl Logger {
566567
match serde_json::to_string(METRICS.deref()) {
567568
Ok(msg) => {
568569
if let Some(guard) = self.metrics_buf_guard().as_mut() {
569-
write_to_destination(msg, guard)
570+
return write_to_destination(msg, guard)
570571
.map_err(|e| {
571572
METRICS.logger.missed_metrics_count.inc();
572573
e
573574
})
574-
.map(|()| true)?;
575+
.map(|_| true);
575576
} else {
577+
// We have not incremented `missed_metrics_count` as there is no way to push metrics
578+
// if destination lock got poisoned.
576579
panic!("Failed to write to the provided metrics destination due to poisoned lock");
577580
}
578581
}

0 commit comments

Comments
 (0)