Skip to content

Commit ef27ac5

Browse files
refactor(euclid): refactor logs for evaluation of equality for dynamic routing evaluate response (#8834)
1 parent 2d3abd7 commit ef27ac5

File tree

2 files changed

+311
-38
lines changed

2 files changed

+311
-38
lines changed

crates/router/src/core/payments/routing.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ use rand::SeedableRng;
4848
use router_env::{instrument, tracing};
4949
use rustc_hash::FxHashMap;
5050
use storage_impl::redis::cache::{CacheKey, CGRAPH_CACHE, ROUTING_CACHE};
51-
use utils::perform_decision_euclid_routing;
5251

5352
#[cfg(feature = "v2")]
5453
use crate::core::admin;
@@ -492,33 +491,24 @@ pub async fn perform_static_routing_v1(
492491
.to_string(),
493492
};
494493

495-
let de_euclid_connectors = if state.conf.open_router.static_routing_enabled {
496-
let routing_events_wrapper = utils::RoutingEventsWrapper::new(
497-
state.tenant.tenant_id.clone(),
498-
state.request_id,
499-
payment_id,
500-
business_profile.get_id().to_owned(),
501-
business_profile.merchant_id.to_owned(),
502-
"DecisionEngine: Euclid Static Routing".to_string(),
503-
None,
504-
true,
505-
false,
506-
);
507-
508-
perform_decision_euclid_routing(
494+
// Decision of de-routing is stored
495+
let de_evaluated_connector = if !state.conf.open_router.static_routing_enabled {
496+
logger::debug!("decision_engine_euclid: decision_engine routing not enabled");
497+
Vec::default()
498+
} else {
499+
utils::decision_engine_routing(
509500
state,
510501
backend_input.clone(),
511-
business_profile.get_id().get_string_repr().to_string(),
512-
routing_events_wrapper,
502+
business_profile,
503+
payment_id,
513504
get_merchant_fallback_config().await?,
514505
)
515506
.await
516507
.map_err(|e|
517508
// errors are ignored as this is just for diff checking as of now (optional flow).
518509
logger::error!(decision_engine_euclid_evaluate_error=?e, "decision_engine_euclid: error in evaluation of rule")
519-
).unwrap_or_default()
520-
} else {
521-
Vec::default()
510+
)
511+
.unwrap_or_default()
522512
};
523513

524514
let (routable_connectors, routing_approach) = match cached_algorithm.as_ref() {
@@ -538,8 +528,14 @@ pub async fn perform_static_routing_v1(
538528
),
539529
};
540530

531+
// Results are logged for diff(between legacy and decision_engine's euclid) and have parameters as:
532+
// is_equal: verifies all output are matching in order,
533+
// is_equal_length: matches length of both outputs (useful for verifying volume based routing
534+
// results)
535+
// de_response: response from the decision_engine's euclid
536+
// hs_response: response from legacy_euclid
541537
utils::compare_and_log_result(
542-
de_euclid_connectors.clone(),
538+
de_evaluated_connector.clone(),
543539
routable_connectors.clone(),
544540
"evaluate_routing".to_string(),
545541
);
@@ -549,7 +545,7 @@ pub async fn perform_static_routing_v1(
549545
state,
550546
business_profile,
551547
routable_connectors,
552-
de_euclid_connectors,
548+
de_evaluated_connector,
553549
)
554550
.await,
555551
routing_approach,

0 commit comments

Comments
 (0)