Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/sentry/quotas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment says it returns None, this is actually 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I updated the docstring here fc37c5d

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there ever be a need to set retention to 0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we wouldn't. If you want a better default here, we can return get_event_retention()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this will read a value linked to the plan at some point?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


def validate(self):
"""
Validates that the quota service is operational.
Expand Down
6 changes: 6 additions & 0 deletions src/sentry/relay/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/sentry/api/endpoints/test_relay_projectconfigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/sentry/api/endpoints/test_relay_projectconfigs_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
---
Expand All @@ -20,6 +20,7 @@ config:
scrubData: true
scrubDefaults: true
sensitiveFields: []
downsampledEventRetention: 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems bad, if we were to store 0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filterSettings:
csp:
disallowedSources:
Expand Down
Loading