Browse Source

ref(severity): Change threshold calculation to use 95th percentile (#62686)

p99 -> p95
Isabella Enriquez 1 year ago
parent
commit
6854e4f505
2 changed files with 4 additions and 5 deletions
  1. 2 2
      src/sentry/issues/issue_velocity.py
  2. 2 3
      tests/sentry/issues/test_issue_velocity.py

+ 2 - 2
src/sentry/issues/issue_velocity.py

@@ -38,7 +38,7 @@ logger = logging.getLogger(__name__)
 
 # for snuba operations
 REFERRER = "sentry.issues.issue_velocity"
-THRESHOLD_QUANTILE = {"name": "p99", "function": "quantile(0.99)"}
+THRESHOLD_QUANTILE = {"name": "p95", "function": "quantile(0.95)"}
 WEEK_IN_HOURS = 7 * 24
 
 # for redis operations
@@ -125,7 +125,7 @@ def calculate_threshold(project: Project) -> Optional[float]:
                 [Column("hourly_event_rate")],
                 THRESHOLD_QUANTILE["name"],
             )
-        ],  # get the approximate 90th percentile of the event frequency in the past week
+        ],  # get the approximate 95th percentile of the event frequency in the past week
         limit=Limit(1),
     )
 

+ 2 - 3
tests/sentry/issues/test_issue_velocity.py

@@ -85,9 +85,8 @@ class IssueVelocityTests(TestCase, SnubaTestCase):
                     },
                 )
 
-        # with 5 issues that are older than a week, p99 should be approximately the hourly event
-        # rate of the most frequent issue
-        expected_threshold = 6 / WEEK_IN_HOURS
+        # approximate calculation of 95th percentile for small sample
+        expected_threshold = 6 * 0.95 / WEEK_IN_HOURS
         actual_threshold = calculate_threshold(self.project)
 
         # clickhouse's quantile function is approximate