Struct KeyedLinear

Source
pub struct KeyedLinear<K, T>
where T: Flatten,
{ /* private fields */ }
Expand description

Linear histograms.

Linear histograms classify numeric integer values into same-sized buckets. This type is typically used for percentages, or to store a relatively precise of the amount of resources (time, memory) used by a section.

With SerializationFormat::SimpleJson, these histograms are serialized as an object

{
  key_1: array_1,
  key_2: array_2,
  ...
}

where each array_i is an array of numbers, one per bucket, in the numeric order of buckets

Implementations§

Source§

impl<K, T> KeyedLinear<K, T>
where K: ToString, T: Flatten,

Source

pub fn new( service: &Service, name: String, min: u32, max: u32, buckets: usize, ) -> KeyedLinear<K, T>

Create a new Linear histogram with a given name.

Argument name is used as key when processing and exporting the data. Each name must be unique to the Service.

min is the minimal value expected to be entered in this histogram. Any value lower than min is rounded up to min.

max is the maximal value expected to be entered in this histogram. Any value higher than max is rounded up to max.

buckets is the number of buckets in this histogram. For highest possible precision, use buckets = max - min + 1. In most cases, however, such precision is not needed, so you should use a lower number of buckets.

§Performance

Increasing the number of buckets increases the memory usage on the client by a few bytes per bucket per key. More importantly, it also increases the size of the payload, hence the total amount of data that the application will eventually upload to a central server. If your application has many clients and you wish to keep your server happy and your bandwidth costs manageable, don’t use too many buckets.

§Panics

If name is already used by another histogram in service.

If min >= max.

If buckets < max - min + 1.

Trait Implementations§

Source§

impl<K, T> Clone for KeyedLinear<K, T>
where T: Flatten,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K, T> KeyedHistogram<K, T> for KeyedLinear<K, T>
where K: ToString, T: Flatten,

Source§

fn record_cb<F>(&self, cb: F)
where F: FnOnce() -> Option<(K, T)>,

Record a value in this histogram, as provided by a callback. Read more
Source§

fn record(&self, key: K, value: T)

Record a value in this histogram. Read more

Auto Trait Implementations§

§

impl<K, T> Freeze for KeyedLinear<K, T>

§

impl<K, T> RefUnwindSafe for KeyedLinear<K, T>

§

impl<K, T> Send for KeyedLinear<K, T>
where T: Send, K: Send,

§

impl<K, T> Sync for KeyedLinear<K, T>
where T: Sync, K: Sync,

§

impl<K, T> Unpin for KeyedLinear<K, T>
where T: Unpin, K: Unpin,

§

impl<K, T> UnwindSafe for KeyedLinear<K, T>
where T: UnwindSafe, K: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.