diff --git a/meilisearch/src/analytics/segment_analytics.rs b/meilisearch/src/analytics/segment_analytics.rs index 21b6696e7..b3c4b8d07 100644 --- a/meilisearch/src/analytics/segment_analytics.rs +++ b/meilisearch/src/analytics/segment_analytics.rs @@ -249,6 +249,7 @@ impl From for Infos { // to add analytics when we add a field in the Opt. // Thus we must not insert `..` at the end. let Opt { + enable_metrics_route: _, db_path, http_addr, master_key: _, diff --git a/meilisearch/src/lib.rs b/meilisearch/src/lib.rs index 7a7555659..54efaac81 100644 --- a/meilisearch/src/lib.rs +++ b/meilisearch/src/lib.rs @@ -92,7 +92,8 @@ pub fn create_app( let app = app.configure(|s| configure_metrics_route(s, opt.enable_metrics_route)); #[cfg(feature = "metrics")] - let app = app.wrap(Condition::new(opt.enable_metrics_route, route_metrics::RouteMetrics)); + let app = + app.wrap(middleware::Condition::new(opt.enable_metrics_route, route_metrics::RouteMetrics)); app.wrap( Cors::default() .send_wildcard() diff --git a/meilisearch/src/route_metrics.rs b/meilisearch/src/route_metrics.rs index 96f0b223d..a23c2b93d 100644 --- a/meilisearch/src/route_metrics.rs +++ b/meilisearch/src/route_metrics.rs @@ -2,21 +2,26 @@ use std::future::{ready, Ready}; use actix_web::dev::{self, Service, ServiceRequest, ServiceResponse, Transform}; use actix_web::http::header; +use actix_web::web::Data; use actix_web::{Error, HttpResponse}; use futures_util::future::LocalBoxFuture; -use meilisearch_lib::MeiliSearch; +use index_scheduler::IndexScheduler; +use meilisearch_auth::AuthController; use meilisearch_types::error::ResponseError; use meilisearch_types::keys::actions; use prometheus::{Encoder, HistogramTimer, TextEncoder}; use crate::extractors::authentication::policies::ActionPolicy; use crate::extractors::authentication::GuardedData; +use crate::routes::create_all_stats; pub async fn get_metrics( - meilisearch: GuardedData, MeiliSearch>, + index_scheduler: GuardedData, Data>, + auth_controller: GuardedData, AuthController>, ) -> Result { - let search_rules = &meilisearch.filters().search_rules; - let response = meilisearch.get_all_stats(search_rules).await?; + let search_rules = &index_scheduler.filters().search_rules; + let response = + create_all_stats((*index_scheduler).clone(), (*auth_controller).clone(), search_rules)?; crate::metrics::MEILISEARCH_DB_SIZE_BYTES.set(response.database_size as i64); crate::metrics::MEILISEARCH_INDEX_COUNT.set(response.indexes.len() as i64);