Skip to content

Commit d221cdb

Browse files
Abdkhan14Abdullah Khan
and
Abdullah Khan
authored
feat(perf-detector-threshold-configuration) Added frontend changes for more threshold configurations. (#52262)
- Frontend changes rely on backend changes from this PR: [link](#52239) for issues other than n+1 db queries and slow db queries. - Adds detection enabled toggles and sliders for configuring thresholds covering the following issues: <img width="1024" alt="Screenshot 2023-07-05 at 9 54 41 AM" src="https://github.com/getsentry/sentry/assets/60121741/cebc729e-bac4-4b27-ae58-3dd7d5377355"> - Will be handling n+1 api calls and consecutive http spans separately - Added tests. Co-authored-by: Abdullah Khan <[email protected]>
1 parent 2da7d38 commit d221cdb

File tree

4 files changed

+341
-6
lines changed

4 files changed

+341
-6
lines changed

static/app/components/forms/formPanel.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Props = {
2929
* The name of the field that should be highlighted
3030
*/
3131
highlighted?: string;
32+
initiallyCollapsed?: boolean;
3233
/**
3334
* Renders inside of PanelBody before PanelBody close
3435
*/
@@ -52,9 +53,10 @@ function FormPanel({
5253
renderFooter,
5354
renderHeader,
5455
collapsible,
56+
initiallyCollapsed = false,
5557
...otherProps
5658
}: Props) {
57-
const [collapsed, setCollapse] = useState(false);
59+
const [collapsed, setCollapse] = useState(initiallyCollapsed);
5860
const handleCollapseToggle = useCallback(() => setCollapse(current => !current), []);
5961

6062
return (
@@ -64,7 +66,11 @@ function FormPanel({
6466
{title}
6567
{collapsible && (
6668
<Collapse onClick={handleCollapseToggle}>
67-
<IconChevron direction={collapsed ? 'down' : 'up'} size="xs" />
69+
<IconChevron
70+
data-test-id="form-panel-collapse-chevron"
71+
direction={collapsed ? 'down' : 'up'}
72+
size="xs"
73+
/>
6874
</Collapse>
6975
)}
7076
</PanelHeader>

static/app/components/forms/jsonForm.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class JsonForm extends Component<Props, State> {
130130
const {
131131
access,
132132
collapsible,
133+
initiallyCollapsed,
133134
fields,
134135
title,
135136
forms,
@@ -154,6 +155,7 @@ class JsonForm extends Component<Props, State> {
154155
renderHeader,
155156
highlighted: this.state.highlighted,
156157
collapsible,
158+
initiallyCollapsed,
157159
};
158160

159161
return (

static/app/views/settings/projectPerformance/projectPerformance.spec.tsx

+74-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
import * as utils from 'sentry/utils/isActiveSuperuser';
1010
import ProjectPerformance, {
1111
allowedDurationValues,
12+
allowedPercentageValues,
13+
allowedSizeValues,
14+
DetectorConfigCustomer,
1215
} from 'sentry/views/settings/projectPerformance/projectPerformance';
1316

1417
describe('projectPerformance', function () {
@@ -191,7 +194,7 @@ describe('projectPerformance', function () {
191194
it.each([
192195
{
193196
title: 'N+1 DB Queries',
194-
threshold: 'n_plus_one_db_duration_threshold',
197+
threshold: DetectorConfigCustomer.N_PLUS_DB_DURATION,
195198
allowedValues: allowedDurationValues,
196199
defaultValue: 100,
197200
newValue: 500,
@@ -200,13 +203,76 @@ describe('projectPerformance', function () {
200203
},
201204
{
202205
title: 'Slow DB Queries',
203-
threshold: 'slow_db_query_duration_threshold',
206+
threshold: DetectorConfigCustomer.SLOW_DB_DURATION,
204207
allowedValues: allowedDurationValues.slice(1),
205208
defaultValue: 1000,
206209
newValue: 3000,
207210
newValueIndex: 7,
208211
sliderIndex: 2,
209212
},
213+
{
214+
title: 'Large Render Blocking Asset',
215+
threshold: DetectorConfigCustomer.RENDER_BLOCKING_ASSET_RATIO,
216+
allowedValues: allowedPercentageValues,
217+
defaultValue: 0.33,
218+
newValue: 0.5,
219+
newValueIndex: 6,
220+
sliderIndex: 3,
221+
},
222+
{
223+
title: 'Large HTTP Payload',
224+
threshold: DetectorConfigCustomer.LARGE_HTT_PAYLOAD_SIZE,
225+
allowedValues: allowedSizeValues.slice(1),
226+
defaultValue: 1000000,
227+
newValue: 5000000,
228+
newValueIndex: 13,
229+
sliderIndex: 4,
230+
},
231+
{
232+
title: 'DB on Main Thread',
233+
threshold: DetectorConfigCustomer.DB_ON_MAIN_THREAD_DURATION,
234+
allowedValues: [10, 16, 33, 50],
235+
defaultValue: 16,
236+
newValue: 33,
237+
newValueIndex: 2,
238+
sliderIndex: 5,
239+
},
240+
{
241+
title: 'File I/O on Main Thread',
242+
threshold: DetectorConfigCustomer.FILE_IO_MAIN_THREAD_DURATION,
243+
allowedValues: [10, 16, 33, 50],
244+
defaultValue: 16,
245+
newValue: 50,
246+
newValueIndex: 3,
247+
sliderIndex: 6,
248+
},
249+
{
250+
title: 'Consecutive DB Queries',
251+
threshold: DetectorConfigCustomer.CONSECUTIVE_DB_MIN_TIME_SAVED,
252+
allowedValues: allowedDurationValues.slice(0, 11),
253+
defaultValue: 100,
254+
newValue: 5000,
255+
newValueIndex: 10,
256+
sliderIndex: 7,
257+
},
258+
{
259+
title: 'Uncompressed Asset',
260+
threshold: DetectorConfigCustomer.UNCOMPRESSED_ASSET_SIZE,
261+
allowedValues: allowedSizeValues.slice(1),
262+
defaultValue: 512000,
263+
newValue: 700000,
264+
newValueIndex: 6,
265+
sliderIndex: 8,
266+
},
267+
{
268+
title: 'Uncompressed Asset',
269+
threshold: DetectorConfigCustomer.UNCOMPRESSED_ASSET_DURATION,
270+
allowedValues: allowedDurationValues.slice(1),
271+
defaultValue: 500,
272+
newValue: 400,
273+
newValueIndex: 3,
274+
sliderIndex: 9,
275+
},
210276
])(
211277
'renders detector thresholds settings for $title issue',
212278
async ({
@@ -247,6 +313,12 @@ describe('projectPerformance', function () {
247313
).toBeInTheDocument();
248314
expect(screen.getByText(title)).toBeInTheDocument();
249315

316+
// Open collapsed panels
317+
const chevrons = screen.getAllByTestId('form-panel-collapse-chevron');
318+
for (const chevron of chevrons) {
319+
await userEvent.click(chevron);
320+
}
321+
250322
const slider = screen.getAllByRole('slider')[sliderIndex];
251323
const indexOfValue = allowedValues.indexOf(defaultValue);
252324

0 commit comments

Comments
 (0)