refactor(storage): remove id from payment intent, attempt and remove datamodel ext from payment intent (#4923)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Prajjwal Kumar <prajjwal.kumar@juspay.in>
This commit is contained in:
Narayan Bhat
2024-06-19 17:10:32 +05:30
committed by GitHub
parent 2106a27f40
commit bec51a3557
71 changed files with 1319 additions and 935 deletions

View File

@ -30,6 +30,9 @@ pub mod static_cache;
pub mod types;
pub mod validation;
#[cfg(feature = "metrics")]
pub mod metrics;
/// Date-time utilities.
pub mod date_time {
#[cfg(feature = "async_ext")]

View File

@ -0,0 +1,2 @@
//! Utilities for metrics
pub mod utils;

View File

@ -0,0 +1,33 @@
//! metric utility functions
use std::time;
use router_env::opentelemetry;
/// Record the time taken by the future to execute
#[inline]
pub async fn time_future<F, R>(future: F) -> (R, time::Duration)
where
F: futures::Future<Output = R>,
{
let start = time::Instant::now();
let result = future.await;
let time_spent = start.elapsed();
(result, time_spent)
}
/// Record the time taken (in seconds) by the operation for the given context
#[inline]
pub async fn record_operation_time<F, R>(
future: F,
metric: &opentelemetry::metrics::Histogram<f64>,
metric_context: &opentelemetry::Context,
key_value: &[opentelemetry::KeyValue],
) -> R
where
F: futures::Future<Output = R>,
{
let (result, time) = time_future(future).await;
metric.record(metric_context, time.as_secs_f64(), key_value);
result
}