Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Correct num_packets stats
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunwangs committed Oct 10, 2023
1 parent 6ea5128 commit ff78f0d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions quic-client/src/nonblocking/quic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +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 stats.
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);
v
self.connection_stats
.add_client_stats(&stats, num_packets, true);
})
.map_err(|e| {
warn!(
Expand All @@ -595,7 +597,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 ff78f0d

Please sign in to comment.