Add error code in prometheus metrics and add X-SMG-Error-Code header (#15036)

This commit is contained in:
fzyzcjy
2025-12-13 13:28:32 +08:00
committed by GitHub
parent 31c23e5fe3
commit 9a5d6a84ab
3 changed files with 31 additions and 7 deletions
@@ -275,7 +275,7 @@ pub fn init_metrics() {
);
describe_counter!(
"sgl_router_http_responses_total",
"Total number of HTTP responses by status code"
"Total number of HTTP responses by status code and error code"
);
}
@@ -593,9 +593,10 @@ impl RouterMetrics {
counter!("sgl_router_http_requests_total").increment(1);
}
pub fn record_http_status_code(status_code: u16) {
pub fn record_http_status_code(status_code: u16, error_code: &str) {
counter!("sgl_router_http_responses_total",
"status_code" => status_code.to_string()
"status_code" => status_code.to_string(),
"error_code" => error_code.to_string()
)
.increment(1);
}