Expand description
Break down the cost of Relay by its components and individual features it handles.
Relay is a one stop shop for all different kinds of events Sentry supports, Errors, Performance, Metrics, Replays, Crons and more. A single shared resource.
This module intends to make it possible to give insights how much time and resources Relay spends processing individual features. The measurements collected can be later used for increased observability and accounting purposes.
relay-cogs
provides a way to give an answer to the questions:
- What portion of Relay’s costs can be attributed to feature X?
- How much does feature X cost?
§Collecting COGs Measurements
Measurements are collected through Cogs
which attributes the measurement to either a single
or to multiple different app features belonging to a resource.
Collected and attributed measurements then are recorded by a CogsRecorder
.
use relay_cogs::{AppFeature, Cogs, FeatureWeights, ResourceId};
enum Message {
Span,
Transaction,
TransactionWithSpans { num_spans: usize },
}
struct Processor {
cogs: Cogs
}
impl From<&Message> for FeatureWeights {
fn from(value: &Message) -> Self {
match value {
Message::Span => FeatureWeights::new(AppFeature::Spans),
Message::Transaction => FeatureWeights::new(AppFeature::Transactions),
Message::TransactionWithSpans { num_spans } => FeatureWeights::builder()
.weight(AppFeature::Spans, *num_spans)
.weight(AppFeature::Transactions, 1)
.build(),
}
}
}
impl Processor {
fn handle_message(&self, mut message: Message) {
let _cogs = self.cogs.timed(ResourceId::Relay, &message);
self.step1(&mut message);
self.step2(&mut message);
// Measurement automatically recorded here.
}
}
Macros§
- with
- Records a categorized measurement of the passed
body
, incategory
ontoken
.
Structs§
- Category
Token - A categorized COGS measurement.
- Cogs
- COGS measurements collector.
- Cogs
Measurement - A COGS measurement.
- Feature
Weights - A collection of weighted app features.
- Feature
Weights Builder - A builder for
FeatureWeights
which can be used to configure different weights perAppFeature
. - Noop
Recorder - A recorder which discards all measurements.
- Token
- An in progress COGS measurement.
Enums§
- AppFeature
- App feature a COGS measurement is related to.
- Resource
Id - Resource ID as tracked in COGS.
- Value
- A COGS measurement value.
Traits§
- Category
- A COGS category.
- Cogs
Recorder - Cogs recorder, recording actual measurements.