mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
chore(analytics): adding status code to connector Kafka events (#3393)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Sampras lopes <lsampras@pm.me>
This commit is contained in:
committed by
GitHub
parent
d91da89065
commit
d6807abba4
@ -18,6 +18,7 @@ pub struct ConnectorEvent {
|
|||||||
created_at: i128,
|
created_at: i128,
|
||||||
request_id: String,
|
request_id: String,
|
||||||
latency: u128,
|
latency: u128,
|
||||||
|
status_code: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConnectorEvent {
|
impl ConnectorEvent {
|
||||||
@ -33,6 +34,7 @@ impl ConnectorEvent {
|
|||||||
merchant_id: String,
|
merchant_id: String,
|
||||||
request_id: Option<&RequestId>,
|
request_id: Option<&RequestId>,
|
||||||
latency: u128,
|
latency: u128,
|
||||||
|
status_code: u16,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
connector_name,
|
connector_name,
|
||||||
@ -52,6 +54,7 @@ impl ConnectorEvent {
|
|||||||
.map(|i| i.as_hyphenated().to_string())
|
.map(|i| i.as_hyphenated().to_string())
|
||||||
.unwrap_or("NO_REQUEST_ID".to_string()),
|
.unwrap_or("NO_REQUEST_ID".to_string()),
|
||||||
latency,
|
latency,
|
||||||
|
status_code,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -372,7 +372,13 @@ where
|
|||||||
let response = call_connector_api(state, request).await;
|
let response = call_connector_api(state, request).await;
|
||||||
let external_latency = current_time.elapsed().as_millis();
|
let external_latency = current_time.elapsed().as_millis();
|
||||||
logger::debug!(connector_response=?response);
|
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(
|
let connector_event = ConnectorEvent::new(
|
||||||
req.connector.clone(),
|
req.connector.clone(),
|
||||||
std::any::type_name::<T>(),
|
std::any::type_name::<T>(),
|
||||||
@ -394,6 +400,7 @@ where
|
|||||||
req.merchant_id.clone(),
|
req.merchant_id.clone(),
|
||||||
state.request_id.as_ref(),
|
state.request_id.as_ref(),
|
||||||
external_latency,
|
external_latency,
|
||||||
|
status_code,
|
||||||
);
|
);
|
||||||
|
|
||||||
match connector_event.try_into() {
|
match connector_event.try_into() {
|
||||||
|
|||||||
Reference in New Issue
Block a user