Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

chore(kv): add metrics while pushing to stream (#3364)

Kartikeya Hegde8c0c49c6bb02
diff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rs
index 7e2c7f2fc3..d31f05b497 100644
--- a/crates/storage_impl/src/lib.rs
+++ b/crates/storage_impl/src/lib.rs
@@ -225,6 +225,11 @@ impl<T: DatabaseStore> KVRouterStore<T> {
.change_context(RedisError::JsonSerializationFailed)?,
)
.await
+ .map(|_| metrics::KV_PUSHED_TO_DRAINER.add(&metrics::CONTEXT, 1, &[]))
+ .map_err(|err| {
+ metrics::KV_FAILED_TO_PUSH_TO_DRAINER.add(&metrics::CONTEXT, 1, &[]);
+ err
+ })
.change_context(RedisError::StreamAppendFailed)
}
}
diff --git a/crates/storage_impl/src/metrics.rs b/crates/storage_impl/src/metrics.rs
index 3310e45887..29bca2a007 100644
--- a/crates/storage_impl/src/metrics.rs
+++ b/crates/storage_impl/src/metrics.rs
@@ -8,3 +8,5 @@ counter_metric!(KV_MISS, GLOBAL_METER); // No. of KV misses
// Metrics for KV
counter_metric!(KV_OPERATION_SUCCESSFUL, GLOBAL_METER);
counter_metric!(KV_OPERATION_FAILED, GLOBAL_METER);
+counter_metric!(KV_PUSHED_TO_DRAINER, GLOBAL_METER);
+counter_metric!(KV_FAILED_TO_PUSH_TO_DRAINER, GLOBAL_METER);