Skip to main content

SingleMetric

Trait SingleMetric 

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

Source

type Start: Clone + Send + 'static

Intermediate state captured at span enter.

Source

type Result: Clone + Send + 'static

Final result captured at span exit.

Required Methods§

Source

fn start(&self) -> Self::Start

Capture intermediate state at span enter.

Source

fn end(&self, start: Self::Start) -> Self::Result

Using provided intermediate state, capture final result at time of span exit.

Source

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§

Source

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.

Implementations on Foreign Types§

Source§

impl SingleMetric for f64

Source§

type Start = ()

Source§

type Result = f64

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for i8

Source§

type Start = ()

Source§

type Result = i8

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for i16

Source§

type Start = ()

Source§

type Result = i16

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for i32

Source§

type Start = ()

Source§

type Result = i32

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for i64

Source§

type Start = ()

Source§

type Result = i64

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for isize

Source§

type Start = ()

Source§

type Result = isize

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for u8

Source§

type Start = ()

Source§

type Result = u8

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for u16

Source§

type Start = ()

Source§

type Result = u16

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for u32

Source§

type Start = ()

Source§

type Result = u32

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for u64

Source§

type Start = ()

Source§

type Result = u64

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for u128

Source§

type Start = ()

Source§

type Result = u128

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Source§

impl SingleMetric for usize

Source§

type Start = ()

Source§

type Result = usize

Source§

fn start(&self) -> Self::Start

Source§

fn end(&self, _start: Self::Start) -> Self::Result

Source§

fn result_to_f64(&self, result: &Self::Result) -> f64

Implementors§