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>
impl<'a> BucketView<'a>
sourcepub fn new(bucket: &'a Bucket) -> Self
pub fn new(bucket: &'a Bucket) -> Self
Creates a new bucket view of a bucket.
The resulting view contains the entire bucket.
sourcepub fn timestamp(&self) -> UnixTimestamp
pub fn timestamp(&self) -> UnixTimestamp
Timestamp of the bucket.
See also: Bucket::timestamp
sourcepub fn width(&self) -> u64
pub fn width(&self) -> u64
Width of the bucket.
See also: Bucket::width
sourcepub fn name(&self) -> &'a MetricName
pub fn name(&self) -> &'a MetricName
Name of the bucket.
See also: Bucket::name
sourcepub fn value(&self) -> BucketViewValue<'a>
pub fn value(&self) -> BucketViewValue<'a>
Value of the bucket view.
sourcepub fn ty(&self) -> MetricType
pub fn ty(&self) -> MetricType
Type of the value of the bucket view.
Name of the bucket.
See also: Bucket::tags
sourcepub fn tag(&self, name: &str) -> Option<&'a str>
pub fn tag(&self, name: &str) -> Option<&'a str>
Returns the value of the specified tag if it exists.
See also: Bucket::tag()
sourcepub fn metadata(&self) -> BucketMetadata
pub fn metadata(&self) -> BucketMetadata
Returns the metadata for this bucket.
The aggregation process of metadata is inheritly lossy, which means some metadata, for example the amount of merges, can not be accurately split or divided over multiple bucket views.
To compensate for this only a bucket view which contains the start of a bucket will yield this metadata, all other views created from the bucket return an identity value. Merging all metadata from non-overlapping bucket views must yield the same values as stored on the original bucket.
This causes some problems when operations on partial buckets are fallible, for example transmitting two bucket views in separate http requests. To deal with this Relay needs to prevent the splitting of buckets in the first place, by never not creating too large buckets via aggregation in the first place.
See also: Bucket::metadata
.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of raw datapoints in this view.
See also: BucketValue::len()
sourcepub fn select(self, range: Range<usize>) -> Option<Self>
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.
sourcepub fn estimated_size(&self) -> usize
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.
sourcepub fn split(
self,
size: usize,
max_size: Option<usize>,
) -> (Option<Self>, Option<Self>)
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>
impl<'a> Clone for BucketView<'a>
source§fn clone(&self) -> BucketView<'a>
fn clone(&self) -> BucketView<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BucketView<'_>
impl Debug for BucketView<'_>
source§impl<'a> From<&'a Bucket> for BucketView<'a>
impl<'a> From<&'a Bucket> for BucketView<'a>
Auto Trait Implementations§
impl<'a> Freeze for BucketView<'a>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)