feat(comparison_alerts): Translate delta percents into comparison percents in the api layer. #28787
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The frontend represents percentages as delta change percents. For example:
This makes sense from a user point of view, but doesn't fit as well into how our system handles
thesholds. For example, with decrease, if we had threshold like:
This would fail our validation, since resolve thresholds on below alerts need to be greater than the
critical/warning thresholds. It also makes comparisons in the subscription processor more difficult.
To work around this, we convert these delta percents into comparison percents. This means that:
This fits well into our validation, since now if we have a decrease % alert like
The resolve threshold is now higher than the critical, and validation will succeed.
Handling this complexity at the api layer seems to work the best, so that internally we can assume
that all of these threshold are comparison percents.
I also considered making increase deltas positive and decrease deltas negative, but I felt like this
reads weirdly in terms of our data schema (we'd have a below trigger that looks like < -30%, if you
just looked at the data).