From ee9f0a5fea43aae37bb29ce33ef91a8ff6332f4b Mon Sep 17 00:00:00 2001 From: OlivierHecart Date: Thu, 12 Dec 2024 12:08:23 +0100 Subject: [PATCH] Fix stats --- io/zenoh-transport/src/common/batch.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/io/zenoh-transport/src/common/batch.rs b/io/zenoh-transport/src/common/batch.rs index 65150f728..b29cc2e82 100644 --- a/io/zenoh-transport/src/common/batch.rs +++ b/io/zenoh-transport/src/common/batch.rs @@ -363,7 +363,14 @@ impl Encode<&TransportMessage> for &mut WBatch { fn encode(self, x: &TransportMessage) -> Self::Output { let mut writer = self.buffer.writer(); - self.codec.write(&mut writer, x) + let res = self.codec.write(&mut writer, x); + #[cfg(feature = "stats")] + { + if let Ok(()) = res { + self.stats.t_msgs += 1; + } + } + res } }