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

fix(normalization): Light normalize logentry [ISSUE-1574] #1442

Merged
merged 6 commits into from
Sep 2, 2022

Conversation

iker-barriocanal
Copy link
Contributor

Error message filters look at the formatted and message entries of
an event, in that order. If formatted is not provided in the payload,
relay builds it from message and params, see
docs
.
That build, aka logentry normalization, doesn't happen before filters
are applied. As a result, events with a formatted string that should
be filtered out are not, due to the string not being built yet.

Error message filters look at the `formatted` and `message` entries of
an event, in that order. If `formatted` is not provided in the payload,
relay builds it from `message` and `params`, [see
docs](https://develop.sentry.dev/sdk/event-payloads/types/#typedef-LogEntry).
That build, aka logentry normalization, doesn't happen before filters
are applied. As a result, events with a `formatted` string that should
be filtered out are not, due to the string not being built yet.
 Please enter the commit message for your changes. Lines starting
@iker-barriocanal iker-barriocanal self-assigned this Aug 31, 2022
@iker-barriocanal iker-barriocanal requested a review from a team August 31, 2022 15:11
Comment on lines +67 to +70
({"logentry": {"message": "filter:"}}, False),
({"logentry": {"message": "filter:yes"}}, True),
({"logentry": {"message": "filter:%s", "params": ["no"]}}, False),
({"logentry": {"message": "filter:%s", "params": ["yes"]}}, True),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not added tests with formatted because I don't think they are valuable at this point. I'm open to adding them and it's not much additional work, so let me know if you think they provide enough value.

@@ -574,6 +578,7 @@ pub fn light_normalize_event(
})?;

// Default required attributes, even if they have errors
normalize_logentry(&mut event.logentry, meta)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally, this used to run between normalizing IP addresses and validating the release, see.

The order here is important. It still runs after the schema processor and normalization of security reports and IP addresses. I've placed it here, after validating the release and environment, because it doesn't affect the output and it makes the function easier to read by placing all normalization logic together.

events_consumer.assert_empty()
else:
events_consumer.get_event()
events_consumer.assert_empty()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran this parametrized test on master, and all 8 instances of it passed, so there might still be something wrong with the hypothesis.

Copy link
Contributor Author

@iker-barriocanal iker-barriocanal Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a 1s wait time after sending the event, in bf1d39c. When I was testing it manually, I saw a successful assert_empty followed by a get_event retrieving the event. I'm not sure what is causing that, but adding that 1s addressed this issue (passing here, failing on master). The failing tests on master are those with a message and parameters, with both processing and non-processing relays.

Why 1s? 0.5s isn't enough, and 2s seems too much for now (we can reconsider this if it causes flakiness).

Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Are you also planning to move the exception type/value splitting, or was that a dead end?

@iker-barriocanal iker-barriocanal merged commit 8113c2d into master Sep 2, 2022
@iker-barriocanal iker-barriocanal deleted the iker/fix/light-norm-logentry branch September 2, 2022 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants