pub mod error;
pub mod metrics;
pub mod server;
#[cfg(feature = "system-metrics")]
pub mod process;
pub use error::{PrometheusError, Result};
pub use metrics::{CdkMetrics, MintMetricGuard, METRICS};
#[cfg(feature = "system-metrics")]
pub use process::SystemMetrics;
pub use prometheus;
pub use server::{PrometheusBuilder, PrometheusConfig, PrometheusServer};
#[macro_export]
macro_rules! record_metrics {
($metrics_opt:expr => { $($method:ident($($arg:expr),*));* $(;)? }) => {
#[cfg(feature = "prometheus")]
{
if let Some(metrics) = $metrics_opt.as_ref() {
$(
metrics.$method($($arg),*);
)*
} else {
$(
$crate::METRICS.$method($($arg),*);
)*
}
}
};
({ $($method:ident($($arg:expr),*));* $(;)? }) => {
#[cfg(feature = "prometheus")]
{
$(
$crate::METRICS.$method($($arg),*);
)*
}
};
}
pub fn create_cdk_metrics() -> Result<CdkMetrics> {
CdkMetrics::new()
}
pub async fn start_default_server_with_metrics(
shutdown_signal: impl std::future::Future<Output = ()> + Send + 'static,
) -> Result<()> {
let server = PrometheusBuilder::new().build_with_cdk_metrics()?;
server.start(shutdown_signal).await
}