From adbc3453986af3d3d0c1ee6de55945b4d148ade4 Mon Sep 17 00:00:00 2001 From: "Pengfei(Andy) Zhang" Date: Mon, 7 Oct 2024 14:56:55 -0400 Subject: [PATCH] feat(middleware): use jsonrpc-method as the makeup http method name. And only log http status for jsonrpc. --- crates/rpc/src/rpc_metrics.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/rpc/src/rpc_metrics.rs b/crates/rpc/src/rpc_metrics.rs index 13f808871..89d694703 100644 --- a/crates/rpc/src/rpc_metrics.rs +++ b/crates/rpc/src/rpc_metrics.rs @@ -147,18 +147,14 @@ where } fn call(&mut self, req: httpRequest) -> Self::Future { - let uri = req.uri().clone(); - let method_name = uri.path().split('/').last().unwrap_or("unknown"); - let mut method_logger = MethodSessionLogger::new( + let method_logger = MethodSessionLogger::new( self.service_name.clone(), - method_name.to_string(), + "jsonrpc-method".to_string(), "http".to_string(), ); - method_logger.start(); let mut svc = self.service.clone(); async move { let rp = svc.call(req).await; - method_logger.done(); let http_status = rp.as_ref().ok().map(|rp| rp.status()); if let Some(status_code) = http_status { method_logger.record_http(get_http_status_from_code(status_code.as_u16()));