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

chore(analytics): adding status code to connector Kafka events (#3393)

harsh-sharma-juspayd6807abba461
diff --git a/crates/router/src/events/connector_api_logs.rs b/crates/router/src/events/connector_api_logs.rs
index 871a7af0d7..45c05a3077 100644
--- a/crates/router/src/events/connector_api_logs.rs
+++ b/crates/router/src/events/connector_api_logs.rs
@@ -18,6 +18,7 @@ pub struct ConnectorEvent {
created_at: i128,
request_id: String,
latency: u128,
+ status_code: u16,
}
impl ConnectorEvent {
@@ -33,6 +34,7 @@ impl ConnectorEvent {
merchant_id: String,
request_id: Option<&RequestId>,
latency: u128,
+ status_code: u16,
) -> Self {
Self {
connector_name,
@@ -52,6 +54,7 @@ impl ConnectorEvent {
.map(|i| i.as_hyphenated().to_string())
.unwrap_or("NO_REQUEST_ID".to_string()),
latency,
+ status_code,
}
}
}
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index bc8ab2e05e..e0c6a08625 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -372,7 +372,13 @@ where
let response = call_connector_api(state, request).await;
let external_latency = current_time.elapsed().as_millis();
logger::debug!(connector_response=?response);
-
+ let status_code = response
+ .as_ref()
+ .map(|i| {
+ i.as_ref()
+ .map_or_else(|value| value.status_code, |value| value.status_code)
+ })
+ .unwrap_or_default();
let connector_event = ConnectorEvent::new(
req.connector.clone(),
std::any::type_name::<T>(),
@@ -394,6 +400,7 @@ where
req.merchant_id.clone(),
state.request_id.as_ref(),
external_latency,
+ status_code,
);
match connector_event.try_into() {