Correct num_packets stats (#33630)

Do not count the empty packets from cache warmer in num_packets stats as they are not sent.
This commit is contained in:
Lijun Wang 2023-10-11 14:00:30 -07:00 committed by GitHub
parent 295d610f43
commit 21b2fce6f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -582,10 +582,13 @@ impl ClientConnection for QuicClientConnection {
async fn send_data(&self, data: &[u8]) -> TransportResult<()> {
let stats = Arc::new(ClientStats::default());
// When data is empty which is from cache warmer, we are not sending packets actually, do not count it in
let num_packets = if data.is_empty() { 0 } else { 1 };
self.client
.send_buffer(data, &stats, self.connection_stats.clone())
.map_ok(|v| {
self.connection_stats.add_client_stats(&stats, 1, true);
self.connection_stats
.add_client_stats(&stats, num_packets, true);
v
})
.map_err(|e| {
@ -595,7 +598,8 @@ impl ClientConnection for QuicClientConnection {
e
);
datapoint_warn!("send-wire-async", ("failure", 1, i64),);
self.connection_stats.add_client_stats(&stats, 1, false);
self.connection_stats
.add_client_stats(&stats, num_packets, false);
e.into()
})
.await