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 } }