pub struct MetricsCollector { /* private fields */ }Implementations§
Source§impl MetricsCollector
impl MetricsCollector
pub fn new() -> (MetricsCollector, Receiver<MetricsSnapshot>)
pub fn update(&self, f: impl FnOnce(&mut MetricsSnapshot))
Sourcepub fn set_context_max_tokens(&self, max_tokens: u64)
pub fn set_context_max_tokens(&self, max_tokens: u64)
Publish the runtime-resolved context window limit.
Call after the provider pool is constructed (builder) and on every successful
/provider switch so the TUI context gauge reflects the active provider’s window.
§Examples
use zeph_core::metrics::MetricsCollector;
let (collector, rx) = MetricsCollector::new();
collector.set_context_max_tokens(128_000);
assert_eq!(rx.borrow().context_max_tokens, 128_000);Sourcepub fn record_compaction(&self, before: u64, after: u64, at_ms: u64)
pub fn record_compaction(&self, before: u64, after: u64, at_ms: u64)
Record the outcome of the most recent compaction event.
Sets all three compaction_last_* fields atomically. at_ms is the Unix epoch in
milliseconds — obtain via SystemTime::UNIX_EPOCH.elapsed().unwrap_or_default().as_millis().
§Examples
use zeph_core::metrics::MetricsCollector;
let (collector, rx) = MetricsCollector::new();
collector.record_compaction(50_000, 12_000, 1_700_000_000_000);
let snap = rx.borrow();
assert_eq!(snap.compaction_last_before, 50_000);
assert_eq!(snap.compaction_last_after, 12_000);
assert_eq!(snap.compaction_last_at_ms, 1_700_000_000_000);Sourcepub fn sender(&self) -> Sender<MetricsSnapshot>
pub fn sender(&self) -> Sender<MetricsSnapshot>
Returns a clone of the underlying watch::Sender.
Use this to pass the sender to code that requires a raw
watch::Sender<MetricsSnapshot> while the MetricsCollector is
also shared (e.g., passed to a MetricsBridge layer).
Auto Trait Implementations§
impl Freeze for MetricsCollector
impl !RefUnwindSafe for MetricsCollector
impl Send for MetricsCollector
impl Sync for MetricsCollector
impl Unpin for MetricsCollector
impl UnsafeUnpin for MetricsCollector
impl !UnwindSafe for MetricsCollector
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
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request