refactor: add instrument to trackers for payment_confirm (#2164)

This commit is contained in:
Kritik Modi
2023-09-14 19:23:50 +05:30
committed by GitHub
parent fb1760b1d8
commit c8049542de
12 changed files with 49 additions and 0 deletions

View File

@ -548,6 +548,7 @@ impl PaymentRedirectFlow for PaymentRedirectSync {
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
#[instrument(skip_all)]
pub async fn call_connector_service<F, RouterDReq, ApiRequest>( pub async fn call_connector_service<F, RouterDReq, ApiRequest>(
state: &AppState, state: &AppState,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
@ -1038,6 +1039,7 @@ pub fn is_preprocessing_required_for_wallets(connector_name: String) -> bool {
connector_name == *"trustpay" || connector_name == *"payme" connector_name == *"trustpay" || connector_name == *"payme"
} }
#[instrument(skip_all)]
pub async fn construct_profile_id_and_get_mca<'a, F>( pub async fn construct_profile_id_and_get_mca<'a, F>(
state: &'a AppState, state: &'a AppState,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,

View File

@ -103,6 +103,7 @@ pub fn filter_mca_based_on_business_profile(
} }
} }
#[instrument(skip_all)]
pub async fn get_address_for_payment_request( pub async fn get_address_for_payment_request(
db: &dyn StorageInterface, db: &dyn StorageInterface,
req_address: Option<&api::Address>, req_address: Option<&api::Address>,
@ -975,6 +976,7 @@ pub fn validate_customer_details_in_request(
/// Get the customer details from customer field if present /// Get the customer details from customer field if present
/// or from the individual fields in `PaymentsRequest` /// or from the individual fields in `PaymentsRequest`
#[instrument(skip_all)]
pub fn get_customer_details_from_request( pub fn get_customer_details_from_request(
request: &api_models::payments::PaymentsRequest, request: &api_models::payments::PaymentsRequest,
) -> CustomerDetails { ) -> CustomerDetails {
@ -2086,6 +2088,7 @@ pub(crate) fn validate_payment_status_against_not_allowed_statuses(
}) })
} }
#[instrument(skip_all)]
pub(crate) fn validate_pm_or_token_given( pub(crate) fn validate_pm_or_token_given(
payment_method: &Option<api_enums::PaymentMethod>, payment_method: &Option<api_enums::PaymentMethod>,
payment_method_data: &Option<api::PaymentMethodData>, payment_method_data: &Option<api::PaymentMethodData>,
@ -2364,6 +2367,7 @@ mod tests {
} }
// This function will be removed after moving this functionality to server_wrap and using cache instead of config // This function will be removed after moving this functionality to server_wrap and using cache instead of config
#[instrument(skip_all)]
pub async fn insert_merchant_connector_creds_to_config( pub async fn insert_merchant_connector_creds_to_config(
db: &dyn StorageInterface, db: &dyn StorageInterface,
merchant_id: &str, merchant_id: &str,
@ -2436,6 +2440,7 @@ impl MerchantConnectorAccountType {
/// Query for merchant connector account either by business label or profile id /// Query for merchant connector account either by business label or profile id
/// If profile_id is passed use it, or use connector_label to query merchant connector account /// If profile_id is passed use it, or use connector_label to query merchant connector account
#[instrument(skip_all)]
pub async fn get_merchant_connector_account( pub async fn get_merchant_connector_account(
state: &AppState, state: &AppState,
merchant_id: &str, merchant_id: &str,
@ -2551,6 +2556,7 @@ pub fn router_data_type_conversion<F1, F2, Req1, Req2, Res1, Res2>(
} }
} }
#[instrument(skip_all)]
pub fn get_attempt_type( pub fn get_attempt_type(
payment_intent: &PaymentIntent, payment_intent: &PaymentIntent,
payment_attempt: &PaymentAttempt, payment_attempt: &PaymentAttempt,
@ -2740,6 +2746,7 @@ impl AttemptType {
} }
} }
#[instrument(skip_all)]
pub async fn modify_payment_intent_and_payment_attempt( pub async fn modify_payment_intent_and_payment_attempt(
&self, &self,
request: &api::PaymentsRequest, request: &api::PaymentsRequest,
@ -2793,6 +2800,7 @@ impl AttemptType {
} }
} }
#[instrument(skip_all)]
pub async fn get_or_insert_connector_response( pub async fn get_or_insert_connector_response(
&self, &self,
payment_attempt: &PaymentAttempt, payment_attempt: &PaymentAttempt,
@ -2821,6 +2829,7 @@ impl AttemptType {
} }
} }
#[instrument(skip_all)]
pub async fn get_connector_response( pub async fn get_connector_response(
&self, &self,
db: &dyn StorageInterface, db: &dyn StorageInterface,
@ -2927,6 +2936,7 @@ mod test {
} }
} }
#[instrument(skip_all)]
pub async fn get_additional_payment_data( pub async fn get_additional_payment_data(
pm_data: &api_models::payments::PaymentMethodData, pm_data: &api_models::payments::PaymentMethodData,
db: &dyn StorageInterface, db: &dyn StorageInterface,

View File

@ -31,6 +31,7 @@ use crate::{
pub struct PaymentConfirm; pub struct PaymentConfirm;
#[async_trait] #[async_trait]
impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for PaymentConfirm { impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for PaymentConfirm {
#[instrument(skip_all)]
async fn get_trackers<'a>( async fn get_trackers<'a>(
&'a self, &'a self,
state: &'a AppState, state: &'a AppState,
@ -429,6 +430,7 @@ impl<F: Clone + Send> Domain<F, api::PaymentsRequest> for PaymentConfirm {
#[async_trait] #[async_trait]
impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for PaymentConfirm { impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for PaymentConfirm {
#[instrument(skip_all)]
async fn update_trackers<'b>( async fn update_trackers<'b>(
&'b self, &'b self,
db: &dyn StorageInterface, db: &dyn StorageInterface,

View File

@ -4,6 +4,7 @@ use async_trait::async_trait;
use error_stack::ResultExt; use error_stack::ResultExt;
use futures::FutureExt; use futures::FutureExt;
use router_derive; use router_derive;
use router_env::{instrument, tracing};
use super::{Operation, PostUpdateTracker}; use super::{Operation, PostUpdateTracker};
use crate::{ use crate::{
@ -276,6 +277,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeData
} }
} }
#[instrument(skip_all)]
async fn payment_response_update_tracker<F: Clone, T: types::Capturable>( async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
db: &dyn StorageInterface, db: &dyn StorageInterface,
_payment_id: &api::PaymentIdType, _payment_id: &api::PaymentIdType,

View File

@ -1,6 +1,7 @@
use common_utils::ext_traits::AsyncExt; use common_utils::ext_traits::AsyncExt;
use diesel_models::address::AddressUpdateInternal; use diesel_models::address::AddressUpdateInternal;
use error_stack::{IntoReport, ResultExt}; use error_stack::{IntoReport, ResultExt};
use router_env::{instrument, tracing};
use super::{MockDb, Store}; use super::{MockDb, Store};
use crate::{ use crate::{
@ -69,6 +70,7 @@ impl AddressInterface for Store {
.await .await
} }
#[instrument(skip_all)]
async fn update_address( async fn update_address(
&self, &self,
address_id: String, address_id: String,
@ -89,6 +91,7 @@ impl AddressInterface for Store {
.await .await
} }
#[instrument(skip_all)]
async fn insert_address( async fn insert_address(
&self, &self,
address: domain::Address, address: domain::Address,
@ -172,6 +175,7 @@ impl AddressInterface for MockDb {
} }
} }
#[instrument(skip_all)]
async fn update_address( async fn update_address(
&self, &self,
address_id: String, address_id: String,
@ -201,6 +205,7 @@ impl AddressInterface for MockDb {
} }
} }
#[instrument(skip_all)]
async fn insert_address( async fn insert_address(
&self, &self,
address_new: domain::Address, address_new: domain::Address,

View File

@ -1,3 +1,5 @@
use router_env::{instrument, tracing};
use super::MockDb; use super::MockDb;
use crate::{ use crate::{
core::errors::{self, CustomResult}, core::errors::{self, CustomResult},
@ -199,6 +201,7 @@ impl CaptureInterface for MockDb {
Ok(capture) Ok(capture)
} }
#[instrument(skip_all)]
async fn update_capture_with_capture_id( async fn update_capture_with_capture_id(
&self, &self,
_this: types::Capture, _this: types::Capture,

View File

@ -1,4 +1,5 @@
use error_stack::IntoReport; use error_stack::IntoReport;
use router_env::{instrument, tracing};
use crate::{ use crate::{
connection, connection,
@ -18,6 +19,7 @@ pub trait CardsInfoInterface {
#[async_trait::async_trait] #[async_trait::async_trait]
impl CardsInfoInterface for Store { impl CardsInfoInterface for Store {
#[instrument(skip_all)]
async fn get_card_info( async fn get_card_info(
&self, &self,
card_iin: &str, card_iin: &str,
@ -32,6 +34,7 @@ impl CardsInfoInterface for Store {
#[async_trait::async_trait] #[async_trait::async_trait]
impl CardsInfoInterface for MockDb { impl CardsInfoInterface for MockDb {
#[instrument(skip_all)]
async fn get_card_info( async fn get_card_info(
&self, &self,
card_iin: &str, card_iin: &str,

View File

@ -1,5 +1,6 @@
use diesel_models::configs::ConfigUpdateInternal; use diesel_models::configs::ConfigUpdateInternal;
use error_stack::{IntoReport, ResultExt}; use error_stack::{IntoReport, ResultExt};
use router_env::{instrument, tracing};
use storage_impl::redis::{ use storage_impl::redis::{
cache::{CacheKind, CONFIG_CACHE}, cache::{CacheKind, CONFIG_CACHE},
kv_store::RedisConnInterface, kv_store::RedisConnInterface,
@ -47,6 +48,7 @@ pub trait ConfigInterface {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ConfigInterface for Store { impl ConfigInterface for Store {
#[instrument(skip_all)]
async fn insert_config( async fn insert_config(
&self, &self,
config: storage::ConfigNew, config: storage::ConfigNew,
@ -123,6 +125,7 @@ impl ConfigInterface for Store {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ConfigInterface for MockDb { impl ConfigInterface for MockDb {
#[instrument(skip_all)]
async fn insert_config( async fn insert_config(
&self, &self,
config: storage::ConfigNew, config: storage::ConfigNew,

View File

@ -1,4 +1,5 @@
use error_stack::{IntoReport, ResultExt}; use error_stack::{IntoReport, ResultExt};
use router_env::{instrument, tracing};
use super::{MockDb, Store}; use super::{MockDb, Store};
use crate::{ use crate::{
@ -33,6 +34,7 @@ pub trait ConnectorResponseInterface {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ConnectorResponseInterface for Store { impl ConnectorResponseInterface for Store {
#[instrument(skip_all)]
async fn insert_connector_response( async fn insert_connector_response(
&self, &self,
connector_response: storage::ConnectorResponseNew, connector_response: storage::ConnectorResponseNew,
@ -46,6 +48,7 @@ impl ConnectorResponseInterface for Store {
.into_report() .into_report()
} }
#[instrument(skip_all)]
async fn find_connector_response_by_payment_id_merchant_id_attempt_id( async fn find_connector_response_by_payment_id_merchant_id_attempt_id(
&self, &self,
payment_id: &str, payment_id: &str,
@ -81,6 +84,7 @@ impl ConnectorResponseInterface for Store {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ConnectorResponseInterface for MockDb { impl ConnectorResponseInterface for MockDb {
#[instrument(skip_all)]
async fn insert_connector_response( async fn insert_connector_response(
&self, &self,
new: storage::ConnectorResponseNew, new: storage::ConnectorResponseNew,
@ -107,6 +111,7 @@ impl ConnectorResponseInterface for MockDb {
Ok(response) Ok(response)
} }
#[instrument(skip_all)]
async fn find_connector_response_by_payment_id_merchant_id_attempt_id( async fn find_connector_response_by_payment_id_merchant_id_attempt_id(
&self, &self,
_payment_id: &str, _payment_id: &str,

View File

@ -1,6 +1,7 @@
use common_utils::ext_traits::AsyncExt; use common_utils::ext_traits::AsyncExt;
use error_stack::{IntoReport, ResultExt}; use error_stack::{IntoReport, ResultExt};
use masking::PeekInterface; use masking::PeekInterface;
use router_env::{instrument, tracing};
use super::{MockDb, Store}; use super::{MockDb, Store};
use crate::{ use crate::{
@ -95,6 +96,7 @@ impl CustomerInterface for Store {
}) })
} }
#[instrument(skip_all)]
async fn update_customer_by_customer_id_merchant_id( async fn update_customer_by_customer_id_merchant_id(
&self, &self,
customer_id: String, customer_id: String,
@ -207,6 +209,7 @@ impl CustomerInterface for MockDb {
.transpose() .transpose()
} }
#[instrument(skip_all)]
async fn update_customer_by_customer_id_merchant_id( async fn update_customer_by_customer_id_merchant_id(
&self, &self,
_customer_id: String, _customer_id: String,

View File

@ -23,6 +23,7 @@ use diesel_models::{
}; };
use error_stack::{IntoReport, ResultExt}; use error_stack::{IntoReport, ResultExt};
use redis_interface::HsetnxReply; use redis_interface::HsetnxReply;
use router_env::{instrument, tracing};
use crate::{ use crate::{
lookup::ReverseLookupInterface, lookup::ReverseLookupInterface,
@ -36,6 +37,7 @@ use crate::{
#[async_trait::async_trait] #[async_trait::async_trait]
impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> { impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[instrument(skip_all)]
async fn insert_payment_attempt( async fn insert_payment_attempt(
&self, &self,
payment_attempt: PaymentAttemptNew, payment_attempt: PaymentAttemptNew,
@ -53,6 +55,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
.map(PaymentAttempt::from_storage_model) .map(PaymentAttempt::from_storage_model)
} }
#[instrument(skip_all)]
async fn update_payment_attempt_with_attempt_id( async fn update_payment_attempt_with_attempt_id(
&self, &self,
this: PaymentAttempt, this: PaymentAttempt,
@ -132,6 +135,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
.map(PaymentAttempt::from_storage_model) .map(PaymentAttempt::from_storage_model)
} }
#[instrument(skip_all)]
async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id( async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(
&self, &self,
payment_id: &str, payment_id: &str,
@ -279,6 +283,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
#[async_trait::async_trait] #[async_trait::async_trait]
impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> { impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
#[instrument(skip_all)]
async fn insert_payment_attempt( async fn insert_payment_attempt(
&self, &self,
payment_attempt: PaymentAttemptNew, payment_attempt: PaymentAttemptNew,
@ -403,6 +408,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
} }
} }
#[instrument(skip_all)]
async fn update_payment_attempt_with_attempt_id( async fn update_payment_attempt_with_attempt_id(
&self, &self,
this: PaymentAttempt, this: PaymentAttempt,
@ -616,6 +622,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
} }
} }
#[instrument(skip_all)]
async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id( async fn find_payment_attempt_by_payment_id_merchant_id_attempt_id(
&self, &self,
payment_id: &str, payment_id: &str,

View File

@ -32,6 +32,7 @@ use error_stack::{IntoReport, ResultExt};
use redis_interface::HsetnxReply; use redis_interface::HsetnxReply;
#[cfg(feature = "olap")] #[cfg(feature = "olap")]
use router_env::logger; use router_env::logger;
use router_env::{instrument, tracing};
use crate::{ use crate::{
redis::kv_store::{PartitionKey, RedisConnInterface}, redis::kv_store::{PartitionKey, RedisConnInterface},
@ -125,6 +126,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
} }
} }
#[instrument(skip_all)]
async fn update_payment_intent( async fn update_payment_intent(
&self, &self,
this: PaymentIntent, this: PaymentIntent,
@ -180,6 +182,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
} }
} }
#[instrument(skip_all)]
async fn find_payment_intent_by_payment_id_merchant_id( async fn find_payment_intent_by_payment_id_merchant_id(
&self, &self,
payment_id: &str, payment_id: &str,
@ -323,6 +326,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
.map(PaymentIntent::from_storage_model) .map(PaymentIntent::from_storage_model)
} }
#[instrument(skip_all)]
async fn find_payment_intent_by_payment_id_merchant_id( async fn find_payment_intent_by_payment_id_merchant_id(
&self, &self,
payment_id: &str, payment_id: &str,