Skip to content

Commit ce183ba

Browse files
Fix the ingestion_rows_per_sec metric calculation (#195)
1 parent 00b1062 commit ce183ba

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

src/commands/load/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct SutInstruments {
5555
disk_write_ops: Counter<u64>,
5656
ingestion_rows_total: Gauge<u64>,
5757
ingestion_bytes_total: Gauge<u64>,
58+
ingestion_rows_per_sec: Gauge<f64>,
5859
}
5960

6061
fn run_metric_attributes(common_args: &CommonArgs, run_id: uuid::Uuid) -> Vec<KeyValue> {
@@ -141,15 +142,17 @@ fn record_sut_metrics(
141142
// Use adapter-provided rows_per_sec if available; otherwise derive it
142143
// from the delta in rows_ingested since the last scrape.
143144
if let Some(v) = response.ingestion.rows_per_sec {
144-
crate::metrics::INGESTION_ROWS_PER_SEC.record(v, attributes);
145+
instruments.ingestion_rows_per_sec.record(v, attributes);
145146
} else if let Some(current_rows) = response.ingestion.rows_ingested
146147
&& let Some(prev_rows) = *prev_rows_ingested
147148
&& let Some(prev_time) = *last_scrape_time
148149
{
149150
let elapsed_secs = prev_time.elapsed().as_secs_f64();
150151
if elapsed_secs > 0.0 {
151152
let rows_per_sec = current_rows.saturating_sub(prev_rows) as f64 / elapsed_secs;
152-
crate::metrics::INGESTION_ROWS_PER_SEC.record(rows_per_sec, attributes);
153+
instruments
154+
.ingestion_rows_per_sec
155+
.record(rows_per_sec, attributes);
153156
}
154157
}
155158
// Update tracking state for the next scrape
@@ -654,6 +657,7 @@ pub(crate) async fn run(
654657
disk_write_ops: m.u64_counter("sut_disk_write_ops").build(),
655658
ingestion_rows_total: m.u64_gauge("ingestion_rows_total").build(),
656659
ingestion_bytes_total: m.u64_gauge("ingestion_bytes_total").build(),
660+
ingestion_rows_per_sec: m.f64_gauge("ingestion_rows_per_sec").build(),
657661
};
658662
let sut_attributes = Arc::new(std::sync::RwLock::new(metric_attributes.clone()));
659663
println!("SUT metrics scraping enabled (run_id={run_id})");

src/metrics.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,6 @@ pub static MEDIAN_MEMORY_USAGE: LazyLock<Gauge<f64>> = LazyLock::new(|| {
100100
.build()
101101
});
102102

103-
// --- Ingestion metrics ---
104-
105-
pub static INGESTION_ROWS_PER_SEC: LazyLock<Gauge<f64>> = LazyLock::new(|| {
106-
meter()
107-
.f64_gauge("ingestion_rows_per_sec")
108-
.with_description("Sustained ingestion throughput in rows per second.")
109-
.with_unit("rows/s")
110-
.build()
111-
});
112-
113103
// --- Query throughput ---
114104

115105
pub static QUERIES_TOTAL: LazyLock<Counter<u64>> = LazyLock::new(|| {

0 commit comments

Comments
 (0)