Add metric for write EAGAIN failures

This commit is contained in:
2025-09-10 16:48:27 -04:00
parent 962a010724
commit 5d289ddd42

View File

@@ -26,6 +26,11 @@ thread_local auto bytes_written =
metric::create_counter("weaseldb_bytes_written_total",
"Total number of bytes written to clients")
.create({});
thread_local auto write_eagain_failures =
metric::create_counter(
"weaseldb_write_eagain_failures_total",
"Total number of write operations that failed with EAGAIN")
.create({});
} // namespace
// Static thread-local storage for iovec buffer
@@ -130,6 +135,8 @@ bool Connection::writeBytes() {
continue; // Standard practice: retry on signal interruption
}
if (errno == EAGAIN) {
// Increment EAGAIN failure metric
write_eagain_failures.inc();
// Increment bytes written metric before returning
if (total_bytes_written > 0) {
bytes_written.inc(total_bytes_written);