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(rule-condition): Add any and all loop conditions #3791

Merged
merged 17 commits into from
Jul 8, 2024
Merged
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
- Fixes metrics dropped due to missing project state. ([#3553](https://github.com/getsentry/relay/issues/3553))
- Report outcomes for spans when transactions are rate limited. ([#3749](https://github.com/getsentry/relay/pull/3749))

**Features**:

- Add support for `all` and `any` `RuleCondition`(s). ([#3791](https://github.com/getsentry/relay/pull/3791))

**Internal**:

- Aggregate metrics before rate limiting. ([#3746](https://github.com/getsentry/relay/pull/3746))
Expand Down
21 changes: 20 additions & 1 deletion relay-event-schema/src/protocol/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use std::str::FromStr;
use relay_common::time;
#[cfg(feature = "jsonschema")]
use relay_jsonschema_derive::JsonSchema;
use relay_protocol::{Annotated, Array, Empty, FromValue, Getter, IntoValue, Object, Val, Value};
use relay_protocol::{
Annotated, Array, Empty, FromValue, Getter, GetterIter, IntoValue, Object, Val, Value,
};
#[cfg(feature = "jsonschema")]
use schemars::{gen::SchemaGenerator, schema::Schema};
use sentry_release_parser::Release as ParsedRelease;
Expand Down Expand Up @@ -805,6 +807,15 @@ impl Getter for Event {
}
})
}

fn get_iter(&self, path: &str) -> Option<GetterIter<'_>> {
Some(match path.strip_prefix("event.")? {
"exceptions.values" => {
iambriccardo marked this conversation as resolved.
Show resolved Hide resolved
GetterIter::new_annotated(self.exceptions.value()?.values.value()?)
}
_ => return None,
})
}
}

#[cfg(test)]
Expand Down Expand Up @@ -1255,6 +1266,14 @@ mod tests {
Some(Val::String("route")),
event.get_value("event.transaction.source")
);

let mut exceptions = event.get_iter("event.exceptions.values").unwrap();
let exception = exceptions.next().unwrap();
assert_eq!(
Some(Val::String("canvas.contentDocument")),
exception.get_value("value")
);
assert!(exceptions.next().is_none());
}

#[test]
Expand Down
12 changes: 11 additions & 1 deletion relay-event-schema/src/protocol/exception.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(feature = "jsonschema")]
use relay_jsonschema_derive::JsonSchema;
use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};
use relay_protocol::{Annotated, Empty, FromValue, Getter, IntoValue, Object, Val, Value};

use crate::processor::ProcessValue;
use crate::protocol::{JsonLenientString, Mechanism, RawStacktrace, Stacktrace, ThreadId};
Expand Down Expand Up @@ -72,6 +72,16 @@ pub struct Exception {
pub other: Object<Value>,
}

impl Getter for Exception {
fn get_value(&self, path: &str) -> Option<Val<'_>> {
Some(match path {
"ty" => self.ty.as_str()?.into(),
"value" => self.value.as_str()?.into(),
_ => return None,
})
}
}

#[cfg(test)]
mod tests {
use relay_protocol::Map;
Expand Down
Loading
Loading