Skip to content

Commit 937816f

Browse files
authored
feat(starfish): Cleanup (#50957)
A bunch of little things done here. 1. Remove the `time spent` info on the span sample sidebar 2. Use `Data titles` in a few more places 3. Ensure throughput charts and duration charts display units in the tooltip.
1 parent 282864b commit 937816f

File tree

11 files changed

+45
-14
lines changed

11 files changed

+45
-14
lines changed

static/app/utils/discover/fields.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
SESSIONS_FIELDS,
88
SESSIONS_OPERATIONS,
99
} from 'sentry/views/dashboards/widgetBuilder/releaseWidget/fields';
10+
import {STARFISH_FIELDS} from 'sentry/views/starfish/components/chart';
1011

1112
import {
1213
AGGREGATION_FIELDS,
@@ -1026,6 +1027,10 @@ export function aggregateFunctionOutputType(
10261027
return SESSIONS_FIELDS[firstArg].type as AggregationOutputType;
10271028
}
10281029

1030+
if (firstArg && STARFISH_FIELDS[firstArg]) {
1031+
return STARFISH_FIELDS[firstArg].outputType;
1032+
}
1033+
10291034
// If the function is an inherit type it will have a field as
10301035
// the first parameter and we can use that to get the type.
10311036
const fieldDef = getFieldDefinition(firstArg ?? '');

static/app/views/starfish/components/chart.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,21 @@ import {
3535
getDurationUnit,
3636
tooltipFormatter,
3737
} from 'sentry/utils/discover/charts';
38-
import {aggregateOutputType} from 'sentry/utils/discover/fields';
38+
import {aggregateOutputType, AggregationOutputType} from 'sentry/utils/discover/fields';
3939
import {DAY, HOUR} from 'sentry/utils/formatters';
4040
import usePageFilters from 'sentry/utils/usePageFilters';
4141
import useRouter from 'sentry/utils/useRouter';
42+
import {SpanMetricsFields} from 'sentry/views/starfish/types';
4243
import {getDateFilters} from 'sentry/views/starfish/utils/getDateFilters';
4344

4445
const STARFISH_CHART_GROUP = 'starfish_chart_group';
4546

47+
export const STARFISH_FIELDS: Record<string, {outputType: AggregationOutputType}> = {
48+
[SpanMetricsFields.SPAN_DURATION]: {
49+
outputType: 'duration',
50+
},
51+
};
52+
4653
type Props = {
4754
data: Series[];
4855
end: DateString;

static/app/views/starfish/components/samplesTable/transactionSamplesTable.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
TextAlignLeft,
2323
TextAlignRight,
2424
} from 'sentry/views/starfish/components/textAlign';
25+
import {DataTitles} from 'sentry/views/starfish/views/spans/types';
2526

2627
type Keys =
2728
| 'id'
@@ -55,7 +56,7 @@ const COLUMN_ORDER: TableColumnHeader[] = [
5556
},
5657
{
5758
key: 'transaction.duration',
58-
name: 'Duration',
59+
name: DataTitles.duration,
5960
width: 100,
6061
},
6162
{

static/app/views/starfish/types.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ export enum ModuleName {
44
NONE = 'none',
55
ALL = '',
66
}
7+
8+
export enum SpanMetricsFields {
9+
SPAN_OP = 'span.op',
10+
SPAN_DESCRIPTION = 'span.description',
11+
SPAN_ACTION = 'span.action',
12+
SPAN_DOMAIN = 'span.domain',
13+
SPAN_DURATION = 'span.duration',
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {t} from 'sentry/locale';
2+
3+
const formatThroughput = (throughputPerSecond: number = -1) => {
4+
const throughput = throughputPerSecond === -1 ? '--' : throughputPerSecond.toFixed(2);
5+
return `${throughput} / ${t('s')}`;
6+
};
7+
8+
export default formatThroughput;

static/app/views/starfish/views/spanSummaryPage/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {TimeSpentCell} from 'sentry/views/starfish/components/tableCells/timeSpe
2424
import {useSpanMeta} from 'sentry/views/starfish/queries/useSpanMeta';
2525
import {useSpanMetrics} from 'sentry/views/starfish/queries/useSpanMetrics';
2626
import {useSpanMetricsSeries} from 'sentry/views/starfish/queries/useSpanMetricsSeries';
27+
import formatThroughput from 'sentry/views/starfish/utils/chartValueFormatters/formatThroughput';
2728
import {DataTitles} from 'sentry/views/starfish/views/spans/types';
2829
import {SampleList} from 'sentry/views/starfish/views/spanSummaryPage/sampleList';
2930
import {SpanTransactionsTable} from 'sentry/views/starfish/views/spanSummaryPage/spanTransactionsTable';
@@ -134,6 +135,9 @@ function SpanSummaryPage({params, location}: Props) {
134135
chartColors={[THROUGHPUT_COLOR]}
135136
isLineChart
136137
definedAxisTicks={4}
138+
tooltipFormatterOptions={{
139+
valueFormatter: value => formatThroughput(value),
140+
}}
137141
/>
138142
</ChartPanel>
139143
</Block>

static/app/views/starfish/views/spanSummaryPage/sampleList/sampleInfo/index.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import DurationCell from 'sentry/views/starfish/components/tableCells/durationCell';
22
import ThroughputCell from 'sentry/views/starfish/components/tableCells/throughputCell';
3-
import {TimeSpentCell} from 'sentry/views/starfish/components/tableCells/timeSpentCell';
43
import {useSpanMetrics} from 'sentry/views/starfish/queries/useSpanMetrics';
54
import {DataTitles} from 'sentry/views/starfish/views/spans/types';
65
import {Block, BlockContainer} from 'sentry/views/starfish/views/spanSummaryPage';
@@ -28,12 +27,6 @@ function SampleInfo(props: Props) {
2827
<Block title={DataTitles.p95}>
2928
<DurationCell milliseconds={spanMetrics?.['p95(span.duration)']} />
3029
</Block>
31-
<Block title={DataTitles.timeSpent}>
32-
<TimeSpentCell
33-
timeSpentPercentage={spanMetrics?.['time_spent_percentage(local)']}
34-
totalSpanTime={spanMetrics?.['sum(span.duration)']}
35-
/>
36-
</Block>
3730
</BlockContainer>
3831
);
3932
}

static/app/views/starfish/views/spans/spanTimeCharts.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {ERRORS_COLOR, P95_COLOR, THROUGHPUT_COLOR} from 'sentry/views/starfish/c
1515
import Chart, {useSynchronizeCharts} from 'sentry/views/starfish/components/chart';
1616
import ChartPanel from 'sentry/views/starfish/components/chartPanel';
1717
import {ModuleName} from 'sentry/views/starfish/types';
18+
import formatThroughput from 'sentry/views/starfish/utils/chartValueFormatters/formatThroughput';
1819
import {getDateFilters} from 'sentry/views/starfish/utils/getDateFilters';
1920
import {useSpansQuery} from 'sentry/views/starfish/utils/useSpansQuery';
2021
import {zeroFillSeries} from 'sentry/views/starfish/utils/zeroFillSeries';
@@ -154,7 +155,7 @@ function ThroughputChart({moduleName, filters}: ChartProps): JSX.Element {
154155
isLineChart
155156
chartColors={[THROUGHPUT_COLOR]}
156157
tooltipFormatterOptions={{
157-
valueFormatter: value => `${value.toFixed(3)} / ${t('sec')}`,
158+
valueFormatter: value => formatThroughput(value),
158159
}}
159160
/>
160161
);

static/app/views/starfish/views/spans/types.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ export type DataKey =
1010
| 'p50'
1111
| 'p95'
1212
| 'throughput'
13+
| 'duration'
1314
| 'errorCount';
1415

1516
export const DataTitles: Record<DataKey, string> = {
1617
timeSpent: t('Time Spent'),
1718
p50p95: t('Duration (P50, P95)'),
1819
p50: t('Duration (P50)'),
1920
p95: t('Duration (P95)'),
21+
duration: t('Duration'),
2022
errorCount: t('5XX Responses'),
2123
throughput: t('Throughput'),
2224
};

static/app/views/starfish/views/webServiceView/endpointOverview/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {ERRORS_COLOR, P95_COLOR, THROUGHPUT_COLOR} from 'sentry/views/starfish/c
2727
import Chart from 'sentry/views/starfish/components/chart';
2828
import {TransactionSamplesTable} from 'sentry/views/starfish/components/samplesTable/transactionSamplesTable';
2929
import {ModuleName} from 'sentry/views/starfish/types';
30+
import formatThroughput from 'sentry/views/starfish/utils/chartValueFormatters/formatThroughput';
3031
import SpansTable from 'sentry/views/starfish/views/spans/spansTable';
3132
import {DataTitles} from 'sentry/views/starfish/views/spans/types';
3233
import IssuesTable from 'sentry/views/starfish/views/webServiceView/endpointOverview/issuesTable';
@@ -111,7 +112,7 @@ export default function EndpointOverview() {
111112
return (
112113
<Fragment>
113114
<Header>
114-
<ChartLabel>{t('Throughput Per Second')}</ChartLabel>
115+
<ChartLabel>{DataTitles.throughput}</ChartLabel>
115116
</Header>
116117
<ChartSummaryValue
117118
isLoading={isTotalsLoading}
@@ -140,7 +141,7 @@ export default function EndpointOverview() {
140141
bottom: '0',
141142
}}
142143
tooltipFormatterOptions={{
143-
valueFormatter: value => t('%s/sec', value.toFixed(2)),
144+
valueFormatter: value => formatThroughput(value),
144145
}}
145146
/>
146147
<SidebarSpacer />

0 commit comments

Comments
 (0)