Skip to content

Commit 6cb8a73

Browse files
author
Bartek Ogryczak
authored
(chore)issues: clean up "organizations:discover-events-rate-limit" flag (#69066)
Clean up ["organizations:discover-events-rate-limit" flag](https://flagr.getsentry.net/#/flags/211), which has been globally "on" since 2022, making its values the new default.
1 parent 2e2eafa commit 6cb8a73

File tree

4 files changed

+7
-34
lines changed

4 files changed

+7
-34
lines changed

src/sentry/api/endpoints/organization_events.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,9 @@
9494

9595
API_TOKEN_REFERRER = Referrer.API_AUTH_TOKEN_EVENTS.value
9696

97-
RATE_LIMIT = 30
98-
RATE_LIMIT_WINDOW = 1
99-
CONCURRENT_RATE_LIMIT = 15
100-
101-
DEFAULT_RATE_LIMIT = 50
97+
DEFAULT_RATE_LIMIT = 30
10298
DEFAULT_RATE_LIMIT_WINDOW = 1
103-
DEFAULT_CONCURRENT_RATE_LIMIT = 50
99+
DEFAULT_CONCURRENT_RATE_LIMIT = 15
104100

105101
DEFAULT_EVENTS_RATE_LIMIT_CONFIG = {
106102
"GET": {
@@ -118,25 +114,7 @@
118114

119115

120116
def rate_limit_events(request: Request, organization_slug=None, *args, **kwargs) -> RateLimitConfig:
121-
try:
122-
organization = Organization.objects.get_from_cache(slug=organization_slug)
123-
except Organization.DoesNotExist:
124-
return DEFAULT_EVENTS_RATE_LIMIT_CONFIG
125-
# Check for feature flag to enforce rate limit otherwise use default rate limit
126-
if features.has("organizations:discover-events-rate-limit", organization, actor=request.user):
127-
return {
128-
"GET": {
129-
RateLimitCategory.IP: RateLimit(
130-
RATE_LIMIT, RATE_LIMIT_WINDOW, CONCURRENT_RATE_LIMIT
131-
),
132-
RateLimitCategory.USER: RateLimit(
133-
RATE_LIMIT, RATE_LIMIT_WINDOW, CONCURRENT_RATE_LIMIT
134-
),
135-
RateLimitCategory.ORGANIZATION: RateLimit(
136-
RATE_LIMIT, RATE_LIMIT_WINDOW, CONCURRENT_RATE_LIMIT
137-
),
138-
}
139-
}
117+
# TODO: keeping this function for future use, as we'll add more rate limits soon
140118
return DEFAULT_EVENTS_RATE_LIMIT_CONFIG
141119

142120

src/sentry/conf/server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,8 +1548,6 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
15481548
"organizations:discover": False,
15491549
# Enable discover 2 basic functions
15501550
"organizations:discover-basic": True,
1551-
# Enables events endpoint rate limit
1552-
"organizations:discover-events-rate-limit": False,
15531551
# Enable discover 2 custom queries and saved queries
15541552
"organizations:discover-query": True,
15551553
# Enable the org recalibration

src/sentry/features/temporary.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def register_temporary_features(manager: FeatureManager):
6969
manager.add("organizations:device-class-synthesis", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
7070
manager.add("organizations:device-classification", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
7171
manager.add("organizations:discover", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
72-
manager.add("organizations:discover-events-rate-limit", OrganizationFeature, FeatureHandlerStrategy.REMOTE)
7372
manager.add("organizations:ds-org-recalibration", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
7473
manager.add("organizations:enterprise-data-secrecy", OrganizationFeature, FeatureHandlerStrategy.INTERNAL)
7574
manager.add("organizations:escalating-issues-msteams", OrganizationFeature, FeatureHandlerStrategy.REMOTE)

tests/sentry/api/test_organization_events.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.test import override_settings
44
from django.urls import reverse
55

6-
from sentry.api.endpoints.organization_events import RATE_LIMIT
6+
from sentry.api.endpoints.organization_events import DEFAULT_RATE_LIMIT
77
from sentry.search.events import constants
88
from sentry.testutils.cases import APITestCase
99
from sentry.testutils.helpers.datetime import before_now, freeze_time, iso_format
@@ -164,9 +164,7 @@ def test_ratelimit(self):
164164
"project": [self.project.id],
165165
}
166166
with freeze_time("2000-01-01"):
167-
for _ in range(RATE_LIMIT):
168-
self.do_request(query, features={"organizations:discover-events-rate-limit": True})
169-
response = self.do_request(
170-
query, features={"organizations:discover-events-rate-limit": True}
171-
)
167+
for _ in range(DEFAULT_RATE_LIMIT):
168+
self.do_request(query)
169+
response = self.do_request(query)
172170
assert response.status_code == 429, response.content

0 commit comments

Comments
 (0)