feat: add series num to metrics

Signed-off-by: evenyag <realevenyag@gmail.com>
This commit is contained in:
evenyag
2025-09-26 17:08:27 +08:00
parent e0d3e6ae97
commit 3aa67c7af4
2 changed files with 11 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ pub struct Metrics {
pub index_update: Duration,
pub index_finish: Duration,
pub close: Duration,
pub num_series: usize,
}
impl Metrics {

View File

@@ -163,6 +163,7 @@ where
let write_format =
WriteFormat::new(self.metadata.clone()).with_override_sequence(override_sequence);
let mut stats = SourceStats::default();
let mut last_key = None;
while let Some(res) = self
.write_next_batch(&mut source, &write_format, opts, metrics)
@@ -171,6 +172,15 @@ where
{
match res {
Ok(mut batch) => {
if let Some(last) = &last_key {
if last != batch.primary_key() {
metrics.num_series += 1;
last_key = Some(batch.primary_key().to_vec());
}
} else {
metrics.num_series += 1;
}
stats.update(&batch);
let index_start = Instant::now();
self.get_or_create_indexer().await.update(&mut batch).await;