Skip to content

Commit

Permalink
Improve logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gurinderu committed Nov 30, 2023
1 parent d0b3dac commit bfcfcf4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
10 changes: 7 additions & 3 deletions aquamarine/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ where
if let Some(Ready((reusables, effects, stats, span))) =
self.future.as_mut().map(|f| f.poll_unpin(cx))
{
let local_span = tracing::info_span!(parent: span.as_ref(), "Poll AVM future");
let local_span = tracing::info_span!(parent: span.as_ref(), "Poll AVM future", particle_id= self.particle.id, deal_id = self.deal_id);
let _span_guard = local_span.enter();
self.future.take();

Expand Down Expand Up @@ -235,11 +235,15 @@ where
let key_pair = self.key_pair.clone();

let async_span = if let Some(ext_particle) = ext_particle.as_ref() {
tracing::info_span!(parent: ext_particle.span.as_ref(),"Actor: async AVM process particle & call results",particle_id = particle.id)
tracing::info_span!(parent: ext_particle.span.as_ref(),
"Actor: async AVM process particle & call results",
particle_id = particle.id,
deal_id = self.deal_id)
} else {
tracing::info_span!(
"Actor: async AVM process call results",
particle_id = particle.id
particle_id = particle.id,
deal_id = self.deal_id
)
};
for span in spans {
Expand Down
9 changes: 5 additions & 4 deletions sorcerer/src/script_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl Sorcerer {
.map_err(|e| JError::new(e.to_string()))
}

#[instrument(level = tracing::Level::INFO, skip_all)]
pub(crate) fn make_spell_particle(
&self,
spell_id: String,
Expand Down Expand Up @@ -114,7 +115,7 @@ impl Sorcerer {
m.observe_spell_cast();
}

let async_span = tracing::info_span!(parent: span.as_ref(), "Script executor: aquamarine async execute");
let async_span = tracing::info_span!(parent: span.as_ref(), "Script executor: aquamarine async execute", spell_id = event.spell_id.to_string());

self.aquamarine
.clone()
Expand All @@ -125,10 +126,10 @@ impl Sorcerer {

if let Err(err) = error {
log::warn!(
"Failed to execute spell script id: {}, event: {:?}, error: {:?}",
event.spell_id,
"Failed to execute spell script id: {spell_id}, event: {:?}, error: {:?}",
event.info,
err
err,
spell_id = event.spell_id.to_string(),
);
}
}
Expand Down
9 changes: 7 additions & 2 deletions sorcerer/src/sorcerer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,17 @@ impl Sorcerer {
spell_id = spell_event.spell_id.to_string()
);
let root_span = Arc::new(root_span);
let async_span = tracing::info_span!(parent: root_span.as_ref(), "Sorcerer: async execute script");
let async_span = tracing::info_span!(parent: root_span.as_ref(),
"Sorcerer: async execute script",
spell_id = spell_event.spell_id.to_string());

let sorcerer = self.clone();
// Note that the event that triggered the spell is in `spell_event.event`
async move {
sorcerer.execute_script(spell_event,root_span).await;
sorcerer
.execute_script(spell_event, root_span)
.in_current_span()
.await;
}
.instrument(async_span)
})
Expand Down

0 comments on commit bfcfcf4

Please sign in to comment.