Skip to content

Commit

Permalink
fix(normalization): Use correct meta object for logentry in light nor…
Browse files Browse the repository at this point in the history
…malization (#1577)

This PR fixes bug for log entry light normalization, where we used wrong
level meta object for errors annotations.
  • Loading branch information
olksdr authored Nov 11, 2022
1 parent 7737c92 commit 2faa33d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
**Bug Fixes**:

- Validate the distribution name in the event. ([#1556](https://github.com/getsentry/relay/pull/1556))
- Use correct meta object for logentry in light normalization. ([#1577](https://github.com/getsentry/relay/pull/1577))

**Internal**:

Expand Down
62 changes: 60 additions & 2 deletions relay-general/src/store/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@ fn normalize_ip_addresses(event: &mut Event, client_ip: Option<&IpAddr>) {
}
}

fn normalize_logentry(logentry: &mut Annotated<LogEntry>, meta: &mut Meta) -> ProcessingResult {
logentry.apply(|le, _| logentry::normalize_logentry(le, meta))
fn normalize_logentry(logentry: &mut Annotated<LogEntry>, _meta: &mut Meta) -> ProcessingResult {
logentry.apply(|le, meta| logentry::normalize_logentry(le, meta))
}

#[derive(Default, Debug)]
Expand Down Expand Up @@ -1865,6 +1865,64 @@ mod tests {
"###);
}

#[test]
fn test_logentry_error() {
let json = r###"
{
"event_id": "74ad1301f4df489ead37d757295442b1",
"timestamp": 1668148328.308933,
"received": 1668148328.308933,
"level": "error",
"platform": "python",
"logentry": {
"params": [
"bogus"
],
"formatted": 42
}
}
"###;
let mut event = Annotated::from_json(json).unwrap();

let mut processor = NormalizeProcessor::default();
let config = LightNormalizationConfig::default();
light_normalize_event(&mut event, &config).unwrap();
process_value(&mut event, &mut processor, ProcessingState::root()).unwrap();

insta::assert_json_snapshot!(SerializableAnnotated(&event), {".received" => "[received]"}, @r###"
{
"event_id": "74ad1301f4df489ead37d757295442b1",
"level": "error",
"type": "default",
"logentry": null,
"logger": "",
"platform": "python",
"timestamp": 1668148328.308933,
"received": "[received]",
"_meta": {
"logentry": {
"": {
"err": [
[
"invalid_data",
{
"reason": "no message present"
}
]
],
"val": {
"formatted": null,
"message": null,
"params": [
"bogus"
]
}
}
}
}
}"###)
}

#[test]
fn test_future_timestamp() {
let mut event = Annotated::new(Event {
Expand Down

0 comments on commit 2faa33d

Please sign in to comment.