Skip to content

Commit 823a92b

Browse files
authored
feat(perf): Improve rendering of HTTP Status Code columns (#68208)
Huh what 403 which one is that is that rate limited or what, I don't know! Adds a little tooltip to explain the status code field, and makes sure it's aligned correctly and so on. - Add special renderer for HTTP status code - Right-align "Status" table column - Provide metadata to the samples table
1 parent 6d6bdf3 commit 823a92b

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

static/app/utils/discover/fieldRenderers.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
stringToFilter,
5252
} from 'sentry/views/performance/transactionSummary/filter';
5353
import {PercentChangeCell} from 'sentry/views/starfish/components/tableCells/percentChangeCell';
54+
import {ResponseStatusCodeCell} from 'sentry/views/starfish/components/tableCells/responseStatusCodeCell';
5455
import {TimeSpentCell} from 'sentry/views/starfish/components/tableCells/timeSpentCell';
5556
import {SpanMetricsField} from 'sentry/views/starfish/types';
5657

@@ -340,6 +341,7 @@ type SpecialFields = {
340341
project: SpecialField;
341342
release: SpecialField;
342343
replayId: SpecialField;
344+
'span.status_code': SpecialField;
343345
team_key_transaction: SpecialField;
344346
'timestamp.to_day': SpecialField;
345347
'timestamp.to_hour': SpecialField;
@@ -690,6 +692,18 @@ const SPECIAL_FIELDS: SpecialFields = {
690692
</Container>
691693
),
692694
},
695+
'span.status_code': {
696+
sortField: 'span.status_code',
697+
renderFunc: data => (
698+
<NumberContainer>
699+
{data['span.status_code'] ? (
700+
<ResponseStatusCodeCell code={parseInt(data['span.status_code'], 10)} />
701+
) : (
702+
t('Unknown')
703+
)}
704+
</NumberContainer>
705+
),
706+
},
693707
};
694708

695709
type SpecialFunctionFieldRenderer = (

static/app/views/performance/http/httpSamplesPanel.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@ export function HTTPSamplesPanel() {
293293
data={samplesData}
294294
isLoading={isDurationDataFetching || isSamplesDataFetching}
295295
error={samplesDataError}
296+
// TODO: The samples endpoint doesn't provide its own meta, so we need to create it manually
297+
meta={{
298+
fields: {
299+
'span.response_code': 'number',
300+
},
301+
units: {},
302+
}}
296303
/>
297304
</ModuleLayout.Full>
298305
</Fragment>

static/app/views/starfish/components/tableCells/renderHeadCell.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import {
99
fieldAlignment,
1010
parseFunction,
1111
} from 'sentry/utils/discover/fields';
12-
import {SpanFunction, SpanMetricsField} from 'sentry/views/starfish/types';
12+
import {
13+
SpanFunction,
14+
SpanIndexedField,
15+
SpanMetricsField,
16+
} from 'sentry/views/starfish/types';
1317
import type {QueryParameterNames} from 'sentry/views/starfish/views/queryParameters';
1418

1519
type Options = {
@@ -22,6 +26,7 @@ type Options = {
2226
const DEFAULT_SORT_PARAMETER_NAME = 'sort';
2327

2428
const {SPAN_SELF_TIME, HTTP_RESPONSE_CONTENT_LENGTH} = SpanMetricsField;
29+
const {RESPONSE_CODE} = SpanIndexedField;
2530
const {TIME_SPENT_PERCENTAGE, SPS, SPM, HTTP_ERROR_COUNT, HTTP_RESPONSE_RATE} =
2631
SpanFunction;
2732

@@ -42,6 +47,8 @@ export const SORTABLE_FIELDS = new Set([
4247
`avg(${HTTP_RESPONSE_CONTENT_LENGTH})`,
4348
]);
4449

50+
const NUMERIC_FIELDS = new Set([`${RESPONSE_CODE}`]);
51+
4552
export const renderHeadCell = ({column, location, sort, sortParameterName}: Options) => {
4653
const {key, name} = column;
4754
const alignment = getAlignment(key);
@@ -76,11 +83,17 @@ export const renderHeadCell = ({column, location, sort, sortParameterName}: Opti
7683

7784
export const getAlignment = (key: string): Alignments => {
7885
const result = parseFunction(key);
86+
7987
if (result) {
8088
const outputType = aggregateFunctionOutputType(result.name, result.arguments[0]);
89+
8190
if (outputType) {
8291
return fieldAlignment(key, outputType);
8392
}
93+
} else {
94+
if (NUMERIC_FIELDS.has(key)) {
95+
return 'right';
96+
}
8497
}
8598
return 'left';
8699
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {Tooltip} from 'sentry/components/tooltip';
2+
import {tct} from 'sentry/locale';
3+
import {HTTP_RESPONSE_STATUS_CODES} from 'sentry/views/performance/http/definitions';
4+
5+
interface Props {
6+
code: number;
7+
}
8+
9+
export function ResponseStatusCodeCell({code}: Props) {
10+
const explanation = HTTP_RESPONSE_STATUS_CODES[code.toString()];
11+
12+
return (
13+
<Tooltip
14+
disabled={!code}
15+
isHoverable
16+
title={tct('Status Code [code] “[explanation]”', {
17+
code,
18+
explanation,
19+
})}
20+
>
21+
{code}
22+
</Tooltip>
23+
);
24+
}

0 commit comments

Comments
 (0)