From 664a12fd75537e453f1147dcc9e1c34abd4f1899 Mon Sep 17 00:00:00 2001 From: Crimson Thompson Date: Thu, 2 Jan 2025 16:44:39 +0100 Subject: [PATCH] fix: (metrics) remove metrics constant from httpwrapper package --- internal/connectors/httpwrapper/client.go | 2 -- .../public/bankingcircle/client/accounts.go | 6 +++--- .../plugins/public/bankingcircle/client/auth.go | 4 ++-- .../public/bankingcircle/client/payments.go | 8 ++++---- .../bankingcircle/client/transfer_payouts.go | 4 ++-- .../public/currencycloud/client/accounts.go | 4 ++-- .../plugins/public/currencycloud/client/auth.go | 4 ++-- .../public/currencycloud/client/balances.go | 4 ++-- .../public/currencycloud/client/beneficiaries.go | 4 ++-- .../public/currencycloud/client/contacts.go | 4 ++-- .../plugins/public/currencycloud/client/payouts.go | 4 ++-- .../public/currencycloud/client/transactions.go | 4 ++-- .../public/currencycloud/client/transfers.go | 4 ++-- .../public/mangopay/client/bank_accounts.go | 14 +++++++------- .../plugins/public/mangopay/client/payin.go | 4 ++-- .../plugins/public/mangopay/client/payout.go | 6 +++--- .../plugins/public/mangopay/client/refund.go | 4 ++-- .../plugins/public/mangopay/client/transactions.go | 4 ++-- .../plugins/public/mangopay/client/transfer.go | 6 +++--- .../plugins/public/mangopay/client/users.go | 4 ++-- .../plugins/public/mangopay/client/wallets.go | 6 +++--- .../plugins/public/mangopay/client/webhooks.go | 8 ++++---- .../plugins/public/modulr/client/accounts.go | 6 +++--- .../plugins/public/modulr/client/beneficiaries.go | 4 ++-- .../plugins/public/modulr/client/payments.go | 4 ++-- .../plugins/public/modulr/client/payout.go | 6 +++--- .../plugins/public/modulr/client/transactions.go | 4 ++-- .../plugins/public/modulr/client/transfer.go | 6 +++--- .../plugins/public/moneycorp/client/accounts.go | 4 ++-- .../plugins/public/moneycorp/client/auth.go | 2 +- .../plugins/public/moneycorp/client/balances.go | 4 ++-- .../plugins/public/moneycorp/client/payouts.go | 4 ++-- .../plugins/public/moneycorp/client/recipients.go | 4 ++-- .../public/moneycorp/client/transactions.go | 4 ++-- .../plugins/public/moneycorp/client/transfers.go | 6 +++--- .../plugins/public/wise/client/balances.go | 6 +++--- .../plugins/public/wise/client/payouts.go | 6 +++--- .../plugins/public/wise/client/profiles.go | 4 ++-- .../plugins/public/wise/client/quotes.go | 4 ++-- .../public/wise/client/recipient_accounts.go | 6 +++--- .../plugins/public/wise/client/transfers.go | 8 ++++---- 41 files changed, 101 insertions(+), 103 deletions(-) diff --git a/internal/connectors/httpwrapper/client.go b/internal/connectors/httpwrapper/client.go index e9518482..d322f48e 100644 --- a/internal/connectors/httpwrapper/client.go +++ b/internal/connectors/httpwrapper/client.go @@ -14,8 +14,6 @@ import ( "golang.org/x/oauth2" ) -const MetricOperationContextKey string = "_metric_operation_context_key" - var ( ErrStatusCodeUnexpected = errors.New("unexpected status code") ErrStatusCodeClientError = fmt.Errorf("%w: http client error", ErrStatusCodeUnexpected) diff --git a/internal/connectors/plugins/public/bankingcircle/client/accounts.go b/internal/connectors/plugins/public/bankingcircle/client/accounts.go index a784b412..77281724 100644 --- a/internal/connectors/plugins/public/bankingcircle/client/accounts.go +++ b/internal/connectors/plugins/public/bankingcircle/client/accounts.go @@ -7,7 +7,7 @@ import ( "net/http" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Balance struct { @@ -43,7 +43,7 @@ func (c *client) GetAccounts(ctx context.Context, page int, pageSize int, fromOp return nil, err } - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_accounts") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_accounts") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint+"/api/v1/accounts", http.NoBody) if err != nil { @@ -80,7 +80,7 @@ func (c *client) GetAccount(ctx context.Context, accountID string) (*Account, er if err := c.ensureAccessTokenIsValid(ctx); err != nil { return nil, err } - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_account") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_account") req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/api/v1/accounts/%s", c.endpoint, accountID), http.NoBody) if err != nil { diff --git a/internal/connectors/plugins/public/bankingcircle/client/auth.go b/internal/connectors/plugins/public/bankingcircle/client/auth.go index 58987fec..961cc458 100644 --- a/internal/connectors/plugins/public/bankingcircle/client/auth.go +++ b/internal/connectors/plugins/public/bankingcircle/client/auth.go @@ -8,11 +8,11 @@ import ( "strconv" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) func (c *client) login(ctx context.Context) error { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "authenticate") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "authenticate") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.authorizationEndpoint+"/api/v1/authorizations/authorize", http.NoBody) diff --git a/internal/connectors/plugins/public/bankingcircle/client/payments.go b/internal/connectors/plugins/public/bankingcircle/client/payments.go index 35c64de3..0219bd01 100644 --- a/internal/connectors/plugins/public/bankingcircle/client/payments.go +++ b/internal/connectors/plugins/public/bankingcircle/client/payments.go @@ -7,7 +7,7 @@ import ( "net/http" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type DebtorInformation struct { @@ -94,7 +94,7 @@ func (c *client) GetPayments(ctx context.Context, page int, pageSize int) ([]Pay return nil, err } - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_payments") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_payments") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint+"/api/v1/payments/singles", http.NoBody) if err != nil { @@ -129,7 +129,7 @@ func (c *client) GetPayment(ctx context.Context, paymentID string) (*Payment, er return nil, err } - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_payment") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_payment") req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/api/v1/payments/singles/%s", c.endpoint, paymentID), http.NoBody) if err != nil { @@ -153,7 +153,7 @@ func (c *client) GetPaymentStatus(ctx context.Context, paymentID string) (*Statu if err := c.ensureAccessTokenIsValid(ctx); err != nil { return nil, err } - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_payment_status") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_payment_status") req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/api/v1/payments/singles/%s/status", c.endpoint, paymentID), http.NoBody) if err != nil { diff --git a/internal/connectors/plugins/public/bankingcircle/client/transfer_payouts.go b/internal/connectors/plugins/public/bankingcircle/client/transfer_payouts.go index 4afb7847..c646e255 100644 --- a/internal/connectors/plugins/public/bankingcircle/client/transfer_payouts.go +++ b/internal/connectors/plugins/public/bankingcircle/client/transfer_payouts.go @@ -8,7 +8,7 @@ import ( "net/http" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type PaymentAccount struct { @@ -38,7 +38,7 @@ func (c *client) InitiateTransferOrPayouts(ctx context.Context, transferRequest return nil, err } - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "create_transfers_payouts") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "create_transfers_payouts") body, err := json.Marshal(transferRequest) if err != nil { diff --git a/internal/connectors/plugins/public/currencycloud/client/accounts.go b/internal/connectors/plugins/public/currencycloud/client/accounts.go index 8b9e7e9f..79b36169 100644 --- a/internal/connectors/plugins/public/currencycloud/client/accounts.go +++ b/internal/connectors/plugins/public/currencycloud/client/accounts.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Account struct { @@ -20,7 +20,7 @@ func (c *client) GetAccounts(ctx context.Context, page int, pageSize int) ([]*Ac if err := c.ensureLogin(ctx); err != nil { return nil, 0, err } - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_accounts") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_accounts") req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.buildEndpoint("v2/accounts/find"), http.NoBody) diff --git a/internal/connectors/plugins/public/currencycloud/client/auth.go b/internal/connectors/plugins/public/currencycloud/client/auth.go index 8b502607..a7b2cf18 100644 --- a/internal/connectors/plugins/public/currencycloud/client/auth.go +++ b/internal/connectors/plugins/public/currencycloud/client/auth.go @@ -7,11 +7,11 @@ import ( "net/url" "strings" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) func (c *client) authenticate(ctx context.Context) error { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "authenticate") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "authenticate") form := make(url.Values) diff --git a/internal/connectors/plugins/public/currencycloud/client/balances.go b/internal/connectors/plugins/public/currencycloud/client/balances.go index b6851cd7..765aa2b2 100644 --- a/internal/connectors/plugins/public/currencycloud/client/balances.go +++ b/internal/connectors/plugins/public/currencycloud/client/balances.go @@ -7,7 +7,7 @@ import ( "net/http" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Balance struct { @@ -20,7 +20,7 @@ type Balance struct { } func (c *client) GetBalances(ctx context.Context, page int, pageSize int) ([]*Balance, int, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_balances") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_balances") if err := c.ensureLogin(ctx); err != nil { return nil, 0, err diff --git a/internal/connectors/plugins/public/currencycloud/client/beneficiaries.go b/internal/connectors/plugins/public/currencycloud/client/beneficiaries.go index e4994da4..ad46bc79 100644 --- a/internal/connectors/plugins/public/currencycloud/client/beneficiaries.go +++ b/internal/connectors/plugins/public/currencycloud/client/beneficiaries.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Beneficiary struct { @@ -19,7 +19,7 @@ type Beneficiary struct { } func (c *client) GetBeneficiaries(ctx context.Context, page int, pageSize int) ([]*Beneficiary, int, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_beneficiaries") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_beneficiaries") if err := c.ensureLogin(ctx); err != nil { return nil, 0, err diff --git a/internal/connectors/plugins/public/currencycloud/client/contacts.go b/internal/connectors/plugins/public/currencycloud/client/contacts.go index 1bdf621d..103174f7 100644 --- a/internal/connectors/plugins/public/currencycloud/client/contacts.go +++ b/internal/connectors/plugins/public/currencycloud/client/contacts.go @@ -7,7 +7,7 @@ import ( "net/url" "strings" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" "github.com/formancehq/payments/internal/models" ) @@ -16,7 +16,7 @@ type Contact struct { } func (c *client) GetContactID(ctx context.Context, accountID string) (*Contact, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_contacts") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_contacts") if err := c.ensureLogin(ctx); err != nil { return nil, err diff --git a/internal/connectors/plugins/public/currencycloud/client/payouts.go b/internal/connectors/plugins/public/currencycloud/client/payouts.go index 1bc10241..fcd0988c 100644 --- a/internal/connectors/plugins/public/currencycloud/client/payouts.go +++ b/internal/connectors/plugins/public/currencycloud/client/payouts.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type PayoutRequest struct { @@ -54,7 +54,7 @@ type PayoutResponse struct { } func (c *client) InitiatePayout(ctx context.Context, payoutRequest *PayoutRequest) (*PayoutResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "initiate_payout") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "initiate_payout") if err := c.ensureLogin(ctx); err != nil { return nil, err diff --git a/internal/connectors/plugins/public/currencycloud/client/transactions.go b/internal/connectors/plugins/public/currencycloud/client/transactions.go index 1ebf3f0b..3105b3c5 100644 --- a/internal/connectors/plugins/public/currencycloud/client/transactions.go +++ b/internal/connectors/plugins/public/currencycloud/client/transactions.go @@ -7,7 +7,7 @@ import ( "net/http" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) //nolint:tagliatelle // allow different styled tags in client @@ -29,7 +29,7 @@ func (c *client) GetTransactions(ctx context.Context, page int, pageSize int, up return nil, 0, fmt.Errorf("page must be greater than 0") } - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_transactions") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_transactions") if err := c.ensureLogin(ctx); err != nil { return nil, 0, err diff --git a/internal/connectors/plugins/public/currencycloud/client/transfers.go b/internal/connectors/plugins/public/currencycloud/client/transfers.go index 4f5199f9..1ebf3ed3 100644 --- a/internal/connectors/plugins/public/currencycloud/client/transfers.go +++ b/internal/connectors/plugins/public/currencycloud/client/transfers.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type TransferRequest struct { @@ -55,7 +55,7 @@ type TransferResponse struct { } func (c *client) InitiateTransfer(ctx context.Context, transferRequest *TransferRequest) (*TransferResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "initiate_transfer") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "initiate_transfer") if err := c.ensureLogin(ctx); err != nil { return nil, err diff --git a/internal/connectors/plugins/public/mangopay/client/bank_accounts.go b/internal/connectors/plugins/public/mangopay/client/bank_accounts.go index 8e6fb097..d9ed564f 100644 --- a/internal/connectors/plugins/public/mangopay/client/bank_accounts.go +++ b/internal/connectors/plugins/public/mangopay/client/bank_accounts.go @@ -9,7 +9,7 @@ import ( "strconv" "github.com/formancehq/go-libs/v2/errorsutils" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type OwnerAddress struct { @@ -33,7 +33,7 @@ type CreateIBANBankAccountRequest struct { } func (c *client) CreateIBANBankAccount(ctx context.Context, userID string, req *CreateIBANBankAccountRequest) (*BankAccount, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "create_iban_bank_account") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "create_iban_bank_account") endpoint := fmt.Sprintf("%s/v2.01/%s/users/%s/bankaccounts/iban", c.endpoint, c.clientID, userID) return c.createBankAccount(ctx, endpoint, req) @@ -49,7 +49,7 @@ type CreateUSBankAccountRequest struct { } func (c *client) CreateUSBankAccount(ctx context.Context, userID string, req *CreateUSBankAccountRequest) (*BankAccount, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "create_us_bank_account") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "create_us_bank_account") endpoint := fmt.Sprintf("%s/v2.01/%s/users/%s/bankaccounts/us", c.endpoint, c.clientID, userID) return c.createBankAccount(ctx, endpoint, req) @@ -66,7 +66,7 @@ type CreateCABankAccountRequest struct { } func (c *client) CreateCABankAccount(ctx context.Context, userID string, req *CreateCABankAccountRequest) (*BankAccount, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "create_ca_bank_account") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "create_ca_bank_account") endpoint := fmt.Sprintf("%s/v2.01/%s/users/%s/bankaccounts/ca", c.endpoint, c.clientID, userID) return c.createBankAccount(ctx, endpoint, req) @@ -81,7 +81,7 @@ type CreateGBBankAccountRequest struct { } func (c *client) CreateGBBankAccount(ctx context.Context, userID string, req *CreateGBBankAccountRequest) (*BankAccount, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "create_gb_bank_account") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "create_gb_bank_account") endpoint := fmt.Sprintf("%s/v2.01/%s/users/%s/bankaccounts/gb", c.endpoint, c.clientID, userID) return c.createBankAccount(ctx, endpoint, req) @@ -97,7 +97,7 @@ type CreateOtherBankAccountRequest struct { } func (c *client) CreateOtherBankAccount(ctx context.Context, userID string, req *CreateOtherBankAccountRequest) (*BankAccount, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "create_other_bank_account") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "create_other_bank_account") endpoint := fmt.Sprintf("%s/v2.01/%s/users/%s/bankaccounts/other", c.endpoint, c.clientID, userID) return c.createBankAccount(ctx, endpoint, req) @@ -130,7 +130,7 @@ type BankAccount struct { } func (c *client) GetBankAccounts(ctx context.Context, userID string, page, pageSize int) ([]BankAccount, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_bank_accounts") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_bank_accounts") endpoint := fmt.Sprintf("%s/v2.01/%s/users/%s/bankaccounts", c.endpoint, c.clientID, userID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) diff --git a/internal/connectors/plugins/public/mangopay/client/payin.go b/internal/connectors/plugins/public/mangopay/client/payin.go index 5242fc01..507805f1 100644 --- a/internal/connectors/plugins/public/mangopay/client/payin.go +++ b/internal/connectors/plugins/public/mangopay/client/payin.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/formancehq/go-libs/v2/errorsutils" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type PayinResponse struct { @@ -29,7 +29,7 @@ type PayinResponse struct { } func (c *client) GetPayin(ctx context.Context, payinID string) (*PayinResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_payin") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_payin") endpoint := fmt.Sprintf("%s/v2.01/%s/payins/%s", c.endpoint, c.clientID, payinID) diff --git a/internal/connectors/plugins/public/mangopay/client/payout.go b/internal/connectors/plugins/public/mangopay/client/payout.go index 1b9ddb28..82b5c14e 100644 --- a/internal/connectors/plugins/public/mangopay/client/payout.go +++ b/internal/connectors/plugins/public/mangopay/client/payout.go @@ -8,7 +8,7 @@ import ( "net/http" "github.com/formancehq/go-libs/v2/errorsutils" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type PayoutRequest struct { @@ -45,7 +45,7 @@ type PayoutResponse struct { } func (c *client) InitiatePayout(ctx context.Context, payoutRequest *PayoutRequest) (*PayoutResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "initiate_payout") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "initiate_payout") endpoint := fmt.Sprintf("%s/v2.01/%s/payouts/bankwire", c.endpoint, c.clientID) @@ -70,7 +70,7 @@ func (c *client) InitiatePayout(ctx context.Context, payoutRequest *PayoutReques } func (c *client) GetPayout(ctx context.Context, payoutID string) (*PayoutResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_payout") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_payout") endpoint := fmt.Sprintf("%s/v2.01/%s/payouts/%s", c.endpoint, c.clientID, payoutID) diff --git a/internal/connectors/plugins/public/mangopay/client/refund.go b/internal/connectors/plugins/public/mangopay/client/refund.go index 414878b6..cdcf4c93 100644 --- a/internal/connectors/plugins/public/mangopay/client/refund.go +++ b/internal/connectors/plugins/public/mangopay/client/refund.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/formancehq/go-libs/v2/errorsutils" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Refund struct { @@ -30,7 +30,7 @@ type Refund struct { } func (c *client) GetRefund(ctx context.Context, refundID string) (*Refund, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_refund") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_refund") endpoint := fmt.Sprintf("%s/v2.01/%s/refunds/%s", c.endpoint, c.clientID, refundID) diff --git a/internal/connectors/plugins/public/mangopay/client/transactions.go b/internal/connectors/plugins/public/mangopay/client/transactions.go index 7e6a8dc0..a6c508a3 100644 --- a/internal/connectors/plugins/public/mangopay/client/transactions.go +++ b/internal/connectors/plugins/public/mangopay/client/transactions.go @@ -8,7 +8,7 @@ import ( "time" "github.com/formancehq/go-libs/v2/errorsutils" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Payment struct { @@ -31,7 +31,7 @@ type Payment struct { } func (c *client) GetTransactions(ctx context.Context, walletsID string, page, pageSize int, afterCreatedAt time.Time) ([]Payment, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_transactions") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_transactions") endpoint := fmt.Sprintf("%s/v2.01/%s/wallets/%s/transactions", c.endpoint, c.clientID, walletsID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) diff --git a/internal/connectors/plugins/public/mangopay/client/transfer.go b/internal/connectors/plugins/public/mangopay/client/transfer.go index 3deaa017..4f41d20e 100644 --- a/internal/connectors/plugins/public/mangopay/client/transfer.go +++ b/internal/connectors/plugins/public/mangopay/client/transfer.go @@ -8,7 +8,7 @@ import ( "net/http" "github.com/formancehq/go-libs/v2/errorsutils" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Funds struct { @@ -45,7 +45,7 @@ type TransferResponse struct { } func (c *client) InitiateWalletTransfer(ctx context.Context, transferRequest *TransferRequest) (*TransferResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "initiate_transfer") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "initiate_transfer") endpoint := fmt.Sprintf("%s/v2.01/%s/transfers", c.endpoint, c.clientID) @@ -72,7 +72,7 @@ func (c *client) InitiateWalletTransfer(ctx context.Context, transferRequest *Tr } func (c *client) GetWalletTransfer(ctx context.Context, transferID string) (TransferResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_transfer") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_transfer") endpoint := fmt.Sprintf("%s/v2.01/%s/transfers/%s", c.endpoint, c.clientID, transferID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) diff --git a/internal/connectors/plugins/public/mangopay/client/users.go b/internal/connectors/plugins/public/mangopay/client/users.go index d4027677..d20f6a16 100644 --- a/internal/connectors/plugins/public/mangopay/client/users.go +++ b/internal/connectors/plugins/public/mangopay/client/users.go @@ -7,7 +7,7 @@ import ( "strconv" "github.com/formancehq/go-libs/v2/errorsutils" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type User struct { @@ -16,7 +16,7 @@ type User struct { } func (c *client) GetUsers(ctx context.Context, page int, pageSize int) ([]User, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_users") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_users") endpoint := fmt.Sprintf("%s/v2.01/%s/users", c.endpoint, c.clientID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) diff --git a/internal/connectors/plugins/public/mangopay/client/wallets.go b/internal/connectors/plugins/public/mangopay/client/wallets.go index 78b2710d..ab0d5c3e 100644 --- a/internal/connectors/plugins/public/mangopay/client/wallets.go +++ b/internal/connectors/plugins/public/mangopay/client/wallets.go @@ -8,7 +8,7 @@ import ( "strconv" "github.com/formancehq/go-libs/v2/errorsutils" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Wallet struct { @@ -24,7 +24,7 @@ type Wallet struct { } func (c *client) GetWallets(ctx context.Context, userID string, page, pageSize int) ([]Wallet, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_wallets") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_wallets") endpoint := fmt.Sprintf("%s/v2.01/%s/users/%s/wallets", c.endpoint, c.clientID, userID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) @@ -48,7 +48,7 @@ func (c *client) GetWallets(ctx context.Context, userID string, page, pageSize i } func (c *client) GetWallet(ctx context.Context, walletID string) (*Wallet, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_wallet") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_wallet") endpoint := fmt.Sprintf("%s/v2.01/%s/wallets/%s", c.endpoint, c.clientID, walletID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) diff --git a/internal/connectors/plugins/public/mangopay/client/webhooks.go b/internal/connectors/plugins/public/mangopay/client/webhooks.go index 1b7865f8..bb042d3c 100644 --- a/internal/connectors/plugins/public/mangopay/client/webhooks.go +++ b/internal/connectors/plugins/public/mangopay/client/webhooks.go @@ -8,7 +8,7 @@ import ( "net/http" "github.com/formancehq/go-libs/v2/errorsutils" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type EventType string @@ -83,7 +83,7 @@ type Hook struct { } func (c *client) ListAllHooks(ctx context.Context) ([]*Hook, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_hooks") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_hooks") endpoint := fmt.Sprintf("%s/v2.01/%s/hooks", c.endpoint, c.clientID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) @@ -111,7 +111,7 @@ type CreateHookRequest struct { } func (c *client) CreateHook(ctx context.Context, eventType EventType, URL string) error { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "create_hook") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "create_hook") body, err := json.Marshal(&CreateHookRequest{ EventType: eventType, @@ -142,7 +142,7 @@ type UpdateHookRequest struct { } func (c *client) UpdateHook(ctx context.Context, hookID string, URL string) error { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "update_hook") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "update_hook") body, err := json.Marshal(&UpdateHookRequest{ URL: URL, diff --git a/internal/connectors/plugins/public/modulr/client/accounts.go b/internal/connectors/plugins/public/modulr/client/accounts.go index 7ce24d49..8f5520ec 100644 --- a/internal/connectors/plugins/public/modulr/client/accounts.go +++ b/internal/connectors/plugins/public/modulr/client/accounts.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) //nolint:tagliatelle // allow for clients @@ -28,7 +28,7 @@ type Account struct { } func (c *client) GetAccounts(ctx context.Context, page, pageSize int, fromCreatedAt time.Time) ([]Account, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_accounts") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_accounts") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.buildEndpoint("accounts"), http.NoBody) if err != nil { @@ -55,7 +55,7 @@ func (c *client) GetAccounts(ctx context.Context, page, pageSize int, fromCreate } func (c *client) GetAccount(ctx context.Context, accountID string) (*Account, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_account") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_account") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.buildEndpoint("accounts/%s", accountID), http.NoBody) if err != nil { diff --git a/internal/connectors/plugins/public/modulr/client/beneficiaries.go b/internal/connectors/plugins/public/modulr/client/beneficiaries.go index 0642045a..48d0f830 100644 --- a/internal/connectors/plugins/public/modulr/client/beneficiaries.go +++ b/internal/connectors/plugins/public/modulr/client/beneficiaries.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Beneficiary struct { @@ -17,7 +17,7 @@ type Beneficiary struct { } func (c *client) GetBeneficiaries(ctx context.Context, page, pageSize int, modifiedSince time.Time) ([]Beneficiary, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_beneficiaries") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_beneficiaries") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.buildEndpoint("beneficiaries"), http.NoBody) if err != nil { diff --git a/internal/connectors/plugins/public/modulr/client/payments.go b/internal/connectors/plugins/public/modulr/client/payments.go index 7a4c6027..9a11a5d4 100644 --- a/internal/connectors/plugins/public/modulr/client/payments.go +++ b/internal/connectors/plugins/public/modulr/client/payments.go @@ -8,7 +8,7 @@ import ( "strconv" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type PaymentType string @@ -39,7 +39,7 @@ type Payment struct { } func (c *client) GetPayments(ctx context.Context, paymentType PaymentType, page, pageSize int, modifiedSince time.Time) ([]Payment, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_payments") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_payments") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.buildEndpoint("payments"), http.NoBody) if err != nil { diff --git a/internal/connectors/plugins/public/modulr/client/payout.go b/internal/connectors/plugins/public/modulr/client/payout.go index e7cee172..2b90e42a 100644 --- a/internal/connectors/plugins/public/modulr/client/payout.go +++ b/internal/connectors/plugins/public/modulr/client/payout.go @@ -7,7 +7,7 @@ import ( "fmt" "net/http" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type PayoutRequest struct { @@ -31,7 +31,7 @@ type PayoutResponse struct { } func (c *client) InitiatePayout(ctx context.Context, payoutRequest *PayoutRequest) (*PayoutResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "initiate_payout") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "initiate_payout") body, err := json.Marshal(payoutRequest) if err != nil { @@ -55,7 +55,7 @@ func (c *client) InitiatePayout(ctx context.Context, payoutRequest *PayoutReques } func (c *client) GetPayout(ctx context.Context, payoutID string) (PayoutResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_payout") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_payout") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.buildEndpoint("payments?id=%s", payoutID), nil) if err != nil { diff --git a/internal/connectors/plugins/public/modulr/client/transactions.go b/internal/connectors/plugins/public/modulr/client/transactions.go index 22ca42c9..c87314b6 100644 --- a/internal/connectors/plugins/public/modulr/client/transactions.go +++ b/internal/connectors/plugins/public/modulr/client/transactions.go @@ -8,7 +8,7 @@ import ( "strconv" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) //nolint:tagliatelle // allow different styled tags in client @@ -26,7 +26,7 @@ type Transaction struct { } func (c *client) GetTransactions(ctx context.Context, accountID string, page, pageSize int, fromTransactionDate time.Time) ([]Transaction, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_transactions") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_transactions") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.buildEndpoint("accounts/%s/transactions", accountID), http.NoBody) if err != nil { diff --git a/internal/connectors/plugins/public/modulr/client/transfer.go b/internal/connectors/plugins/public/modulr/client/transfer.go index affba012..f09a38a0 100644 --- a/internal/connectors/plugins/public/modulr/client/transfer.go +++ b/internal/connectors/plugins/public/modulr/client/transfer.go @@ -7,7 +7,7 @@ import ( "fmt" "net/http" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type DestinationType string @@ -54,7 +54,7 @@ type TransferResponse struct { } func (c *client) InitiateTransfer(ctx context.Context, transferRequest *TransferRequest) (*TransferResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "initiate_transfer") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "initiate_transfer") body, err := json.Marshal(transferRequest) if err != nil { @@ -78,7 +78,7 @@ func (c *client) InitiateTransfer(ctx context.Context, transferRequest *Transfer } func (c *client) GetTransfer(ctx context.Context, transferID string) (TransferResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_transfer") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_transfer") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.buildEndpoint("payments?id=%s", transferID), nil) if err != nil { diff --git a/internal/connectors/plugins/public/moneycorp/client/accounts.go b/internal/connectors/plugins/public/moneycorp/client/accounts.go index 49f5fb06..13649e77 100644 --- a/internal/connectors/plugins/public/moneycorp/client/accounts.go +++ b/internal/connectors/plugins/public/moneycorp/client/accounts.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type accountsResponse struct { @@ -21,7 +21,7 @@ type Account struct { } func (c *client) GetAccounts(ctx context.Context, page int, pageSize int) ([]*Account, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_accounts") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_accounts") endpoint := fmt.Sprintf("%s/accounts", c.endpoint) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) diff --git a/internal/connectors/plugins/public/moneycorp/client/auth.go b/internal/connectors/plugins/public/moneycorp/client/auth.go index 32836e11..b5154bf8 100644 --- a/internal/connectors/plugins/public/moneycorp/client/auth.go +++ b/internal/connectors/plugins/public/moneycorp/client/auth.go @@ -83,7 +83,7 @@ func (t *apiTransport) login(ctx context.Context) error { req.Header.Set("Content-Type", "application/json") - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "authenticate") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "authenticate") var res loginResponse var errRes moneycorpErrors diff --git a/internal/connectors/plugins/public/moneycorp/client/balances.go b/internal/connectors/plugins/public/moneycorp/client/balances.go index 6e6981b2..2795acc7 100644 --- a/internal/connectors/plugins/public/moneycorp/client/balances.go +++ b/internal/connectors/plugins/public/moneycorp/client/balances.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type balancesResponse struct { @@ -28,7 +28,7 @@ type Attributes struct { } func (c *client) GetAccountBalances(ctx context.Context, accountID string) ([]*Balance, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_account_balances") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_account_balances") endpoint := fmt.Sprintf("%s/accounts/%s/balances", c.endpoint, accountID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) diff --git a/internal/connectors/plugins/public/moneycorp/client/payouts.go b/internal/connectors/plugins/public/moneycorp/client/payouts.go index a72e2469..1d5fd84d 100644 --- a/internal/connectors/plugins/public/moneycorp/client/payouts.go +++ b/internal/connectors/plugins/public/moneycorp/client/payouts.go @@ -7,7 +7,7 @@ import ( "fmt" "net/http" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type payoutRequest struct { @@ -61,7 +61,7 @@ type PayoutResponse struct { } func (c *client) InitiatePayout(ctx context.Context, pr *PayoutRequest) (*PayoutResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "initiate_payout") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "initiate_payout") endpoint := fmt.Sprintf("%s/accounts/%s/payments", c.endpoint, pr.SourceAccountID) diff --git a/internal/connectors/plugins/public/moneycorp/client/recipients.go b/internal/connectors/plugins/public/moneycorp/client/recipients.go index 60076094..06b63a3a 100644 --- a/internal/connectors/plugins/public/moneycorp/client/recipients.go +++ b/internal/connectors/plugins/public/moneycorp/client/recipients.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type recipientsResponse struct { @@ -25,7 +25,7 @@ type RecipientAttributes struct { } func (c *client) GetRecipients(ctx context.Context, accountID string, page int, pageSize int) ([]*Recipient, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_recipients") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_recipients") endpoint := fmt.Sprintf("%s/accounts/%s/recipients", c.endpoint, accountID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) diff --git a/internal/connectors/plugins/public/moneycorp/client/transactions.go b/internal/connectors/plugins/public/moneycorp/client/transactions.go index 43651e60..4d05ed25 100644 --- a/internal/connectors/plugins/public/moneycorp/client/transactions.go +++ b/internal/connectors/plugins/public/moneycorp/client/transactions.go @@ -10,7 +10,7 @@ import ( "strconv" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type transactionsResponse struct { @@ -53,7 +53,7 @@ type TransactionAttributes struct { } func (c *client) GetTransactions(ctx context.Context, accountID string, page, pageSize int, lastCreatedAt time.Time) ([]*Transaction, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_transactions") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_transactions") var body io.Reader if !lastCreatedAt.IsZero() { diff --git a/internal/connectors/plugins/public/moneycorp/client/transfers.go b/internal/connectors/plugins/public/moneycorp/client/transfers.go index daca499f..d0e74ae0 100644 --- a/internal/connectors/plugins/public/moneycorp/client/transfers.go +++ b/internal/connectors/plugins/public/moneycorp/client/transfers.go @@ -7,7 +7,7 @@ import ( "fmt" "net/http" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type transferRequest struct { @@ -52,7 +52,7 @@ type TransferResponse struct { } func (c *client) InitiateTransfer(ctx context.Context, tr *TransferRequest) (*TransferResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "initiate_transfer") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "initiate_transfer") endpoint := fmt.Sprintf("%s/accounts/%s/transfers", c.endpoint, tr.SourceAccountID) @@ -81,7 +81,7 @@ func (c *client) InitiateTransfer(ctx context.Context, tr *TransferRequest) (*Tr } func (c *client) GetTransfer(ctx context.Context, accountID string, transferID string) (*TransferResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_transfer") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_transfer") endpoint := fmt.Sprintf("%s/accounts/%s/transfers/%s", c.endpoint, accountID, transferID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, http.NoBody) diff --git a/internal/connectors/plugins/public/wise/client/balances.go b/internal/connectors/plugins/public/wise/client/balances.go index 278ee941..029423b9 100644 --- a/internal/connectors/plugins/public/wise/client/balances.go +++ b/internal/connectors/plugins/public/wise/client/balances.go @@ -7,7 +7,7 @@ import ( "net/http" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type BalanceAmount struct { @@ -39,7 +39,7 @@ type Balance struct { } func (c *client) GetBalances(ctx context.Context, profileID uint64) ([]Balance, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_balances") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_balances") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint(fmt.Sprintf("v4/profiles/%d/balances?types=STANDARD", profileID)), http.NoBody) @@ -57,7 +57,7 @@ func (c *client) GetBalances(ctx context.Context, profileID uint64) ([]Balance, } func (c *client) GetBalance(ctx context.Context, profileID uint64, balanceID uint64) (*Balance, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_balance") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_balance") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint(fmt.Sprintf("v4/profiles/%d/balances/%d", profileID, balanceID)), http.NoBody) diff --git a/internal/connectors/plugins/public/wise/client/payouts.go b/internal/connectors/plugins/public/wise/client/payouts.go index 374c66d7..4a7d9a8f 100644 --- a/internal/connectors/plugins/public/wise/client/payouts.go +++ b/internal/connectors/plugins/public/wise/client/payouts.go @@ -8,7 +8,7 @@ import ( "net/http" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Payout struct { @@ -62,7 +62,7 @@ func (t *Payout) UnmarshalJSON(data []byte) error { } func (c *client) GetPayout(ctx context.Context, payoutID string) (*Payout, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_payout") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_payout") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint("v1/transfers/"+payoutID), http.NoBody) @@ -80,7 +80,7 @@ func (c *client) GetPayout(ctx context.Context, payoutID string) (*Payout, error } func (c *client) CreatePayout(ctx context.Context, quote Quote, targetAccount uint64, transactionID string) (*Payout, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "initiate_payout") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "initiate_payout") reqBody, err := json.Marshal(map[string]interface{}{ "targetAccount": targetAccount, diff --git a/internal/connectors/plugins/public/wise/client/profiles.go b/internal/connectors/plugins/public/wise/client/profiles.go index 0aa32b24..d93b0824 100644 --- a/internal/connectors/plugins/public/wise/client/profiles.go +++ b/internal/connectors/plugins/public/wise/client/profiles.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Profile struct { @@ -14,7 +14,7 @@ type Profile struct { } func (c *client) GetProfiles(ctx context.Context) ([]Profile, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_profiles") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_profiles") var profiles []Profile req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint("v2/profiles"), http.NoBody) diff --git a/internal/connectors/plugins/public/wise/client/quotes.go b/internal/connectors/plugins/public/wise/client/quotes.go index c011c846..a958e215 100644 --- a/internal/connectors/plugins/public/wise/client/quotes.go +++ b/internal/connectors/plugins/public/wise/client/quotes.go @@ -7,7 +7,7 @@ import ( "fmt" "net/http" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" "github.com/google/uuid" ) @@ -16,7 +16,7 @@ type Quote struct { } func (c *client) CreateQuote(ctx context.Context, profileID, currency string, amount json.Number) (Quote, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "create_quote") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "create_quote") var quote Quote diff --git a/internal/connectors/plugins/public/wise/client/recipient_accounts.go b/internal/connectors/plugins/public/wise/client/recipient_accounts.go index 89d7fa3d..58b7b11e 100644 --- a/internal/connectors/plugins/public/wise/client/recipient_accounts.go +++ b/internal/connectors/plugins/public/wise/client/recipient_accounts.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type RecipientAccountsResponse struct { @@ -27,7 +27,7 @@ type RecipientAccount struct { } func (c *client) GetRecipientAccounts(ctx context.Context, profileID uint64, pageSize int, seekPositionForNext uint64) (*RecipientAccountsResponse, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_recipient_accounts") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_recipient_accounts") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint("v2/accounts"), http.NoBody) @@ -54,7 +54,7 @@ func (c *client) GetRecipientAccounts(ctx context.Context, profileID uint64, pag } func (c *client) GetRecipientAccount(ctx context.Context, accountID uint64) (*RecipientAccount, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_recipient_accounts") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_recipient_accounts") c.mux.Lock() defer c.mux.Unlock() diff --git a/internal/connectors/plugins/public/wise/client/transfers.go b/internal/connectors/plugins/public/wise/client/transfers.go index 3d0f7b13..2b3731c9 100644 --- a/internal/connectors/plugins/public/wise/client/transfers.go +++ b/internal/connectors/plugins/public/wise/client/transfers.go @@ -8,7 +8,7 @@ import ( "net/http" "time" - "github.com/formancehq/payments/internal/connectors/httpwrapper" + "github.com/formancehq/payments/internal/connectors/metrics" ) type Transfer struct { @@ -62,7 +62,7 @@ func (t *Transfer) UnmarshalJSON(data []byte) error { } func (c *client) GetTransfers(ctx context.Context, profileID uint64, offset int, limit int) ([]Transfer, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "list_transfers") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "list_transfers") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint("v1/transfers"), http.NoBody) @@ -156,7 +156,7 @@ func (c *client) GetTransfers(ctx context.Context, profileID uint64, offset int, } func (c *client) GetTransfer(ctx context.Context, transferID string) (*Transfer, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "get_transfer") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "get_transfer") req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint("v1/transfers/"+transferID), http.NoBody) @@ -174,7 +174,7 @@ func (c *client) GetTransfer(ctx context.Context, transferID string) (*Transfer, } func (c *client) CreateTransfer(ctx context.Context, quote Quote, targetAccount uint64, transactionID string) (*Transfer, error) { - ctx = context.WithValue(ctx, httpwrapper.MetricOperationContextKey, "initiate_transfer") + ctx = context.WithValue(ctx, metrics.MetricOperationContextKey, "initiate_transfer") reqBody, err := json.Marshal(map[string]interface{}{ "targetAccount": targetAccount,