mirror of
https://github.com/actix/examples
synced 2024-11-23 14:31:07 +01:00
fix: add metric labels
This commit is contained in:
parent
8e0b57e658
commit
e0ae11ab86
@ -13,7 +13,8 @@ As stated in the exercise brief, this example will:
|
||||
- Create a top-level INFO span for each incoming request;
|
||||
- Track the number of concurrent requests using a gauge;
|
||||
- Track request duration using a histogram;
|
||||
- Track the number of handled requests All metrics should include success/failure as a label.
|
||||
- Track the number of handled requests
|
||||
- All metrics should include success/failure as a label.
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -31,8 +31,14 @@ pub(crate) async fn request_telemetry(
|
||||
);
|
||||
};
|
||||
|
||||
let outcome = if res.status().is_success() || res.status().is_redirection() {
|
||||
"success"
|
||||
} else {
|
||||
"failure"
|
||||
};
|
||||
|
||||
let diff = now.elapsed();
|
||||
metrics::histogram!(HISTOGRAM_HTTP_REQUEST_DURATION).record(diff);
|
||||
metrics::histogram!(HISTOGRAM_HTTP_REQUEST_DURATION, "outcome" => outcome).record(diff);
|
||||
|
||||
metrics::gauge!(GAUGE_HTTP_CONCURRENT_REQUESTS).decrement(1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user