Skip to content

Commit c907b8f

Browse files
committed
ref(insights): Refactor cacheLandingPage widgets
Part of #88560
1 parent 6cd3028 commit c907b8f

File tree

3 files changed

+69
-35
lines changed

3 files changed

+69
-35
lines changed

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

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ import {
2121
} from 'sentry/views/insights/cache/components/tables/transactionsTable';
2222
import {Referrer} from 'sentry/views/insights/cache/referrers';
2323
import {BASE_FILTERS, MODULE_DOC_LINK} from 'sentry/views/insights/cache/settings';
24-
import {InsightsLineChartWidget} from 'sentry/views/insights/common/components/insightsLineChartWidget';
2524
import * as ModuleLayout from 'sentry/views/insights/common/components/moduleLayout';
2625
import {ModulePageFilterBar} from 'sentry/views/insights/common/components/modulePageFilterBar';
2726
import {ModulePageProviders} from 'sentry/views/insights/common/components/modulePageProviders';
2827
import {ModulesOnboarding} from 'sentry/views/insights/common/components/modulesOnboarding';
2928
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';
3031
import {
3132
useMetrics,
3233
useSpanMetrics,
@@ -37,10 +38,6 @@ import {useOnboardingProject} from 'sentry/views/insights/common/queries/useOnbo
3738
import {useInsightsEap} from 'sentry/views/insights/common/utils/useEap';
3839
import {useSamplesDrawer} from 'sentry/views/insights/common/utils/useSamplesDrawer';
3940
import {QueryParameterNames} from 'sentry/views/insights/common/views/queryParameters';
40-
import {
41-
DataTitles,
42-
getThroughputChartTitle,
43-
} from 'sentry/views/insights/common/views/spans/types';
4441
import {BackendHeader} from 'sentry/views/insights/pages/backend/backendPageHeader';
4542
import {
4643
type MetricsProperty,
@@ -81,11 +78,7 @@ export function CacheLandingPage() {
8178
requiredParams: ['transaction'],
8279
});
8380

84-
const {
85-
isPending: isCacheMissRateLoading,
86-
data: cacheMissRateData,
87-
error: cacheMissRateError,
88-
} = useSpanMetricsSeries(
81+
const {error: cacheMissRateError} = useSpanMetricsSeries(
8982
{
9083
yAxis: [`${CACHE_MISS_RATE}()`],
9184
search: MutableSearch.fromQueryObject(BASE_FILTERS),
@@ -94,19 +87,6 @@ export function CacheLandingPage() {
9487
Referrer.LANDING_CACHE_HIT_MISS_CHART
9588
);
9689

97-
const {
98-
isPending: isThroughputDataLoading,
99-
data: throughputData,
100-
error: throughputError,
101-
} = useSpanMetricsSeries(
102-
{
103-
search: MutableSearch.fromQueryObject(BASE_FILTERS),
104-
yAxis: ['epm()'],
105-
transformAliasToInputFormat: true,
106-
},
107-
Referrer.LANDING_CACHE_THROUGHPUT_CHART
108-
);
109-
11090
const {
11191
isFetching: isTransactionsListFetching,
11292
data: transactionsList,
@@ -211,20 +191,10 @@ export function CacheLandingPage() {
211191
</ModuleLayout.Full>
212192
<ModulesOnboarding moduleName={ModuleName.CACHE}>
213193
<ModuleLayout.Half>
214-
<InsightsLineChartWidget
215-
title={DataTitles[`cache_miss_rate()`]}
216-
series={[cacheMissRateData[`${CACHE_MISS_RATE}()`]]}
217-
isLoading={isCacheMissRateLoading}
218-
error={cacheMissRateError}
219-
/>
194+
<CacheMissRateWidget />
220195
</ModuleLayout.Half>
221196
<ModuleLayout.Half>
222-
<InsightsLineChartWidget
223-
title={getThroughputChartTitle('cache.get_item')}
224-
series={[throughputData['epm()']]}
225-
isLoading={isThroughputDataLoading}
226-
error={throughputError}
227-
/>
197+
<CacheThroughputWidget />
228198
</ModuleLayout.Half>
229199
<ModuleLayout.Full>
230200
<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)