From 6433ce060dd1627fba98e43673549bb5eb9319e7 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 16 May 2018 16:24:29 -0700 Subject: [PATCH] proxy: Fix end events not firing when a stream is ended by a DATA frame (#957) A recent upstream change in `tower-h2` (tower-rs/tower-h2@d9b3140) caused some HTTP/2 streams that were previously terminated by TRAILERS frames to be terminated by empty DATA frames with the end of stream bit set, instead. This broke some tests in my dev branch for #944, as our test server also uses `tower-h2`, and some of the metrics tests were no longer seeing the expected `StreamResponseEnd` events due to this change. This issue may also occur in other cases, resulting in incorrect metrics. This PR changes `MeasuredBody::poll_data` to trigger the Stream End event if it sees a DATA frame that ends the stream. Fixes #954 Signed-off-by: Eliza Weisman --- proxy/src/telemetry/sensor/http.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/proxy/src/telemetry/sensor/http.rs b/proxy/src/telemetry/sensor/http.rs index b9f08f417..adedb2b52 100644 --- a/proxy/src/telemetry/sensor/http.rs +++ b/proxy/src/telemetry/sensor/http.rs @@ -442,6 +442,15 @@ where } frame }); + + // If the frame ended the stream, send the end of stream event now, + // as we may not be polled again. + if self.is_end_stream() { + if let Some(inner) = self.inner.take() { + inner.end(None); + } + } + Ok(Async::Ready(frame)) }