Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(metric-alerts): Remove metric-alert-threshold-period flag #83203

Merged
merged 1 commit into from
Jan 13, 2025
Merged
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 @@ -12,7 +12,6 @@ describe('AnomalyDetectionFeedbackBanner', () => {
const initialData = initializeOrg({
organization: {
features: [
'metric-alert-threshold-period',
'change-alerts',
'anomaly-detection-alerts',
'anomaly-detection-rollout',
Expand Down
12 changes: 1 addition & 11 deletions static/app/views/alerts/rules/metric/ruleForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {MetricRuleFixture} from 'sentry-fixture/metricRule';

import {initializeOrg} from 'sentry-test/initializeOrg';
import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
import selectEvent from 'sentry-test/selectEvent';

import {addErrorMessage} from 'sentry/actionCreators/indicator';
import type FormModel from 'sentry/components/forms/model';
Expand Down Expand Up @@ -48,7 +47,7 @@ describe('Incident Rules Form', () => {

beforeEach(() => {
const initialData = initializeOrg({
organization: {features: ['metric-alert-threshold-period', 'change-alerts']},
organization: {features: ['change-alerts']},
});
organization = initialData.organization;
project = initialData.project;
Expand Down Expand Up @@ -201,9 +200,6 @@ describe('Incident Rules Form', () => {
'Incident Rule'
);

// Set thresholdPeriod
await selectEvent.select(screen.getAllByText('For 1 minute')[0]!, 'For 10 minutes');

await userEvent.click(screen.getByLabelText('Save Rule'));

expect(createRule).toHaveBeenCalledWith(
Expand All @@ -213,7 +209,6 @@ describe('Incident Rules Form', () => {
name: 'Incident Rule',
projects: ['project-slug'],
eventTypes: ['default'],
thresholdPeriod: 10,
}),
})
);
Expand Down Expand Up @@ -401,9 +396,6 @@ describe('Incident Rules Form', () => {
'EAP Incident Rule'
);

// Set thresholdPeriod
await selectEvent.select(screen.getAllByText('For 1 minute')[0]!, 'For 10 minutes');

await userEvent.click(screen.getByLabelText('Save Rule'));

expect(createRule).toHaveBeenCalledWith(
Expand All @@ -413,7 +405,6 @@ describe('Incident Rules Form', () => {
name: 'EAP Incident Rule',
projects: ['project-slug'],
eventTypes: [],
thresholdPeriod: 10,
alertType: 'eap_metrics',
dataset: 'events_analytics_platform',
}),
Expand Down Expand Up @@ -473,7 +464,6 @@ describe('Incident Rules Form', () => {
name: 'Query Rule',
projects: ['project-slug'],
eventTypes: ['num_errors'],
thresholdPeriod: 10,
query: 'is:unresolved',
rule,
ruleId: rule.id,
Expand Down
8 changes: 0 additions & 8 deletions static/app/views/alerts/rules/metric/ruleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ type State = {
query: string;
resolveThreshold: UnsavedMetricRule['resolveThreshold'];
sensitivity: UnsavedMetricRule['sensitivity'];
thresholdPeriod: UnsavedMetricRule['thresholdPeriod'];
thresholdType: UnsavedMetricRule['thresholdType'];
timeWindow: number;
triggerErrors: Map<number, {[fieldName: string]: string}>;
Expand Down Expand Up @@ -872,10 +871,6 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
);
};

handleThresholdPeriodChange = (value: number) => {
this.setState({thresholdPeriod: value}, () => this.fetchAnomalies());
};

handleResolveThresholdChange = (
resolveThreshold: UnsavedMetricRule['resolveThreshold']
) => {
Expand Down Expand Up @@ -1234,7 +1229,6 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
triggers,
aggregate,
thresholdType,
thresholdPeriod,
comparisonDelta,
comparisonType,
resolveThreshold,
Expand Down Expand Up @@ -1263,15 +1257,13 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
isMigration={isMigration}
resolveThreshold={resolveThreshold}
sensitivity={sensitivity}
thresholdPeriod={thresholdPeriod}
thresholdType={thresholdType}
comparisonType={comparisonType}
currentProject={project.slug}
organization={organization}
availableActions={this.state.availableActions}
onChange={this.handleChangeTriggers}
onThresholdTypeChange={this.handleThresholdTypeChange}
onThresholdPeriodChange={this.handleThresholdPeriodChange}
onResolveThresholdChange={this.handleResolveThresholdChange}
onSensitivityChange={this.handleSensitivityChange}
/>
Expand Down
12 changes: 0 additions & 12 deletions static/app/views/alerts/rules/metric/triggers/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ type Props = {
fieldHelp: React.ReactNode;
isCritical: boolean;
onChange: (trigger: Trigger, changeObj: Partial<Trigger>) => void;
onThresholdPeriodChange: (value: number) => void;
onThresholdTypeChange: (thresholdType: AlertRuleThresholdType) => void;
organization: Organization;
placeholder: string;
projects: Project[];
resolveThreshold: UnsavedMetricRule['resolveThreshold'];
thresholdPeriod: UnsavedMetricRule['thresholdPeriod'];
thresholdType: UnsavedMetricRule['thresholdType'];
trigger: Trigger;

Expand Down Expand Up @@ -79,14 +77,12 @@ class TriggerFormItem extends PureComponent<Props> {
trigger,
isCritical,
thresholdType,
thresholdPeriod,
hideControl,
comparisonType,
fieldHelp,
triggerLabel,
placeholder,
onThresholdTypeChange,
onThresholdPeriodChange,
} = this.props;

return (
Expand All @@ -101,14 +97,12 @@ class TriggerFormItem extends PureComponent<Props> {
disableThresholdType={!isCritical}
type={trigger.label}
thresholdType={thresholdType}
thresholdPeriod={thresholdPeriod}
hideControl={hideControl}
threshold={trigger.alertThreshold}
comparisonType={comparisonType}
placeholder={placeholder}
onChange={this.handleChangeThreshold}
onThresholdTypeChange={onThresholdTypeChange}
onThresholdPeriodChange={onThresholdPeriodChange}
/>
</StyledField>
);
Expand Down Expand Up @@ -193,13 +187,11 @@ class TriggerFormContainer extends Component<TriggerFormContainerProps> {
organization,
triggers,
thresholdType,
thresholdPeriod,
comparisonType,
aggregate,
resolveThreshold,
projects,
onThresholdTypeChange,
onThresholdPeriodChange,
} = this.props;

const resolveTrigger: UnsavedTrigger = {
Expand All @@ -223,7 +215,6 @@ class TriggerFormContainer extends Component<TriggerFormContainerProps> {
disabled={disabled}
error={errors?.get(index)}
trigger={trigger}
thresholdPeriod={thresholdPeriod}
thresholdType={thresholdType}
comparisonType={comparisonType}
aggregate={aggregate}
Expand Down Expand Up @@ -254,7 +245,6 @@ class TriggerFormContainer extends Component<TriggerFormContainerProps> {
}
onChange={this.handleChangeTrigger(index)}
onThresholdTypeChange={onThresholdTypeChange}
onThresholdPeriodChange={onThresholdPeriodChange}
/>
);
})}
Expand All @@ -265,7 +255,6 @@ class TriggerFormContainer extends Component<TriggerFormContainerProps> {
error={errors?.get(2)}
trigger={resolveTrigger}
// Flip rule thresholdType to opposite
thresholdPeriod={thresholdPeriod}
thresholdType={+!thresholdType}
comparisonType={comparisonType}
aggregate={aggregate}
Expand All @@ -284,7 +273,6 @@ class TriggerFormContainer extends Component<TriggerFormContainerProps> {
placeholder={t('Automatic')}
onChange={this.handleChangeResolveTrigger}
onThresholdTypeChange={onThresholdTypeChange}
onThresholdPeriodChange={onThresholdPeriodChange}
/>
</Fragment>
);
Expand Down
6 changes: 0 additions & 6 deletions static/app/views/alerts/rules/metric/triggers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ type Props = {
resolveThreshold: UnsavedMetricRule['resolveThreshold']
) => void;
onSensitivityChange: (sensitivity: AlertRuleSensitivity) => void;
onThresholdPeriodChange: (value: number) => void;
onThresholdTypeChange: (thresholdType: AlertRuleThresholdType) => void;
organization: Organization;
projects: Project[];
resolveThreshold: UnsavedMetricRule['resolveThreshold'];

sensitivity: UnsavedMetricRule['sensitivity'];

thresholdPeriod: UnsavedMetricRule['thresholdPeriod'];
thresholdType: UnsavedMetricRule['thresholdType'];
triggers: Trigger[];
isMigration?: boolean;
Expand Down Expand Up @@ -108,14 +106,12 @@ class Triggers extends Component<Props> {
disabled,
aggregate,
thresholdType,
thresholdPeriod,
comparisonType,
resolveThreshold,
isMigration,
onSensitivityChange,
onThresholdTypeChange,
onResolveThresholdChange,
onThresholdPeriodChange,
sensitivity,
} = this.props;

Expand All @@ -142,12 +138,10 @@ class Triggers extends Component<Props> {
aggregate={aggregate}
resolveThreshold={resolveThreshold}
thresholdType={thresholdType}
thresholdPeriod={thresholdPeriod}
comparisonType={comparisonType}
onChange={this.handleChangeTrigger}
onThresholdTypeChange={onThresholdTypeChange}
onResolveThresholdChange={onResolveThresholdChange}
onThresholdPeriodChange={onThresholdPeriodChange}
/>
)}
</PanelBody>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {Component} from 'react';
import styled from '@emotion/styled';

import Feature from 'sentry/components/acl/feature';
import SelectControl from 'sentry/components/forms/controls/selectControl';
import Input from 'sentry/components/input';
import NumberDragControl from 'sentry/components/numberDragControl';
import {Tooltip} from 'sentry/components/tooltip';
import {t, tct, tn} from 'sentry/locale';
import {t, tct} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import type {ThresholdControlValue} from 'sentry/views/alerts/rules/metric/types';
import {
Expand All @@ -19,10 +18,8 @@ type Props = ThresholdControlValue & {
disableThresholdType: boolean;
disabled: boolean;
onChange: (value: ThresholdControlValue, e: React.FormEvent) => void;
onThresholdPeriodChange: (value: number) => void;
onThresholdTypeChange: (thresholdType: AlertRuleThresholdType) => void;
placeholder: string;
thresholdPeriod: number | null;
type: string;
hideControl?: boolean;
};
Expand Down Expand Up @@ -90,14 +87,9 @@ class ThresholdControl extends Component<Props, State> {
onChange({thresholdType, threshold: currentValue + delta}, e);
};

handleThresholdPeriodChange = ({value}) => {
this.props.onThresholdPeriodChange(value);
};

render() {
const {currentValue} = this.state;
const {
thresholdPeriod,
thresholdType,
comparisonType,
hideControl,
Expand Down Expand Up @@ -195,22 +187,6 @@ class ThresholdControl extends Component<Props, State> {
</ThresholdContainer>
)}
</Container>
{!hideControl && (
<Feature features="metric-alert-threshold-period">
<SelectContainer>
<SelectControl
isDisabled={disabled}
name="thresholdPeriod"
value={thresholdPeriod}
options={[1, 2, 5, 10, 20].map(value => ({
value,
label: tn('For %s minute', 'For %s minutes', value),
}))}
onChange={this.handleThresholdPeriodChange}
/>
</SelectContainer>
</Feature>
)}
</Wrapper>
);
}
Expand Down
Loading