feat: add/correct some kafka-related metrics (#5757)

* feat: add/correct some kafka-related metrics

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* fix clippy

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* fix dumb issues

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* per-partition produce latency

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2025-03-25 12:16:39 -07:00
committed by GitHub
parent d88482b996
commit e81213728b
3 changed files with 44 additions and 3 deletions

View File

@@ -57,8 +57,9 @@ pub struct NaiveEntry {
}
impl NaiveEntry {
/// Estimates the persisted size of the entry.
fn estimated_size(&self) -> usize {
size_of::<Self>() + self.data.capacity() * size_of::<u8>()
size_of::<Self>() + self.data.len() * size_of::<u8>()
}
}
@@ -84,14 +85,15 @@ impl MultiplePartEntry {
&& self.headers.contains(&MultiplePartHeader::Last)
}
/// Estimates the persisted size of the entry.
fn estimated_size(&self) -> usize {
size_of::<Self>()
+ self
.parts
.iter()
.map(|data| data.capacity() * size_of::<u8>())
.map(|data| data.len() * size_of::<u8>())
.sum::<usize>()
+ self.headers.capacity() * size_of::<MultiplePartHeader>()
+ self.headers.len() * size_of::<MultiplePartHeader>()
}
}