From cc7c59af9f09932168bad4b3f94e3e09d336f6be Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 22 Dec 2023 21:14:01 -0800 Subject: [PATCH] v1.17: add metrics on throttled streams (backport of #34579) (#34582) add metrics on throttled streams (#34579) (cherry picked from commit 1a001751dd5631eb956eeed64c4ea07aa4cc41af) Co-authored-by: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> --- streamer/src/nonblocking/quic.rs | 1 + streamer/src/quic.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/streamer/src/nonblocking/quic.rs b/streamer/src/nonblocking/quic.rs index 8f8adc506103ba..951ec6cb317fcd 100644 --- a/streamer/src/nonblocking/quic.rs +++ b/streamer/src/nonblocking/quic.rs @@ -742,6 +742,7 @@ async fn handle_connection( if reset_throttling_params_if_needed(&mut last_throttling_instant) { streams_in_current_interval = 0; } else if streams_in_current_interval >= max_streams_per_100ms { + stats.throttled_streams.fetch_add(1, Ordering::Relaxed); let _ = stream.stop(VarInt::from_u32(STREAM_STOP_CODE_THROTTLING)); continue; } diff --git a/streamer/src/quic.rs b/streamer/src/quic.rs index fee0db110f11ec..8b2b4f9d852cac 100644 --- a/streamer/src/quic.rs +++ b/streamer/src/quic.rs @@ -156,6 +156,7 @@ pub struct StreamStats { pub(crate) connection_setup_error_locally_closed: AtomicUsize, pub(crate) connection_removed: AtomicUsize, pub(crate) connection_remove_failed: AtomicUsize, + pub(crate) throttled_streams: AtomicUsize, } impl StreamStats { @@ -386,6 +387,11 @@ impl StreamStats { self.total_stream_read_timeouts.swap(0, Ordering::Relaxed), i64 ), + ( + "throttled_streams", + self.throttled_streams.swap(0, Ordering::Relaxed), + i64 + ), ); } }