Skip to content

Commit b867000

Browse files
MasterPtatoNathanFlurry
authored andcommitted
chore: fix guard metrics
1 parent 1eac431 commit b867000

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/edge/infra/guard/core/src/proxy_service.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,11 @@ impl ProxyService {
680680
self.handle_http_request(req, target).await
681681
};
682682

683+
let status = match &res {
684+
Ok(resp) => resp.status().as_u16().to_string(),
685+
Err(_) => "error".to_string(),
686+
};
687+
683688
// Record metrics
684689
let duration_secs = start_time.elapsed().as_secs_f64();
685690
metrics::PROXY_REQUEST_DURATION
@@ -691,16 +696,11 @@ impl ProxyService {
691696
res
692697
};
693698

694-
let status = match &res {
695-
Ok(resp) => resp.status().as_u16().to_string(),
696-
Err(err) => {
697-
metrics::PROXY_REQUEST_ERROR
698-
.with_label_values(&[&err.to_string()])
699-
.inc();
700-
701-
"error".to_string()
702-
}
703-
};
699+
if let Err(err) = &res {
700+
metrics::PROXY_REQUEST_ERROR
701+
.with_label_values(&[&err.to_string()])
702+
.inc();
703+
}
704704

705705
res
706706
}

0 commit comments

Comments
 (0)