Skip to content

feat(uptime)Create Advanced Config Section #93064

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
170 changes: 95 additions & 75 deletions static/app/views/alerts/rules/uptime/uptimeAlertForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function UptimeAlertForm({project, handleDelete, rule}: Props) {
: {projectSlug: project.slug, method: 'GET', headers: []};

const [formModel] = useState(() => new FormModel());
const [advancedVisible, setAdvancedVisible] = useState(false);

const [knownEnvironments, setEnvironments] = useState<string[]>([]);
const [newEnvironment, setNewEnvironment] = useState<string | undefined>(undefined);
Expand Down Expand Up @@ -186,49 +187,6 @@ export function UptimeAlertForm({project, handleDelete, rule}: Props) {
</ListItemSubText>
<Configuration>
<ConfigurationPanel>
<SelectField
options={VALID_INTERVALS_SEC.map(value => ({
value,
label: t('Every %s', getDuration(value)),
}))}
name="intervalSeconds"
label={t('Interval')}
defaultValue={60}
flexibleControlStateSize
showHelpInTooltip={{isHoverable: true}}
help={({model}) =>
tct(
'The amount of time between each uptime check request. Selecting a period of [interval] means it will take at least [expectedFailureInterval] until you are notified of a failure. [link:Learn more].',
{
link: (
<ExternalLink href="https://docs.sentry.io/product/alerts/uptime-monitoring/#uptime-check-failures" />
),
interval: (
<strong>{getDuration(model.getValue('intervalSeconds'))}</strong>
),
expectedFailureInterval: (
<strong>
{getDuration(Number(model.getValue('intervalSeconds')) * 3)}
</strong>
),
}
)
}
required
/>
<RangeField
name="timeoutMs"
label={t('Timeout')}
min={1000}
max={30_000}
step={250}
tickValues={[1_000, 5_000, 10_000, 15_000, 20_000, 25_000, 30_000]}
defaultValue={5_000}
showTickLabels
formatLabel={value => getDuration((value || 0) / 1000, 2, true)}
flexibleControlStateSize
required
/>
<TextField
name="url"
label={t('URL')}
Expand All @@ -248,39 +206,90 @@ export function UptimeAlertForm({project, handleDelete, rule}: Props) {
flexibleControlStateSize
required
/>
<UptimeHeadersField
name="headers"
label={t('Headers')}
flexibleControlStateSize
/>
<TextareaField
name="body"
label={t('Body')}
visible={({model}: any) =>
!['GET', 'HEAD'].includes(model.getValue('method'))
}
rows={4}
maxRows={15}
autosize
monospace
placeholder='{"key": "value"}'
flexibleControlStateSize
/>
<BooleanField
name="traceSampling"
label={t('Allow Sampling')}
showHelpInTooltip={{isHoverable: true}}
help={tct(
'Defer the sampling decision to a Sentry SDK configured in your application. Disable to prevent all span sampling. [link:Learn more].',
{
link: (
<ExternalLink href="https://docs.sentry.io/product/alerts/uptime-monitoring/uptime-tracing/" />
),
}
)}
flexibleControlStateSize
/>
</ConfigurationPanel>
<AdvancedConfigToggle onClick={() => setAdvancedVisible(v => !v)}>
<span>{advancedVisible ? '▼' : '▶'}</span>
<span>{t('Advanced Configuration')}</span>
</AdvancedConfigToggle>
{advancedVisible && (
<ConfigurationPanel style={{paddingTop: space(2)}}>
<SelectField
options={VALID_INTERVALS_SEC.map(value => ({
value,
label: t('Every %s', getDuration(value)),
}))}
name="intervalSeconds"
label={t('Interval')}
defaultValue={60}
flexibleControlStateSize
showHelpInTooltip={{isHoverable: true}}
help={({model}) =>
tct(
'The amount of time between each uptime check request. Selecting a period of [interval] means it will take at least [expectedFailureInterval] until you are notified of a failure. [link:Learn more].',
{
link: (
<ExternalLink href="https://docs.sentry.io/product/alerts/uptime-monitoring/#uptime-check-failures" />
),
interval: (
<strong>{getDuration(model.getValue('intervalSeconds'))}</strong>
),
expectedFailureInterval: (
<strong>
{getDuration(Number(model.getValue('intervalSeconds')) * 3)}
</strong>
),
}
)
}
required
/>
<RangeField
name="timeoutMs"
label={t('Timeout')}
min={1000}
max={30_000}
step={250}
tickValues={[1_000, 5_000, 10_000, 15_000, 20_000, 25_000, 30_000]}
defaultValue={5_000}
showTickLabels
formatLabel={value => getDuration((value || 0) / 1000, 2, true)}
flexibleControlStateSize
required
/>
<UptimeHeadersField
name="headers"
label={t('Headers')}
flexibleControlStateSize
/>
<TextareaField
name="body"
label={t('Body')}
visible={({model}: any) =>
!['GET', 'HEAD'].includes(model.getValue('method'))
}
rows={4}
maxRows={15}
autosize
monospace
placeholder='{"key": "value"}'
flexibleControlStateSize
/>
<BooleanField
name="traceSampling"
label={t('Allow Sampling')}
showHelpInTooltip={{isHoverable: true}}
help={tct(
'Defer the sampling decision to a Sentry SDK configured in your application. Disable to prevent all span sampling. [link:Learn more].',
{
link: (
<ExternalLink href="https://docs.sentry.io/product/alerts/uptime-monitoring/uptime-tracing/" />
),
}
)}
flexibleControlStateSize
/>
</ConfigurationPanel>
)}
<Alert.Container>
<Alert type="muted" showIcon>
{tct(
Expand Down Expand Up @@ -387,3 +396,14 @@ const ConfigurationPanel = styled(Panel)`
}
}
`;

const AdvancedConfigToggle = styled('div')`
cursor: pointer;
display: flex;
align-items: center;
gap: ${space(1)};
color: ${p => p.theme.subText};
margin-top: ${space(2)};
font-size: ${p => p.theme.fontSizeSmall};
margin-left: ${space(4)};
`;
Loading