From ccf2330b2864b4d3b32d2a0bcb9f51f681c00dfc Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Thu, 25 Dec 2025 15:20:43 +0800 Subject: [PATCH] Tiny fix missing record_router_upstream_response (#15811) --- sgl-model-gateway/src/routers/http/router.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sgl-model-gateway/src/routers/http/router.rs b/sgl-model-gateway/src/routers/http/router.rs index 50e1071ca..2b94f20d8 100644 --- a/sgl-model-gateway/src/routers/http/router.rs +++ b/sgl-model-gateway/src/routers/http/router.rs @@ -213,8 +213,18 @@ impl Router { &self.retry_config, // operation per attempt |_: u32| async { - self.route_typed_request_once(headers, typed_req, route, model_id, is_stream, &info) - .await + let res = self + .route_typed_request_once(headers, typed_req, route, model_id, is_stream, &info) + .await; + + // Need to be outside `route_typed_request_once` because that function has multiple return paths + Metrics::record_router_upstream_response( + metrics_labels::ROUTER_HTTP, + res.status().as_u16(), + extract_error_code_from_response(&res), + ); + + res }, // should_retry predicate |res, _attempt| is_retryable_status(res.status()), @@ -686,6 +696,8 @@ fn convert_reqwest_error(e: reqwest::Error) -> Response { use async_trait::async_trait; +use crate::routers::error::extract_error_code_from_response; + #[async_trait] impl RouterTrait for Router { fn as_any(&self) -> &dyn std::any::Any {