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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Support extrapolation of metrics extracted from sampled data, as long as the sample rate is set in the DynamicSamplingContext. ([#3753](https://github.com/getsentry/relay/pull/3753))
- Extract thread ID and name in spans. ([#3771](https://github.com/getsentry/relay/pull/3771))
- Compute metrics summary on the extracted custom metrics. ([#3769](https://github.com/getsentry/relay/pull/3769))
- Add support for `all` and `any` `RuleCondition`(s). ([#3791](https://github.com/getsentry/relay/pull/3791))

## 24.6.0

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.")? {
"exception.values" => {
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.exception.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