async fn on_response<'r>(&self, req: &'r Request<'_>, res: &mut Response<'r>) {
        let start_time = req.local_cache(|| TimerStart(None));
        if let Some(Ok(duration)) = start_time.0.map(|st| st.elapsed()) {
            let ms = (duration.as_secs() * 1000 + duration.subsec_millis() as u64) as f64;
            RESPONSE_TIME_COLLECTOR
                .with_label_values(&[&format!("{} {}", req.method(), req.uri())])
                .observe(ms)
        }
        match res.status().code {
            500..=599 => RESPONSE_CODE_COLLECTOR
                .with_label_values(&[&res.status().code.to_string(), "500"])
                .inc(),
            400..=499 => RESPONSE_CODE_COLLECTOR
                .with_label_values(&[&res.status().code.to_string(), "400"])
                .inc(),
            300..=399 => RESPONSE_CODE_COLLECTOR
                .with_label_values(&[&res.status().code.to_string(), "300"])
                .inc(),
            200..=299 => RESPONSE_CODE_COLLECTOR
                .with_label_values(&[&res.status().code.to_string(), "200"])
                .inc(),
            100..=199 => RESPONSE_CODE_COLLECTOR
                .with_label_values(&[&res.status().code.to_string(), "100"])
                .inc(),
            _ => (),
        }
    }
/// Adds a header to the response indicating how long the server took to
/// process the request.
Adds a header to the response indicating how long the server took to
process the request.
Adds a header to the response indicating how long the server took to process the request .
async fn on_response<'r>(&self, req: &'r Request<'_>, res: &mut Response<'r>) {
        let start_time = req.local_cache(|| TimerStart(None));
        if let Some(Ok(duration)) = start_time.0.map(|st| st.elapsed()) {
            let ms = (duration.as_secs() * 1000 + duration.subsec_millis() as u64) as f64;
            RESPONSE_TIME_COLLECTOR
                .with_label_values(&[&format!("{} {}", req.method(), req.uri())])
                .observe(ms)
        }
        match res.status().code {
            500..=599 => RESPONSE_CODE_COLLECTOR
                .with_label_values(&[&res.status().code.to_string(), "500"])
                .inc(),
            400..=499 => RESPONSE_CODE_COLLECTOR
                .with_label_values(&[&res.status().code.to_string(), "400"])
                .inc(),
            300..=399 => RESPONSE_CODE_COLLECTOR
                .with_label_values(&[&res.status().code.to_string(), "300"])
                .inc(),
            200..=299 => RESPONSE_CODE_COLLECTOR
                .with_label_values(&[&res.status().code.to_string(), "200"])
                .inc(),
            100..=199 => RESPONSE_CODE_COLLECTOR
                .with_label_values(&[&res.status().code.to_string(), "100"])
                .inc(),
            _ => (),
        }
    }
async fn on_response < ' r > ( & self , req : & ' r Request < ' _ > , res : & mut Response < ' r > ) { let start_time = req . local_cache ( | | TimerStart ( None ) ) ; if let Some ( Ok ( duration ) ) = start_time . 0 . map ( | st | st . elapsed ( ) ) { let ms = ( duration . as_secs ( ) * 1000 + duration . subsec_millis ( ) as u64 ) as f64 ; RESPONSE_TIME_COLLECTOR . with_label_values ( & [ & format ! ( " " req method ( ) req uri ( ) ) ] ) . observe ( ms ) } match res . status ( ) . code { 500 ..= 599 => RESPONSE_CODE_COLLECTOR . with_label_values ( & [ & res . status ( ) . code . to_string ( ) , " " ] ) . inc ( ) , 400 ..= 499 => RESPONSE_CODE_COLLECTOR . with_label_values ( & [ & res . status ( ) . code . to_string ( ) , " " ] ) . inc ( ) , 300 ..= 399 => RESPONSE_CODE_COLLECTOR . with_label_values ( & [ & res . status ( ) . code . to_string ( ) , " " ] ) . inc ( ) , 200 ..= 299 => RESPONSE_CODE_COLLECTOR . with_label_values ( & [ & res . status ( ) . code . to_string ( ) , " " ] ) . inc ( ) , 100 ..= 199 => RESPONSE_CODE_COLLECTOR . with_label_values ( & [ & res . status ( ) . code . to_string ( ) , " " ] ) . inc ( ) , _ => ( ) , } }
Adds a header to the response indicating how long the server took to
process the request.
Adds a header to the response indicating how long the server took to process the request .
&self
req
&'r Request<'_>
res
&mut Response<'r>