Skip to content

Commit

Permalink
fix: don't emit a content-type header for 304s (#1526)
Browse files Browse the repository at this point in the history
or bodyless 412s

and kill the old periodic reporter (moved to
server::spawn_metric_periodic_reporter)

Closes SYNC-4162
  • Loading branch information
pjenvey authored Feb 29, 2024
1 parent 3edd420 commit 8faf728
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 42 deletions.
2 changes: 1 addition & 1 deletion syncserver/src/web/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ pub async fn lbheartbeat(req: HttpRequest) -> Result<HttpResponse, ApiError> {
Some(s) => s,
None => {
error!("⚠️ Could not load the app state");
return Ok(HttpResponse::InternalServerError().body(""));
return Ok(HttpResponse::InternalServerError().finish());
}
};

Expand Down
3 changes: 1 addition & 2 deletions syncserver/src/web/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
};
}

Expand Down
39 changes: 0 additions & 39 deletions syncstorage-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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<T: GetPoolState + Send + 'static>(
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(())
}

0 comments on commit 8faf728

Please sign in to comment.