fix(api): add status, endpoint to metrics/logger

This commit is contained in:
spiral 2023-03-19 12:30:31 -04:00
parent d7e34bb884
commit 636535fa33
1 changed files with 12 additions and 3 deletions

View File

@ -41,10 +41,19 @@ pub async fn logger<B>(request: Request<B>, next: Next<B>) -> Response {
let elapsed = start.elapsed().as_millis();
info!(
"handled request for {} {} in {}ms",
method, endpoint, elapsed
"{} handled request for {} {} in {}ms",
response.status(),
method,
endpoint,
elapsed
);
histogram!(
"pk_http_requests",
(elapsed as f64) / 1_000_f64,
"method" => method.to_string(),
"route" => endpoint.clone(),
"status" => response.status().to_string()
);
histogram!("pk_http_requests", (elapsed as f64) / 1_000_f64, "method" => method.to_string(), "endpoint" => endpoint.clone());
if elapsed > MIN_LOG_TIME {
warn!(