From 4864c4fb9fb053a0383a6da0e21c84249a0737f1 Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Wed, 28 Feb 2024 17:40:14 -0800 Subject: [PATCH] fix: don't emit a content-type header for 304s or bodyless 412s and kill the old periodic reporter (moved to server::spawn_metric_periodic_reporter) Closes SYNC-4162 --- syncserver/src/web/handlers.rs | 2 +- syncserver/src/web/transaction.rs | 3 +-- syncstorage-db/src/lib.rs | 39 ------------------------------- 3 files changed, 2 insertions(+), 42 deletions(-) diff --git a/syncserver/src/web/handlers.rs b/syncserver/src/web/handlers.rs index e8bf797b0e..7c2edc7244 100644 --- a/syncserver/src/web/handlers.rs +++ b/syncserver/src/web/handlers.rs @@ -579,7 +579,7 @@ pub async fn lbheartbeat(req: HttpRequest) -> Result { Some(s) => s, None => { error!("⚠️ Could not load the app state"); - return Ok(HttpResponse::InternalServerError().body("")); + return Ok(HttpResponse::InternalServerError().finish()); } }; diff --git a/syncserver/src/web/transaction.rs b/syncserver/src/web/transaction.rs index 13809ceb43..3975a315b1 100644 --- a/syncserver/src/web/transaction.rs +++ b/syncserver/src/web/transaction.rs @@ -147,9 +147,8 @@ impl DbTransactionPool { }; if status != StatusCode::OK { return Ok(HttpResponse::build(status) - .content_type("application/json") .insert_header((X_LAST_MODIFIED, resource_ts.as_header())) - .body("".to_owned())); + .finish()); }; } diff --git a/syncstorage-db/src/lib.rs b/syncstorage-db/src/lib.rs index 6d6efcc77b..cfd0ee8fea 100644 --- a/syncstorage-db/src/lib.rs +++ b/syncstorage-db/src/lib.rs @@ -8,11 +8,6 @@ pub mod mock; #[cfg(test)] mod tests; -use std::time::Duration; - -use cadence::{Gauged, StatsdClient}; -use tokio::{self, time}; - #[cfg(feature = "mysql")] pub type DbPoolImpl = syncstorage_mysql::MysqlDbPool; #[cfg(feature = "mysql")] @@ -41,37 +36,3 @@ compile_error!("only one of the \"mysql\" and \"spanner\" features can be enable #[cfg(not(any(feature = "mysql", feature = "spanner")))] compile_error!("exactly one of the \"mysql\" and \"spanner\" features must be enabled"); - -/// Emit DbPool metrics periodically -pub fn spawn_pool_periodic_reporter( - interval: Duration, - metrics: StatsdClient, - pool: T, -) -> Result<(), DbError> { - let hostname = hostname::get() - .expect("Couldn't get hostname") - .into_string() - .expect("Couldn't get hostname"); - tokio::spawn(async move { - loop { - let PoolState { - connections, - idle_connections, - } = pool.state(); - metrics - .gauge_with_tags( - "storage.pool.connections.active", - (connections - idle_connections) as u64, - ) - .with_tag("hostname", &hostname) - .send(); - metrics - .gauge_with_tags("storage.pool.connections.idle", idle_connections as u64) - .with_tag("hostname", &hostname) - .send(); - time::sleep(interval).await; - } - }); - - Ok(()) -}