@@ -613,8 +613,6 @@ impl ProxyService {
613613 . path_and_query ( )
614614 . map ( |x| x. to_string ( ) )
615615 . unwrap_or_else ( || req. uri ( ) . path ( ) . to_string ( ) ) ;
616- let method = req. method ( ) . clone ( ) ;
617- let method_str = method. as_str ( ) ;
618616
619617 let start_time = Instant :: now ( ) ;
620618
@@ -642,11 +640,6 @@ impl ProxyService {
642640 } ;
643641
644642 let actor_id = target. actor_id ;
645- let server_id = target. server_id ;
646-
647- // Convert UUIDs to strings for metrics, handling Optional fields
648- let actor_id_str = actor_id. map_or_else ( || "none" . to_string ( ) , |id| id. to_string ( ) ) ;
649- let server_id_str = server_id. map_or_else ( || "none" . to_string ( ) , |id| id. to_string ( ) ) ;
650643
651644 // Extract IP address from remote_addr
652645 let client_ip = self . remote_addr . ip ( ) ;
@@ -666,13 +659,8 @@ impl ProxyService {
666659 . map_err ( Into :: into)
667660 } else {
668661 // Increment metrics
669- metrics:: PROXY_REQUEST_PENDING
670- . with_label_values ( & [ & actor_id_str, & server_id_str, method_str, & path] )
671- . inc ( ) ;
672-
673- metrics:: PROXY_REQUEST_TOTAL
674- . with_label_values ( & [ & actor_id_str, & server_id_str, method_str, & path] )
675- . inc ( ) ;
662+ metrics:: PROXY_REQUEST_PENDING . inc ( ) ;
663+ metrics:: PROXY_REQUEST_TOTAL . inc ( ) ;
676664
677665 // Prepare to release in-flight counter when done
678666 let state_clone = self . state . clone ( ) ;
@@ -684,29 +672,35 @@ impl ProxyService {
684672
685673 // Branch for WebSocket vs HTTP handling
686674 // Both paths will handle their own metrics and error handling
687- if hyper_tungstenite:: is_upgrade_request ( & req) {
675+ let res = if hyper_tungstenite:: is_upgrade_request ( & req) {
688676 // WebSocket upgrade
689677 self . handle_websocket_upgrade ( req, target) . await
690678 } else {
691679 // Regular HTTP request
692680 self . handle_http_request ( req, target) . await
693- }
681+ } ;
682+
683+ // Record metrics
684+ let duration_secs = start_time. elapsed ( ) . as_secs_f64 ( ) ;
685+ metrics:: PROXY_REQUEST_DURATION
686+ . with_label_values ( & [ & status] )
687+ . observe ( duration_secs) ;
688+
689+ metrics:: PROXY_REQUEST_PENDING . dec ( ) ;
690+
691+ res
694692 } ;
695693
696694 let status = match & res {
697695 Ok ( resp) => resp. status ( ) . as_u16 ( ) . to_string ( ) ,
698- Err ( _) => "error" . to_string ( ) ,
699- } ;
700-
701- // Record metrics
702- let duration = start_time. elapsed ( ) ;
703- metrics:: PROXY_REQUEST_DURATION
704- . with_label_values ( & [ & actor_id_str, & server_id_str, & status] )
705- . observe ( duration. as_secs_f64 ( ) ) ;
696+ Err ( err) => {
697+ metrics:: PROXY_REQUEST_ERROR
698+ . with_label_values ( & [ & err. to_string ( ) ] )
699+ . inc ( ) ;
706700
707- metrics :: PROXY_REQUEST_PENDING
708- . with_label_values ( & [ & actor_id_str , & server_id_str , method_str , & path ] )
709- . dec ( ) ;
701+ "error" . to_string ( )
702+ }
703+ } ;
710704
711705 res
712706 }
0 commit comments