Skip to main content

relay_metrics/
lib.rs

1//! Metric protocol, aggregation and processing for Sentry.
2//!
3//! Metrics are high-volume values sent from Sentry clients, integrations, or extracted from errors
4//! and transactions, that can be aggregated and queried over large time windows. As opposed to rich
5//! errors and transactions, metrics carry relatively little context information in tags with low
6//! cardinality.
7//!
8//! The metric type is part of its signature just like the unit. Therefore, it is allowed to reuse a
9//! metric name for multiple metric types, which will result in multiple metrics being recorded.
10//!
11//! # Aggregation
12//!
13//! Relay accumulates all metrics in [time buckets](Bucket) before sending them onwards. Aggregation
14//! is handled by the [`aggregator::Aggregator`], which should be created once for the entire system. It flushes
15//! aggregates in regular intervals, either shortly after their original time window has passed or
16//! with a debounce delay for backdated submissions.
17//!
18//! **Warning**: With chained Relays submission delays accumulate.
19//!
20//! Aggregate buckets are encoded in JSON with the following schema:
21//!
22//! ```json
23#![doc = include_str!("../tests/fixtures/buckets.json")]
24//! ```
25//!
26//! # Ingestion
27//!
28//! Processing Relays write aggregate buckets into the ingestion Kafka stream. The schema is similar
29//! to the aggregation payload, with the addition of scoping information. Each bucket is sent in a
30//! separate message:
31//!
32//! ```json
33#![doc = include_str!("../tests/fixtures/kafka.json")]
34//! ```
35#![warn(missing_docs)]
36#![doc(
37    html_logo_url = "https://raw.githubusercontent.com/getsentry/relay/master/artwork/relay-icon.png",
38    html_favicon_url = "https://raw.githubusercontent.com/getsentry/relay/master/artwork/relay-icon.png"
39)]
40
41pub mod aggregator;
42pub mod cogs;
43
44mod bucket;
45mod protocol;
46mod statsd;
47mod utils;
48mod view;
49
50pub use bucket::*;
51pub use protocol::*;
52pub use utils::ByNamespace;
53pub use view::*;