Skip to content

Commit c5ad0fc

Browse files
mtopo27claude
andcommitted
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 <noreply@anthropic.com>
1 parent a1eb5dc commit c5ad0fc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/sentry/preprod/size_analysis/grouptype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def extract_value(self, data_packet: SizeAnalysisDataPacket) -> SizeAnalysisEval
193193
return self._extract_head(data_packet) - self._extract_base(data_packet)
194194
case "relative_diff":
195195
base = self._extract_base(data_packet)
196-
return (self._extract_head(data_packet) - base) / base
196+
return ((self._extract_head(data_packet) - base) / base) * 100
197197
case _:
198198
raise ValueError(f"Unknown threshold_type: {threshold_type}")
199199

tests/sentry/preprod/size_analysis/test_grouptype.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,11 @@ def test_evaluate_relative_diff(self):
281281
condition_group = self.create_data_condition_group(
282282
organization=self.project.organization,
283283
)
284-
# Trigger when relative diff > 0.1 (10%)
284+
# Trigger when relative diff > 10 (10%)
285285
self.create_data_condition(
286286
condition_group=condition_group,
287287
type=Condition.GREATER,
288-
comparison=0.1,
288+
comparison=10,
289289
condition_result=DetectorPriorityLevel.HIGH,
290290
)
291291
detector = self.create_detector(
@@ -296,7 +296,7 @@ def test_evaluate_relative_diff(self):
296296
workflow_condition_group=condition_group,
297297
)
298298

299-
# (5000000 - 4000000) / 4000000 = 0.25 > 0.1
299+
# (5000000 - 4000000) / 4000000 = 25% > 10%
300300
data_packet: SizeAnalysisDataPacket = DataPacket(
301301
source_id="test",
302302
packet={
@@ -316,11 +316,11 @@ def test_evaluate_relative_diff_no_trigger_when_below_threshold(self):
316316
condition_group = self.create_data_condition_group(
317317
organization=self.project.organization,
318318
)
319-
# Trigger when relative diff > 0.1 (10%)
319+
# Trigger when relative diff > 10 (10%)
320320
self.create_data_condition(
321321
condition_group=condition_group,
322322
type=Condition.GREATER,
323-
comparison=0.1,
323+
comparison=10,
324324
condition_result=DetectorPriorityLevel.HIGH,
325325
)
326326
detector = self.create_detector(
@@ -331,7 +331,7 @@ def test_evaluate_relative_diff_no_trigger_when_below_threshold(self):
331331
workflow_condition_group=condition_group,
332332
)
333333

334-
# (5000000 - 4900000) / 4900000 ≈ 0.02 < 0.1
334+
# (5000000 - 4900000) / 4900000 ≈ 2.04% < 10%
335335
data_packet: SizeAnalysisDataPacket = DataPacket(
336336
source_id="test",
337337
packet={

0 commit comments

Comments
 (0)