From be33d7b513e5f7a552ae3bdbc413f40521fd6198 Mon Sep 17 00:00:00 2001 From: David Herberth Date: Mon, 8 Apr 2024 09:47:08 +0200 Subject: [PATCH] feat(metric-stats): Add cardinality limited outcome id --- CHANGELOG.md | 1 + relay-server/src/services/outcome.rs | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66165f84d1..8e5531abb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ **Features**: +- Add `cardinality_limited` outcome with id `6`. ([#3389](https://github.com/getsentry/relay/pull/3389)) - Add support for continuous profiling. ([#3270](https://github.com/getsentry/relay/pull/3270)) - Add support for Reporting API for CSP reports ([#3277](https://github.com/getsentry/relay/pull/3277)) - Extract op and description while converting opentelemetry spans to sentry spans. ([#3287](https://github.com/getsentry/relay/pull/3287)) diff --git a/relay-server/src/services/outcome.rs b/relay-server/src/services/outcome.rs index ab24adf486..a0bc89bcc7 100644 --- a/relay-server/src/services/outcome.rs +++ b/relay-server/src/services/outcome.rs @@ -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 @@ -102,6 +103,7 @@ trait TrackOutcomeLike { OutcomeId::INVALID => "invalid", OutcomeId::ABUSE => "abuse", OutcomeId::CLIENT_DISCARD => "client_discard", + OutcomeId::CARDINALITY_LIMITED => "cardinality_limited", _ => "", } } @@ -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, @@ -197,17 +199,16 @@ impl Outcome { } /// Returns the `reason` code field of this outcome. - pub fn to_reason(&self) -> Option> { + pub fn to_reason(&self) -> Option> { 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,