Skip to main content

CompositeAggregator

Struct CompositeAggregator 

Source
pub struct CompositeAggregator { /* private fields */ }
Expand description

A composite aggregator that runs multiple aggregations in parallel

This is useful when you want to compute multiple statistics at once (e.g., count, avg, p95, stddev) without making multiple passes over the data.

§Examples

use processor::aggregation::{CompositeAggregator, AggregationResult};

let mut composite = CompositeAggregator::new();
composite.add_count("request_count");
composite.add_avg("avg_latency");
composite.add_p95("p95_latency");
composite.add_stddev("stddev_latency");

// Feed values
for latency in vec![100.0, 150.0, 200.0, 250.0, 300.0] {
    composite.update(latency).unwrap();
}

// Get all results
let results = composite.finalize().unwrap();
println!("Count: {}", results.get_count("request_count").unwrap());
println!("Avg: {}", results.get_value("avg_latency").unwrap());
println!("P95: {}", results.get_value("p95_latency").unwrap());
println!("StdDev: {}", results.get_value("stddev_latency").unwrap());

Implementations§

Source§

impl CompositeAggregator

Source

pub fn new() -> Self

Create a new composite aggregator

Source

pub fn add_count(&mut self, name: impl Into<String>) -> &mut Self

Add a count aggregation

Source

pub fn add_sum(&mut self, name: impl Into<String>) -> &mut Self

Add a sum aggregation

Source

pub fn add_avg(&mut self, name: impl Into<String>) -> &mut Self

Add an average aggregation

Source

pub fn add_min(&mut self, name: impl Into<String>) -> &mut Self

Add a min aggregation

Source

pub fn add_max(&mut self, name: impl Into<String>) -> &mut Self

Add a max aggregation

Source

pub fn add_percentile( &mut self, name: impl Into<String>, percentile: f64, ) -> Result<&mut Self>

Add a percentile aggregation

Source

pub fn add_p50(&mut self, name: impl Into<String>) -> &mut Self

Add a p50 (median) aggregation

Source

pub fn add_p95(&mut self, name: impl Into<String>) -> &mut Self

Add a p95 aggregation

Source

pub fn add_p99(&mut self, name: impl Into<String>) -> &mut Self

Add a p99 aggregation

Source

pub fn add_stddev(&mut self, name: impl Into<String>) -> &mut Self

Add a standard deviation aggregation

Source

pub fn update(&mut self, value: f64) -> Result<()>

Update all aggregations with a new value

Source

pub fn update_batch(&mut self, values: &[f64]) -> Result<()>

Update all aggregations with multiple values

Source

pub fn finalize(&self) -> Result<AggregationResult>

Compute final results for all aggregations

Source

pub fn reset(&mut self)

Reset all aggregations to initial state

Source

pub fn len(&self) -> usize

Get the number of aggregations

Source

pub fn is_empty(&self) -> bool

Check if there are no aggregations

Trait Implementations§

Source§

impl Debug for CompositeAggregator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CompositeAggregator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more