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(spans): Reject spans with invalid timestamps #3013

Merged
merged 9 commits into from
Jan 30, 2024

Conversation

iker-barriocanal
Copy link
Contributor

90fa749 removed the timestamp_range from span normalization as it was not used. This PR introduces it back and validates a span's timestamps are valid. A span has valid timestamps when the following conditions are met:

  • start and end timestamps exist.
  • start <= end timestamps.
  • end timestamp is within the valid timestamp range. This range is defined in relay's config, in the secondary aggregator.

@iker-barriocanal iker-barriocanal self-assigned this Jan 29, 2024
@iker-barriocanal iker-barriocanal marked this pull request as ready for review January 29, 2024 12:20
@iker-barriocanal iker-barriocanal requested a review from a team as a code owner January 29, 2024 12:20

**Internal**:

- Drop spans ending outside the valid timestamp range. ([#3013](https://github.com/getsentry/relay/pull/3013))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change only applies to Relays and not librelay, so not updating py/Changelog.

Comment on lines 47 to 48
// Transactions with spans with invalid timestamps are not expected to be
// rejected.
Copy link
Contributor

Choose a reason for hiding this comment

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

This statement is not really true right now, since in the validate_span function we can return an error if either start or end timestamps are absent (which is kind of invalid too), so we will return the error from validate_transaction as well and reject the transaction as well.

It would be great to change this comment here to reflect what condition wouldn't actually reject the transaction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing it out! I reworded it in b9b8b70, let me know if this is still unclear.

relay-server/src/services/processor/span/processing.rs Outdated Show resolved Hide resolved
@@ -1881,3 +1881,74 @@ def test_span_extraction_with_ddm_missing_values(
}

spans_consumer.assert_empty()


def test_span_reject_invalid_timestamps(
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 need an integration test for this? Could it be a unit test instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A unit test is not as solid. The timestamp range on spans is only enforced in stand-alone spans and not on spans processed as part of transactions, meaning testing a single component is not enough and we should test the span processing pipeline instead.

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.

See rename typo, rest LGTM.

relay-server/src/services/processor/span/processing.rs Outdated Show resolved Hide resolved
@iker-barriocanal iker-barriocanal merged commit 8796838 into master Jan 30, 2024
20 checks passed
@iker-barriocanal iker-barriocanal deleted the iker/fix/spans-timestamps branch January 30, 2024 16:04
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