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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(drainer): properly log deserialization errors (#3075)
Kartikeya Hegde42b5bd4f3d14
diff --git a/crates/drainer/src/lib.rs b/crates/drainer/src/lib.rsindex 7b77873a64..796c9aa695 100644--- a/crates/drainer/src/lib.rs+++ b/crates/drainer/src/lib.rs@@ -7,7 +7,7 @@ pub mod settings;mod utils;use std::sync::{atomic, Arc};-use common_utils::signals::get_allowed_signals;+use common_utils::{ext_traits::StringExt, signals::get_allowed_signals};use diesel_models::kv;use error_stack::{IntoReport, ResultExt};use router_env::{instrument, tracing};@@ -205,10 +205,15 @@ async fn drainer(tracing::Span::current().record("global_id", global_id);tracing::Span::current().record("session_id", &session_id);- let result = serde_json::from_str::<kv::DBOperation>(&typed_sql);+ let result = typed_sql.parse_struct("DBOperation");+let db_op = match result {Ok(f) => f,- Err(_err) => continue, // TODO: handle error+ Err(err) => {+ logger::error!(operation= "deserialization",error = %err);+ metrics::STREAM_PARSE_FAIL.add(&metrics::CONTEXT, 1, &[]);+ continue;+ }};let conn = pg_connection(&store.master_pool).await;diff --git a/crates/drainer/src/metrics.rs b/crates/drainer/src/metrics.rsindex 06e9119787..750f23bc73 100644--- a/crates/drainer/src/metrics.rs+++ b/crates/drainer/src/metrics.rs@@ -14,6 +14,7 @@ counter_metric!(SUCCESSFUL_QUERY_EXECUTION, DRAINER_METER);counter_metric!(SHUTDOWN_SIGNAL_RECEIVED, DRAINER_METER);counter_metric!(SUCCESSFUL_SHUTDOWN, DRAINER_METER);counter_metric!(STREAM_EMPTY, DRAINER_METER);+counter_metric!(STREAM_PARSE_FAIL, DRAINER_METER);counter_metric!(DRAINER_HEALTH, DRAINER_METER);histogram_metric!(QUERY_EXECUTION_TIME, DRAINER_METER); // Time in (ms) milliseconds