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

ref(normalization): Move span validation to NormalizeProcessor #2679

Merged
merged 20 commits into from
Nov 10, 2023

Conversation

iker-barriocanal
Copy link
Contributor

TransactionsProcessor performs some span attribute validation logic. This PR moves that logic to NormalizeProcessor in an attempt to move a step closer to having a single processor.

Notes:

  • This new logic runs before light normalization's is_renormalize flag check. This means that this new code will run even if the flag is disabled, which previously wasn't the case. The purpose of is_renormalize is to make a decision on non-idempotent steps, and these checks are idempotent so this action should be safe.
  • I've started moving stuff from light normalization to NormalizeProcessor from top to bottom, but the end result will be the same. The span-related functionality at the bottom of the function is being updated often, so I'd rather to approach that at a later time to avoid conflicts.

@iker-barriocanal iker-barriocanal self-assigned this Oct 31, 2023
@iker-barriocanal iker-barriocanal requested a review from a team October 31, 2023 09:37
Comment on lines 706 to 707
let span = get_value!(event.spans).unwrap().first().unwrap();
assert_eq!(get_value!(span.op).unwrap(), &"default".to_owned());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is modified from the original test. There used to be a snapshot over the whole span that now fails because transaction.received and transaction.contexts.trace.status exist. Instead of updating the snapshot, I've updated the assertion of what the test is validating.

Copy link
Member

Choose a reason for hiding this comment

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

Could we simplify this test and just call validate_span_timestamps on a Span instead of creating an event?

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'd like to minimize the changes on this PR, but happy to update it in a follow-up.

relay-event-normalization/src/normalize/span/attributes.rs Outdated Show resolved Hide resolved
assert_eq!(
process_value(
&mut event,
&mut NormalizeProcessor::default(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests also use NormalizeProcessor instead of TransactionProcessor.

@@ -188,6 +197,22 @@ impl<'a> Processor for NormalizeProcessor<'a> {

Ok(())
}

fn process_span(
Copy link
Member

Choose a reason for hiding this comment

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

Does this now also run for error events? I believe the TransactionProcessor prevented that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it does for errors. Errors aren't supposed to have spans so I thought it'd be convenient to skip that check over being a bit more defensive.

relay-event-normalization/src/normalize/span/attributes.rs Outdated Show resolved Hide resolved
Comment on lines 706 to 707
let span = get_value!(event.spans).unwrap().first().unwrap();
assert_eq!(get_value!(span.op).unwrap(), &"default".to_owned());
Copy link
Member

Choose a reason for hiding this comment

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

Could we simplify this test and just call validate_span_timestamps on a Span instead of creating an event?

relay-event-normalization/src/normalize/processor.rs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated
@@ -14,6 +14,7 @@
- Disable resource link span ingestion. ([#2647](https://github.com/getsentry/relay/pull/2647))
- Collect `http.decoded_response_content_length`. ([#2638](https://github.com/getsentry/relay/pull/2638))
- Add TTID and TTFD tags to mobile spans. ([#2662](https://github.com/getsentry/relay/pull/2662))
- Validate span timestamps and IDs in light normalization. ([#2679](https://github.com/getsentry/relay/pull/2679))
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need a changelog for this? Span validation was already part of light normalization (through the TransactionProcessor), so that does not change from an outsider's point of view. Let me know if I'm missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! These checks didn't run when renormalize was enabled, which now do (first note on the PR description). I updated the changelog to be a bit more explicit.

Base automatically changed from iker/feat/normalize-processor to master November 6, 2023 16:32
Copy link
Contributor

@olksdr olksdr left a comment

Choose a reason for hiding this comment

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

This new logic runs before light normalization's is_renormalize flag check. This means that this new code will run even if the flag is disabled, which previously wasn't the case. The purpose of is_renormalize is to make a decision on non-idempotent steps, and these checks are idempotent so this action should be safe.

Do we have enough test coverage to prove this?

relay-event-normalization/src/normalize/processor.rs Outdated Show resolved Hide resolved
relay-event-normalization/src/normalize/span/validation.rs Outdated Show resolved Hide resolved
relay-event-normalization/src/normalize/processor.rs Outdated Show resolved Hide resolved
@iker-barriocanal iker-barriocanal merged commit 59fe0c5 into master Nov 10, 2023
20 checks passed
@iker-barriocanal iker-barriocanal deleted the iker/ref/tx-proc-norm-proc branch November 10, 2023 09:30
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.

3 participants