From 8190c221954dd1ec3d280c674c25eb4f99fe70ef Mon Sep 17 00:00:00 2001 From: Yingjie Shang Date: Mon, 30 Sep 2024 21:48:53 +0800 Subject: [PATCH] Add 'text' modifier in code part of doc. --- src/metrics/middleware.rs | 3 +-- src/metrics/mod.rs | 6 +++--- src/metrics/system_metrics.rs | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/metrics/middleware.rs b/src/metrics/middleware.rs index 136c9d0..caa5f14 100644 --- a/src/metrics/middleware.rs +++ b/src/metrics/middleware.rs @@ -3,14 +3,13 @@ //! # Usage //! The actix-web middleware function could be used as following: //! -//! ```rust +//! ```text //! let mut http_server = HttpServer::new(move || { //! App::new() //! //skip //! .wrap(from_fn(metrics_midleware)) //! //skip //! }) -//! .on_connect(http::request_on_connect_handler); //! ``` use std::{ sync::{Arc, RwLock}, diff --git a/src/metrics/mod.rs b/src/metrics/mod.rs index d319699..6058905 100644 --- a/src/metrics/mod.rs +++ b/src/metrics/mod.rs @@ -18,7 +18,7 @@ //! //! Define your metrics under `src/metrics/` and register them with the `Registry` like this: //! -//! ```rust +//! ```text //! pub const HTTP_REQUEST_COUNT: &str = "http_request_count"; //! pub const HTTP_REQUEST_COUNT_HELP: &str = "Number of HTTP requests received, labeled by method and status"; //! @@ -43,7 +43,7 @@ //! //! Register the metrics within the `MetricsManager` struct: //! -//! ```rust +//! ```text //! pub struct MetricsManager { //! pub registry: Arc>, //! pub http_metrics: Arc, @@ -63,7 +63,7 @@ //! //! Invoke methods to update metrics where relevant events occur. In this example, retrieve `MetricsManager` from the `app_data` in the Actix Web application: //! -//! ```rust +//! ```text //! if let Some(m) = res.request().app_data::>>>() { //! let metrics_manager = m.read().unwrap(); //! metrics_manager.http_metrics.increment_request_count(&label); diff --git a/src/metrics/system_metrics.rs b/src/metrics/system_metrics.rs index 2baeb2d..b1d3c80 100644 --- a/src/metrics/system_metrics.rs +++ b/src/metrics/system_metrics.rs @@ -180,7 +180,8 @@ mod tests { let gauge_map = parse_gauge(resp["metrics"].as_str().unwrap()); assert_eq!(SYS_METRICS_MAP.len(), gauge_map.len()); - for (_, value) in gauge_map { + for (metric, value) in gauge_map { + println!("{}:{}", metric, value); assert!(value != 0.0); } }