Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sentry/preprod/size_analysis/grouptype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
mtopo27 marked this conversation as resolved.
case _:
raise ValueError(f"Unknown threshold_type: {threshold_type}")

Expand Down
12 changes: 6 additions & 6 deletions tests/sentry/preprod/size_analysis/test_grouptype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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={
Expand All @@ -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(
Expand All @@ -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={
Expand Down
Loading