Skip to content

Commit 644abfd

Browse files
committed
ref(insights): Refactor cacheLandingPage widgets
Part of #88560
1 parent bc24e5b commit 644abfd

File tree

3 files changed

+69
-32
lines changed

3 files changed

+69
-32
lines changed

static/app/views/insights/cache/views/cacheLandingPage.tsx

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {ModulePageFilterBar} from 'sentry/views/insights/common/components/modul
2626
import {ModulePageProviders} from 'sentry/views/insights/common/components/modulePageProviders';
2727
import {ModulesOnboarding} from 'sentry/views/insights/common/components/modulesOnboarding';
2828
import {ModuleBodyUpsellHook} from 'sentry/views/insights/common/components/moduleUpsellHookWrapper';
29+
import CacheMissRateWidget from 'sentry/views/insights/common/components/widgets/cacheMissRateWidget';
30+
import CacheThroughputWidget from 'sentry/views/insights/common/components/widgets/cacheThroughputWidget';
2931
import {
3032
useMetrics,
3133
useSpanMetrics,
@@ -43,9 +45,7 @@ import {
4345
SpanMetricsField,
4446
} from 'sentry/views/insights/types';
4547

46-
import {InsightsLineChartWidget} from '../../common/components/insightsLineChartWidget';
4748
import {useSamplesDrawer} from '../../common/utils/useSamplesDrawer';
48-
import {DataTitles, getThroughputChartTitle} from '../../common/views/spans/types';
4949

5050
const {CACHE_MISS_RATE} = SpanFunction;
5151
const {CACHE_ITEM_SIZE} = SpanMetricsField;
@@ -79,11 +79,7 @@ export function CacheLandingPage() {
7979
requiredParams: ['transaction'],
8080
});
8181

82-
const {
83-
isPending: isCacheMissRateLoading,
84-
data: cacheMissRateData,
85-
error: cacheMissRateError,
86-
} = useSpanMetricsSeries(
82+
const {error: cacheMissRateError} = useSpanMetricsSeries(
8783
{
8884
yAxis: [`${CACHE_MISS_RATE}()`],
8985
search: MutableSearch.fromQueryObject(BASE_FILTERS),
@@ -92,19 +88,6 @@ export function CacheLandingPage() {
9288
Referrer.LANDING_CACHE_HIT_MISS_CHART
9389
);
9490

95-
const {
96-
isPending: isThroughputDataLoading,
97-
data: throughputData,
98-
error: throughputError,
99-
} = useSpanMetricsSeries(
100-
{
101-
search: MutableSearch.fromQueryObject(BASE_FILTERS),
102-
yAxis: ['epm()'],
103-
transformAliasToInputFormat: true,
104-
},
105-
Referrer.LANDING_CACHE_THROUGHPUT_CHART
106-
);
107-
10891
const {
10992
isFetching: isTransactionsListFetching,
11093
data: transactionsList,
@@ -209,20 +192,10 @@ export function CacheLandingPage() {
209192
</ModuleLayout.Full>
210193
<ModulesOnboarding moduleName={ModuleName.CACHE}>
211194
<ModuleLayout.Half>
212-
<InsightsLineChartWidget
213-
title={DataTitles[`cache_miss_rate()`]}
214-
series={[cacheMissRateData[`${CACHE_MISS_RATE}()`]]}
215-
isLoading={isCacheMissRateLoading}
216-
error={cacheMissRateError}
217-
/>
195+
<CacheMissRateWidget />
218196
</ModuleLayout.Half>
219197
<ModuleLayout.Half>
220-
<InsightsLineChartWidget
221-
title={getThroughputChartTitle('cache.get_item')}
222-
series={[throughputData['epm()']]}
223-
isLoading={isThroughputDataLoading}
224-
error={throughputError}
225-
/>
198+
<CacheThroughputWidget />
226199
</ModuleLayout.Half>
227200
<ModuleLayout.Full>
228201
<TransactionsTable
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
2+
import {Referrer} from 'sentry/views/insights/cache/referrers';
3+
import {BASE_FILTERS} from 'sentry/views/insights/cache/settings';
4+
import {InsightsLineChartWidget} from 'sentry/views/insights/common/components/insightsLineChartWidget';
5+
import {useSpanMetricsSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries';
6+
import {DataTitles} from 'sentry/views/insights/common/views/spans/types';
7+
import {SpanFunction} from 'sentry/views/insights/types';
8+
9+
const {CACHE_MISS_RATE} = SpanFunction;
10+
11+
export default function CacheMissRateWidget() {
12+
const {
13+
isPending: isCacheMissRateLoading,
14+
data: cacheMissRateData,
15+
error: cacheMissRateError,
16+
} = useSpanMetricsSeries(
17+
{
18+
yAxis: [`${CACHE_MISS_RATE}()`],
19+
search: MutableSearch.fromQueryObject(BASE_FILTERS),
20+
transformAliasToInputFormat: true,
21+
},
22+
Referrer.LANDING_CACHE_HIT_MISS_CHART
23+
);
24+
return (
25+
<InsightsLineChartWidget
26+
id="cacheMissRateWidget"
27+
title={DataTitles[`cache_miss_rate()`]}
28+
series={[cacheMissRateData[`${CACHE_MISS_RATE}()`]]}
29+
isLoading={isCacheMissRateLoading}
30+
error={cacheMissRateError}
31+
/>
32+
);
33+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
2+
import {Referrer} from 'sentry/views/insights/cache/referrers';
3+
import {BASE_FILTERS} from 'sentry/views/insights/cache/settings';
4+
import {InsightsLineChartWidget} from 'sentry/views/insights/common/components/insightsLineChartWidget';
5+
import {useSpanMetricsSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries';
6+
import {getThroughputChartTitle} from 'sentry/views/insights/common/views/spans/types';
7+
8+
export default function CacheThroughputWidget() {
9+
const {
10+
isPending: isThroughputDataLoading,
11+
data: throughputData,
12+
error: throughputError,
13+
} = useSpanMetricsSeries(
14+
{
15+
search: MutableSearch.fromQueryObject(BASE_FILTERS),
16+
yAxis: ['epm()'],
17+
transformAliasToInputFormat: true,
18+
},
19+
Referrer.LANDING_CACHE_THROUGHPUT_CHART
20+
);
21+
22+
return (
23+
<InsightsLineChartWidget
24+
id="cacheThroughputWidget"
25+
title={getThroughputChartTitle('cache.get_item')}
26+
series={[throughputData['epm()']]}
27+
isLoading={isThroughputDataLoading}
28+
error={throughputError}
29+
/>
30+
);
31+
}

0 commit comments

Comments
 (0)