add metrics on throttled streams (#34579)

This commit is contained in:
Lijun Wang 2023-12-22 16:49:01 -08:00 committed by GitHub
parent cc584a0c19
commit 1a001751dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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;
}

View File

@ -175,6 +175,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 {
@ -405,6 +406,11 @@ impl StreamStats {
self.total_stream_read_timeouts.swap(0, Ordering::Relaxed),
i64
),
(
"throttled_streams",
self.throttled_streams.swap(0, Ordering::Relaxed),
i64
),
);
}
}