Skip to content

Commit

Permalink
feat(ui): Add 30 minutes window to crash rate alerts (#28938)
Browse files Browse the repository at this point in the history
  • Loading branch information
matejminar authored Sep 30, 2021
1 parent f76f9b4 commit e031bae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class RuleConditionsForm extends React.PureComponent<Props, State> {

if (this.props.dataset === Dataset.SESSIONS) {
options = pick(TIME_WINDOW_MAP, [
TimeWindow.THIRTY_MINUTES,
TimeWindow.ONE_HOUR,
TimeWindow.TWO_HOURS,
TimeWindow.FOUR_HOURS,
Expand Down
18 changes: 16 additions & 2 deletions static/app/views/alerts/incidentRules/triggers/chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const SESSION_AGGREGATE_TO_FIELD = {
};

const TIME_WINDOW_TO_SESSION_INTERVAL = {
[TimeWindow.THIRTY_MINUTES]: '30m',
[TimeWindow.ONE_HOUR]: '1h',
[TimeWindow.TWO_HOURS]: '2h',
[TimeWindow.FOUR_HOURS]: '4h',
Expand Down Expand Up @@ -191,14 +192,27 @@ class TriggersChart extends React.PureComponent<Props, State> {
}
}

get availableTimePeriods() {
// We need to special case sessions, because sub-hour windows are available
// only when time period is six hours or less (backend limitation)
if (isSessionAggregate(this.props.aggregate)) {
return {
...AVAILABLE_TIME_PERIODS,
[TimeWindow.THIRTY_MINUTES]: [TimePeriod.SIX_HOURS],
};
}

return AVAILABLE_TIME_PERIODS;
}

handleStatsPeriodChange = (timePeriod: string) => {
this.setState({statsPeriod: timePeriod as TimePeriod});
};

getStatsPeriod = () => {
const {statsPeriod} = this.state;
const {timeWindow} = this.props;
const statsPeriodOptions = AVAILABLE_TIME_PERIODS[timeWindow];
const statsPeriodOptions = this.availableTimePeriods[timeWindow];
const period = statsPeriodOptions.includes(statsPeriod)
? statsPeriod
: statsPeriodOptions[0];
Expand Down Expand Up @@ -278,7 +292,7 @@ class TriggersChart extends React.PureComponent<Props, State> {
const {triggers, resolveThreshold, thresholdType, header, timeWindow, aggregate} =
this.props;
const {statsPeriod, totalCount} = this.state;
const statsPeriodOptions = AVAILABLE_TIME_PERIODS[timeWindow];
const statsPeriodOptions = this.availableTimePeriods[timeWindow];
const period = this.getStatsPeriod();
return (
<React.Fragment>
Expand Down

0 comments on commit e031bae

Please sign in to comment.