Skip to content

Commit

Permalink
feat(getter): Add logentry getter to event (#3796)
Browse files Browse the repository at this point in the history
  • Loading branch information
iambriccardo committed Jul 8, 2024
1 parent 180282b commit 9d24cb3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions relay-event-schema/src/protocol/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ impl Getter for Event {
"platform" => self.platform.as_str().unwrap_or("other").into(),

// Fields in top level structures (called "interfaces" in Sentry)
"logentry.formatted" => self.logentry.value()?.formatted.value()?.as_ref().into(),
"logentry.message" => self.logentry.value()?.message.value()?.as_ref().into(),
"user.email" => or_none(&self.user.value()?.email)?.into(),
"user.id" => or_none(&self.user.value()?.id)?.into(),
"user.ip_address" => self.user.value()?.ip_address.as_str()?.into(),
Expand Down Expand Up @@ -1123,6 +1125,11 @@ mod tests {
})]),
..Default::default()
}),
logentry: Annotated::new(LogEntry {
formatted: Annotated::new("formatted".to_string().into()),
message: Annotated::new("message".to_string().into()),
..Default::default()
}),
request: Annotated::new(Request {
headers: Annotated::new(Headers(PairList(vec![Annotated::new((
Annotated::new("user-agent".into()),
Expand Down Expand Up @@ -1274,6 +1281,15 @@ mod tests {
exception.get_value("value")
);
assert!(exceptions.next().is_none());

assert_eq!(
Some(Val::String("formatted")),
event.get_value("event.logentry.formatted")
);
assert_eq!(
Some(Val::String("message")),
event.get_value("event.logentry.message")
);
}

#[test]
Expand Down

0 comments on commit 9d24cb3

Please sign in to comment.