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

View File

@ -41,10 +41,19 @@ pub async fn logger<B>(request: Request<B>, next: Next<B>) -> Response {
let elapsed = start.elapsed().as_millis(); let elapsed = start.elapsed().as_millis();
info!( info!(
"handled request for {} {} in {}ms", "{} handled request for {} {} in {}ms",
method, endpoint, elapsed 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 { if elapsed > MIN_LOG_TIME {
warn!( warn!(