Skip to content

Commit

Permalink
add that metric to get locker sucessful response count
Browse files Browse the repository at this point in the history
  • Loading branch information
ShankarSinghC committed Nov 29, 2023
1 parent e2a4f43 commit fd514d0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
46 changes: 44 additions & 2 deletions crates/router/src/core/payment_methods/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,13 @@ pub async fn add_card_to_locker(
)
.await
.map_err(|error| {
metrics::CARD_LOCKER_FAILURES.add(&metrics::CONTEXT, 1, &[]);
metrics::CARD_LOCKER_FAILURES.add(
&metrics::CONTEXT,
1,
&[router_env::opentelemetry::KeyValue::new(
"locker", "basilisk",
)],
);
error
})
},
Expand All @@ -250,7 +256,11 @@ pub async fn add_card_to_locker(
)
.await
.map_err(|error| {
metrics::CARD_LOCKER_FAILURES.add(&metrics::CONTEXT, 1, &[]);
metrics::CARD_LOCKER_FAILURES.add(
&metrics::CONTEXT,
1,
&[router_env::opentelemetry::KeyValue::new("locker", "rust")],
);
error
})
},
Expand All @@ -262,10 +272,26 @@ pub async fn add_card_to_locker(
match add_card_to_rs_resp {
value @ Ok(_) => {
logger::debug!("card added to rust locker");
let _ = &metrics::CARD_LOCKER_SUCCESSFUL_RESPONSE.add(
&metrics::CONTEXT,
1,
&[
router_env::opentelemetry::KeyValue::new("locker", "rust"),
router_env::opentelemetry::KeyValue::new("operation", "add"),
],
);
value
}
Err(err) => {
logger::debug!(error =? err,"failed to add card to rust locker");
let _ = &metrics::CARD_LOCKER_SUCCESSFUL_RESPONSE.add(
&metrics::CONTEXT,
1,
&[
router_env::opentelemetry::KeyValue::new("locker", "basilisk"),
router_env::opentelemetry::KeyValue::new("operation", "add"),
],
);
Ok(add_card_to_hs_resp)
}
}
Expand Down Expand Up @@ -337,10 +363,26 @@ pub async fn get_card_from_locker(
.await
.map(|inner_card| {
logger::debug!("card retrieved from basilisk locker");
let _ = &metrics::CARD_LOCKER_SUCCESSFUL_RESPONSE.add(
&metrics::CONTEXT,
1,
&[
router_env::opentelemetry::KeyValue::new("locker", "basilisk"),
router_env::opentelemetry::KeyValue::new("operation", "get"),
],
);
inner_card
}),
Ok(_) => {
logger::debug!("card retrieved from rust locker");
let _ = &metrics::CARD_LOCKER_SUCCESSFUL_RESPONSE.add(
&metrics::CONTEXT,
1,
&[
router_env::opentelemetry::KeyValue::new("locker", "rust"),
router_env::opentelemetry::KeyValue::new("operation", "add"),
],
);
get_card_from_rs_locker_resp
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/routes/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ counter_metric!(CONNECTOR_HTTP_STATUS_CODE_5XX_COUNT, GLOBAL_METER);

// Service Level
counter_metric!(CARD_LOCKER_FAILURES, GLOBAL_METER);
counter_metric!(CARD_LOCKER_SUCCESSFUL_RESPONSE, GLOBAL_METER);
counter_metric!(TEMP_LOCKER_FAILURES, GLOBAL_METER);
histogram_metric!(CARD_ADD_TIME, GLOBAL_METER);
histogram_metric!(CARD_GET_TIME, GLOBAL_METER);
Expand Down

0 comments on commit fd514d0

Please sign in to comment.