From a3cb1e47a2107805cfed54f617483644c68b5f71 Mon Sep 17 00:00:00 2001 From: Oliver Gould Date: Thu, 24 May 2018 10:40:29 -0700 Subject: [PATCH] proxy: Record EOS when bodies are dropped (#1003) It appears that hyper does not necessarily poll bodies to completion, and instead simply drops a body as soon as `content-length` is reached (hyperium/hyper#1521). This change implements Drop for MeasuredBody such that the stream-end event is triggered if it had not been triggered previously. This ensures that response latencies and counts are recorded for HTTP/1 streams. Fixes #994 --- proxy/src/telemetry/sensor/http.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/proxy/src/telemetry/sensor/http.rs b/proxy/src/telemetry/sensor/http.rs index 895188e6f..c9177938b 100644 --- a/proxy/src/telemetry/sensor/http.rs +++ b/proxy/src/telemetry/sensor/http.rs @@ -507,6 +507,14 @@ where } +impl Drop for MeasuredBody { + fn drop(&mut self) { + if let Some(inner) = self.inner.take() { + inner.end(None); + } + } +} + // ===== impl BodySensor ===== impl BodySensor for ResponseBodyInner {