pub struct TimeSeries {
pub metric: MetricType,
pub data: VecDeque<DataPoint>,
pub max_size: usize,
}Expand description
Time series for a metric
Fields§
§metric: MetricType§data: VecDeque<DataPoint>§max_size: usizeImplementations§
Source§impl TimeSeries
impl TimeSeries
pub fn new(metric: MetricType, max_size: usize) -> Self
pub fn add(&mut self, point: DataPoint)
pub fn values(&self) -> Vec<f64>
Sourcepub fn moving_average(&self, window: usize) -> Vec<f64>
pub fn moving_average(&self, window: usize) -> Vec<f64>
Calculate moving average
Sourcepub fn exponential_moving_average(&self, alpha: f64) -> Vec<f64>
pub fn exponential_moving_average(&self, alpha: f64) -> Vec<f64>
Calculate exponential moving average
Sourcepub fn linear_trend(&self) -> Option<(f64, f64)>
pub fn linear_trend(&self) -> Option<(f64, f64)>
Simple linear regression for trend
Sourcepub fn predict_linear(&self, steps: usize) -> Vec<f64>
pub fn predict_linear(&self, steps: usize) -> Vec<f64>
Predict next N values using linear trend
Trait Implementations§
Source§impl Clone for TimeSeries
impl Clone for TimeSeries
Source§fn clone(&self) -> TimeSeries
fn clone(&self) -> TimeSeries
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TimeSeries
impl RefUnwindSafe for TimeSeries
impl Send for TimeSeries
impl Sync for TimeSeries
impl Unpin for TimeSeries
impl UnwindSafe for TimeSeries
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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