pub struct SlaMonitor { /* private fields */ }Expand description
SLA 监控器,按操作名聚合延迟与错误统计,并生成 SlaReport。
内部使用 RwLock<HashMap> 实现线程安全,observe 通过 &self 提供
内部可变性,因此可通过 Arc<SlaMonitor> 在多线程中并发调用。
Implementations§
Source§impl SlaMonitor
impl SlaMonitor
pub fn new(slo_target: f64) -> Self
Sourcepub fn observe(&self, operation: &str, duration: Duration, success: bool)
pub fn observe(&self, operation: &str, duration: Duration, success: bool)
记录一次操作观测:延迟与成功/失败。
使用 &self 而非 &mut self,以便通过 Arc<SlaMonitor> 在多线程
中并发写入(与项目现有 SzTracer::end_span 模式一致)。
pub fn report(&self, operation: &str) -> Option<SlaReport>
pub fn operations(&self) -> Vec<String>
Auto Trait Implementations§
impl !Freeze for SlaMonitor
impl RefUnwindSafe for SlaMonitor
impl Send for SlaMonitor
impl Sync for SlaMonitor
impl Unpin for SlaMonitor
impl UnsafeUnpin for SlaMonitor
impl UnwindSafe for SlaMonitor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more