Skip to content

Commit

Permalink
Fix stats
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHecart committed Dec 12, 2024
1 parent c5ba11e commit d93be73
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions io/zenoh-transport/src/common/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 res.is_ok() {
self.stats.t_msgs += 1;
}
}
res
}
}

Expand All @@ -381,7 +388,14 @@ impl Encode<(&NetworkMessage, &FrameHeader)> for &mut WBatch {

fn encode(self, x: (&NetworkMessage, &FrameHeader)) -> 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 res.is_ok() {
self.stats.t_msgs += 1;
}
}
res
}
}

Expand All @@ -390,7 +404,14 @@ impl Encode<(&mut ZBufReader<'_>, &mut FragmentHeader)> for &mut WBatch {

fn encode(self, x: (&mut ZBufReader<'_>, &mut FragmentHeader)) -> 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 res.is_ok() {
self.stats.t_msgs += 1;
}
}
res
}
}

Expand Down

0 comments on commit d93be73

Please sign in to comment.