Tiny support sgl-router http response status code metrics (#14689)
This commit is contained in:
@@ -332,9 +332,12 @@ impl Default for ResponseLogger {
|
|||||||
impl<B> OnResponse<B> for ResponseLogger {
|
impl<B> OnResponse<B> for ResponseLogger {
|
||||||
fn on_response(self, response: &Response<B>, latency: Duration, span: &Span) {
|
fn on_response(self, response: &Response<B>, latency: Duration, span: &Span) {
|
||||||
let status = response.status();
|
let status = response.status();
|
||||||
|
let status_code = status.as_u16();
|
||||||
|
|
||||||
|
RouterMetrics::record_http_status_code(status_code);
|
||||||
|
|
||||||
// Record these in the span for structured logging/observability tools
|
// Record these in the span for structured logging/observability tools
|
||||||
span.record("status_code", status.as_u16());
|
span.record("status_code", status_code);
|
||||||
// Use microseconds as integer to avoid format! string allocation
|
// Use microseconds as integer to avoid format! string allocation
|
||||||
span.record("latency", latency.as_micros() as u64);
|
span.record("latency", latency.as_micros() as u64);
|
||||||
|
|
||||||
|
|||||||
@@ -263,6 +263,11 @@ pub fn init_metrics() {
|
|||||||
"sgl_tokenizer_factory_load_duration_seconds",
|
"sgl_tokenizer_factory_load_duration_seconds",
|
||||||
"Time to load and initialize tokenizer"
|
"Time to load and initialize tokenizer"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
describe_counter!(
|
||||||
|
"sgl_router_http_responses_total",
|
||||||
|
"Total number of HTTP responses by status code"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_prometheus(config: PrometheusConfig) {
|
pub fn start_prometheus(config: PrometheusConfig) {
|
||||||
@@ -563,6 +568,13 @@ impl RouterMetrics {
|
|||||||
pub fn record_job_shutdown_rejected() {
|
pub fn record_job_shutdown_rejected() {
|
||||||
counter!("sgl_router_job_shutdown_rejected_total").increment(1);
|
counter!("sgl_router_job_shutdown_rejected_total").increment(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn record_http_status_code(status_code: u16) {
|
||||||
|
counter!("sgl_router_http_responses_total",
|
||||||
|
"status_code" => status_code.to_string()
|
||||||
|
)
|
||||||
|
.increment(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TokenizerMetrics {
|
impl TokenizerMetrics {
|
||||||
|
|||||||
Reference in New Issue
Block a user