From 88a18677d032d45aec19c154cb7aa61662c4f050 Mon Sep 17 00:00:00 2001 From: Tamo Date: Tue, 21 Feb 2023 18:27:45 +0100 Subject: [PATCH] rename the metrics cli flag --- meilisearch/src/lib.rs | 4 ++-- meilisearch/src/option.rs | 17 +++++++++++------ meilisearch/tests/common/server.rs | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/meilisearch/src/lib.rs b/meilisearch/src/lib.rs index 78841e4bd..7d32f546a 100644 --- a/meilisearch/src/lib.rs +++ b/meilisearch/src/lib.rs @@ -83,11 +83,11 @@ pub fn create_app( analytics.clone(), ) }) - .configure(|cfg| routes::configure(cfg, opt.enable_metrics_route)) + .configure(|cfg| routes::configure(cfg, opt.experimental_enable_metrics)) .configure(|s| dashboard(s, enable_dashboard)); let app = app.wrap(actix_web::middleware::Condition::new( - opt.enable_metrics_route, + opt.experimental_enable_metrics, middleware::RouteMetrics, )); app.wrap( diff --git a/meilisearch/src/option.rs b/meilisearch/src/option.rs index a5d98ab5b..8cca5f0ad 100644 --- a/meilisearch/src/option.rs +++ b/meilisearch/src/option.rs @@ -47,7 +47,7 @@ const MEILI_IGNORE_MISSING_DUMP: &str = "MEILI_IGNORE_MISSING_DUMP"; const MEILI_IGNORE_DUMP_IF_DB_EXISTS: &str = "MEILI_IGNORE_DUMP_IF_DB_EXISTS"; const MEILI_DUMP_DIR: &str = "MEILI_DUMP_DIR"; const MEILI_LOG_LEVEL: &str = "MEILI_LOG_LEVEL"; -const MEILI_ENABLE_METRICS_ROUTE: &str = "MEILI_ENABLE_METRICS_ROUTE"; +const MEILI_EXPERIMENTAL_ENABLE_METRICS: &str = "MEILI_EXPERIMENTAL_ENABLE_METRICS"; const DEFAULT_CONFIG_FILE_PATH: &str = "./config.toml"; const DEFAULT_DB_PATH: &str = "./data.ms"; @@ -286,10 +286,12 @@ pub struct Opt { #[serde(default)] pub log_level: LogLevel, - /// Enables Prometheus metrics and /metrics route. - #[clap(long, env = MEILI_ENABLE_METRICS_ROUTE)] + /// Experimental metrics feature. For more information, see: https://github.com/meilisearch/meilisearch/discussions/3518 + /// + /// Enables the Prometheus metrics on the `GET /metrics` endpoint. + #[clap(long, env = MEILI_EXPERIMENTAL_ENABLE_METRICS)] #[serde(default)] - pub enable_metrics_route: bool, + pub experimental_enable_metrics: bool, #[serde(flatten)] #[clap(flatten)] @@ -382,7 +384,7 @@ impl Opt { config_file_path: _, #[cfg(all(not(debug_assertions), feature = "analytics"))] no_analytics, - enable_metrics_route, + experimental_enable_metrics: enable_metrics_route, } = self; export_to_env_if_not_present(MEILI_DB_PATH, db_path); export_to_env_if_not_present(MEILI_HTTP_ADDR, http_addr); @@ -420,7 +422,10 @@ impl Opt { export_to_env_if_not_present(MEILI_DUMP_DIR, dump_dir); export_to_env_if_not_present(MEILI_LOG_LEVEL, log_level.to_string()); - export_to_env_if_not_present(MEILI_ENABLE_METRICS_ROUTE, enable_metrics_route.to_string()); + export_to_env_if_not_present( + MEILI_EXPERIMENTAL_ENABLE_METRICS, + enable_metrics_route.to_string(), + ); indexer_options.export_to_env(); } diff --git a/meilisearch/tests/common/server.rs b/meilisearch/tests/common/server.rs index 4b15adbf1..bd0a47432 100644 --- a/meilisearch/tests/common/server.rs +++ b/meilisearch/tests/common/server.rs @@ -207,7 +207,7 @@ pub fn default_settings(dir: impl AsRef) -> Opt { max_indexing_memory: MaxMemory::unlimited(), ..Parser::parse_from(None as Option<&str>) }, - enable_metrics_route: true, + experimental_enable_metrics: true, ..Parser::parse_from(None as Option<&str>) } }