Skip to content
Closed
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
1 change: 1 addition & 0 deletions snuba/web/rpc/v1/endpoint_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Loading