diff --git a/book/examples/ch-02-getting-started/Cargo.toml b/book/examples/ch-02-getting-started/Cargo.toml index b9ed1465..7838054b 100644 --- a/book/examples/ch-02-getting-started/Cargo.toml +++ b/book/examples/ch-02-getting-started/Cargo.toml @@ -5,4 +5,3 @@ edition = "2021" publish = false [dependencies] -roadster = { path = "../../.." } diff --git a/src/api/core/health.rs b/src/api/core/health.rs index ca675cea..83388fe7 100644 --- a/src/api/core/health.rs +++ b/src/api/core/health.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use std::time::Duration; use std::time::Instant; use tokio::time::timeout; -use tracing::{info, instrument}; +use tracing::{debug, error, info, instrument}; #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "open-api", derive(JsonSchema, OperationIo))] @@ -59,7 +59,14 @@ where let check_timer = Instant::now(); let result = match run_check(check, duration).await { Ok(response) => { - info!(%name, "Resource is healthy"); + info!(%name, latency_ms=%response.latency, "Check completed"); + match &response.status { + Status::Ok => {} + Status::Err(_) => { + error!(%name, "Resource is not healthy"); + debug!(%name, "Error details: {response:?}"); + } + } response } Err(err) => CheckResponse::builder() @@ -81,7 +88,7 @@ where let latency = timer.elapsed().as_millis(); - info!(latency_ms=%latency, "Checks successful"); + info!(latency_ms=%latency, "Checks completed"); Ok(HeathCheckResponse { latency, resources }) } diff --git a/src/service/runner.rs b/src/service/runner.rs index 96e122cb..a1d8ebd1 100644 --- a/src/service/runner.rs +++ b/src/service/runner.rs @@ -14,7 +14,7 @@ use std::sync::Arc; use std::time::Duration; use tokio::task::JoinSet; use tokio_util::sync::CancellationToken; -use tracing::{debug, error, info, instrument}; +use tracing::{error, info, instrument}; #[cfg(feature = "cli")] #[instrument(skip_all)] @@ -40,10 +40,6 @@ where #[instrument(skip_all)] pub(crate) async fn health_checks(context: &AppContext) -> RoadsterResult<()> { let duration = Duration::from_secs(60); - info!( - "Running checks for a maximum duration of {} seconds", - duration.as_secs() - ); let response = health_check(context, Some(duration)).await?; let error_responses = response @@ -52,16 +48,11 @@ pub(crate) async fn health_checks(context: &AppContext) -> RoadsterResult<()> { .filter(|(_name, response)| !matches!(response.status, Status::Ok)) .collect_vec(); - error_responses.iter().for_each(|(name, response)| { - error!(%name, "Resource is not healthy"); - debug!(%name, "Error details: {response:?}"); - }); - if error_responses.is_empty() { Ok(()) } else { let names = error_responses.iter().map(|(name, _)| name).collect_vec(); - Err(anyhow!("Health checks failed: {names:?}"))? + Err(anyhow!("Health checks failed: {names:?}").into()) } }