Skip to content

Commit 7cceb28

Browse files
authored
fix(issues): Add project id to occurrence rate limit key (#79695)
this pr adds the project id to the occurrence rate limit key, some fingerprints can be the same across projects and we don't want to rate limit across projects
1 parent 04127b7 commit 7cceb28

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/sentry/issues/occurrence_consumer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,21 @@ class EventLookupError(Exception):
4646
pass
4747

4848

49-
def create_rate_limit_key(fingerprint: str) -> str:
50-
rate_limit_key = f"occurrence_rate_limit:{fingerprint}"
49+
def create_rate_limit_key(project_id: int, fingerprint: str) -> str:
50+
rate_limit_key = f"occurrence_rate_limit:{project_id}-{fingerprint}"
5151
return rate_limit_key
5252

5353

5454
def is_rate_limited(
55+
project_id: int,
5556
fingerprint: str,
5657
) -> bool:
5758
try:
5859
rate_limit_enabled = options.get("issues.occurrence-consumer.rate-limit.enabled")
5960
if not rate_limit_enabled:
6061
return False
6162

62-
rate_limit_key = create_rate_limit_key(fingerprint)
63+
rate_limit_key = create_rate_limit_key(project_id, fingerprint)
6364
rate_limit_quota = Quota(**options.get("issues.occurrence-consumer.rate-limit.quota"))
6465
granted_quota = rate_limiter.check_and_use_quotas(
6566
[
@@ -353,7 +354,7 @@ def process_occurrence_message(
353354
txn.set_tag("result", "dropped_feature_disabled")
354355
return None
355356

356-
if is_rate_limited(fingerprint=occurrence_data["fingerprint"][0]):
357+
if is_rate_limited(project.id, fingerprint=occurrence_data["fingerprint"][0]):
357358
metrics.incr(
358359
"occurrence_ingest.dropped_rate_limited",
359360
sample_rate=1.0,

0 commit comments

Comments
 (0)