Skip to content

Commit

Permalink
Emit the status code for responses, in addition to other stats (#416)
Browse files Browse the repository at this point in the history
Emit the response status code when emitting stats about the request that was handled. Additionally, move the tracing span so that it covers all messages emitted for request handling, not just run_guest.
  • Loading branch information
elliottt authored Aug 15, 2024
1 parent ab7f0f0 commit a945b34
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 a945b34

Please sign in to comment.