pub struct PollReport { /* private fields */ }Expand description
What has been measured on one subscription: the samples taken, the moving average and the 99th percentile of the time its handler spent in one poll.
§Examples
use ruststream::runtime::PollDiagnostics;
/// A report the operators read: the tail next to the average, and how many polls they rest on.
fn describe(diagnostics: &PollDiagnostics, subscription: &str) -> Option<String> {
let report = diagnostics.report(subscription)?;
Some(format!(
"{}: average {:?}, p99 {:?}, {} polls",
report.subscription(),
report.average(),
report.p99(),
report.samples(),
))
}Implementations§
Source§impl PollReport
impl PollReport
Sourcepub fn subscription(&self) -> &str
pub fn subscription(&self) -> &str
The subscription measured.
§Examples
use ruststream::runtime::PollDiagnostics;
fn log_reports(diagnostics: &PollDiagnostics) {
for report in diagnostics.reports() {
let subscription = report.subscription();
tracing::info!(subscription, average = ?report.average(), "poll time");
}
}Sourcepub const fn samples(&self) -> u64
pub const fn samples(&self) -> u64
How many polls were timed.
§Examples
use ruststream::runtime::PollDiagnostics;
/// How many polls the whole app has timed so far.
fn timed(diagnostics: &PollDiagnostics) -> u64 {
diagnostics
.reports()
.iter()
.map(|report| report.samples())
.sum()
}Sourcepub const fn average(&self) -> Duration
pub const fn average(&self) -> Duration
The exponential moving average of the time in one poll: each sample moves it by a sixteenth of the difference.
§Examples
use std::time::Duration;
use ruststream::runtime::PollDiagnostics;
/// The subscriptions whose handler averages over a budget: candidates for `threads(n)`.
fn over_budget(diagnostics: &PollDiagnostics, budget: Duration) -> Vec<String> {
diagnostics
.reports()
.into_iter()
.filter(|report| report.average() > budget)
.map(|report| report.subscription().to_owned())
.collect()
}Sourcepub const fn p99(&self) -> Duration
pub const fn p99(&self) -> Duration
The 99th percentile of the time in one poll over every sample, read off the histogram.
§Examples
use ruststream::runtime::PollDiagnostics;
/// The tail, which an average hides: one slow poll in a hundred is still a stalled runtime.
fn log_tails(diagnostics: &PollDiagnostics) {
for report in diagnostics.reports() {
let subscription = report.subscription();
tracing::info!(subscription, p99 = ?report.p99(), "poll tail");
}
}Trait Implementations§
Source§impl Clone for PollReport
impl Clone for PollReport
Source§impl Debug for PollReport
impl Debug for PollReport
impl Eq for PollReport
Source§impl Hash for PollReport
impl Hash for PollReport
Source§impl PartialEq for PollReport
impl PartialEq for PollReport
impl StructuralPartialEq for PollReport
Auto Trait Implementations§
impl Freeze for PollReport
impl RefUnwindSafe for PollReport
impl Send for PollReport
impl Sync for PollReport
impl Unpin for PollReport
impl UnsafeUnpin for PollReport
impl UnwindSafe for PollReport
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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