Tiny add e2e http request arrival metric (#14893)
This commit is contained in:
@@ -307,6 +307,8 @@ impl<B> OnRequest<B> for RequestLogger {
|
|||||||
span.record("request_id", request_id.0.as_str());
|
span.record("request_id", request_id.0.as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RouterMetrics::record_http_request();
|
||||||
|
|
||||||
// Log the request start
|
// Log the request start
|
||||||
info!(
|
info!(
|
||||||
target: "sgl_model_gateway::request",
|
target: "sgl_model_gateway::request",
|
||||||
|
|||||||
@@ -270,6 +270,10 @@ pub fn init_metrics() {
|
|||||||
"Time to load and initialize tokenizer"
|
"Time to load and initialize tokenizer"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
describe_counter!(
|
||||||
|
"sgl_router_http_requests_total",
|
||||||
|
"Total number of HTTP requests"
|
||||||
|
);
|
||||||
describe_counter!(
|
describe_counter!(
|
||||||
"sgl_router_http_responses_total",
|
"sgl_router_http_responses_total",
|
||||||
"Total number of HTTP responses by status code"
|
"Total number of HTTP responses by status code"
|
||||||
@@ -589,6 +593,16 @@ impl RouterMetrics {
|
|||||||
counter!("sgl_router_job_shutdown_rejected_total").increment(1);
|
counter!("sgl_router_job_shutdown_rejected_total").increment(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is different from the following:
|
||||||
|
// * sgl_router_requests_total: bump when a request is handled and response is to be returned, thus very different from this.
|
||||||
|
// * sgl_router_processed_requests_total: bump when routing decision is made.
|
||||||
|
// Here we want a metric to directly reflect user's experience ("I am sending a request")
|
||||||
|
// when viewing the router as a blackbox, and is bumped immediately when the request arrives.
|
||||||
|
// TODO: add route name
|
||||||
|
pub fn record_http_request() {
|
||||||
|
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) {
|
||||||
counter!("sgl_router_http_responses_total",
|
counter!("sgl_router_http_responses_total",
|
||||||
"status_code" => status_code.to_string()
|
"status_code" => status_code.to_string()
|
||||||
|
|||||||
Reference in New Issue
Block a user