Skip to content

Commit

Permalink
Correct num_packets stats (solana-labs#33630)
Browse files Browse the repository at this point in the history
Do not count the empty packets from cache warmer in num_packets stats as they are not sent.
  • Loading branch information
lijunwangs authored Oct 11, 2023
1 parent 295d610 commit 21b2fce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions quic-client/src/nonblocking/quic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand All @@ -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
Expand Down

0 comments on commit 21b2fce

Please sign in to comment.