pub mod monitoring;
pub use monitoring::{
AlertConfig, AlertLevel, AlertThresholdF64, AlertThresholdU64, MetricsSnapshot,
};
#[cfg(feature = "monitoring")]
use log::error;
use log::{info, warn};
#[cfg(feature = "monitoring")]
use prometheus::{Counter, Encoder, Gauge, Histogram, HistogramOpts, Registry, TextEncoder};
use std::sync::Arc;
use std::time::{Duration, Instant};
#[cfg(feature = "telemetry")]
use tracing_subscriber;
mod telemetry_impl;
#[cfg(feature = "telemetry")]
pub use telemetry_impl::init_telemetry;
pub use telemetry_impl::start_prometheus_server;
#[cfg(feature = "monitoring")]
pub use telemetry_impl::{set_global_metrics, try_global};
#[cfg(not(feature = "monitoring"))]
#[derive(Clone, Default)]
pub struct Metrics;
#[cfg(feature = "monitoring")]
#[derive(Clone)]
pub struct Metrics {
pub requests_total: Counter,
pub requests_allowed: Counter,
pub requests_rejected: Counter,
pub requests_banned: Counter,
pub errors_total: Counter,
pub check_duration: Histogram,
pub limiter_duration: Histogram,
pub quota_usage: Gauge,
pub concurrent_connections: Gauge,
pub token_bucket_tokens: Gauge,
pub sliding_window_requests: Gauge,
pub fixed_window_requests: Gauge,
registry: Registry,
}
#[derive(Clone)]
pub struct Tracer {
enabled: bool,
}
#[allow(clippy::type_complexity)]
pub struct Span {
started_at: Option<Instant>,
enabled: bool,
attributes: std::sync::Arc<tokio::sync::Mutex<Vec<(String, String)>>>,
events: std::sync::Arc<tokio::sync::Mutex<Vec<(String, Vec<(String, String)>)>>>,
error: std::sync::Arc<tokio::sync::Mutex<Option<String>>>,
}
#[derive(Debug, Clone)]
pub struct TelemetryConfig {
pub service_name: String,
pub jaeger_endpoint: Option<String>,
pub enable_prometheus: bool,
pub enable_tracing: bool,
pub prometheus_port: u16,
pub sampling_rate: f64,
}