diff --git a/src/https.rs b/src/https.rs index 20df354..ebdac6d 100644 --- a/src/https.rs +++ b/src/https.rs @@ -197,6 +197,10 @@ async fn handle_request( let tags = [host_tag, method_tag.clone()]; metrics.requests_received.add(1, &tags); metrics.requests_in_flight.add(1, &tags); + + // The guard ensures that we decrement requests_in_flight in all cases where + // the current tasks ends, including the case where it gets canceled and + // doesn't run to completion (which may happen e.g. if it timeouts). let _guard = InFlightGuard { metrics: Arc::clone(&metrics), tags: &tags,