Skip to content

Commit 6c64cdf

Browse files
authored
feat(nextjs-insights): add avg & p95 duration to navigations table (#91708)
1 parent e851dd4 commit 6c64cdf

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

static/app/views/insights/pages/platform/shared/pagesTable.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ type SortableField =
3636
| 'failure_rate()'
3737
| 'sum(span.duration)'
3838
| 'avg(span.duration)'
39+
| 'p95(span.duration)'
3940
| 'performance_score(measurements.score.total)';
4041

4142
interface TableData {
4243
avgDuration: number;
4344
errorRate: number;
45+
p95: number;
4446
page: string;
4547
pageViews: number;
4648
projectID: number;
@@ -54,6 +56,13 @@ const errorRateColorThreshold = {
5456
warning: 0.05,
5557
} as const;
5658

59+
const getP95Threshold = (avg: number) => {
60+
return {
61+
error: avg * 3,
62+
warning: avg * 2,
63+
};
64+
};
65+
5766
const getCellColor = (value: number, thresholds: Record<string, number>) => {
5867
return Object.entries(thresholds).find(([_, threshold]) => value >= threshold)?.[0] as
5968
| 'errorText'
@@ -80,6 +89,8 @@ const pageloadColumnOrder: Array<GridColumnOrder<SortableField>> = [
8089
const navigationColumnOrder: Array<GridColumnOrder<SortableField>> = [
8190
{key: 'transaction', name: t('Page'), width: COL_WIDTH_UNDEFINED},
8291
{key: 'count()', name: t('Navigations'), width: 132},
92+
{key: 'avg(span.duration)', name: t('Avg'), width: 90},
93+
{key: 'p95(span.duration)', name: t('P95'), width: 90},
8394
{key: 'sum(span.duration)', name: t('Time Spent'), width: 110},
8495
];
8596

@@ -169,6 +180,7 @@ export function PagesTable({spanOperationFilter}: PagesTableProps) {
169180
'count()',
170181
'sum(span.duration)',
171182
'avg(span.duration)',
183+
'p95(span.duration)',
172184
'performance_score(measurements.score.total)',
173185
'project.id',
174186
],
@@ -195,6 +207,7 @@ export function PagesTable({spanOperationFilter}: PagesTableProps) {
195207
errorRate: span['failure_rate()'],
196208
totalTime: span['sum(span.duration)'],
197209
avgDuration: span['avg(span.duration)'],
210+
p95: span['p95(span.duration)'],
198211
spanOp: span['span.op'],
199212
projectID: span['project.id'],
200213
'performance_score(measurements.score.total)':
@@ -368,6 +381,18 @@ const BodyCell = memo(function PagesBodyCell({
368381
}
369382
case 'sum(span.duration)':
370383
return <Duration>{getDuration(dataRow.totalTime / 1000, 2, true)}</Duration>;
384+
case 'avg(span.duration)': {
385+
return <Duration>{getDuration(dataRow.avgDuration / 1000, 2, true)}</Duration>;
386+
}
387+
case 'p95(span.duration)': {
388+
const thresholds = getP95Threshold(dataRow.avgDuration);
389+
const color = getCellColor(dataRow.p95, thresholds);
390+
return (
391+
<ColoredValue color={color}>
392+
{getDuration(dataRow.p95 / 1000, 2, true)}
393+
</ColoredValue>
394+
);
395+
}
371396
default:
372397
return <div />;
373398
}

0 commit comments

Comments
 (0)