diff --git a/crates/queryd/src/service.rs b/crates/queryd/src/service.rs index 8842af7..5dec8fc 100644 --- a/crates/queryd/src/service.rs +++ b/crates/queryd/src/service.rs @@ -69,6 +69,11 @@ struct QueryResponse { columns: Vec, rows: serde_json::Value, row_count: usize, + // Elapsed wall time from handler entry to response. Required for + // audit-log parity — gateway's audit row previously stored null here. + // Scrum iter 9 finding, populated from std::time::Instant captured + // at the top of execute_query / paged_query. + latency_ms: u64, } #[derive(Serialize)] @@ -115,6 +120,7 @@ async fn execute_query( State(state): State, Json(req): Json, ) -> impl IntoResponse { + let started = std::time::Instant::now(); tracing::info!("executing query: {}", req.sql); if let Some(reason) = sql_policy_check(&state.truth, &req.sql) { @@ -129,6 +135,7 @@ async fn execute_query( columns: vec![], rows: serde_json::Value::Array(vec![]), row_count: 0, + latency_ms: started.elapsed().as_millis() as u64, })); } @@ -147,6 +154,7 @@ async fn execute_query( columns, rows, row_count, + latency_ms: started.elapsed().as_millis() as u64, })) } Err(e) => Err((StatusCode::BAD_REQUEST, e)),