[][src]Trait envoy_sdk::host::stats::Stats

pub trait Stats {
    fn counter(&self, name: &str) -> Result<Box<dyn Counter>>;
fn gauge(&self, name: &str) -> Result<Box<dyn Gauge>>;
fn histogram(&self, name: &str) -> Result<Box<dyn Histogram>>; }

An interface of the Envoy Stats API.

Examples

Basic usage of Stats:

use envoy::host::Stats;

let stats = Stats::default();

let requests_total = stats.counter("requests_total")?;

requests_total.inc();

Injecting Stats into a HTTP Filter as a dependency:

use envoy::host::Stats;

struct MyHttpFilter<'a> {
    stats: &'a dyn Stats,
}

impl<'a> MyHttpFilter<'a> {
    /// Creates a new instance parameterized with a given [`Stats`] implementation.
    pub fn new(stats: &'a dyn Stats) -> Self {
        MyHttpFilter { stats }
    }

    /// Creates a new instance parameterized with the default [`Stats`] implementation.
    pub fn default() -> Self {
        Self::new(Stats::default())
    }
}

Required methods

fn counter(&self, name: &str) -> Result<Box<dyn Counter>>

Creates a Counter from the stat name.

Tag extraction will be performed on the name.

fn gauge(&self, name: &str) -> Result<Box<dyn Gauge>>

Creates a Gauge from the stat name.

Tag extraction will be performed on the name.

fn histogram(&self, name: &str) -> Result<Box<dyn Histogram>>

Creates a Histogram from the stat name.

Tag extraction will be performed on the name.

Loading content...

Implementations

impl dyn Stats[src]

pub fn default() -> &'static dyn Stats[src]

Returns the default implementation that interacts with Envoy through its ABI.

Implementors

Loading content...