From 636535fa338f4e92561307f7ab66d1cca91c2c5c Mon Sep 17 00:00:00 2001 From: spiral Date: Sun, 19 Mar 2023 12:30:31 -0400 Subject: [PATCH] fix(api): add status, endpoint to metrics/logger --- services/api/src/middleware/logger.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/services/api/src/middleware/logger.rs b/services/api/src/middleware/logger.rs index eaf26c8b..4da52995 100644 --- a/services/api/src/middleware/logger.rs +++ b/services/api/src/middleware/logger.rs @@ -41,10 +41,19 @@ pub async fn logger(request: Request, next: Next) -> Response { let elapsed = start.elapsed().as_millis(); info!( - "handled request for {} {} in {}ms", - method, endpoint, elapsed + "{} handled request for {} {} in {}ms", + response.status(), + method, + endpoint, + elapsed + ); + histogram!( + "pk_http_requests", + (elapsed as f64) / 1_000_f64, + "method" => method.to_string(), + "route" => endpoint.clone(), + "status" => response.status().to_string() ); - histogram!("pk_http_requests", (elapsed as f64) / 1_000_f64, "method" => method.to_string(), "endpoint" => endpoint.clone()); if elapsed > MIN_LOG_TIME { warn!(