Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stats bugs #1664

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 4 additions & 4 deletions zenoh/src/net/routing/dispatcher/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ pub fn route_data(
drop(tables);
#[cfg(feature = "stats")]
if !admin {
inc_stats!(face, tx, user, msg.payload)
inc_stats!(outface, tx, user, msg.payload)
} else {
inc_stats!(face, tx, admin, msg.payload)
inc_stats!(outface, tx, admin, msg.payload)
}

outface.primitives.send_push(
Expand Down Expand Up @@ -465,9 +465,9 @@ pub fn route_data(
for (outface, key_expr, context) in route {
#[cfg(feature = "stats")]
if !admin {
inc_stats!(face, tx, user, msg.payload)
inc_stats!(outface, tx, user, msg.payload)
} else {
inc_stats!(face, tx, admin, msg.payload)
inc_stats!(outface, tx, admin, msg.payload)
}

outface.primitives.send_push(
Expand Down
Loading