Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split info spans when logging request IDs #420

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading