pub struct SlaMonitor { /* private fields */ }Expand description
SLA monitor, aggregates latency and error statistics by operation name, and generates SlaReport.
Uses RwLock<HashMap> internally for thread safety; observe provides interior mutability via
&self, so it can be called concurrently from multiple threads via Arc<SlaMonitor>.
Implementations§
Source§impl SlaMonitor
impl SlaMonitor
pub fn new(slo_target: f64) -> SlaMonitor
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more