init
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
//! Traits communs pour l'uniformisation des métriques.
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
|
||||
use crate::http::metrics::HttpMetrics;
|
||||
use crate::udp::metrics::UdpMetrics;
|
||||
|
||||
/// Contrat minimal pour un jeu de compteurs métriques.
|
||||
pub trait Metrics {
|
||||
type Snapshot: MetricsSnapshot;
|
||||
|
||||
/// Prend un instantané cohérent des compteurs à l'instant T.
|
||||
fn snapshot(&self) -> Self::Snapshot;
|
||||
}
|
||||
|
||||
/// Contrat minimal pour un snapshot de métriques.
|
||||
pub trait MetricsSnapshot: Clone {
|
||||
/// Instant auquel le snapshot a été pris.
|
||||
fn taken_at(&self) -> Instant;
|
||||
}
|
||||
|
||||
// ── AppMetrics ────────────────────────────────────────────────────────────────
|
||||
|
||||
/// Regroupe toutes les métriques de l'application.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AppMetrics {
|
||||
pub http: Arc<HttpMetrics>,
|
||||
pub udp: Arc<UdpMetrics>,
|
||||
}
|
||||
|
||||
impl AppMetrics {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
http: HttpMetrics::new(),
|
||||
udp: UdpMetrics::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod reporter;
|
||||
Reference in New Issue
Block a user