Skip to content

Commit fc69657

Browse files
feat(eap): add downsampled event retention to config (#96818)
depends on getsentry/relay#5013 This PR is the second change needed to resolve https://linear.app/getsentry/issue/EAP-160/modify-the-org-setting-to-reflect-the-retention-change-based-on-the.
1 parent 1f4ba8d commit fc69657

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

src/sentry/quotas/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,13 @@ def get_event_retention(self, organization):
401401
"""
402402
return _limit_from_settings(options.get("system.event-retention-days"))
403403

404+
def get_downsampled_event_retention(self, organization):
405+
"""
406+
Returns the retention for downsampled events in the given organization in days.
407+
Returning ``0`` means downsampled event retention will default to the value of ``get_event_retention``.
408+
"""
409+
return 0
410+
404411
def validate(self):
405412
"""
406413
Validates that the quota service is operational.

src/sentry/relay/config/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,12 @@ def _get_project_config(
11501150
event_retention = quotas.backend.get_event_retention(project.organization)
11511151
if event_retention is not None:
11521152
config["eventRetention"] = event_retention
1153+
with sentry_sdk.start_span(op="get_downsampled_event_retention"):
1154+
downsampled_event_retention = quotas.backend.get_downsampled_event_retention(
1155+
project.organization
1156+
)
1157+
if downsampled_event_retention is not None:
1158+
config["downsampledEventRetention"] = downsampled_event_retention
11531159
with sentry_sdk.start_span(op="get_all_quotas"):
11541160
if quotas_config := get_quotas(project, keys=project_keys):
11551161
config["quotas"] = quotas_config

tests/sentry/api/endpoints/test_relay_projectconfigs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ def test_internal_relays_should_receive_full_configs(
150150
assert safe.get_path(cfg, "config", "eventRetention") == quotas.backend.get_event_retention(
151151
default_project.organization
152152
)
153+
assert safe.get_path(
154+
cfg, "config", "downsampledEventRetention"
155+
) == quotas.backend.get_downsampled_event_retention(default_project.organization)
153156

154157

155158
@django_db_all

tests/sentry/api/endpoints/test_relay_projectconfigs_v2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def test_internal_relays_should_receive_full_configs(
106106
assert safe.get_path(cfg, "config", "eventRetention") == quotas.backend.get_event_retention(
107107
default_project.organization
108108
)
109+
assert safe.get_path(
110+
cfg, "config", "downsampledEventRetention"
111+
) == quotas.backend.get_downsampled_event_retention(default_project.organization)
109112

110113

111114
@django_db_all

tests/sentry/relay/snapshots/test_config/test_get_project_config/REGION.pysnap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
created: '2025-08-06T00:04:51.292281+00:00'
2+
created: '2025-08-11T23:31:41.914727+00:00'
33
creator: sentry
44
source: tests/sentry/relay/test_config.py
55
---
@@ -20,6 +20,7 @@ config:
2020
scrubData: true
2121
scrubDefaults: true
2222
sensitiveFields: []
23+
downsampledEventRetention: 0
2324
filterSettings:
2425
csp:
2526
disallowedSources:

0 commit comments

Comments
 (0)