Skip to main content

ProcessingMetrics

Struct ProcessingMetrics 

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

Metrics collector for tracking processing performance and statistics

Thread-safe metrics tracking for queries, document processing, batches, rate limiting, and system resource usage. Uses atomic operations for counters and locks for duration collections.

Implementations§

Source§

impl ProcessingMetrics

Source

pub fn new() -> Self

Creates a new metrics collector with all counters initialized to zero

Source

pub fn increment_query_started(&self)

Increments the counter for queries started

Source

pub fn increment_query_success(&self)

Increments the counter for successfully completed queries

Source

pub fn increment_query_error(&self)

Increments the counter for failed queries

Source

pub fn record_query_duration(&self, duration: Duration)

Records the execution duration of a query

Keeps only the most recent 1000 measurements to prevent unbounded memory growth.

§Parameters
  • duration: Time taken to execute the query
Source

pub fn increment_document_processing_started(&self)

Increments the counter for document processing operations started

Source

pub fn increment_document_processing_success(&self)

Increments the counter for successfully processed documents

Source

pub fn increment_document_processing_error(&self)

Increments the counter for failed document processing operations

Source

pub fn record_document_processing_duration(&self, duration: Duration)

Records the processing duration of a document

Keeps only the most recent 1000 measurements to prevent unbounded memory growth.

§Parameters
  • duration: Time taken to process the document
Source

pub fn increment_batch_processing_started(&self)

Increments the counter for batch processing operations started

Source

pub fn record_batch_processing_duration(&self, duration: Duration)

Records the processing duration of a batch

Keeps only the most recent 100 measurements to prevent unbounded memory growth.

§Parameters
  • duration: Time taken to process the batch
Source

pub fn increment_rate_limit_errors(&self)

Increments the counter for rate limiting errors

Source

pub fn update_peak_memory_usage(&self, memory_bytes: u64)

Updates peak memory usage if the new value exceeds the current peak

§Parameters
  • memory_bytes: Current memory usage in bytes
Source

pub fn get_queries_started(&self) -> usize

Returns the number of queries started

Source

pub fn get_queries_succeeded(&self) -> usize

Returns the number of queries that succeeded

Source

pub fn get_queries_failed(&self) -> usize

Returns the number of queries that failed

Source

pub fn get_documents_started(&self) -> usize

Returns the number of document processing operations started

Source

pub fn get_documents_succeeded(&self) -> usize

Returns the number of documents processed successfully

Source

pub fn get_documents_failed(&self) -> usize

Returns the number of document processing operations that failed

Source

pub fn get_batches_started(&self) -> usize

Returns the number of batch processing operations started

Source

pub fn get_rate_limit_errors(&self) -> usize

Returns the number of rate limiting errors encountered

Source

pub fn get_peak_memory_usage(&self) -> u64

Returns the peak memory usage observed in bytes

Source

pub fn get_uptime(&self) -> Duration

Returns the time elapsed since metrics tracking started

Source

pub fn get_average_query_duration(&self) -> Option<Duration>

Calculates the average query execution duration

§Returns

Average duration if queries have been recorded, None otherwise

Source

pub fn get_average_document_duration(&self) -> Option<Duration>

Calculates the average document processing duration

§Returns

Average duration if documents have been processed, None otherwise

Source

pub fn get_query_success_rate(&self) -> f64

Calculates the query success rate

§Returns

Ratio of successful queries to total queries (0.0-1.0), or 1.0 if no queries

Source

pub fn get_document_success_rate(&self) -> f64

Calculates the document processing success rate

§Returns

Ratio of successful documents to total documents (0.0-1.0), or 1.0 if no documents

Source

pub fn get_summary(&self) -> MetricsSummary

Generates a comprehensive summary of all metrics

§Returns

Structured summary containing query, document, and system metrics

Source

pub fn print_summary(&self)

Prints a formatted summary of all metrics to the log

Trait Implementations§

Source§

impl Debug for ProcessingMetrics

Source§

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

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

impl Default for ProcessingMetrics

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> 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> ErasedDestructor for T
where T: 'static,