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

feat(protocol): Support comparisons in rule conditions on strings #2721

Merged
merged 9 commits into from
Nov 16, 2023

Conversation

jan-auer
Copy link
Member

@jan-auer jan-auer commented Nov 14, 2023

Adds the ability to run all comparison operators (>, >=, <, <=)
on strings. This applies to dynamic sampling and metric extraction.

Since this change breaks backwards compatibility, the versioning for
metrics extraction and dynamic sampling were bumped.

Dynamic sampling configs did not have a versioning schema before. The
last breaking change introduced a rules_v2 array. To fix this, there
is now versioning built into the new config. Additionally, an
ErrorBoundary is added around sampling configuration to prevent
accidental deserialization failures.

Backwards compatibility is as follows:

  • New Relay <> Old Sentry: Rules are automatically upgraded from
    rules_v2.
  • Old Relay <> New Sentry: Cannot see the new rules and forwards events.

Relates to getsentry/sentry#59896
Resolves https://github.com/getsentry/team-ingest/issues/244

@jan-auer jan-auer self-assigned this Nov 14, 2023
@jan-auer jan-auer requested a review from Dav1dde November 14, 2023 15:27
@jan-auer jan-auer marked this pull request as ready for review November 15, 2023 08:47
@jan-auer jan-auer requested a review from a team November 15, 2023 08:47
@jan-auer
Copy link
Member Author

For reviewers: A regression test for the legacy config is still missing.

py/tests/test_processing.py Outdated Show resolved Hide resolved
@@ -106,12 +106,12 @@ macro_rules! impl_cmp_condition {
/// Path of the field that should match the value.
pub name: String,
/// The numeric value to check against.
pub value: Number,
pub value: Value,
Copy link
Member

Choose a reason for hiding this comment

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

Now since this is a value, should we also add array support like Eq has?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't wanna add this since the semantics of a comparison with an array are questionable. For eq, we defined it as "one of", but for comparisons this seemed weird to me. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I personally found it already surprising for Eq, usually this would be a In operator. So for me then I assumed the value can always be an array and it turns into something like value <OPERATOR> ANY(value).

I agree though this is weird but we already have a precedent for the array. Though I think we just leave it as is and implement it when we need it (we can bump versions now, yay)

relay-sampling/src/config.rs Outdated Show resolved Hide resolved
relay-sampling/src/config.rs Outdated Show resolved Hide resolved
relay-sampling/src/config.rs Show resolved Hide resolved
relay-sampling/src/config.rs Show resolved Hide resolved
relay-sampling/src/config.rs Show resolved Hide resolved
Comment on lines +39 to 40
#[serde(default, skip_serializing)]
pub rules_v2: Vec<SamplingRule>,
Copy link
Contributor

Choose a reason for hiding this comment

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

In some enums we've renamed the option to deprecated and set a serde alias on it. Could that be helpful here?

Copy link
Member

Choose a reason for hiding this comment

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

I like this

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a good idea, however it creates a difference between how Sentry serializes the schema and how it looks in Relay. I'm afraid that it causes more confusion when looking at the code.

@jan-auer jan-auer merged commit 4ccb5b7 into master Nov 16, 2023
20 checks passed
@jan-auer jan-auer deleted the feat/rule-condition-str-cmp branch November 16, 2023 09:27
jan-auer added a commit that referenced this pull request Nov 16, 2023
jan-auer added a commit that referenced this pull request Nov 16, 2023
…ings" (#2727)

Reverts #2721 due to CPU spikes during deploy.
@jan-auer jan-auer restored the feat/rule-condition-str-cmp branch November 16, 2023 11:56
jan-auer added a commit that referenced this pull request Nov 16, 2023
* master:
  feat(protocol): Add access to `device.model` on contexts (#2728)
  Revert "feat(protocol): Support comparisons in rule conditions on strings" (#2727)
  ref(normalization): Remove TransactionsProcessor (#2714)
  feat(protocol): Support comparisons in rule conditions on strings (#2721)
  test(normalization): Reduce span default op test scope (#2726)
  release: 23.11.0
  fix(normalization): Restore performance score normalization (#2725)
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.

4 participants