pub trait SingleMetric:
Send
+ Sync
+ 'static {
type Start: Clone + Send + 'static;
type Result: Clone + Send + 'static;
// Required methods
fn start(&self) -> Self::Start;
fn end(&self, start: Self::Start) -> Self::Result;
fn result_to_f64(&self, result: &Self::Result) -> f64;
// Provided method
fn format_value(&self, value: f64) -> (String, &'static str) { ... }
}Expand description
Trait for metric provider. The metrics is some value that can be measured during program run.
Required Associated Types§
Required Methods§
Sourcefn end(&self, start: Self::Start) -> Self::Result
fn end(&self, start: Self::Start) -> Self::Result
Using provided intermediate state, capture final result at time of span exit.
Sourcefn result_to_f64(&self, result: &Self::Result) -> f64
fn result_to_f64(&self, result: &Self::Result) -> f64
Convert Result to easy-to-analyze f64 values.
During analysis, these values can be summed/averaged across multiple measurements/spans based on configuration.
Provided Methods§
Sourcefn format_value(&self, value: f64) -> (String, &'static str)
fn format_value(&self, value: f64) -> (String, &'static str)
Format Result represented as f64 value into human-readable format.
Result output in form: (formatted_value, unit).
Check format_unit_helper for implementation example.