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
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def make_timeseries_result(
values: list[Row],
) -> TimeSeries:
meta = SeriesMeta(
interval=interval.seconds * 1000,
interval=int(interval.total_seconds()) * 1000,
valueType="integer",
valueUnit=None,
)
Expand Down
1 change: 1 addition & 0 deletions src/sentry/search/eap/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
6 * 3600,
12 * 3600,
24 * 3600, # hours
30 * 24 * 3600, # days
}
)
TRUTHY_VALUES = {"1", "true"}
Expand Down
8 changes: 6 additions & 2 deletions src/sentry/snuba/snuba_query_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@
CRASH_RATE_ALERTS_ALLOWED_TIME_WINDOWS = [1800, 3600, 7200, 14400, 43200, 86400]

MIN_EAP_ALERT_TIME_WINDOW_SECONDS = 300
# Snuba subscriptions reject time windows longer than a day.
MAX_EAP_ALERT_TIME_WINDOW_SECONDS = 86400

# Valid time windows for EAP alerts: valid Snuba granularities at or above the alert minimum.
# Valid time windows for EAP alerts: valid Snuba granularities within the alert bounds.
EAP_ALERTS_ALLOWED_TIME_WINDOWS = sorted(
g for g in VALID_GRANULARITIES if g >= MIN_EAP_ALERT_TIME_WINDOW_SECONDS
g
for g in VALID_GRANULARITIES
if MIN_EAP_ALERT_TIME_WINDOW_SECONDS <= g <= MAX_EAP_ALERT_TIME_WINDOW_SECONDS
)


Expand Down
11 changes: 9 additions & 2 deletions src/sentry/uptime/endpoints/organization_uptime_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

logger = logging.getLogger(__name__)

# Don't default to the multi-day granularities; they're only used when requested explicitly.
MAX_DEFAULT_ROLLUP_SECONDS = 24 * 3600


@cell_silo_endpoint
@extend_schema(tags=["Uptime Monitors"])
Expand All @@ -51,8 +54,12 @@ def get(self, request: Request, organization: Organization) -> Response:
timerange_args = self._parse_args(request, restrict_rollups=False)
if "resolution" not in request.GET:
timerange_args["rollup"] = min(
(g for g in VALID_GRANULARITIES if g >= timerange_args["rollup"]),
default=max(VALID_GRANULARITIES),
(
g
for g in VALID_GRANULARITIES
if timerange_args["rollup"] <= g <= MAX_DEFAULT_ROLLUP_SECONDS
),
default=MAX_DEFAULT_ROLLUP_SECONDS,
)
rollup_error = self._validate_rollup(timerange_args)
if rollup_error:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,19 @@ def test_get_new_issues(self) -> None:
"interval": 3_600_000,
}

def test_meta_interval_with_multi_day_interval(self) -> None:
response = self.do_request(
{
"start": self.end - timedelta(days=90),
"end": self.end,
"interval": "30d",
"category": "issue",
"yAxis": "count(new_issues)",
},
)
assert response.status_code == 200, response.content
assert response.data["timeSeries"][0]["meta"]["interval"] == 2_592_000_000

def test_get_resolved_issues(self) -> None:
response = self.do_request(
{
Expand Down
Loading