Struct Configuration

Source
pub struct Configuration<T> { /* private fields */ }
Expand description

A configuration builder for Receiver.

Implementations§

Source§

impl<T: Send + Eq + Hash + Display + Clone> Configuration<T>

Source

pub fn new() -> Configuration<T>

Creates a new Configuration with default values.

Source

pub fn capacity(self, capacity: usize) -> Self

Sets the buffer capacity.

Defaults to 512.

This controls the size of the channel used to send metrics. This channel is shared amongst all active sinks. If this channel is full when sending a metric, that send will be blocked until the channel has free space.

Tweaking this value allows for a trade-off between low memory consumption and throughput burst capabilities. By default, we expect samples to occupy approximately 64 bytes. Thus, at our default value, we preallocate roughly ~32KB.

Generally speaking, sending and processing metrics is fast enough that the default value of 4096 supports millions of samples per second.

Source

pub fn batch_size(self, batch_size: usize) -> Self

Sets the batch size.

Defaults to 64.

This controls the size of message batches that we collect for processing. The only real reason to tweak this is to control the latency from the sender side. Larger batches lower the ingest latency in the face of high metric ingest pressure at the cost of higher tail latencies.

Long story short, you shouldn’t need to change this, but it’s here if you really do.

Source

pub fn histogram(self, window: Duration, granularity: Duration) -> Self

Sets the histogram configuration.

Defaults to a 10 second window with 1 second granularity.

This controls how long of a time frame the histogram will track, on a rolling window. We’ll create enough underlying histogram buckets so that we have (window / granularity) buckets, and every interval that passes (granularity), we’ll add a new bucket and drop the oldest one, thereby providing a rolling window.

Histograms, under the hood, are hard-coded to track three significant digits, and will take a theoretical maximum of around 60KB per bucket, so a single histogram metric with the default window/granularity will take a maximum of around 600KB.

In practice, this should be much smaller based on the maximum values pushed into the histogram, as the underlying histogram storage is automatically resized on the fly.

Source

pub fn percentiles(self, percentiles: &[f64]) -> Self

Sets the default percentiles for histograms.

Defaults to min/p50/p95/p99/p999/max.

This controls the percentiles we extract from histograms when taking a snapshot. Percentiles are represented in metrics as pXXX, where XXX is the percentile i.e. p99 is 99.0, p999 is 99.9, etc. min and max are 0.0 and 100.0, respectively.

Source

pub fn build(self) -> Receiver<T>

Create a Receiver based on this configuration.

Trait Implementations§

Source§

impl<T: Clone> Clone for Configuration<T>

Source§

fn clone(&self) -> Configuration<T>

Returns a copy 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<T> Default for Configuration<T>

Source§

fn default() -> Configuration<T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Configuration<T>

§

impl<T> RefUnwindSafe for Configuration<T>
where T: RefUnwindSafe,

§

impl<T> Send for Configuration<T>
where T: Send,

§

impl<T> Sync for Configuration<T>
where T: Sync,

§

impl<T> Unpin for Configuration<T>
where T: Unpin,

§

impl<T> UnwindSafe for Configuration<T>
where T: 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.
Source§

impl<T> Erased for T