feat(analytics): analytics APIs (#2676)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
ivor-juspay
2023-11-03 12:01:47 +05:30
committed by GitHub
parent 53b8fefbc2
commit c0a5e7b7d9
47 changed files with 4507 additions and 13 deletions

View File

@ -1,5 +1,5 @@
#![forbid(unsafe_code)]
#![warn(missing_docs, missing_debug_implementations)]
#![warn(missing_debug_implementations)]
//!
//! Environment of payment router: logger, basic config, its environment awareness.
@ -22,6 +22,7 @@ pub mod vergen;
pub use logger::*;
pub use once_cell;
pub use opentelemetry;
use strum::Display;
pub use tracing;
#[cfg(feature = "actix_web")]
pub use tracing_actix_web;
@ -29,3 +30,19 @@ pub use tracing_appender;
#[doc(inline)]
pub use self::env::*;
use crate::types::FlowMetric;
/// Analytics Flow routes Enums
/// Info - Dimensions and filters available for the domain
/// Filters - Set of values present for the dimension
/// Metrics - Analytical data on dimensions and metrics
#[derive(Debug, Display, Clone, PartialEq, Eq)]
pub enum AnalyticsFlow {
GetInfo,
GetPaymentFilters,
GetRefundFilters,
GetRefundsMetrics,
GetPaymentMetrics,
}
impl FlowMetric for AnalyticsFlow {}

View File

@ -63,3 +63,22 @@ macro_rules! histogram_metric {
> = once_cell::sync::Lazy::new(|| $meter.f64_histogram($description).init());
};
}
/// Create a [`Histogram`][Histogram] u64 metric with the specified name and an optional description,
/// associated with the specified meter. Note that the meter must be to a valid [`Meter`][Meter].
///
/// [Histogram]: opentelemetry::metrics::Histogram
/// [Meter]: opentelemetry::metrics::Meter
#[macro_export]
macro_rules! histogram_metric_u64 {
($name:ident, $meter:ident) => {
pub(crate) static $name: once_cell::sync::Lazy<
$crate::opentelemetry::metrics::Histogram<u64>,
> = once_cell::sync::Lazy::new(|| $meter.u64_histogram(stringify!($name)).init());
};
($name:ident, $meter:ident, $description:literal) => {
pub(crate) static $name: once_cell::sync::Lazy<
$crate::opentelemetry::metrics::Histogram<u64>,
> = once_cell::sync::Lazy::new(|| $meter.u64_histogram($description).init());
};
}