Skip to content

Commit

Permalink
refactor(routing): Added more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak1799 committed Feb 1, 2024
1 parent a51f873 commit 9475e7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2599,6 +2599,10 @@ where
.attach_printable("Failed execution of straight through routing")?;

logger::debug!(routable_connector_choice=?connectors, "Routing: Initiating Straight through routing (from request) with list of connectors: ");
tracing::Span::current().record(
"Straight_through_routing_connectors",
format!("{:?}", connectors),
);

if check_eligibility {
connectors = routing::perform_eligibility_analysis_with_fallback(
Expand Down Expand Up @@ -2660,6 +2664,10 @@ where
.attach_printable("Failed execution of straight through routing")?;

logger::debug!(routable_connector_choice=?connectors, "Routing: Initiating Straight through routing (fallback to DB) with list of connectors: ");
tracing::Span::current().record(
"Straight_through_routing_connectors_fallback",
format!("{:?}", connectors),
);

if check_eligibility {
connectors = routing::perform_eligibility_analysis_with_fallback(
Expand Down
10 changes: 10 additions & 0 deletions crates/router/src/core/payments/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use rand::{
distributions::{self, Distribution},
SeedableRng,
};
use router_env::{instrument, tracing};
use rustc_hash::FxHashMap;

#[cfg(not(feature = "business_profile_routing"))]
Expand Down Expand Up @@ -675,6 +676,7 @@ pub async fn perform_fallback_routing<F: Clone>(
.await
}

#[instrument(skip_all, fields(selected_connectors, final_selected_connectors))]
pub async fn perform_eligibility_analysis_with_fallback<F: Clone>(
state: &AppState,
key_store: &domain::MerchantKeyStore,
Expand Down Expand Up @@ -703,6 +705,10 @@ pub async fn perform_eligibility_analysis_with_fallback<F: Clone>(
.map(|item| item.connector)
.collect::<Vec<_>>();
logger::debug!(final_selected_connectors_before_fallback=?selected_connectors, "List of final selected connectors before fallback");
tracing::Span::current().record(
"selected_connectors_before_fallback",
format!("{:?}", selected_connectors),
);

let fallback_selection = perform_fallback_routing(
state,
Expand Down Expand Up @@ -732,6 +738,10 @@ pub async fn perform_eligibility_analysis_with_fallback<F: Clone>(
.collect::<Vec<_>>();

logger::debug!(final_selected_connectors_for_routing=?final_selected_connectors, "List of final selected connectors for routing after fallback");
tracing::Span::current().record(
"selected_connectors_after_fallback",
format!("{:?}", final_selected_connectors),
);

Ok(final_selection)
}
Expand Down

0 comments on commit 9475e7d

Please sign in to comment.