Skip to content

Commit fda9681

Browse files
committed
Combine metrics things into one spawn_blocking
1 parent 2d88cad commit fda9681

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

crates/core/src/host/host_controller.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,18 +1063,19 @@ async fn metric_reporter(replica_ctx: Arc<ReplicaContext>) {
10631063
.with_label_values(&replica_ctx.database_identity);
10641064

10651065
loop {
1066-
// We spawn a blocking task here because this grabs blocking locks.
1067-
{
1068-
let ctx = replica_ctx.clone();
1069-
let _ = tokio::task::spawn_blocking(move || ctx.update_gauges()).await;
1070-
}
10711066
let ctx = replica_ctx.clone();
1072-
let disk_usage = tokio::task::block_in_place(move || ctx.total_disk_usage());
1073-
if let Some(num_bytes) = disk_usage.durability {
1074-
message_log_size.set(num_bytes as i64);
1075-
}
1076-
if let Some(num_bytes) = disk_usage.logs {
1077-
module_log_file_size.set(num_bytes as i64);
1067+
// We spawn a blocking task here because this grabs blocking locks.
1068+
let disk_usage_future = tokio::task::spawn_blocking(move || {
1069+
ctx.update_gauges();
1070+
ctx.total_disk_usage()
1071+
});
1072+
if let Ok(disk_usage) = disk_usage_future.await {
1073+
if let Some(num_bytes) = disk_usage.durability {
1074+
message_log_size.set(num_bytes as i64);
1075+
}
1076+
if let Some(num_bytes) = disk_usage.logs {
1077+
module_log_file_size.set(num_bytes as i64);
1078+
}
10781079
}
10791080
tokio::time::sleep(STORAGE_METERING_INTERVAL).await;
10801081
}

0 commit comments

Comments
 (0)