diff --git a/snuba/web/rpc/v1/endpoint_time_series.py b/snuba/web/rpc/v1/endpoint_time_series.py index b49371862b..ebd91cfe4a 100644 --- a/snuba/web/rpc/v1/endpoint_time_series.py +++ b/snuba/web/rpc/v1/endpoint_time_series.py @@ -492,6 +492,7 @@ def _build_snuba_request( 6 * 3600, 12 * 3600, 24 * 3600, # hours + 30 * 24 * 3600, # days } # MAX 1 minute granularity over 7 days (10080 buckets) + additional buckets to allow for partial time buckets on diff --git a/tests/web/rpc/v1/test_endpoint_time_series/test_endpoint_time_series.py b/tests/web/rpc/v1/test_endpoint_time_series/test_endpoint_time_series.py index 81c9588746..ddaad66440 100644 --- a/tests/web/rpc/v1/test_endpoint_time_series/test_endpoint_time_series.py +++ b/tests/web/rpc/v1/test_endpoint_time_series/test_endpoint_time_series.py @@ -2205,6 +2205,7 @@ def test_no_duplicate_labels(self) -> None: (BASE_TIME, BASE_TIME + timedelta(hours=1), 0), (BASE_TIME + timedelta(hours=1), BASE_TIME, 0), (BASE_TIME, BASE_TIME + timedelta(hours=1), 3 * 3600), + (BASE_TIME, BASE_TIME + timedelta(days=7), 30 * 24 * 3600), ], ) def test_bad_granularity(self, start_ts: datetime, end_ts: datetime, granularity: int) -> None: @@ -2259,3 +2260,32 @@ def test_adjust_buckets(self) -> None: _validate_time_buckets(message) # add another bucket to fit into granularity_secs assert message.meta.end_timestamp.seconds == int(BASE_TIME.timestamp()) + 75 + + def test_thirty_day_granularity(self) -> None: + start = int(BASE_TIME.timestamp()) + end = start + int(timedelta(days=90).total_seconds()) + message = TimeSeriesRequest( + meta=RequestMeta( + project_ids=[1, 2, 3], + organization_id=1, + cogs_category="something", + referrer="something", + start_timestamp=Timestamp(seconds=start), + end_timestamp=Timestamp(seconds=end), + debug=True, + trace_item_type=TraceItemType.TRACE_ITEM_TYPE_SPAN, + ), + aggregations=[ + AttributeAggregation( + aggregate=Function.FUNCTION_SUM, + key=AttributeKey(type=AttributeKey.TYPE_FLOAT, name="test_metric"), + label="sum", + extrapolation_mode=ExtrapolationMode.EXTRAPOLATION_MODE_NONE, + ), + ], + granularity_secs=30 * 24 * 3600, + ) + + _validate_time_buckets(message) + # 90 days divides evenly into three 30 day buckets + assert message.meta.end_timestamp.seconds == end