diff --git a/src/sentry/quotas/base.py b/src/sentry/quotas/base.py index 83cdb6eb748f06..9b1e9fb5b27952 100644 --- a/src/sentry/quotas/base.py +++ b/src/sentry/quotas/base.py @@ -401,6 +401,13 @@ def get_event_retention(self, organization): """ return _limit_from_settings(options.get("system.event-retention-days")) + def get_downsampled_event_retention(self, organization): + """ + Returns the retention for downsampled events in the given organization in days. + Returning ``0`` means downsampled event retention will default to the value of ``get_event_retention``. + """ + return 0 + def validate(self): """ Validates that the quota service is operational. diff --git a/src/sentry/relay/config/__init__.py b/src/sentry/relay/config/__init__.py index 42adc0a080daa8..5b4aac045ad2bb 100644 --- a/src/sentry/relay/config/__init__.py +++ b/src/sentry/relay/config/__init__.py @@ -1150,6 +1150,12 @@ def _get_project_config( event_retention = quotas.backend.get_event_retention(project.organization) if event_retention is not None: config["eventRetention"] = event_retention + with sentry_sdk.start_span(op="get_downsampled_event_retention"): + downsampled_event_retention = quotas.backend.get_downsampled_event_retention( + project.organization + ) + if downsampled_event_retention is not None: + config["downsampledEventRetention"] = downsampled_event_retention with sentry_sdk.start_span(op="get_all_quotas"): if quotas_config := get_quotas(project, keys=project_keys): config["quotas"] = quotas_config diff --git a/tests/sentry/api/endpoints/test_relay_projectconfigs.py b/tests/sentry/api/endpoints/test_relay_projectconfigs.py index 1dd6c662b4d7ee..009557890c10e6 100644 --- a/tests/sentry/api/endpoints/test_relay_projectconfigs.py +++ b/tests/sentry/api/endpoints/test_relay_projectconfigs.py @@ -150,6 +150,9 @@ def test_internal_relays_should_receive_full_configs( assert safe.get_path(cfg, "config", "eventRetention") == quotas.backend.get_event_retention( default_project.organization ) + assert safe.get_path( + cfg, "config", "downsampledEventRetention" + ) == quotas.backend.get_downsampled_event_retention(default_project.organization) @django_db_all diff --git a/tests/sentry/api/endpoints/test_relay_projectconfigs_v2.py b/tests/sentry/api/endpoints/test_relay_projectconfigs_v2.py index 98bbfe092f5744..16fedccad2d8e0 100644 --- a/tests/sentry/api/endpoints/test_relay_projectconfigs_v2.py +++ b/tests/sentry/api/endpoints/test_relay_projectconfigs_v2.py @@ -106,6 +106,9 @@ def test_internal_relays_should_receive_full_configs( assert safe.get_path(cfg, "config", "eventRetention") == quotas.backend.get_event_retention( default_project.organization ) + assert safe.get_path( + cfg, "config", "downsampledEventRetention" + ) == quotas.backend.get_downsampled_event_retention(default_project.organization) @django_db_all diff --git a/tests/sentry/relay/snapshots/test_config/test_get_project_config/REGION.pysnap b/tests/sentry/relay/snapshots/test_config/test_get_project_config/REGION.pysnap index fc0f867ac96546..2d8d554eb4d0a8 100644 --- a/tests/sentry/relay/snapshots/test_config/test_get_project_config/REGION.pysnap +++ b/tests/sentry/relay/snapshots/test_config/test_get_project_config/REGION.pysnap @@ -1,5 +1,5 @@ --- -created: '2025-08-06T00:04:51.292281+00:00' +created: '2025-08-11T23:31:41.914727+00:00' creator: sentry source: tests/sentry/relay/test_config.py --- @@ -20,6 +20,7 @@ config: scrubData: true scrubDefaults: true sensitiveFields: [] + downsampledEventRetention: 0 filterSettings: csp: disallowedSources: