Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix: log detailed error reports during deep health check failures (#5984)

Sanchith Hegde19e52b420002
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 15038da012..afde434f40 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -503,7 +503,7 @@ database_name = "default"
[analytics.sqlx]
username = "db_user"
password = "db_pass"
-host = "localhost"
+host = "pg"
port = 5432
dbname = "hyperswitch_db"
pool_size = 5
diff --git a/crates/drainer/src/health_check.rs b/crates/drainer/src/health_check.rs
index 946489513b..48d5f31190 100644
--- a/crates/drainer/src/health_check.rs
+++ b/crates/drainer/src/health_check.rs
@@ -72,11 +72,14 @@ pub async fn deep_health_check_func(
logger::debug!("Database health check begin");
- let db_status = store.health_check_db().await.map(|_| true).map_err(|err| {
- error_stack::report!(HealthCheckError::DbError {
- message: err.to_string()
- })
- })?;
+ let db_status = store
+ .health_check_db()
+ .await
+ .map(|_| true)
+ .map_err(|error| {
+ let message = error.to_string();
+ error.change_context(HealthCheckError::DbError { message })
+ })?;
logger::debug!("Database health check end");
@@ -86,10 +89,9 @@ pub async fn deep_health_check_func(
.health_check_redis(&conf.into_inner())
.await
.map(|_| true)
- .map_err(|err| {
- error_stack::report!(HealthCheckError::RedisError {
- message: err.to_string()
- })
+ .map_err(|error| {
+ let message = error.to_string();
+ error.change_context(HealthCheckError::RedisError { message })
})?;
logger::debug!("Redis health check end");
diff --git a/crates/router/src/bin/scheduler.rs b/crates/router/src/bin/scheduler.rs
index 346d36156e..62c8c03e1a 100644
--- a/crates/router/src/bin/scheduler.rs
+++ b/crates/router/src/bin/scheduler.rs
@@ -204,12 +204,17 @@ pub async fn deep_health_check_func(
logger::debug!("Database health check begin");
- let db_status = state.health_check_db().await.map(|_| true).map_err(|err| {
- error_stack::report!(errors::ApiErrorResponse::HealthCheckError {
- component: "Database",
- message: err.to_string()
- })
- })?;
+ let db_status = state
+ .health_check_db()
+ .await
+ .map(|_| true)
+ .map_err(|error| {
+ let message = error.to_string();
+ error.change_context(errors::ApiErrorResponse::HealthCheckError {
+ component: "Database",
+ message,
+ })
+ })?;
logger::debug!("Database health check end");
@@ -219,23 +224,26 @@ pub async fn deep_health_check_func(
.health_check_redis()
.await
.map(|_| true)
- .map_err(|err| {
- error_stack::report!(errors::ApiErrorResponse::HealthCheckError {
+ .map_err(|error| {
+ let message = error.to_string();
+ error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Redis",
- message: err.to_string()
+ message,
})
})?;
- let outgoing_req_check = state
- .health_check_outgoing()
- .await
- .map(|_| true)
- .map_err(|err| {
- error_stack::report!(errors::ApiErrorResponse::HealthCheckError {
- component: "Outgoing Request",
- message: err.to_string()
- })
- })?;
+ let outgoing_req_check =
+ state
+ .health_check_outgoing()
+ .await
+ .map(|_| true)
+ .map_err(|error| {
+ let message = error.to_string();
+ error.change_context(errors::ApiErrorResponse::HealthCheckError {
+ component: "Outgoing Request",
+ message,
+ })
+ })?;
logger::debug!("Redis health check end");
diff --git a/crates/router/src/routes/health.rs b/crates/router/src/routes/health.rs
index f15a0db192..c1cf28d00a 100644
--- a/crates/router/src/routes/health.rs
+++ b/crates/router/src/routes/health.rs
@@ -48,10 +48,11 @@ async fn deep_health_check_func(
logger::debug!("Database health check begin");
- let db_status = state.health_check_db().await.map_err(|err| {
- error_stack::report!(errors::ApiErrorResponse::HealthCheckError {
+ let db_status = state.health_check_db().await.map_err(|error| {
+ let message = error.to_string();
+ error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Database",
- message: err.to_string()
+ message,
})
})?;
@@ -59,10 +60,11 @@ async fn deep_health_check_func(
logger::debug!("Redis health check begin");
- let redis_status = state.health_check_redis().await.map_err(|err| {
- error_stack::report!(errors::ApiErrorResponse::HealthCheckError {
+ let redis_status = state.health_check_redis().await.map_err(|error| {
+ let message = error.to_string();
+ error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Redis",
- message: err.to_string()
+ message,
})
})?;
@@ -70,10 +72,11 @@ async fn deep_health_check_func(
logger::debug!("Locker health check begin");
- let locker_status = state.health_check_locker().await.map_err(|err| {
- error_stack::report!(errors::ApiErrorResponse::HealthCheckError {
+ let locker_status = state.health_check_locker().await.map_err(|error| {
+ let message = error.to_string();
+ error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Locker",
- message: err.to_string()
+ message,
})
})?;
@@ -82,10 +85,11 @@ async fn deep_health_check_func(
logger::debug!("Analytics health check begin");
#[cfg(feature = "olap")]
- let analytics_status = state.health_check_analytics().await.map_err(|err| {
- error_stack::report!(errors::ApiErrorResponse::HealthCheckError {
+ let analytics_status = state.health_check_analytics().await.map_err(|error| {
+ let message = error.to_string();
+ error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Analytics",
- message: err.to_string()
+ message,
})
})?;
@@ -94,10 +98,11 @@ async fn deep_health_check_func(
logger::debug!("Opensearch health check begin");
#[cfg(feature = "olap")]
- let opensearch_status = state.health_check_opensearch().await.map_err(|err| {
- error_stack::report!(errors::ApiErrorResponse::HealthCheckError {
+ let opensearch_status = state.health_check_opensearch().await.map_err(|error| {
+ let message = error.to_string();
+ error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Opensearch",
- message: err.to_string()
+ message,
})
})?;
@@ -105,10 +110,11 @@ async fn deep_health_check_func(
logger::debug!("Outgoing Request health check begin");
- let outgoing_check = state.health_check_outgoing().await.map_err(|err| {
- error_stack::report!(errors::ApiErrorResponse::HealthCheckError {
+ let outgoing_check = state.health_check_outgoing().await.map_err(|error| {
+ let message = error.to_string();
+ error.change_context(errors::ApiErrorResponse::HealthCheckError {
component: "Outgoing Request",
- message: err.to_string()
+ message,
})
})?;