pub struct MetricsRegistry { /* private fields */ }Expand description
Registry of all metrics in the game
Implementations§
Source§impl MetricsRegistry
impl MetricsRegistry
Sourcepub fn with_config(config: MetricsConfig) -> Self
pub fn with_config(config: MetricsConfig) -> Self
Create a registry with custom config
Sourcepub fn config(&self) -> &MetricsConfig
pub fn config(&self) -> &MetricsConfig
Get the current configuration
Sourcepub fn set_config(&mut self, config: MetricsConfig)
pub fn set_config(&mut self, config: MetricsConfig)
Set the configuration
Sourcepub fn define(&mut self, definition: MetricDefinition)
pub fn define(&mut self, definition: MetricDefinition)
Define a new metric
Sourcepub fn all_values(
&self,
) -> impl Iterator<Item = (&MetricId, &VecDeque<MetricValue>)>
pub fn all_values( &self, ) -> impl Iterator<Item = (&MetricId, &VecDeque<MetricValue>)>
Get all values for all metrics (for snapshot creation)
Sourcepub fn aggregate(
&self,
metric_id: &MetricId,
aggregation: AggregationType,
period_start: u64,
period_end: u64,
) -> Option<AggregatedMetric>
pub fn aggregate( &self, metric_id: &MetricId, aggregation: AggregationType, period_start: u64, period_end: u64, ) -> Option<AggregatedMetric>
Get aggregated metric for a specific period
Sourcepub fn get_values(&self, metric_id: &MetricId) -> Option<&VecDeque<MetricValue>>
pub fn get_values(&self, metric_id: &MetricId) -> Option<&VecDeque<MetricValue>>
Get all values for a metric (within window)
Sourcepub fn get_definition(&self, metric_id: &MetricId) -> Option<&MetricDefinition>
pub fn get_definition(&self, metric_id: &MetricId) -> Option<&MetricDefinition>
Get metric definition
Sourcepub fn list_metrics(&self) -> Vec<&MetricDefinition>
pub fn list_metrics(&self) -> Vec<&MetricDefinition>
List all defined metrics
Sourcepub fn last_snapshot_time(&self) -> u64
pub fn last_snapshot_time(&self) -> u64
Get last snapshot time
Sourcepub fn set_last_snapshot_time(&mut self, time: u64)
pub fn set_last_snapshot_time(&mut self, time: u64)
Set last snapshot time
Sourcepub fn last_report_time(&self) -> u64
pub fn last_report_time(&self) -> u64
Get last report time
Sourcepub fn set_last_report_time(&mut self, time: u64)
pub fn set_last_report_time(&mut self, time: u64)
Set last report time
Sourcepub fn is_snapshot_due(&self, current_time: u64) -> bool
pub fn is_snapshot_due(&self, current_time: u64) -> bool
Check if snapshot is due
Sourcepub fn is_report_due(&self, current_time: u64) -> bool
pub fn is_report_due(&self, current_time: u64) -> bool
Check if report is due
Trait Implementations§
Source§impl Clone for MetricsRegistry
impl Clone for MetricsRegistry
Source§fn clone(&self) -> MetricsRegistry
fn clone(&self) -> MetricsRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MetricsRegistry
impl Debug for MetricsRegistry
Source§impl Default for MetricsRegistry
impl Default for MetricsRegistry
Source§impl<'de> Deserialize<'de> for MetricsRegistry
impl<'de> Deserialize<'de> for MetricsRegistry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for MetricsRegistry
impl RefUnwindSafe for MetricsRegistry
impl Send for MetricsRegistry
impl Sync for MetricsRegistry
impl Unpin for MetricsRegistry
impl UnsafeUnpin for MetricsRegistry
impl UnwindSafe for MetricsRegistry
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,
impl<T> Component for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more