Skip to content

Commit

Permalink
chore(analytics): adding status code to connector events
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-sharma-juspay committed Jan 18, 2024
1 parent 5a791aa commit a46f4da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/router/src/events/connector_api_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct ConnectorEvent {
created_at: i128,
request_id: String,
latency: u128,
status_code: u16,
}

impl ConnectorEvent {
Expand All @@ -33,6 +34,7 @@ impl ConnectorEvent {
merchant_id: String,
request_id: Option<&RequestId>,
latency: u128,
status_code: u16,
) -> Self {
Self {
connector_name,
Expand All @@ -52,6 +54,7 @@ impl ConnectorEvent {
.map(|i| i.as_hyphenated().to_string())
.unwrap_or("NO_REQUEST_ID".to_string()),
latency,
status_code,
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion crates/router/src/services/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,12 @@ 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.clone().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>(),
Expand All @@ -394,6 +399,7 @@ where
req.merchant_id.clone(),
state.request_id.as_ref(),
external_latency,
status_code,
);

match connector_event.try_into() {
Expand Down

0 comments on commit a46f4da

Please sign in to comment.