From 60cff894eb5eecdbbd483064f68309deb8b5d0ae Mon Sep 17 00:00:00 2001 From: Meredith Heller Date: Tue, 28 Apr 2026 13:43:58 -0700 Subject: [PATCH 1/2] ref(outcomes-routing): check request retention_days --- .../routing_strategies/outcomes_based.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/snuba/web/rpc/storage_routing/routing_strategies/outcomes_based.py b/snuba/web/rpc/storage_routing/routing_strategies/outcomes_based.py index 4a7fb5f44a6..9942aaca65c 100644 --- a/snuba/web/rpc/storage_routing/routing_strategies/outcomes_based.py +++ b/snuba/web/rpc/storage_routing/routing_strategies/outcomes_based.py @@ -25,6 +25,7 @@ from snuba.query.logical import Query from snuba.query.query_settings import OutcomesQuerySettings from snuba.request import Request as SnubaRequest +from snuba.settings import LOWER_RETENTION_DAYS from snuba.web.query import run_query from snuba.web.rpc.common.common import ( timestamp_in_range_condition, @@ -218,12 +219,21 @@ def _update_routing_decision( in_msg_meta = extract_message_meta(routing_decision.routing_context.in_msg) - thirty_one_days_ago_ts = int((datetime.now(tz=UTC) - timedelta(days=31)).timestamp()) - older_than_thirty_days = thirty_one_days_ago_ts > in_msg_meta.start_timestamp.seconds + if in_msg_meta.HasField("retention_days"): + full_fidelity_retention_days = in_msg_meta.retention_days + else: + full_fidelity_retention_days = LOWER_RETENTION_DAYS + + full_fidelity_days_ago_ts = int( + (datetime.now(tz=UTC) - timedelta(days=full_fidelity_retention_days + 1)).timestamp() + ) + older_than_full_fidelity_days = ( + full_fidelity_days_ago_ts > in_msg_meta.start_timestamp.seconds + ) if ( state.get_int_config("enable_long_term_retention_downsampling", 0) - and older_than_thirty_days + and older_than_full_fidelity_days and in_msg_meta.trace_item_type not in ITEM_TYPE_FULL_RETENTION ): routing_decision.tier = Tier.TIER_8 From c85555d768c63d5ef3109c197f58b30420b927af Mon Sep 17 00:00:00 2001 From: Meredith Heller Date: Tue, 28 Apr 2026 13:54:41 -0700 Subject: [PATCH 2/2] check VALID_RETENTION_DAYS --- .../storage_routing/routing_strategies/outcomes_based.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/snuba/web/rpc/storage_routing/routing_strategies/outcomes_based.py b/snuba/web/rpc/storage_routing/routing_strategies/outcomes_based.py index 9942aaca65c..5bd0adba2ee 100644 --- a/snuba/web/rpc/storage_routing/routing_strategies/outcomes_based.py +++ b/snuba/web/rpc/storage_routing/routing_strategies/outcomes_based.py @@ -25,7 +25,7 @@ from snuba.query.logical import Query from snuba.query.query_settings import OutcomesQuerySettings from snuba.request import Request as SnubaRequest -from snuba.settings import LOWER_RETENTION_DAYS +from snuba.settings import LOWER_RETENTION_DAYS, VALID_RETENTION_DAYS from snuba.web.query import run_query from snuba.web.rpc.common.common import ( timestamp_in_range_condition, @@ -219,7 +219,10 @@ def _update_routing_decision( in_msg_meta = extract_message_meta(routing_decision.routing_context.in_msg) - if in_msg_meta.HasField("retention_days"): + if ( + in_msg_meta.HasField("retention_days") + and in_msg_meta.retention_days in VALID_RETENTION_DAYS + ): full_fidelity_retention_days = in_msg_meta.retention_days else: full_fidelity_retention_days = LOWER_RETENTION_DAYS