Skip to content

Commit 6151dae

Browse files
authored
feat(billing): add transaction retention to config as span (#102095)
1 parent eb67741 commit 6151dae

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/sentry/quotas/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ def to_object(self) -> Mapping[str, Any]:
7171

7272
# This mirrors the Retentions struct in relay
7373
# https://github.com/getsentry/relay/blob/641e7f20cd/relay-dynamic-config/src/project.rs#L34-L45
74-
RETENTIONS_CONFIG_MAPPING = {DataCategory.SPAN: "span", DataCategory.LOG_BYTE: "log"}
74+
RETENTIONS_CONFIG_MAPPING = {
75+
DataCategory.LOG_BYTE: "log",
76+
DataCategory.TRANSACTION: "span",
77+
DataCategory.SPAN: "span",
78+
}
7579

7680

7781
def build_metric_abuse_quotas() -> list[AbuseQuota]:

tests/sentry/api/endpoints/test_relay_projectconfigs.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,31 @@ def test_parse_retentions(call_endpoint, default_project):
192192
}
193193

194194

195+
@django_db_all
196+
def test_parse_retentions_with_transactions(call_endpoint, default_project):
197+
with patch("sentry.quotas.backend") as quotas_mock:
198+
quotas_mock.get_retentions = lambda x: {
199+
DataCategory.ERROR: RetentionSettings(standard=10, downsampled=20),
200+
DataCategory.REPLAY: RetentionSettings(standard=11, downsampled=21),
201+
DataCategory.TRANSACTION: RetentionSettings(standard=12, downsampled=22),
202+
DataCategory.LOG_BYTE: RetentionSettings(standard=13, downsampled=23),
203+
}
204+
quotas_mock.get_event_retention = lambda x: 45
205+
quotas_mock.get_downsampled_event_retention = lambda x: 90
206+
207+
result, status_code = call_endpoint()
208+
assert status_code < 400
209+
assert_no_snakecase_key(result)
210+
cfg = safe.get_path(result, "configs", str(default_project.id))
211+
212+
assert safe.get_path(cfg, "config", "eventRetention") == 45
213+
assert safe.get_path(cfg, "config", "downsampledEventRetention") == 90
214+
assert safe.get_path(cfg, "config", "retentions") == {
215+
"span": {"standard": 12, "downsampled": 22},
216+
"log": {"standard": 13, "downsampled": 23},
217+
}
218+
219+
195220
@django_db_all
196221
def test_relays_dyamic_sampling(call_endpoint, default_project) -> None:
197222
"""

0 commit comments

Comments
 (0)