Skip to content

Commit

Permalink
Merge pull request #420 from fastly/joeshaw/split-info-spans
Browse files Browse the repository at this point in the history
  • Loading branch information
joeshaw authored Aug 28, 2024
2 parents 8961565 + e5ea252 commit c70154b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use {
time::{Duration, Instant, SystemTime},
},
tokio::sync::oneshot::{self, Sender},
tracing::{event, info, info_span, warn, Level},
tracing::{event, info, info_span, warn, Instrument, Level},
wasmtime::{
component::{self, Component},
Engine, GuestProfiler, InstancePre, Linker, Module, ProfilingStrategy,
Expand Down Expand Up @@ -373,9 +373,6 @@ impl ExecuteCtx {
.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
let active_cpu_time_us = Arc::new(AtomicU64::new(0));

let span = info_span!("request", id = req_id);
let _span = span.enter();

// Spawn a separate task to run the guest code. That allows _this_ method to return a response early
// if the guest sends one, while the guest continues to run afterward within its task.
let guest_handle = tokio::task::spawn(CpuTimeTracking::new(
Expand All @@ -387,10 +384,15 @@ impl ExecuteCtx {
local,
remote,
active_cpu_time_us.clone(),
),
)
.instrument(info_span!("request", id = req_id)),
));

let resp = match receiver.await {
let res = receiver.await;
let span = info_span!("request", id = req_id);
let _span = span.enter();

let resp = match res {
Ok(resp) => (resp, None),
Err(_) => match guest_handle
.await
Expand Down

0 comments on commit c70154b

Please sign in to comment.