diff --git a/src/euclid/handlers/routing_rules.rs b/src/euclid/handlers/routing_rules.rs index d40409d1..b101f1a4 100644 --- a/src/euclid/handlers/routing_rules.rs +++ b/src/euclid/handlers/routing_rules.rs @@ -55,7 +55,7 @@ pub async fn config_sr_dimentions( if !invalid_dimensions.is_empty() { metrics::API_REQUEST_COUNTER - .with_label_values(&["config_sr_dimentions", "failure"]) + .with_label_values(&["config_sr_dimentions", "failure", "400"]) .inc(); timer.observe_duration(); @@ -107,7 +107,7 @@ pub async fn config_sr_dimentions( if let Err(_) = result { metrics::API_REQUEST_COUNTER - .with_label_values(&["config_sr_dimentions", "failure"]) + .with_label_values(&["config_sr_dimentions", "failure", "500"]) .inc(); timer.observe_duration(); logger::error!( @@ -117,7 +117,7 @@ pub async fn config_sr_dimentions( return Err(ContainerError::from(EuclidErrors::StorageError)); } metrics::API_REQUEST_COUNTER - .with_label_values(&["config_sr_dimentions", "success"]) + .with_label_values(&["config_sr_dimentions", "success", "200"]) .inc(); timer.observe_duration(); logger::info!( @@ -154,7 +154,7 @@ pub async fn routing_create( logger::error!("Routing rule validation failed with errors: {detailed_error}"); metrics::API_REQUEST_COUNTER - .with_label_values(&["routing_create", "failure"]) + .with_label_values(&["routing_create", "failure", "400"]) .inc(); timer.observe_duration(); return Err(ContainerError::new_with_status_code_and_payload( @@ -169,7 +169,7 @@ pub async fn routing_create( } } metrics::API_REQUEST_COUNTER - .with_label_values(&["routing_create", "failure"]) + .with_label_values(&["routing_create", "failure", "400"]) .inc(); timer.observe_duration(); return Err(err.into()); @@ -218,7 +218,7 @@ pub async fn routing_create( logger::info!("Response: {response:?}"); metrics::API_REQUEST_COUNTER - .with_label_values(&["routing_create", "success"]) + .with_label_values(&["routing_create", "success", "200"]) .inc(); timer.observe_duration(); Ok(Json(response)) @@ -269,7 +269,7 @@ pub async fn routing_evaluate( Ok(mapper) => mapper.routing_algorithm_id, Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "404"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -287,7 +287,7 @@ pub async fn routing_evaluate( Ok(config) => config, Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "500"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -299,7 +299,7 @@ pub async fn routing_evaluate( && value.as_ref().is_some_and(|val| !val.is_metadata()) { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "400"]) .inc(); timer.observe_duration(); return Err(EuclidErrors::InvalidRequestParameter(key.clone()).into()); @@ -310,7 +310,7 @@ pub async fn routing_evaluate( if let Some(Some(ValueType::EnumVariant(value))) = parameters.get(key) { if !is_valid_enum_value(routing_config, key, value) { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "400"]) .inc(); timer.observe_duration(); return Err(EuclidErrors::InvalidRequest(format!( @@ -321,7 +321,7 @@ pub async fn routing_evaluate( } } else { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "400"]) .inc(); timer.observe_duration(); return Err(EuclidErrors::InvalidRequest(format!( @@ -353,7 +353,7 @@ pub async fn routing_evaluate( Ok(algo) => algo, Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "500"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -373,7 +373,7 @@ pub async fn routing_evaluate( Ok(data) => data, Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "400"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -393,7 +393,7 @@ pub async fn routing_evaluate( Ok((_, eval)) => (out_enum, eval, Some("straight_through_rule".into())), Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "500"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -412,7 +412,7 @@ pub async fn routing_evaluate( Ok((_, eval)) => (out_enum, eval, Some("priority_rule".into())), Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "500"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -431,7 +431,7 @@ pub async fn routing_evaluate( Ok((_, eval)) => (out_enum, eval, Some("volume_split_rule".into())), Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "500"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -465,7 +465,7 @@ pub async fn routing_evaluate( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "failure"]) + .with_label_values(&["routing_evaluate", "failure", "400"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -495,7 +495,7 @@ pub async fn routing_evaluate( logger::info!("Response: {response:?}"); API_REQUEST_COUNTER - .with_label_values(&["routing_evaluate", "success"]) + .with_label_values(&["routing_evaluate", "success", "200"]) .inc(); timer.observe_duration(); Ok(Json(response)) @@ -526,7 +526,7 @@ pub async fn activate_routing_rule( Ok(connection) => connection, Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["activate_routing_rule", "failure"]) + .with_label_values(&["activate_routing_rule", "failure", "500"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -546,7 +546,7 @@ pub async fn activate_routing_rule( Ok(algorithm) => algorithm.algorithm_for, Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["activate_routing_rule", "failure"]) + .with_label_values(&["activate_routing_rule", "failure", "404"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -589,14 +589,14 @@ pub async fn activate_routing_rule( { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["activate_routing_rule", "success"]) + .with_label_values(&["activate_routing_rule", "success", "200"]) .inc(); timer.observe_duration(); return Ok(()); } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["activate_routing_rule", "failure"]) + .with_label_values(&["activate_routing_rule", "failure", "500"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -604,7 +604,7 @@ pub async fn activate_routing_rule( } } API_REQUEST_COUNTER - .with_label_values(&["activate_routing_rule", "success"]) + .with_label_values(&["activate_routing_rule", "success", "200"]) .inc(); timer.observe_duration(); return Ok(()); @@ -623,14 +623,14 @@ pub async fn activate_routing_rule( { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["activate_routing_rule", "success"]) + .with_label_values(&["activate_routing_rule", "success", "200"]) .inc(); timer.observe_duration(); Ok(()) } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["activate_routing_rule", "failure"]) + .with_label_values(&["activate_routing_rule", "failure", "500"]) .inc(); timer.observe_duration(); Err(e.into()) @@ -660,14 +660,14 @@ pub async fn list_all_routing_algorithm_id( { Ok(algorithms) => { API_REQUEST_COUNTER - .with_label_values(&["list_all_routing_algorithm_id", "success"]) + .with_label_values(&["list_all_routing_algorithm_id", "success", "200"]) .inc(); timer.observe_duration(); Ok(Json(algorithms.into_iter().map(Into::into).collect())) } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["list_all_routing_algorithm_id", "failure"]) + .with_label_values(&["list_all_routing_algorithm_id", "failure", "500"]) .inc(); timer.observe_duration(); Err(e.into()) @@ -699,7 +699,7 @@ pub async fn list_active_routing_algorithm( Ok(mappings) => mappings, Err(e) => { metrics::API_REQUEST_COUNTER - .with_label_values(&["list_active_routing_algorithm", "failure"]) + .with_label_values(&["list_active_routing_algorithm", "failure", "404"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -722,7 +722,7 @@ pub async fn list_active_routing_algorithm( Ok(algos) => algos, Err(e) => { metrics::API_REQUEST_COUNTER - .with_label_values(&["list_active_routing_algorithm", "failure"]) + .with_label_values(&["list_active_routing_algorithm", "failure", "500"]) .inc(); timer.observe_duration(); return Err(e.into()); @@ -734,7 +734,7 @@ pub async fn list_active_routing_algorithm( .collect(); API_REQUEST_COUNTER - .with_label_values(&["list_active_routing_algorithm", "success"]) + .with_label_values(&["list_active_routing_algorithm", "success", "200"]) .inc(); timer.observe_duration(); diff --git a/src/metrics.rs b/src/metrics.rs index 2ce6aeaf..76f4d7fd 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -18,7 +18,7 @@ lazy_static! { pub static ref API_REQUEST_COUNTER: IntCounterVec = register_int_counter_vec!( "api_requests_by_status", "Count of API requests grouped by endpoint and result", - &["endpoint", "status"] + &["endpoint", "status", "status_code"] ).unwrap(); /// Latency of API calls grouped by endpoint diff --git a/src/routes/decide_gateway.rs b/src/routes/decide_gateway.rs index 8b79d23b..cf0e61d4 100644 --- a/src/routes/decide_gateway.rs +++ b/src/routes/decide_gateway.rs @@ -54,7 +54,7 @@ pub async fn decide_gateway( Err(e) => { logger::debug!(tag = "DecideGateway", "Error: {:?}", e); metrics::API_REQUEST_COUNTER - .with_label_values(&["decide_gateway", "failure"]) + .with_label_values(&["decide_gateway", "failure", "400"]) .inc(); timer.observe_duration(); return Err(ErrorResponse { @@ -80,14 +80,14 @@ pub async fn decide_gateway( Ok(payload) => match deciderFullPayloadHSFunction(payload).await { Ok(decided_gateway) => { metrics::API_REQUEST_COUNTER - .with_label_values(&["decide_gateway", "success"]) + .with_label_values(&["decide_gateway", "success", "200"]) .inc(); Ok(decided_gateway) } Err(e) => { logger::debug!(tag = "DecideGateway", "Error: {:?}", e); metrics::API_REQUEST_COUNTER - .with_label_values(&["decide_gateway", "failure"]) + .with_label_values(&["decide_gateway", "failure", "400"]) .inc(); Err(e) } @@ -95,7 +95,7 @@ pub async fn decide_gateway( Err(e) => { logger::debug!(tag = "DecideGateway", "Error: {:?}", e); metrics::API_REQUEST_COUNTER - .with_label_values(&["decide_gateway", "failure"]) + .with_label_values(&["decide_gateway", "failure", "400"]) .inc(); Err(ErrorResponse { status: "400".to_string(), diff --git a/src/routes/decision_gateway.rs b/src/routes/decision_gateway.rs index 73eb8256..4c8ec824 100644 --- a/src/routes/decision_gateway.rs +++ b/src/routes/decision_gateway.rs @@ -116,7 +116,7 @@ where ); API_REQUEST_COUNTER - .with_label_values(&["decision_gateway", "failure"]) + .with_label_values(&["decision_gateway", "failure", "400"]) .inc(); timer.observe_duration(); @@ -176,7 +176,7 @@ where ); API_REQUEST_COUNTER - .with_label_values(&["decision_gateway", "success"]) + .with_label_values(&["decision_gateway", "success", "200"]) .inc(); Ok(response) } @@ -205,9 +205,9 @@ where category = "INCOMING_API", "Error occurred while processing decider function" ); - + let status_code = e.status.clone(); API_REQUEST_COUNTER - .with_label_values(&["decision_gateway", "failure"]) + .with_label_values(&["decision_gateway", "failure", &status_code]) .inc(); Err(e) } @@ -260,7 +260,7 @@ where ); API_REQUEST_COUNTER - .with_label_values(&["decision_gateway", "failure"]) + .with_label_values(&["decision_gateway", "failure", "400"]) .inc(); timer.observe_duration(); Err(error_response) diff --git a/src/routes/merchant_account_config.rs b/src/routes/merchant_account_config.rs index af7aedf3..45d1b94e 100644 --- a/src/routes/merchant_account_config.rs +++ b/src/routes/merchant_account_config.rs @@ -30,13 +30,13 @@ pub async fn get_merchant_config( let response = match result { Ok(merchant_account) => { API_REQUEST_COUNTER - .with_label_values(&["merchant_account_get", "success"]) + .with_label_values(&["merchant_account_get", "success", "200"]) .inc(); Ok(Json(merchant_account.into())) } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["merchant_account_get", "failure"]) + .with_label_values(&["merchant_account_get", "failure", "404"]) .inc(); Err(e.into()) } @@ -68,7 +68,7 @@ pub async fn create_merchant_config( if merchant_account.is_some() { API_REQUEST_COUNTER - .with_label_values(&["merchant_account_create", "failure"]) + .with_label_values(&["merchant_account_create", "failure", "409"]) .inc(); timer.observe_duration(); return Err(error::MerchantAccountConfigurationError::MerchantAlreadyExists.into()); @@ -82,13 +82,13 @@ pub async fn create_merchant_config( Ok(_) => { logger::debug!("Merchant account configuration created successfully"); API_REQUEST_COUNTER - .with_label_values(&["merchant_account_create", "success"]) + .with_label_values(&["merchant_account_create", "success", "200"]) .inc(); Ok(Json("Merchant account created successfully".to_string())) } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["merchant_account_create", "failure"]) + .with_label_values(&["merchant_account_create", "failure", "500"]) .inc(); Err(e.into()) } @@ -122,13 +122,13 @@ pub async fn delete_merchant_config( let response = match result { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["merchant_account_delete", "success"]) + .with_label_values(&["merchant_account_delete", "success", "200"]) .inc(); Ok(Json("Merchant account deleted successfully".to_string())) } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["merchant_account_delete", "failure"]) + .with_label_values(&["merchant_account_delete", "failure", "500"]) .inc(); Err(e.into()) } diff --git a/src/routes/rule_configuration.rs b/src/routes/rule_configuration.rs index 51b1d9f1..2243e5b6 100644 --- a/src/routes/rule_configuration.rs +++ b/src/routes/rule_configuration.rs @@ -24,7 +24,7 @@ pub async fn create_rule_config( .is_none() { API_REQUEST_COUNTER - .with_label_values(&["create_rule_config", "failure"]) + .with_label_values(&["create_rule_config", "failure", "404"]) .inc(); timer.observe_duration(); return Err(error::RuleConfigurationError::MerchantNotFound.into()); @@ -44,7 +44,7 @@ pub async fn create_rule_config( match result { Some(_) => { API_REQUEST_COUNTER - .with_label_values(&["sr_create_rule_config", "failure"]) + .with_label_values(&["sr_create_rule_config", "failure", "409"]) .inc(); Err(error::RuleConfigurationError::ConfigurationAlreadyExists.into()) } @@ -55,7 +55,7 @@ pub async fn create_rule_config( { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["sr_create_rule_config", "success"]) + .with_label_values(&["sr_create_rule_config", "success", "200"]) .inc(); Ok(Json( "Success Rate Configuration created successfully".to_string(), @@ -63,7 +63,7 @@ pub async fn create_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["sr_create_rule_config", "failure"]) + .with_label_values(&["sr_create_rule_config", "failure", "500"]) .inc(); Err(e.into()) } @@ -84,7 +84,7 @@ pub async fn create_rule_config( match result { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["elimination_create_rule_config", "success"]) + .with_label_values(&["elimination_create_rule_config", "success", "200"]) .inc(); Ok(Json( "Elimination Configuration created successfully".to_string(), @@ -92,7 +92,7 @@ pub async fn create_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["elimination_create_rule_config", "failure"]) + .with_label_values(&["elimination_create_rule_config", "failure", "500"]) .inc(); Err(e.into()) } @@ -111,7 +111,7 @@ pub async fn create_rule_config( match result { Some(_) => { API_REQUEST_COUNTER - .with_label_values(&["debit_routing_create_rule_config", "failure"]) + .with_label_values(&["debit_routing_create_rule_config", "failure", "409"]) .inc(); Err(error::RuleConfigurationError::ConfigurationAlreadyExists.into()) } @@ -122,7 +122,11 @@ pub async fn create_rule_config( { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["debit_routing_create_rule_config", "success"]) + .with_label_values(&[ + "debit_routing_create_rule_config", + "success", + "200", + ]) .inc(); Ok(Json( "Debit Routing Configuration created successfully".to_string(), @@ -130,7 +134,11 @@ pub async fn create_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["debit_routing_create_rule_config", "failure"]) + .with_label_values(&[ + "debit_routing_create_rule_config", + "failure", + "500", + ]) .inc(); Err(e.into()) } @@ -183,7 +191,7 @@ pub async fn get_rule_config( match result { Ok(success_rate_config) => { API_REQUEST_COUNTER - .with_label_values(&["sr_get_rule_config", "success"]) + .with_label_values(&["sr_get_rule_config", "success", "200"]) .inc(); Ok(Json(types::routing_configuration::RoutingRule { merchant_id: mid, @@ -194,7 +202,7 @@ pub async fn get_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["sr_get_rule_config", "failure"]) + .with_label_values(&["sr_get_rule_config", "failure", "500"]) .inc(); Err(e.into()) } @@ -215,7 +223,7 @@ pub async fn get_rule_config( match result { Ok(elimination_config) => { API_REQUEST_COUNTER - .with_label_values(&["elimination_get_rule_config", "success"]) + .with_label_values(&["elimination_get_rule_config", "success", "200"]) .inc(); Ok(Json(types::routing_configuration::RoutingRule { merchant_id: mid, @@ -226,7 +234,7 @@ pub async fn get_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["elimination_get_rule_config", "failure"]) + .with_label_values(&["elimination_get_rule_config", "failure", "500"]) .inc(); Err(e.into()) } @@ -250,7 +258,7 @@ pub async fn get_rule_config( match result { Ok(debit_routing_config) => { API_REQUEST_COUNTER - .with_label_values(&["debit_routing_get_rule_config", "success"]) + .with_label_values(&["debit_routing_get_rule_config", "success", "200"]) .inc(); Ok(Json(types::routing_configuration::RoutingRule { merchant_id: mid, @@ -261,7 +269,7 @@ pub async fn get_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["debit_routing_get_rule_config", "failure"]) + .with_label_values(&["debit_routing_get_rule_config", "failure", "500"]) .inc(); Err(e.into()) } @@ -303,7 +311,7 @@ pub async fn update_rule_config( match result { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["sr_update_rule_config", "success"]) + .with_label_values(&["sr_update_rule_config", "success", "200"]) .inc(); Ok(Json( "Success Rate Configuration updated successfully".to_string(), @@ -311,7 +319,7 @@ pub async fn update_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["sr_update_rule_config", "failure"]) + .with_label_values(&["sr_update_rule_config", "failure", "500"]) .inc(); Err(e.into()) } @@ -330,7 +338,7 @@ pub async fn update_rule_config( match result { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["elimination_update_rule_config", "success"]) + .with_label_values(&["elimination_update_rule_config", "success", "200"]) .inc(); Ok(Json( "Elimination Configuration created successfully".to_string(), @@ -338,7 +346,7 @@ pub async fn update_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["elimination_update_rule_config", "failure"]) + .with_label_values(&["elimination_update_rule_config", "failure", "500"]) .inc(); Err(e.into()) } @@ -356,7 +364,7 @@ pub async fn update_rule_config( match result { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["debit_routing_update_rule_config", "success"]) + .with_label_values(&["debit_routing_update_rule_config", "success", "200"]) .inc(); Ok(Json( "Debit Routing Configuration updated successfully".to_string(), @@ -364,7 +372,7 @@ pub async fn update_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["debit_routing_update_rule_config", "failure"]) + .with_label_values(&["debit_routing_update_rule_config", "failure", "500"]) .inc(); Err(e.into()) } @@ -403,7 +411,7 @@ pub async fn delete_rule_config( match result { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["sr_delete_rule_config", "success"]) + .with_label_values(&["sr_delete_rule_config", "success", "200"]) .inc(); Ok(Json( "Success Rate Configuration deleted successfully".to_string(), @@ -411,7 +419,7 @@ pub async fn delete_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["sr_delete_rule_config", "failure"]) + .with_label_values(&["sr_delete_rule_config", "failure", "500"]) .inc(); Err(e.into()) } @@ -428,7 +436,7 @@ pub async fn delete_rule_config( match result { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["elimination_delete_rule_config", "success"]) + .with_label_values(&["elimination_delete_rule_config", "success", "200"]) .inc(); Ok(Json( "Elimination Configuration deleted successfully".to_string(), @@ -436,7 +444,7 @@ pub async fn delete_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["elimination_delete_rule_config", "failure"]) + .with_label_values(&["elimination_delete_rule_config", "failure", "500"]) .inc(); Err(e.into()) } @@ -451,7 +459,7 @@ pub async fn delete_rule_config( match result { Ok(_) => { API_REQUEST_COUNTER - .with_label_values(&["debit_routing_delete_rule_config", "success"]) + .with_label_values(&["debit_routing_delete_rule_config", "success", "200"]) .inc(); Ok(Json( "Debit Routing Configuration deleted successfully".to_string(), @@ -459,7 +467,7 @@ pub async fn delete_rule_config( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["debit_routing_delete_rule_config", "failure"]) + .with_label_values(&["debit_routing_delete_rule_config", "failure", "500"]) .inc(); Err(e.into()) } diff --git a/src/routes/update_gateway_score.rs b/src/routes/update_gateway_score.rs index b2405f62..ff659de3 100644 --- a/src/routes/update_gateway_score.rs +++ b/src/routes/update_gateway_score.rs @@ -51,7 +51,7 @@ pub async fn update_gateway_score( Err(e) => { crate::logger::debug!(tag = "UpdateGatewayScore", "Error: {:?}", e); API_REQUEST_COUNTER - .with_label_values(&["update_gateway_score", "failure"]) + .with_label_values(&["update_gateway_score", "failure", "400"]) .inc(); timer.observe_duration(); return Err(ErrorResponse { @@ -79,7 +79,7 @@ pub async fn update_gateway_score( match result { Ok(success) => { API_REQUEST_COUNTER - .with_label_values(&["update_gateway_score", "success"]) + .with_label_values(&["update_gateway_score", "success", "200"]) .inc(); timer.observe_duration(); Ok(Json(UpdateScoreResponse { @@ -88,7 +88,7 @@ pub async fn update_gateway_score( } Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["update_gateway_score", "failure"]) + .with_label_values(&["update_gateway_score", "failure", "400"]) .inc(); timer.observe_duration(); println!("Error: {:?}", e); @@ -99,7 +99,7 @@ pub async fn update_gateway_score( Err(e) => { crate::logger::debug!(tag = "UpdateScoreRequest", "Error: {:?}", e); API_REQUEST_COUNTER - .with_label_values(&["update_gateway_score", "failure"]) + .with_label_values(&["update_gateway_score", "failure", "400"]) .inc(); timer.observe_duration(); return Err(ErrorResponse { diff --git a/src/routes/update_score.rs b/src/routes/update_score.rs index e371f1c3..e72f3573 100644 --- a/src/routes/update_score.rs +++ b/src/routes/update_score.rs @@ -2,7 +2,7 @@ use crate::decider::gatewaydecider::types::{ErrorResponse, UnifiedError}; use crate::feedback::gateway_scoring_service::check_and_update_gateway_score; use crate::metrics::{API_LATENCY_HISTOGRAM, API_REQUEST_COUNTER, API_REQUEST_TOTAL_COUNTER}; use crate::types::card::txn_card_info::TxnCardInfo; -use crate::types::txn_details::types::{TxnDetail, TransactionLatency}; +use crate::types::txn_details::types::{TransactionLatency, TxnDetail}; use crate::{logger, metrics}; use axum::body::to_bytes; use cpu_time::ProcessTime; @@ -49,7 +49,7 @@ pub async fn update_score( Ok(bytes) => bytes, Err(e) => { API_REQUEST_COUNTER - .with_label_values(&["update_score", "failure"]) + .with_label_values(&["update_score", "failure", "400"]) .inc(); timer.observe_duration(); let error_response = ErrorResponse { @@ -149,7 +149,7 @@ pub async fn update_score( ); API_REQUEST_COUNTER - .with_label_values(&["update_score", "failure"]) + .with_label_values(&["update_score", "failure", "400"]) .inc(); timer.observe_duration(); return Err(error_response); @@ -172,7 +172,7 @@ pub async fn update_score( log_message.as_str(), enforce_failure, gateway_reference_id, - txn_latency + txn_latency, ) .await; @@ -202,7 +202,7 @@ pub async fn update_score( ); API_REQUEST_COUNTER - .with_label_values(&["update_score", "success"]) + .with_label_values(&["update_score", "success", "200"]) .inc(); timer.observe_duration(); return Ok("Success"); @@ -249,7 +249,7 @@ pub async fn update_score( ); API_REQUEST_COUNTER - .with_label_values(&["update_score", "failure"]) + .with_label_values(&["update_score", "failure", "400"]) .inc(); timer.observe_duration(); return Err(error_response);