Skip to content

refactor(euclid): refactor logs for evaluation of equality for dynamic routing evaluate response #8834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions crates/router/src/core/payments/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ use rand::SeedableRng;
use router_env::{instrument, tracing};
use rustc_hash::FxHashMap;
use storage_impl::redis::cache::{CacheKey, CGRAPH_CACHE, ROUTING_CACHE};
use utils::perform_decision_euclid_routing;

#[cfg(feature = "v2")]
use crate::core::admin;
Expand Down Expand Up @@ -492,33 +491,24 @@ pub async fn perform_static_routing_v1(
.to_string(),
};

let de_euclid_connectors = if state.conf.open_router.static_routing_enabled {
let routing_events_wrapper = utils::RoutingEventsWrapper::new(
state.tenant.tenant_id.clone(),
state.request_id,
payment_id,
business_profile.get_id().to_owned(),
business_profile.merchant_id.to_owned(),
"DecisionEngine: Euclid Static Routing".to_string(),
None,
true,
false,
);

perform_decision_euclid_routing(
// Decision of de-routing is stored
let de_evaluated_connector = if !state.conf.open_router.static_routing_enabled {
logger::debug!("decision_engine_euclid: decision_engine routing not enabled");
Vec::default()
} else {
utils::decision_engine_routing(
state,
backend_input.clone(),
business_profile.get_id().get_string_repr().to_string(),
routing_events_wrapper,
business_profile,
payment_id,
get_merchant_fallback_config().await?,
)
.await
.map_err(|e|
// errors are ignored as this is just for diff checking as of now (optional flow).
logger::error!(decision_engine_euclid_evaluate_error=?e, "decision_engine_euclid: error in evaluation of rule")
).unwrap_or_default()
} else {
Vec::default()
)
.unwrap_or_default()
};

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

// Results are logged for diff(between legacy and decision_engine's euclid) and have parameters as:
// is_equal: verifies all output are matching in order,
// is_equal_length: matches length of both outputs (useful for verifying volume based routing
// results)
// de_response: response from the decision_engine's euclid
// hs_response: response from legacy_euclid
utils::compare_and_log_result(
de_euclid_connectors.clone(),
de_evaluated_connector.clone(),
routable_connectors.clone(),
"evaluate_routing".to_string(),
);
Expand All @@ -549,7 +545,7 @@ pub async fn perform_static_routing_v1(
state,
business_profile,
routable_connectors,
de_euclid_connectors,
de_evaluated_connector,
)
.await,
routing_approach,
Expand Down
Loading
Loading