From c5ad0fc7270cb269b4a19a92ecf44a93b17e5dee Mon Sep 17 00:00:00 2001 From: Max Topolsky <30879163+mtopo27@users.noreply.github.com> Date: Thu, 26 Mar 2026 14:05:22 -0700 Subject: [PATCH] fix(preprod): Align relative_diff extract_value with frontend percentage convention extract_value returned a ratio (0.05 for 5%) while the frontend stores percentage-scale values (5.0 for 5%), so the condition check was always false and relative_diff monitors never triggered. Multiply by 100 to match the frontend convention and align with VCS status checks. Refs LINEAR-EME-985 Co-Authored-By: Claude Opus 4.6 --- src/sentry/preprod/size_analysis/grouptype.py | 2 +- tests/sentry/preprod/size_analysis/test_grouptype.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sentry/preprod/size_analysis/grouptype.py b/src/sentry/preprod/size_analysis/grouptype.py index 26134e46047195..6d03b72e55f634 100644 --- a/src/sentry/preprod/size_analysis/grouptype.py +++ b/src/sentry/preprod/size_analysis/grouptype.py @@ -193,7 +193,7 @@ def extract_value(self, data_packet: SizeAnalysisDataPacket) -> SizeAnalysisEval return self._extract_head(data_packet) - self._extract_base(data_packet) case "relative_diff": base = self._extract_base(data_packet) - return (self._extract_head(data_packet) - base) / base + return ((self._extract_head(data_packet) - base) / base) * 100 case _: raise ValueError(f"Unknown threshold_type: {threshold_type}") diff --git a/tests/sentry/preprod/size_analysis/test_grouptype.py b/tests/sentry/preprod/size_analysis/test_grouptype.py index e35cdb909ac01b..f14d659b5d7c35 100644 --- a/tests/sentry/preprod/size_analysis/test_grouptype.py +++ b/tests/sentry/preprod/size_analysis/test_grouptype.py @@ -281,11 +281,11 @@ def test_evaluate_relative_diff(self): condition_group = self.create_data_condition_group( organization=self.project.organization, ) - # Trigger when relative diff > 0.1 (10%) + # Trigger when relative diff > 10 (10%) self.create_data_condition( condition_group=condition_group, type=Condition.GREATER, - comparison=0.1, + comparison=10, condition_result=DetectorPriorityLevel.HIGH, ) detector = self.create_detector( @@ -296,7 +296,7 @@ def test_evaluate_relative_diff(self): workflow_condition_group=condition_group, ) - # (5000000 - 4000000) / 4000000 = 0.25 > 0.1 + # (5000000 - 4000000) / 4000000 = 25% > 10% data_packet: SizeAnalysisDataPacket = DataPacket( source_id="test", packet={ @@ -316,11 +316,11 @@ def test_evaluate_relative_diff_no_trigger_when_below_threshold(self): condition_group = self.create_data_condition_group( organization=self.project.organization, ) - # Trigger when relative diff > 0.1 (10%) + # Trigger when relative diff > 10 (10%) self.create_data_condition( condition_group=condition_group, type=Condition.GREATER, - comparison=0.1, + comparison=10, condition_result=DetectorPriorityLevel.HIGH, ) detector = self.create_detector( @@ -331,7 +331,7 @@ def test_evaluate_relative_diff_no_trigger_when_below_threshold(self): workflow_condition_group=condition_group, ) - # (5000000 - 4900000) / 4900000 ≈ 0.02 < 0.1 + # (5000000 - 4900000) / 4900000 ≈ 2.04% < 10% data_packet: SizeAnalysisDataPacket = DataPacket( source_id="test", packet={