From 9d82206a8d4f68cc8eeb0e1149e38186bc480cdc Mon Sep 17 00:00:00 2001 From: ltitanb Date: Wed, 13 Aug 2025 11:59:33 +0100 Subject: [PATCH] more logs --- crates/pbs/src/mev_boost/get_header.rs | 2 ++ crates/pbs/src/routes/router.rs | 31 ++++++++++++++++++++++++-- crates/pbs/src/state.rs | 4 ++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/crates/pbs/src/mev_boost/get_header.rs b/crates/pbs/src/mev_boost/get_header.rs index 2db0bd0c..613815ce 100644 --- a/crates/pbs/src/mev_boost/get_header.rs +++ b/crates/pbs/src/mev_boost/get_header.rs @@ -328,6 +328,7 @@ async fn send_one_get_header( RELAY_STATUS_CODE.with_label_values(&[code.as_str(), GET_HEADER_ENDPOINT_TAG, &relay.id]).inc(); let response_bytes = read_chunked_body_with_max(res, MAX_SIZE_GET_HEADER_RESPONSE).await?; + let header_size_bytes = response_bytes.len(); if !code.is_success() { return Err(PbsError::RelayResponse { error_msg: String::from_utf8_lossy(&response_bytes).into_owned(), @@ -357,6 +358,7 @@ async fn send_one_get_header( debug!( relay_id = relay.id.as_ref(), + header_size_bytes, latency = ?request_latency, version = get_header_response.version(), value_eth = format_ether(get_header_response.value()), diff --git a/crates/pbs/src/routes/router.rs b/crates/pbs/src/routes/router.rs index 80b6156d..aafcd8db 100644 --- a/crates/pbs/src/routes/router.rs +++ b/crates/pbs/src/routes/router.rs @@ -1,4 +1,5 @@ use axum::{ + body::HttpBody, extract::{DefaultBodyLimit, MatchedPath, Request}, middleware::{self, Next}, response::Response, @@ -10,7 +11,7 @@ use cb_common::pbs::{ BUILDER_V1_API_PATH, BUILDER_V2_API_PATH, GET_HEADER_PATH, GET_STATUS_PATH, REGISTER_VALIDATOR_PATH, RELOAD_PATH, SUBMIT_BLOCK_PATH, }; -use tracing::trace; +use tracing::{trace, warn}; use uuid::Uuid; use super::{ @@ -75,6 +76,8 @@ pub fn create_app_router>(state: PbsStateGu ), )] pub async fn tracing_middleware(req: Request, next: Next) -> Response { + let mut watcher = RequestWatcher::new(); + trace!( http.method = %req.method(), http.user_agent = req.headers().typed_get::().map(|ua| ua.to_string()).unwrap_or_default(), @@ -84,8 +87,32 @@ pub async fn tracing_middleware(req: Request, next: Next) -> Response { let response = next.run(req).await; let status = response.status(); + let response_size = response.body().size_hint().upper().unwrap_or(0); - trace!(http.response.status_code = ?status, "end request"); + trace!(http.response.status_code = ?status, response_size, "end request"); + watcher.observe(); response } + +struct RequestWatcher { + observed: bool, +} + +impl RequestWatcher { + fn new() -> Self { + Self { observed: false } + } + + fn observe(&mut self) { + self.observed = true; + } +} + +impl Drop for RequestWatcher { + fn drop(&mut self) { + if !self.observed { + warn!("client timed out") + } + } +} diff --git a/crates/pbs/src/state.rs b/crates/pbs/src/state.rs index 3b892c63..fbf211d3 100644 --- a/crates/pbs/src/state.rs +++ b/crates/pbs/src/state.rs @@ -18,14 +18,14 @@ pub type PbsStateGuard = Arc>>; #[derive(Clone)] pub struct PbsState { /// Config data for the Pbs service - pub config: PbsModuleConfig, + pub config: Arc, /// Opaque extra data for library use pub data: S, } impl PbsState<()> { pub fn new(config: PbsModuleConfig) -> Self { - Self { config, data: () } + Self { config: Arc::new(config), data: () } } pub fn with_data(self, data: S) -> PbsState {