Skip to content

Commit 7bd1c51

Browse files
authored
ref(trace): fix formatter (#69185)
Fix formatting of hour+ long traces
1 parent 6eb9477 commit 7bd1c51

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

static/app/views/performance/newTraceDetails/formatters.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ const format = (v: number, abbrev: string, precision: number) => {
99
// which the trace view is already doing a lot of, so we try to avoid it here as
1010
// gc during scrolling causes jank
1111
export function formatTraceDuration(duration_ms: number) {
12-
if (duration_ms >= 24 * 60 * 60 * 1e3) {
13-
return format((duration_ms / 24) * 60 * 60e3, 'd', 2);
12+
if (duration_ms <= 0) {
13+
return '0ms';
1414
}
15-
if (duration_ms >= 60 * 60 * 1e3) {
16-
return format((duration_ms / 60) * 60e3, 'h', 2);
15+
if (duration_ms < 1000) {
16+
return format(duration_ms, 'ms', 2);
1717
}
18-
if (duration_ms >= 60 * 1e3) {
19-
return format(duration_ms / 60e3, 'min', 2);
18+
if (duration_ms < 60000) {
19+
return format(duration_ms / 1000, 's', 2);
2020
}
21-
if (duration_ms >= 1e3) {
22-
return format(duration_ms / 1e3, 's', 2);
21+
if (duration_ms < 3600000) {
22+
return format(duration_ms / 60000, 'm', 2);
2323
}
24-
return format(duration_ms, 'ms', 2);
24+
if (duration_ms < 86400000) {
25+
return format(duration_ms / 3600000, 'h', 2);
26+
}
27+
return format(duration_ms / 86400000, 'd', 2);
2528
}

0 commit comments

Comments
 (0)