aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-08-31 19:44:27 +0200
committerAlex Auvolat <alex@adnab.me>2022-08-31 19:44:27 +0200
commit70231d68b27054c2185b73b5ceee1c445baaaa2d (patch)
tree44bd71406569facaf51dbe7d9b3df569aac36cf6
parente598231ca442715af8321ff5520e5b3d59609ed9 (diff)
downloadgarage-70231d68b27054c2185b73b5ceee1c445baaaa2d.tar.gz
garage-70231d68b27054c2185b73b5ceee1c445baaaa2d.zip
Fix bytes_read counter
-rw-r--r--src/block/manager.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/block/manager.rs b/src/block/manager.rs
index 80c52510..b8fe4c74 100644
--- a/src/block/manager.rs
+++ b/src/block/manager.rs
@@ -449,8 +449,6 @@ impl BlockManager {
let (header, data) = block.into_parts();
- self.metrics.bytes_read.add(data.len() as u64);
-
Resp::new(Ok(BlockRpc::PutBlock {
hash: *hash,
header,
@@ -460,9 +458,16 @@ impl BlockManager {
/// Read block from disk, verifying it's integrity
pub(crate) async fn read_block(&self, hash: &Hash) -> Result<DataBlock, Error> {
- self.read_block_internal(hash)
+ let data = self
+ .read_block_internal(hash)
.bound_record_duration(&self.metrics.block_read_duration)
- .await
+ .await?;
+
+ self.metrics
+ .bytes_read
+ .add(data.inner_buffer().len() as u64);
+
+ Ok(data)
}
async fn read_block_internal(&self, hash: &Hash) -> Result<DataBlock, Error> {