pub struct StatsCollector {
pub cache: Option<FileCache>,
/* private fields */
}
Expand description
Statistics collector for gathering and storing metrics
Fields§
§cache: Option<FileCache>
Implementations§
Source§impl StatsCollector
impl StatsCollector
Sourcepub fn new(config: StatsConfig) -> Self
pub fn new(config: StatsConfig) -> Self
Create a new statistics collector
Sourcepub fn from_config(config: &Config) -> Result<Self>
pub fn from_config(config: &Config) -> Result<Self>
Create a new statistics collector from the main config
Sourcepub fn with_api_client(self, api_client: ApiClient) -> Self
pub fn with_api_client(self, api_client: ApiClient) -> Self
Add an API client to the collector
Sourcepub fn with_cache(self, cache: FileCache) -> Self
pub fn with_cache(self, cache: FileCache) -> Self
Add a cache to the collector
Sourcepub async fn start_timer(&self, name: impl Into<String>) -> Result<String>
pub async fn start_timer(&self, name: impl Into<String>) -> Result<String>
Start a timer with the given name
Sourcepub async fn stop_timer(&self, name: &str) -> Result<Option<Duration>>
pub async fn stop_timer(&self, name: &str) -> Result<Option<Duration>>
Stop a timer and record the duration
Sourcepub async fn record_metric(
&self,
source: impl Into<String>,
name: impl Into<String>,
value: MetricValue,
) -> Result<()>
pub async fn record_metric( &self, source: impl Into<String>, name: impl Into<String>, value: MetricValue, ) -> Result<()>
Record a metric value
Sourcepub async fn record_metrics(
&self,
source: impl Into<String>,
metrics: HashMap<String, MetricValue>,
) -> Result<()>
pub async fn record_metrics( &self, source: impl Into<String>, metrics: HashMap<String, MetricValue>, ) -> Result<()>
Record multiple metrics at once
Sourcepub async fn collect_system_stats(
&self,
source: impl Into<String>,
) -> Result<StatsRecord>
pub async fn collect_system_stats( &self, source: impl Into<String>, ) -> Result<StatsRecord>
Collect system statistics
Sourcepub async fn store_record(&self, record: StatsRecord) -> Result<()>
pub async fn store_record(&self, record: StatsRecord) -> Result<()>
Store a statistics record
Trait Implementations§
Source§impl Clone for StatsCollector
impl Clone for StatsCollector
Source§fn clone(&self) -> StatsCollector
fn clone(&self) -> StatsCollector
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 StatsCollector
impl !RefUnwindSafe for StatsCollector
impl Send for StatsCollector
impl Sync for StatsCollector
impl Unpin for StatsCollector
impl !UnwindSafe for StatsCollector
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