mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 16:51:01 +00:00
add a view for the task queue in the metrics
This commit is contained in:
@ -40,4 +40,7 @@ lazy_static! {
|
||||
HTTP_RESPONSE_TIME_CUSTOM_BUCKETS.to_vec()
|
||||
)
|
||||
.expect("Can't create a metric");
|
||||
pub static ref NB_TASKS: IntGaugeVec =
|
||||
register_int_gauge_vec!(opts!("nb_tasks", "Number of tasks"), &["kind", "value"])
|
||||
.expect("Can't create a metric");
|
||||
}
|
||||
|
@ -39,6 +39,12 @@ pub async fn get_metrics(
|
||||
.set(value.number_of_documents as i64);
|
||||
}
|
||||
|
||||
for (kind, value) in index_scheduler.get_stats()? {
|
||||
for (value, count) in value {
|
||||
crate::metrics::NB_TASKS.with_label_values(&[&kind, &value]).set(count as i64);
|
||||
}
|
||||
}
|
||||
|
||||
let encoder = TextEncoder::new();
|
||||
let mut buffer = vec![];
|
||||
encoder.encode(&prometheus::gather(), &mut buffer).expect("Failed to encode metrics");
|
||||
|
Reference in New Issue
Block a user