Skip to content

Commit 425b2ea

Browse files
committed
metrics: only log recurring WouldBlock errors.
1 parent 31766eb commit 425b2ea

File tree

1 file changed

+16
-1
lines changed
  • tokio-quiche/src/quic/io

1 file changed

+16
-1
lines changed

tokio-quiche/src/quic/io/gso.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ pub async fn send_to(
126126
const INSTANT_ZERO: Instant = unsafe { std::mem::transmute(0u128) };
127127

128128
let mut sendmsg_retry_timer = None;
129+
// Only log recurring WouldBlock errors.
130+
let mut recurring_would_block = false;
129131
loop {
130132
let iov = [std::io::IoSlice::new(send_buf)];
131133
let segment_size_u16 = segment_size as u16;
@@ -167,7 +169,20 @@ pub async fn send_to(
167169
sendmsg_retry_timer =
168170
Some(send_to_wouldblock_duration_s.start_timer());
169171
}
170-
would_block_metric.inc();
172+
// Only log if we see recurring would block errors in the same
173+
// loop.
174+
//
175+
// A WouldBlock error suggests that the library should try again
176+
// later since it is expected that a socket will block
177+
// occasionally.
178+
//
179+
// We would like to measure WouldBlock errors that result because
180+
// of the hot `loop`ing calls to `sendmsg`.
181+
if recurring_would_block {
182+
would_block_metric.inc();
183+
}
184+
recurring_would_block = true;
185+
171186
socket.writable().await?
172187
},
173188
res => return res,

0 commit comments

Comments
 (0)