Skip to content

Commit

Permalink
Review feedback: logging & instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pcholakov committed Nov 20, 2024
1 parent 06487b1 commit 5fa2226
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 4 additions & 5 deletions crates/worker/src/partition_processor_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use tokio::sync::oneshot;
use tokio::sync::{mpsc, watch};
use tokio::task::JoinSet;
use tokio::time::MissedTickBehavior;
use tracing::{debug, error, info, instrument, warn, Instrument};
use tracing::{debug, error, info, instrument, warn};

use crate::metric_definitions::NUM_ACTIVE_PARTITIONS;
use crate::metric_definitions::PARTITION_IS_ACTIVE;
Expand Down Expand Up @@ -619,7 +619,7 @@ impl PartitionProcessorManager {
processor_state.stop();
}
if self.pending_snapshots.contains_key(&partition_id) {
warn!(%partition_id, "Partition processor stopped while snapshot task is still pending.");
warn!(%partition_id, "Partition processor requested to stop while a snapshot task is still outstanding.");
}
}
ProcessorCommand::Follower | ProcessorCommand::Leader => {
Expand Down Expand Up @@ -726,7 +726,7 @@ impl PartitionProcessorManager {
if let Some(pending) = self.pending_snapshots.remove(&partition_id) {
let _ = pending.sender.send(response);
} else {
error!("Snapshot task result received, but there was no pending sender found!")
warn!("Snapshot task result received, but there was no pending sender found!")
}
}

Expand Down Expand Up @@ -800,12 +800,11 @@ impl PartitionProcessorManager {
node_name: config.common.node_name().into(),
};

let snapshot_span = tracing::info_span!("create-snapshot", %snapshot_id, %partition_id);
let spawn_task_result = restate_core::task_center().spawn_unmanaged(
TaskKind::PartitionSnapshotProducer,
"create-snapshot",
Some(partition_id),
async move { create_snapshot_task.run().await }.instrument(snapshot_span),
create_snapshot_task.run(),
);

match spawn_task_result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::path::PathBuf;
use std::time::SystemTime;

use tokio::sync::oneshot;
use tracing::{debug, warn};
use tracing::{debug, instrument, warn};

use restate_core::worker_api::SnapshotError;
use restate_partition_store::snapshots::{
Expand All @@ -33,6 +33,7 @@ pub struct SnapshotPartitionTask {
}

impl SnapshotPartitionTask {
#[instrument(level = "info", skip_all, fields(snapshot_id = %self.snapshot_id, partition_id = %self.partition_id))]
pub async fn run(self) {
debug!("Creating partition snapshot");

Expand Down

0 comments on commit 5fa2226

Please sign in to comment.