pub struct LiveSketches { /* private fields */ }Expand description
Live in-process sketches (DW-092): sub-second-freshness per-route
rolling window with counts, errors, and capped latency samples.
Maintained inside EmbeddedAnalytics and updated synchronously
on every record() call — never blocks the dataplane (atomics for
counts, a short mutex over a capped vector for samples). When the
window expires, the completed window’s aggregates are handed to
the insights engine (if attached) for forecasting and anomaly
detection.
Implementations§
Source§impl LiveSketches
impl LiveSketches
Sourcepub fn new(window_size_ms: u64) -> Arc<Self>
pub fn new(window_size_ms: u64) -> Arc<Self>
Construct a new live-sketches store with the given window size.
Sourcepub fn set_insights(&self, engine: Arc<InsightsEngine>)
pub fn set_insights(&self, engine: Arc<InsightsEngine>)
Attach the insights engine so window rotations feed it. Called
once during EmbeddedAnalytics::open wiring.
Sourcepub fn window_start(&self) -> u64
pub fn window_start(&self) -> u64
The current window’s start time (wall-clock ms).
Sourcepub fn record(&self, route: &str, status: u16, duration_ms: f64, now_ms: u64)
pub fn record(&self, route: &str, status: u16, duration_ms: f64, now_ms: u64)
Record one request completion into the current window. Rotates
the window (handing the completed aggregates to the insights
engine) when now_ms has passed the window boundary.
Sourcepub fn snapshot(&self, now_ms: u64) -> LiveSnapshot
pub fn snapshot(&self, now_ms: u64) -> LiveSnapshot
Snapshot the current window’s per-route aggregates. Computes p50/p95/p99 from the retained latency samples (sort-and-pick, O(n log n) with n capped at 1000). This is an admin-path operation, never on the request hot path.
Auto Trait Implementations§
impl !Freeze for LiveSketches
impl RefUnwindSafe for LiveSketches
impl Send for LiveSketches
impl Sync for LiveSketches
impl Unpin for LiveSketches
impl UnwindSafe for LiveSketches
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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