Skip to content

Commit 5f42131

Browse files
feat(browser-starfish): handle 0 resource size case (#59014)
If the resource size is 0, we will display `---`. This complements the CTA in #59009 ![image](https://github.com/getsentry/sentry/assets/44422760/c55feb0e-afd4-4071-a3df-d4fa83ae6e6d) This is to solve some confusion over a 0 size. Its very unlikely that the resource size is ever 0.0B, every case i have seen, the resource size was 0 because we simply don't have the size. Showing 0 may mislead users to thinking the size is actually 0. --------- Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
1 parent e7dcee8 commit 5f42131

File tree

4 files changed

+44
-11
lines changed

4 files changed

+44
-11
lines changed

static/app/views/performance/browser/resources/imageView/resourceTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {Fragment} from 'react';
22
import {Link} from 'react-router';
33

4-
import FileSize from 'sentry/components/fileSize';
54
import GridEditable, {
65
COL_WIDTH_UNDEFINED,
76
GridColumnHeader,
@@ -12,6 +11,7 @@ import {t} from 'sentry/locale';
1211
import {useLocation} from 'sentry/utils/useLocation';
1312
import {ValidSort} from 'sentry/views/performance/browser/resources/imageView/utils/useImageResourceSort';
1413
import {useIndexedResourcesQuery} from 'sentry/views/performance/browser/resources/imageView/utils/useIndexedResourcesQuery';
14+
import ResourceSize from 'sentry/views/performance/browser/resources/shared/resourceSize';
1515
import {DurationCell} from 'sentry/views/starfish/components/tableCells/durationCell';
1616
import {renderHeadCell} from 'sentry/views/starfish/components/tableCells/renderHeadCell';
1717
import {WiderHovercard} from 'sentry/views/starfish/components/tableCells/spanDescriptionCell';
@@ -77,7 +77,7 @@ function ResourceTable({sort}: Props) {
7777
);
7878
}
7979
if (key === 'http.response_content_length') {
80-
return <FileSize bytes={row[key]} />;
80+
return <ResourceSize bytes={row[key]} />;
8181
}
8282
if (key === `span.self_time`) {
8383
return <DurationCell milliseconds={row[key]} />;

static/app/views/performance/browser/resources/jsCssView/resourceTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Fragment} from 'react';
22

3-
import FileSize from 'sentry/components/fileSize';
43
import GridEditable, {
54
COL_WIDTH_UNDEFINED,
65
GridColumnHeader,
@@ -10,6 +9,7 @@ import Pagination from 'sentry/components/pagination';
109
import {t} from 'sentry/locale';
1110
import {RateUnits} from 'sentry/utils/discover/fields';
1211
import {useLocation} from 'sentry/utils/useLocation';
12+
import ResourceSize from 'sentry/views/performance/browser/resources/shared/resourceSize';
1313
import {ValidSort} from 'sentry/views/performance/browser/resources/utils/useResourceSort';
1414
import {useResourcesQuery} from 'sentry/views/performance/browser/resources/utils/useResourcesQuery';
1515
import {DurationCell} from 'sentry/views/starfish/components/tableCells/durationCell';
@@ -95,7 +95,7 @@ function ResourceTable({sort}: Props) {
9595
return <ThroughputCell rate={row[key] * 60} unit={RateUnits.PER_SECOND} />;
9696
}
9797
if (key === 'avg(http.response_content_length)') {
98-
return <FileSize bytes={row[key]} />;
98+
return <ResourceSize bytes={row[key]} />;
9999
}
100100
if (key === `avg(span.self_time)`) {
101101
return <DurationCell milliseconds={row[key]} />;

static/app/views/performance/browser/resources/resourceSummaryPage/resourceInfo.tsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {Fragment} from 'react';
22

33
import Alert from 'sentry/components/alert';
4-
import FileSize from 'sentry/components/fileSize';
54
import {Tooltip} from 'sentry/components/tooltip';
65
import {t, tct} from 'sentry/locale';
76
import {formatBytesBase2} from 'sentry/utils';
87
import {RateUnits} from 'sentry/utils/discover/fields';
98
import getDynamicText from 'sentry/utils/getDynamicText';
9+
import ResourceSize from 'sentry/views/performance/browser/resources/shared/resourceSize';
1010
import {DurationCell} from 'sentry/views/starfish/components/tableCells/durationCell';
1111
import {ThroughputCell} from 'sentry/views/starfish/components/tableCells/throughputCell';
1212
import {DataTitles, getThroughputTitle} from 'sentry/views/starfish/views/spans/types';
@@ -63,18 +63,33 @@ function ResourceInfo(props: Props) {
6363
<Fragment>
6464
<BlockContainer>
6565
<Block title={t('Avg encoded size')}>
66-
<Tooltip isHoverable title={tooltips.avgContentLength} showUnderline>
67-
<FileSize bytes={avgContentLength} />
66+
<Tooltip
67+
isHoverable
68+
title={tooltips.avgContentLength}
69+
showUnderline
70+
disabled={!avgContentLength}
71+
>
72+
<ResourceSize bytes={avgContentLength} />
6873
</Tooltip>
6974
</Block>
7075
<Block title={t('Avg decoded size')}>
71-
<Tooltip isHoverable title={tooltips.avgDecodedContentLength} showUnderline>
72-
<FileSize bytes={avgDecodedContentLength} />
76+
<Tooltip
77+
isHoverable
78+
title={tooltips.avgDecodedContentLength}
79+
showUnderline
80+
disabled={!avgDecodedContentLength}
81+
>
82+
<ResourceSize bytes={avgDecodedContentLength} />
7383
</Tooltip>
7484
</Block>
7585
<Block title={t('Avg transfer size')}>
76-
<Tooltip isHoverable title={tooltips.avgTransferSize} showUnderline>
77-
<FileSize bytes={avgTransferSize} />
86+
<Tooltip
87+
isHoverable
88+
title={tooltips.avgTransferSize}
89+
showUnderline
90+
disabled={!avgTransferSize}
91+
>
92+
<ResourceSize bytes={avgTransferSize} />
7893
</Tooltip>
7994
</Block>
8095
<Block title={DataTitles.avg}>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {Fragment} from 'react';
2+
3+
import FileSize from 'sentry/components/fileSize';
4+
5+
type Props = {
6+
bytes: number;
7+
};
8+
9+
function ResourceSize(props: Props) {
10+
const {bytes} = props;
11+
if (bytes === 0) {
12+
return <Fragment>--</Fragment>;
13+
}
14+
15+
return <FileSize bytes={bytes} />;
16+
}
17+
18+
export default ResourceSize;

0 commit comments

Comments
 (0)