Skip to content

Commit

Permalink
Add 'text' modifier in code part of doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
cybershang committed Sep 30, 2024
1 parent bccb31d commit 8190c22
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/metrics/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
6 changes: 3 additions & 3 deletions src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
//!
Expand All @@ -43,7 +43,7 @@
//!
//! Register the metrics within the `MetricsManager` struct:
//!
//! ```rust
//! ```text
//! pub struct MetricsManager {
//! pub registry: Arc<Mutex<Registry>>,
//! pub http_metrics: Arc<HttpMetrics>,
Expand All @@ -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::<Data<Arc<RwLock<MetricsManager>>>>() {
//! let metrics_manager = m.read().unwrap();
//! metrics_manager.http_metrics.increment_request_count(&label);
Expand Down
3 changes: 2 additions & 1 deletion src/metrics/system_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 8190c22

Please sign in to comment.