Skip to content

Commit

Permalink
Emit the status code for responses, in addition to other stats
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottt committed Aug 14, 2024
1 parent ab7f0f0 commit abd7806
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use {
time::{Duration, Instant, SystemTime},
},
tokio::sync::oneshot::{self, Sender},
tracing::{event, info, info_span, warn, Instrument, Level},
tracing::{event, info, info_span, warn, Level},
wasmtime::{
component::{self, Component},
Engine, GuestProfiler, InstancePre, Linker, Module, ProfilingStrategy,
Expand Down Expand Up @@ -366,12 +366,12 @@ impl ExecuteCtx {
.next_req_id
.fetch_add(1, std::sync::atomic::Ordering::SeqCst);

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(
self.run_guest(req, req_id, sender, local, remote)
.instrument(info_span!("request", id = req_id)),
);
let guest_handle = tokio::task::spawn(self.run_guest(req, req_id, sender, local, remote));

let resp = match receiver.await {
Ok(resp) => (resp, None),
Expand All @@ -397,6 +397,8 @@ impl ExecuteCtx {
},
};

info!("response status: {:?}", resp.0.status());

Ok(resp)
}

Expand Down

0 comments on commit abd7806

Please sign in to comment.