Skip to content

Commit

Permalink
refactor(storage-manager): improve logging
Browse files Browse the repository at this point in the history
* plugins/zenoh-plugin-storage-manager/src/replication/aligner.rs:
  removed the addition of the sample key expression and timestamp in the
  `span` as the `record` method can only append new values. That means
  that when several events are processed, the information accumulate in
  the span.

* plugins/zenoh-plugin-storage-manager/src/replication/core.rs:
  - Log the `DigestDiff` when a misalignment is detected.
  - Removed the log indicated that an alignment query is received as it
    is redundant with later logs.

* plugins/zenoh-plugin-storage-manager/src/replication/log.rs: added a
  trace when an event is added to the Replication Log.

* plugins/zenoh-plugin-storage-manager/src/storages_mgt/service.rs:
  - Only print the key expression of the sample being processed.
  - Remove the redundant log indicating the the sample is being
    processed.

Signed-off-by: Julien Loudet <[email protected]>
  • Loading branch information
J-Loudet committed Oct 2, 2024
1 parent f4c34bd commit 4d62aee
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
16 changes: 4 additions & 12 deletions plugins/zenoh-plugin-storage-manager/src/replication/aligner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,21 +601,13 @@ impl Replication {
}
}
AlignmentReply::Events(replica_events) => {
tracing::trace!("Processing `AlignmentReply::Events`");
let mut diff_events = Vec::default();

for replica_event in replica_events {
{
let span = tracing::Span::current();
span.record(
"sample",
replica_event
.stripped_key
.as_ref()
.map_or("", |key| key.as_str()),
);
span.record("t", replica_event.timestamp.to_string());
}
tracing::trace!(
"Processing `AlignmentReply::Events` on: < {:?} >",
replica_event.stripped_key
);

if self
.latest_updates
Expand Down
4 changes: 1 addition & 3 deletions plugins/zenoh-plugin-storage-manager/src/replication/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl Replication {
};

if let Some(digest_diff) = digest.diff(other_digest) {
tracing::debug!("Potential misalignment detected");
tracing::debug!("Potential misalignment detected: {digest_diff:?}");

let replica_aligner_ke = match keformat!(
aligner_key_expr_formatter::formatter(),
Expand Down Expand Up @@ -460,8 +460,6 @@ impl Replication {
continue;
}

tracing::trace!("Received Alignment Query");

let replication = replication.clone();
tokio::task::spawn(async move { replication.aligner(query).await });
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/zenoh-plugin-storage-manager/src/replication/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ impl LogLatest {

self.bloom_filter_event.set(event.key_expr());

tracing::trace!("Inserting < {:?} > in Replication Log", event.key_expr());

self.intervals
.entry(interval_idx)
.or_default()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl StorageService {
// The storage should only simply save the key, sample pair while put and retrieve the same
// during get the trimming during PUT and GET should be handled by the plugin
pub(crate) async fn process_sample(&self, sample: Sample) -> ZResult<()> {
tracing::trace!("[STORAGE] Processing sample: {:?}", sample);
tracing::trace!("[STORAGE] Processing sample: {:?}", sample.key_expr());

// A Sample, in theory, will not arrive to a Storage without a Timestamp. This check (which,
// again, should never enter the `None` branch) ensures that the Storage Manager
Expand Down Expand Up @@ -254,12 +254,6 @@ impl StorageService {
continue;
}

tracing::trace!(
"Sample `{:?}` identified as needed processing for key {}",
sample,
k
);

// there might be the case that the actual update was outdated due to a wild card
// update, but not stored yet in the storage. get the relevant wild
// card entry and use that value and timestamp to update the storage
Expand Down

0 comments on commit 4d62aee

Please sign in to comment.