pub struct Bucket {
pub timestamp: UnixTimestamp,
pub width: u64,
pub name: MetricName,
pub value: BucketValue,
pub tags: MetricTags,
pub metadata: BucketMetadata,
}Expand description
An aggregation of metric values.
As opposed to single metric values, bucket aggregations can carry multiple values. See
MetricType for a description on how values are aggregated in buckets. Values are aggregated
by metric name, type, time window, and all tags. Particularly, this allows metrics to have the
same name even if their types differ.
See the crate documentation for general information on Metrics.
§Values
The contents of a bucket, especially their representation and serialization, depend on the metric type:
- Counters store a single value, serialized as floating point.
- Distributions and sets store the full set of reported values.
- Gauges store a snapshot of reported values, see
GaugeValue.
§JSON Representation
Metrics are represented as structured data in JSON.
The data type of the value field is determined by the metric type.
Buckets have a required width field in their JSON representation.
[
{
"timestamp": 1615889440,
"width": 0,
"name": "d:transactions/endpoint.response_time@millisecond",
"type": "d",
"value": [
36.0,
49.0,
57.0,
68.0
],
"tags": {
"route": "user_index"
}
},
{
"timestamp": 1615889440,
"width": 0,
"name": "c:transactions/endpoint.hits@none",
"type": "c",
"value": 4.0,
"tags": {
"route": "user_index"
}
},
{
"timestamp": 1615889440,
"width": 0,
"name": "g:transactions/endpoint.parallel_requests@none",
"type": "g",
"value": {
"last": 25.0,
"min": 17.0,
"max": 42.0,
"sum": 220.0,
"count": 85
},
"tags": {
"route": "user_index"
}
},
{
"timestamp": 1615889440,
"width": 0,
"name": "s:transactions/endpoint.users@none",
"type": "s",
"value": [
3182887624,
4267882815
],
"tags": {
"route": "user_index"
}
}
]Fields§
§timestamp: UnixTimestampThe start time of the bucket’s time window, in seconds since the Unix epoch.
width: u64The length of the time window in seconds.
To initialize a new bucket, choose 0 as width. Once the bucket is tracked by Relay’s
aggregator, the width is aligned with configuration for the namespace and the timestamp is
adjusted accordingly.
name: MetricNameThe name of the metric in MRI (metric resource identifier) format.
MRIs have the format <type>:<ns>/<name>@<unit>. See crate::MetricResourceIdentifier for
information on fields and representations.
value: BucketValueThe type and aggregated values of this bucket.
The metric type determines how values are aggregated and represented in JSON.
See BucketValue for more examples and semantics.
A list of tags adding dimensions to the metric for filtering and aggregation.
Tags allow to compute separate aggregates to filter or group metric values by any number of
dimensions. Tags consist of a unique tag key and one associated value. For tags with missing
values, an empty "" value is assumed at query time.
metadata: BucketMetadataRelay internal metadata for a metric bucket.
The metadata contains meta information about the metric bucket itself, for example how many this bucket has been aggregated in total.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Bucket
impl<'de> Deserialize<'de> for Bucket
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'a> From<&'a Bucket> for BucketView<'a>
impl<'a> From<&'a Bucket> for BucketView<'a>
impl StructuralPartialEq for Bucket
Auto Trait Implementations§
impl Freeze for Bucket
impl RefUnwindSafe for Bucket
impl Send for Bucket
impl Sync for Bucket
impl Unpin for Bucket
impl UnsafeUnpin for Bucket
impl UnwindSafe for Bucket
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more