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

@ -9,8 +9,9 @@ license.workspace = true
[features]
signals = ["dep:signal-hook-tokio", "dep:signal-hook", "dep:tokio", "dep:router_env", "dep:futures"]
async_ext = ["dep:futures", "dep:async-trait"]
async_ext = ["dep:async-trait", "dep:futures"]
logs = ["dep:router_env"]
metrics = ["dep:router_env", "dep:futures"]
[dependencies]
async-trait = { version = "0.1.79", optional = true }
@ -29,7 +30,9 @@ rand = "0.8.5"
regex = "1.10.4"
reqwest = { version = "0.11.27", features = ["json", "native-tls", "gzip", "multipart"] }
ring = { version = "0.17.8", features = ["std", "wasm32_unknown_unknown_js"] }
rust_decimal = "1.35"
rustc-hash = "1.1.0"
semver = { version = "1.0.22", features = ["serde"] }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
serde_urlencoded = "0.7.1"
@ -38,12 +41,10 @@ strum = { version = "0.26.2", features = ["derive"] }
thiserror = "1.0.58"
time = { version = "0.3.35", features = ["serde", "serde-well-known", "std"] }
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"], optional = true }
semver = { version = "1.0.22", features = ["serde"] }
utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order"] }
uuid = { version = "1.8.0", features = ["v7"] }
# First party crates
rust_decimal = "1.35"
rusty-money = { git = "https://github.com/varunsrin/rusty_money", rev = "bbc0150742a0fff905225ff11ee09388e9babdcc", features = ["iso", "crypto"] }
common_enums = { version = "0.1.0", path = "../common_enums" }
masking = { version = "0.1.0", path = "../masking" }

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
}