Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metric-stats): Add cardinality limited outcome id #3389

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
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