Skip to content

Commit

Permalink
feat(metric-stats): Add cardinality limited outcome id (#3389)
Browse files Browse the repository at this point in the history
Adds the new outcome id `6` `cardinality_limited` to the outcomes enum.

The outcome will already be emitted for the `METRIC_BUCKET` data
category with this change, but the main purpose is to use the outcome
for metric stats.
  • Loading branch information
Dav1dde committed Apr 11, 2024
1 parent 3f124cb commit 7104021
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Allow IP addresses in metrics domain tag. ([#3365](https://github.com/getsentry/relay/pull/3365))
- Support the full unicode character set via UTF-8 encoding for metric tags submitted via the statsd format. Certain restricted characters require escape sequences, see [docs](https://develop.sentry.dev/sdk/metrics/#normalization) for the precise rules. ([#3358](https://github.com/getsentry/relay/pull/3358))
- Stop extracting count_per_segment and count_per_op metrics. ([#3380](https://github.com/getsentry/relay/pull/3380))
- Add `cardinality_limited` outcome with id `6`. ([#3389](https://github.com/getsentry/relay/pull/3389))
- Extract `cache.item_size` and `cache.hit` metrics. ([#3371]https://github.com/getsentry/relay/pull/3371)

**Internal**:
Expand Down
15 changes: 8 additions & 7 deletions relay-server/src/services/outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl OutcomeId {
const INVALID: OutcomeId = OutcomeId(3);
const ABUSE: OutcomeId = OutcomeId(4);
const CLIENT_DISCARD: OutcomeId = OutcomeId(5);
const CARDINALITY_LIMITED: OutcomeId = OutcomeId(6);

pub fn as_u8(self) -> u8 {
self.0
Expand All @@ -102,6 +103,7 @@ trait TrackOutcomeLike {
OutcomeId::INVALID => "invalid",
OutcomeId::ABUSE => "abuse",
OutcomeId::CLIENT_DISCARD => "client_discard",
OutcomeId::CARDINALITY_LIMITED => "cardinality_limited",
_ => "<unknown>",
}
}
Expand Down Expand Up @@ -188,7 +190,7 @@ impl Outcome {
Outcome::Filtered(_) | Outcome::FilteredSampling(_) => OutcomeId::FILTERED,
Outcome::RateLimited(_) => OutcomeId::RATE_LIMITED,
#[cfg(feature = "processing")]
Outcome::CardinalityLimited => OutcomeId::RATE_LIMITED,
Outcome::CardinalityLimited => OutcomeId::CARDINALITY_LIMITED,
Outcome::Invalid(_) => OutcomeId::INVALID,
Outcome::Abuse => OutcomeId::ABUSE,
Outcome::ClientDiscard(_) => OutcomeId::CLIENT_DISCARD,
Expand All @@ -197,17 +199,16 @@ impl Outcome {
}

/// Returns the `reason` code field of this outcome.
pub fn to_reason(&self) -> Option<Cow<str>> {
pub fn to_reason(&self) -> Option<Cow<'_, str>> {
match self {
Outcome::Invalid(discard_reason) => Some(Cow::Borrowed(discard_reason.name())),
Outcome::Filtered(filter_key) => Some(filter_key.clone().name()),
Outcome::FilteredSampling(rule_ids) => Some(Cow::Owned(format!("Sampled:{rule_ids}"))),
//TODO can we do better ? (not re copying the string )
Outcome::RateLimited(code_opt) => code_opt
.as_ref()
.map(|code| Cow::Owned(code.as_str().into())),
Outcome::RateLimited(code_opt) => {
code_opt.as_ref().map(|code| Cow::Borrowed(code.as_str()))
}
#[cfg(feature = "processing")]
Outcome::CardinalityLimited => Some(Cow::Borrowed("cardinality_limited")),
Outcome::CardinalityLimited => None,
Outcome::ClientDiscard(ref discard_reason) => Some(Cow::Borrowed(discard_reason)),
Outcome::Abuse => None,
Outcome::Accepted => None,
Expand Down

0 comments on commit 7104021

Please sign in to comment.