From cca6e47ec1e65cdf78d30b1f6ca6e2b626e3a078 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 22 Jun 2023 23:14:01 +0200 Subject: [PATCH] Errors when GETting metrics without the feature gate --- meilisearch/src/lib.rs | 2 +- meilisearch/src/routes/metrics.rs | 1 + meilisearch/src/routes/mod.rs | 7 ++----- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/meilisearch/src/lib.rs b/meilisearch/src/lib.rs index a9bd68934..fc8017715 100644 --- a/meilisearch/src/lib.rs +++ b/meilisearch/src/lib.rs @@ -111,7 +111,7 @@ pub fn create_app( analytics.clone(), ) }) - .configure(|cfg| routes::configure(cfg, opt.experimental_enable_metrics)) + .configure(routes::configure) .configure(|s| dashboard(s, enable_dashboard)); let app = app.wrap(actix_web::middleware::Condition::new( diff --git a/meilisearch/src/routes/metrics.rs b/meilisearch/src/routes/metrics.rs index a7d41e33e..492fec417 100644 --- a/meilisearch/src/routes/metrics.rs +++ b/meilisearch/src/routes/metrics.rs @@ -19,6 +19,7 @@ pub async fn get_metrics( index_scheduler: GuardedData, Data>, auth_controller: Data, ) -> Result { + index_scheduler.features()?.check_metrics()?; let auth_filters = index_scheduler.filters(); if !auth_filters.all_indexes_authorized() { let mut error = ResponseError::from(AuthenticationError::InvalidToken); diff --git a/meilisearch/src/routes/mod.rs b/meilisearch/src/routes/mod.rs index 9c5d29119..d14ddf48a 100644 --- a/meilisearch/src/routes/mod.rs +++ b/meilisearch/src/routes/mod.rs @@ -27,7 +27,7 @@ mod multi_search; mod swap_indexes; pub mod tasks; -pub fn configure(cfg: &mut web::ServiceConfig, enable_metrics: bool) { +pub fn configure(cfg: &mut web::ServiceConfig) { cfg.service(web::scope("/tasks").configure(tasks::configure)) .service(web::resource("/health").route(web::get().to(get_health))) .service(web::scope("/keys").configure(api_key::configure)) @@ -37,11 +37,8 @@ pub fn configure(cfg: &mut web::ServiceConfig, enable_metrics: bool) { .service(web::scope("/indexes").configure(indexes::configure)) .service(web::scope("/multi-search").configure(multi_search::configure)) .service(web::scope("/swap-indexes").configure(swap_indexes::configure)) + .service(web::scope("/metrics").configure(metrics::configure)) .service(web::scope("/experimental-features").configure(features::configure)); - - if enable_metrics { - cfg.service(web::scope("/metrics").configure(metrics::configure)); - } } #[derive(Debug, Serialize)]