chore(analytics): adding dispute id to api log events (#3450)

This commit is contained in:
harsh-sharma-juspay
2024-01-30 12:53:58 +05:30
committed by GitHub
parent d6807abba4
commit 937aea906e
6 changed files with 55 additions and 12 deletions

View File

@ -18,7 +18,8 @@ CREATE TABLE hyperswitch.api_events_queue on cluster '{cluster}' (
`created_at` DateTime CODEC(T64, LZ4),
`latency` Nullable(UInt128),
`user_agent` Nullable(String),
`ip_addr` Nullable(String)
`ip_addr` Nullable(String),
`dispute_id` Nullable(String)
) ENGINE = Kafka SETTINGS kafka_broker_list = 'hyper-c1-kafka-brokers.kafka-cluster.svc.cluster.local:9092',
kafka_topic_list = 'hyperswitch-api-log-events',
kafka_group_name = 'hyper-c1',
@ -81,7 +82,8 @@ CREATE TABLE hyperswitch.api_events_dist on cluster '{cluster}' (
`created_at` DateTime64(3),
`latency` Nullable(UInt128),
`user_agent` Nullable(String),
`ip_addr` Nullable(String)
`ip_addr` Nullable(String),
`dispute_id` Nullable(String)
) ENGINE = Distributed('{cluster}', 'hyperswitch', 'api_events_clustered', rand());
CREATE MATERIALIZED VIEW hyperswitch.api_events_mv on cluster '{cluster}' TO hyperswitch.api_events_dist (
@ -105,7 +107,8 @@ CREATE MATERIALIZED VIEW hyperswitch.api_events_mv on cluster '{cluster}' TO hyp
`created_at` DateTime64(3),
`latency` Nullable(UInt128),
`user_agent` Nullable(String),
`ip_addr` Nullable(String)
`ip_addr` Nullable(String),
`dispute_id` Nullable(String)
) AS
SELECT
merchant_id,
@ -158,7 +161,7 @@ WHERE length(_error) > 0
ALTER TABLE hyperswitch.api_events_clustered on cluster '{cluster}' ADD COLUMN `url_path` LowCardinality(Nullable(String));
ALTER TABLE hyperswitch.api_events_clustered on cluster '{cluster}' ADD COLUMN `event_type` LowCardinality(Nullable(String));
ALTER TABLE hyperswitch.api_events_clustered on cluster '{cluster}' ADD COLUMN `dispute_id` Nullable(String);
CREATE TABLE hyperswitch.api_audit_log ON CLUSTER '{cluster}' (
`merchant_id` LowCardinality(String),
@ -209,7 +212,8 @@ CREATE MATERIALIZED VIEW hyperswitch.api_audit_log_mv ON CLUSTER `{cluster}` TO
`created_at` DateTime64(3),
`latency` Nullable(UInt128),
`user_agent` Nullable(String),
`ip_addr` Nullable(String)
`ip_addr` Nullable(String),
`dispute_id` Nullable(String)
) AS
SELECT
merchant_id,
@ -232,6 +236,7 @@ SELECT
created_at,
latency,
user_agent,
ip_addr
ip_addr,
dispute_id
FROM hyperswitch.api_events_queue
WHERE length(_error) = 0

View File

@ -23,7 +23,8 @@ CREATE TABLE api_events_queue (
`ip_addr` String,
`hs_latency` Nullable(UInt128),
`http_method` LowCardinality(String),
`url_path` String
`url_path` String,
`dispute_id` Nullable(String)
) ENGINE = Kafka SETTINGS kafka_broker_list = 'kafka0:29092',
kafka_topic_list = 'hyperswitch-api-log-events',
kafka_group_name = 'hyper-c1',
@ -57,6 +58,7 @@ CREATE TABLE api_events_dist (
`hs_latency` Nullable(UInt128),
`http_method` LowCardinality(String),
`url_path` String,
`dispute_id` Nullable(String)
INDEX flowIndex flow_type TYPE bloom_filter GRANULARITY 1,
INDEX apiIndex api_flow TYPE bloom_filter GRANULARITY 1,
INDEX statusIndex status_code TYPE bloom_filter GRANULARITY 1
@ -92,7 +94,8 @@ CREATE MATERIALIZED VIEW api_events_mv TO api_events_dist (
`ip_addr` String,
`hs_latency` Nullable(UInt128),
`http_method` LowCardinality(String),
`url_path` String
`url_path` String,
`dispute_id` Nullable(String)
) AS
SELECT
merchant_id,
@ -120,7 +123,8 @@ SELECT
ip_addr,
hs_latency,
http_method,
url_path
url_path,
dispute_id
FROM
api_events_queue
where length(_error) = 0;

View File

@ -1,5 +1,6 @@
pub mod connector_onboarding;
pub mod customer;
pub mod dispute;
pub mod gsm;
mod locker_migration;
pub mod payment;
@ -44,8 +45,6 @@ impl_misc_api_event_type!(
RetrievePaymentLinkResponse,
MandateListConstraints,
CreateFileResponse,
DisputeResponse,
SubmitEvidenceRequest,
MerchantConnectorResponse,
MerchantConnectorId,
MandateResponse,

View File

@ -0,0 +1,25 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};
use super::{DisputeResponse, DisputeResponsePaymentsRetrieve, SubmitEvidenceRequest};
impl ApiEventMetric for SubmitEvidenceRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Dispute {
dispute_id: self.dispute_id.clone(),
})
}
}
impl ApiEventMetric for DisputeResponsePaymentsRetrieve {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Dispute {
dispute_id: self.dispute_id.clone(),
})
}
}
impl ApiEventMetric for DisputeResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Dispute {
dispute_id: self.dispute_id.clone(),
})
}
}

View File

@ -50,6 +50,9 @@ pub enum ApiEventsType {
RustLocker,
FraudCheck,
Recon,
Dispute {
dispute_id: String,
},
}
impl ApiEventMetric for serde_json::Value {}

View File

@ -114,7 +114,6 @@ impl_misc_api_event_type!(
CreateFileRequest,
FileId,
AttachEvidenceRequest,
DisputeId,
PaymentLinkFormData,
ConfigUpdate
);
@ -142,3 +141,11 @@ impl ApiEventMetric for PaymentsRedirectResponseData {
})
}
}
impl ApiEventMetric for DisputeId {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Dispute {
dispute_id: self.dispute_id.clone(),
})
}
}