pub struct BucketView<'a> { /* private fields */ }
Expand description

A view into a metrics bucket. Sometimes also called a partial bucket. A view contains a subset of datapoints of the original bucket.

            Full Bucket
/-------------------------------\
[0, 1, 2, 3, 5, 5, 5, 10, 11, 11]
\----------------/\-------------/
      View 1          View 2

A view can be split again into multiple smaller views.

Implementations§

source§

impl<'a> BucketView<'a>

source

pub fn new(bucket: &'a Bucket) -> Self

Creates a new bucket view of a bucket.

The resulting view contains the entire bucket.

source

pub fn timestamp(&self) -> UnixTimestamp

Timestamp of the bucket.

See also: Bucket::timestamp

source

pub fn width(&self) -> u64

Width of the bucket.

See also: Bucket::width

source

pub fn name(&self) -> &'a MetricName

Name of the bucket.

See also: Bucket::name

source

pub fn value(&self) -> BucketViewValue<'a>

Value of the bucket view.

source

pub fn ty(&self) -> MetricType

Type of the value of the bucket view.

source

pub fn tags(&self) -> &'a BTreeMap<String, String>

Name of the bucket.

See also: Bucket::tags

source

pub fn tag(&self, name: &str) -> Option<&'a str>

Returns the value of the specified tag if it exists.

See also: Bucket::tag()

source

pub fn metadata(&self) -> &BucketMetadata

Returns the metadata for this bucket.

See also: Bucket::metadata.

source

pub fn len(&self) -> usize

Number of raw datapoints in this view.

See also: BucketValue::len()

source

pub fn is_empty(&self) -> bool

Returns true if this bucket view contains no values.

source

pub fn select(self, range: Range<usize>) -> Option<Self>

Selects a sub-view of the current view.

Returns None when:

  • the passed range is not contained in the current view.
  • trying to split a counter or gauge bucket.
source

pub fn estimated_size(&self) -> usize

Estimates the number of bytes needed to serialize the bucket.

Note that this does not match the exact size of the serialized payload. Instead, the size is approximated through the number of contained values, assuming an average size of serialized values.

source

pub fn split( self, size: usize, max_size: Option<usize> ) -> (Option<Self>, Option<Self>)

Calculates a split for this bucket if its estimated serialization size exceeds a threshold.

There are three possible return values:

  • (Some, None) if the bucket fits entirely into the size budget. There is no split.
  • (None, Some) if the size budget cannot even hold the bucket name and tags. There is no split, the entire bucket is moved.
  • (Some, Some) if the bucket fits partially. Remaining values are moved into a new bucket with all other information cloned.

This is an approximate function. The bucket is not actually serialized, but rather its footprint is estimated through the number of data points contained. See estimated_size for more information.

Trait Implementations§

source§

impl<'a> Clone for BucketView<'a>

source§

fn clone(&self) -> BucketView<'a>

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<'a> Debug for BucketView<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Bucket> for BucketView<'a>

source§

fn from(value: &'a Bucket) -> Self

Converts to this type from the input type.
source§

impl<'a> Serialize for BucketView<'a>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for BucketView<'a>

§

impl<'a> Send for BucketView<'a>

§

impl<'a> Sync for BucketView<'a>

§

impl<'a> Unpin for BucketView<'a>

§

impl<'a> UnwindSafe for BucketView<'a>

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> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

§

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>,

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more