Skip to content

Commit

Permalink
expose dataset height in metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgroul committed Nov 8, 2023
1 parent 73e9db8 commit f79bd7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crates/router/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
use lazy_static::lazy_static;
use prometheus::{opts, register_int_counter_vec, IntCounterVec};
use prometheus::{
opts, register_int_counter_vec, register_int_gauge_vec, IntCounterVec, IntGaugeVec,
};

lazy_static! {
pub static ref DATASET_SYNC_ERRORS: IntCounterVec = register_int_counter_vec!(
opts!("sqd_dataset_sync_errors", "Dataset syncronization errors"),
&["dataset"]
)
.expect("Can't create a metric");
pub static ref DATASET_HEIGHT: IntGaugeVec =
register_int_gauge_vec!(opts!("sqd_dataset_height", "Dataset height"), &["dataset"])
.expect("Can't create a metric");
}
9 changes: 8 additions & 1 deletion crates/router/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tracing::{error, info};
use router_controller::controller::Controller;

use crate::dataset::Storage;
use crate::metrics::DATASET_SYNC_ERRORS;
use crate::metrics::{DATASET_HEIGHT, DATASET_SYNC_ERRORS};

pub fn start(
controller: Arc<Controller>,
Expand All @@ -26,6 +26,13 @@ pub fn start(
match storage.get_chunks(next_block) {
Ok(chunks) => {
info!("found new chunks in {}: {:?}", dataset, chunks);

if let Some(chunk) = chunks.last() {
DATASET_HEIGHT
.with_label_values(&[dataset])
.set(chunk.last_block().into())
}

Ok(chunks)
}
Err(err) => {
Expand Down

0 comments on commit f79bd7c

Please sign in to comment.