Skip to content

Commit

Permalink
chore: Add computed and replayed receipt logs
Browse files Browse the repository at this point in the history
  • Loading branch information
bgins committed Mar 13, 2024
1 parent 60c4d41 commit 4e30711
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
5 changes: 5 additions & 0 deletions homestar-runtime/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ fn init(

let filter = if every_cli {
EnvFilter::new("off")
.add_directive(
"homestar_runtime::runner[run_worker]=info"
.parse()
.expect(DIRECTIVE_EXPECT),
)
.add_directive(
"homestar_runtime::worker[run]=info"
.parse()
Expand Down
25 changes: 21 additions & 4 deletions homestar-runtime/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use tokio::{
time,
};
use tokio_util::time::{delay_queue, DelayQueue};
use tracing::{debug, error, info, warn};
use tracing::{debug, error, info, info_span, instrument, warn, Instrument};

mod error;
pub(crate) mod file;
Expand Down Expand Up @@ -702,6 +702,7 @@ impl Runner {
}
}

#[instrument(skip_all)]
async fn run_worker<S: Into<FastStr>>(
&self,
workflow: Workflow<'static, Arg>,
Expand Down Expand Up @@ -767,9 +768,11 @@ impl Runner {
async move { Fetch::get_resources(rscs, workflow_settings).await }.boxed()
};

let handle = self
.runtime
.spawn(worker.run(self.running_tasks(), fetch_fn));
let handle = self.runtime.spawn(
worker
.run(self.running_tasks(), fetch_fn)
.instrument(info_span!("run").or_current()),
);

// Add Cid to expirations timing wheel
let delay_key = self
Expand All @@ -790,6 +793,20 @@ impl Runner {
.collect();
let replayed_receipt_info = find_receipt_info_by_pointers(&receipt_pointers, db)?;

// Log replayed receipts if any
if !replayed_receipt_info.is_empty() {
info!(
subject = "workflow.receipts",
category = "workflow",
receipt_cids = replayed_receipt_info
.iter()
.map(|info| info.0.to_string())
.collect::<Vec<String>>()
.join(","),
"replaying receipts",
);
};

Ok(WorkflowData {
info: initial_info,
name: workflow_name,
Expand Down
7 changes: 7 additions & 0 deletions homestar-runtime/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,13 @@ where
"committed to database"
);

info!(
subject = "worker.receipt",
category = "worker.run",
receipt_cid = stored_receipt.cid().to_string(),
"computed receipt"
);

let _ = self
.event_sender
.send_async(Event::CapturedReceipt(Captured::with(
Expand Down

0 comments on commit 4e30711

Please sign in to comment.