Skip to content

Commit 9c9db48

Browse files
committed
remove useEap caches/queues
1 parent 3eb2d8f commit 9c9db48

File tree

5 files changed

+41
-139
lines changed

5 files changed

+41
-139
lines changed

static/app/components/performance/spanSearchQueryBuilder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function IndexedSpanSearchQueryBuilder({
190190
return <SearchQueryBuilder {...searchQueryBuilderProps} />;
191191
}
192192

193-
function EapSpanSearchQueryBuilderWrapper(props: SpanSearchQueryBuilderProps) {
193+
export function EapSpanSearchQueryBuilderWrapper(props: SpanSearchQueryBuilderProps) {
194194
const {tags: numberTags} = useTraceItemTags('number');
195195
const {tags: stringTags} = useTraceItemTags('string');
196196

static/app/views/insights/cache/components/charts/transactionDurationChartWithSamples.tsx

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@ import {Referrer} from 'sentry/views/insights/cache/referrers';
77
// TODO(release-drawer): Only used in cache/components/samplePanel
88
// eslint-disable-next-line no-restricted-imports
99
import {InsightsLineChartWidget} from 'sentry/views/insights/common/components/insightsLineChartWidget';
10-
import type {DiscoverSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries';
11-
import {
12-
useEAPSeries,
13-
useMetricsSeries,
14-
} from 'sentry/views/insights/common/queries/useDiscoverSeries';
15-
import {useInsightsEap} from 'sentry/views/insights/common/utils/useEap';
16-
import type {SearchHook, SpanQueryFilters} from 'sentry/views/insights/types';
17-
import {MetricsFields, SpanFields} from 'sentry/views/insights/types';
10+
import {useEAPSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries';
11+
import type {SpanQueryFilters} from 'sentry/views/insights/types';
12+
import {SpanFields} from 'sentry/views/insights/types';
1813

1914
type Props = {
2015
samples: Samples;
@@ -28,10 +23,19 @@ export function TransactionDurationChartWithSamples({samples}: Props) {
2823
},
2924
});
3025

31-
const {search} = useTransactionDurationSearch({transaction});
26+
const search = MutableSearch.fromQueryObject({
27+
transaction,
28+
is_transaction: 'true',
29+
} satisfies SpanQueryFilters);
3230
const referrer = Referrer.SAMPLES_CACHE_TRANSACTION_DURATION_CHART;
3331

34-
const {data, isPending, error} = useTransactionDurationSeries({search});
32+
const {data, isPending, error} = useEAPSeries(
33+
{
34+
search,
35+
yAxis: [`avg(${SpanFields.SPAN_DURATION})`],
36+
},
37+
Referrer.SAMPLES_CACHE_TRANSACTION_DURATION
38+
);
3539

3640
return (
3741
<InsightsLineChartWidget
@@ -45,52 +49,3 @@ export function TransactionDurationChartWithSamples({samples}: Props) {
4549
/>
4650
);
4751
}
48-
49-
const useTransactionDurationSearch = ({
50-
transaction,
51-
}: {
52-
transaction: string;
53-
}): SearchHook => {
54-
const useEap = useInsightsEap();
55-
const search = useEap
56-
? MutableSearch.fromQueryObject({
57-
transaction,
58-
is_transaction: 'true',
59-
} satisfies SpanQueryFilters)
60-
: MutableSearch.fromQueryObject({transaction} satisfies SpanQueryFilters);
61-
62-
return {search};
63-
};
64-
65-
const useTransactionDurationSeries = ({search}: {search: MutableSearch}) => {
66-
const useEap = useInsightsEap();
67-
68-
const metricsResult = useMetricsSeries(
69-
{
70-
yAxis: [`avg(${MetricsFields.TRANSACTION_DURATION})`],
71-
search,
72-
transformAliasToInputFormat: true,
73-
enabled: !useEap,
74-
},
75-
Referrer.SAMPLES_CACHE_TRANSACTION_DURATION_CHART
76-
);
77-
78-
const eapResult = useEAPSeries(
79-
{
80-
search,
81-
yAxis: [`avg(${SpanFields.SPAN_DURATION})`],
82-
enabled: useEap,
83-
},
84-
Referrer.SAMPLES_CACHE_TRANSACTION_DURATION
85-
);
86-
87-
const result = useEap ? eapResult : metricsResult;
88-
const finalData: {['avg(span.duration)']: DiscoverSeries} = useEap
89-
? eapResult.data
90-
: {
91-
[`avg(${SpanFields.SPAN_DURATION})`]:
92-
metricsResult.data['avg(transaction.duration)'],
93-
};
94-
95-
return {...result, data: finalData};
96-
};

static/app/views/insights/cache/components/samplePanel.tsx

Lines changed: 19 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import keyBy from 'lodash/keyBy';
44
import {Button} from 'sentry/components/core/button';
55
import {CompactSelect} from 'sentry/components/core/compactSelect';
66
import {EventDrawerHeader} from 'sentry/components/events/eventDrawer';
7-
import {SpanSearchQueryBuilder} from 'sentry/components/performance/spanSearchQueryBuilder';
7+
import {EapSpanSearchQueryBuilderWrapper} from 'sentry/components/performance/spanSearchQueryBuilder';
88
import {t} from 'sentry/locale';
99
import {trackAnalytics} from 'sentry/utils/analytics';
1010
import {DurationUnit, RateUnit, SizeUnit} from 'sentry/utils/discover/fields';
@@ -32,18 +32,15 @@ import {SampleDrawerHeaderTransaction} from 'sentry/views/insights/common/compon
3232
import {
3333
useDiscoverOrEap,
3434
useEAPSpans,
35-
useMetrics,
3635
useSpanMetrics,
3736
useSpansIndexed,
3837
} from 'sentry/views/insights/common/queries/useDiscover';
39-
import {useInsightsEap} from 'sentry/views/insights/common/utils/useEap';
4038
import {
4139
DataTitles,
4240
getThroughputTitle,
4341
} from 'sentry/views/insights/common/views/spans/types';
4442
import {InsightsSpanTagProvider} from 'sentry/views/insights/pages/insightsSpanTagProvider';
4543
import type {
46-
MetricsQueryFilters,
4744
SpanIndexedQueryFilters,
4845
SpanIndexedResponse,
4946
SpanMetricsQueryFilters,
@@ -118,18 +115,23 @@ export function CacheSamplePanel() {
118115
);
119116

120117
const {data: transactionDurationData, isPending: isTransactionDurationLoading} =
121-
useTransactionDuration({transaction: query.transaction});
118+
useEAPSpans(
119+
{
120+
search: MutableSearch.fromQueryObject({
121+
transaction: query.transaction,
122+
is_transaction: 'true',
123+
} satisfies SpanQueryFilters),
124+
fields: [`avg(${SpanFields.SPAN_DURATION})`],
125+
},
126+
Referrer.SAMPLES_CACHE_TRANSACTION_DURATION
127+
);
122128

123129
const sampleFilters: SpanIndexedQueryFilters = {
124130
...BASE_FILTERS,
125131
transaction: query.transaction,
126132
project_id: query.project,
127133
};
128134

129-
const transactionIdField = useEap
130-
? SpanIndexedField.TRANSACTION_SPAN_ID
131-
: SpanIndexedField.TRANSACTION_ID;
132-
133135
const useIndexedCacheSpans = (
134136
isCacheHit: SpanIndexedResponse['cache.hit'],
135137
limit: number
@@ -152,7 +154,6 @@ export function CacheSamplePanel() {
152154
SpanIndexedField.SPAN_OP,
153155
SpanIndexedField.CACHE_ITEM_SIZE,
154156
SpanIndexedField.TRACE,
155-
...(useEap ? [] : ([SpanIndexedField.TRANSACTION_ID] as const)),
156157
],
157158
sorts: [SPAN_SAMPLES_SORT],
158159
limit,
@@ -188,11 +189,10 @@ export function CacheSamplePanel() {
188189
return [...(cacheHitSamples || []), ...(cacheMissSamples || [])];
189190
}, [cacheHitSamples, cacheMissSamples]);
190191

191-
const transactionIds = cacheSamples?.map(span => span[transactionIdField]) || [];
192+
const transactionIds =
193+
cacheSamples?.map(span => span[SpanIndexedField.TRANSACTION_SPAN_ID]) || [];
192194
const traceIds = cacheSamples?.map(span => span.trace) || [];
193-
const transactionDurationSearch = useEap
194-
? `${SpanIndexedField.TRANSACTION_SPAN_ID}:[${transactionIds.join(',')}] trace:[${traceIds.join(',')}] is_transaction:true`
195-
: `id:[${transactionIds.join(',')}]`;
195+
const transactionDurationSearch = `${SpanIndexedField.TRANSACTION_SPAN_ID}:[${transactionIds.join(',')}] trace:[${traceIds.join(',')}] is_transaction:true`;
196196

197197
const {
198198
data: transactionData,
@@ -212,9 +212,11 @@ export function CacheSamplePanel() {
212212
return cacheSamples.map(span => ({
213213
...span,
214214
'transaction.duration':
215-
transactionDurationsMap[span[transactionIdField]]?.['span.duration']!,
215+
transactionDurationsMap[span[SpanIndexedField.TRANSACTION_SPAN_ID]]?.[
216+
'span.duration'
217+
]!,
216218
}));
217-
}, [cacheSamples, transactionData, transactionIdField]);
219+
}, [cacheSamples, transactionData]);
218220

219221
const spanSamplesById = useMemo(() => {
220222
return keyBy(spansWithDuration, 'id');
@@ -355,13 +357,12 @@ export function CacheSamplePanel() {
355357
</ModuleLayout.Half>
356358

357359
<ModuleLayout.Full>
358-
<SpanSearchQueryBuilder
360+
<EapSpanSearchQueryBuilderWrapper
359361
searchSource={`${ModuleName.CACHE}-sample-panel`}
360362
initialQuery={query.spanSearchQuery}
361363
onSearch={handleSearch}
362364
placeholder={t('Search for span attributes')}
363365
projects={selection.projects}
364-
useEap={useEap}
365366
/>
366367
</ModuleLayout.Full>
367368

@@ -431,38 +432,3 @@ const CACHE_STATUS_OPTIONS = [
431432
label: t('Miss'),
432433
},
433434
];
434-
435-
const useTransactionDuration = ({transaction}: {transaction: string}) => {
436-
const useEap = useInsightsEap();
437-
438-
const metricsResult = useMetrics(
439-
{
440-
enabled: !useEap && Boolean(transaction),
441-
search: MutableSearch.fromQueryObject({
442-
transaction,
443-
} satisfies MetricsQueryFilters),
444-
fields: [`avg(${MetricsFields.TRANSACTION_DURATION})`],
445-
},
446-
Referrer.SAMPLES_CACHE_TRANSACTION_DURATION
447-
);
448-
449-
const eapResult = useEAPSpans(
450-
{
451-
search: MutableSearch.fromQueryObject({
452-
transaction,
453-
is_transaction: 'true',
454-
} satisfies SpanQueryFilters),
455-
fields: [`avg(${SpanFields.SPAN_DURATION})`],
456-
},
457-
Referrer.SAMPLES_CACHE_TRANSACTION_DURATION
458-
);
459-
460-
const result = useEap ? eapResult : metricsResult;
461-
const finalData: Array<{[`avg(span.duration)`]: number}> = useEap
462-
? eapResult.data
463-
: metricsResult.data.map(row => ({
464-
'avg(span.duration)': row[`avg(${MetricsFields.TRANSACTION_DURATION})`],
465-
}));
466-
467-
return {...result, data: finalData};
468-
};

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

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,10 @@ import {useSpanMetricsSeries} from 'sentry/views/insights/common/queries/useDisc
3636
import {useHasFirstSpan} from 'sentry/views/insights/common/queries/useHasFirstSpan';
3737
import {useOnboardingProject} from 'sentry/views/insights/common/queries/useOnboardingProject';
3838
import {combineMeta} from 'sentry/views/insights/common/utils/combineMeta';
39-
import {useInsightsEap} from 'sentry/views/insights/common/utils/useEap';
4039
import {useSamplesDrawer} from 'sentry/views/insights/common/utils/useSamplesDrawer';
4140
import {QueryParameterNames} from 'sentry/views/insights/common/views/queryParameters';
4241
import {BackendHeader} from 'sentry/views/insights/pages/backend/backendPageHeader';
43-
import {
44-
type MetricsProperty,
45-
ModuleName,
46-
SpanFunction,
47-
SpanMetricsField,
48-
} from 'sentry/views/insights/types';
42+
import {ModuleName, SpanFunction, SpanMetricsField} from 'sentry/views/insights/types';
4943

5044
const {CACHE_MISS_RATE} = SpanFunction;
5145
const {CACHE_ITEM_SIZE} = SpanMetricsField;
@@ -66,7 +60,6 @@ const CACHE_ERROR_MESSAGE = 'Column cache.hit was not found in metrics indexer';
6660
export function CacheLandingPage() {
6761
const location = useLocation();
6862
const {setPageInfo, pageAlert} = usePageAlert();
69-
const useEap = useInsightsEap();
7063

7164
const sortField = decodeScalar(location.query?.[QueryParameterNames.TRANSACTIONS_SORT]);
7265

@@ -113,13 +106,7 @@ export function CacheLandingPage() {
113106
Referrer.LANDING_CACHE_TRANSACTION_LIST
114107
);
115108

116-
const search = useEap
117-
? `transaction:[${transactionsList.map(({transaction}) => `"${transaction.replaceAll('"', '\\"')}"`).join(',')}] AND is_transaction:true`
118-
: `transaction:[${transactionsList.map(({transaction}) => `"${transaction.replaceAll('"', '\\"')}"`).join(',')}]`;
119-
120-
const fields: MetricsProperty[] = useEap
121-
? ['avg(span.duration)', 'transaction']
122-
: [`avg(transaction.duration)`, 'transaction'];
109+
const search = `transaction:[${transactionsList.map(({transaction}) => `"${transaction.replaceAll('"', '\\"')}"`).join(',')}] AND is_transaction:true`;
123110

124111
const {
125112
data: transactionDurationData,
@@ -129,7 +116,7 @@ export function CacheLandingPage() {
129116
} = useMetrics(
130117
{
131118
search,
132-
fields,
119+
fields: ['avg(span.duration)', 'transaction'],
133120
enabled: !isTransactionsListFetching && transactionsList.length > 0,
134121
noPagination: true,
135122
},
@@ -168,11 +155,8 @@ export function CacheLandingPage() {
168155
const transactionsListWithDuration =
169156
transactionsList?.map(transaction => ({
170157
...transaction,
171-
'avg(span.duration)': useEap
172-
? transactionDurationsMap[transaction.transaction]?.['avg(span.duration)']!
173-
: transactionDurationsMap[transaction.transaction]?.[
174-
'avg(transaction.duration)'
175-
]!,
158+
'avg(span.duration)':
159+
transactionDurationsMap[transaction.transaction]?.['avg(span.duration)']!,
176160
})) || [];
177161

178162
const meta = combineMeta(transactionsListMeta, transactionDurationMeta);

static/app/views/insights/queues/components/messageSpanSamplesPanel.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import keyBy from 'lodash/keyBy';
55
import {Button} from 'sentry/components/core/button';
66
import {CompactSelect, type SelectOption} from 'sentry/components/core/compactSelect';
77
import {EventDrawerHeader} from 'sentry/components/events/eventDrawer';
8-
import {SpanSearchQueryBuilder} from 'sentry/components/performance/spanSearchQueryBuilder';
8+
import {EapSpanSearchQueryBuilderWrapper} from 'sentry/components/performance/spanSearchQueryBuilder';
99
import {t} from 'sentry/locale';
1010
import {space} from 'sentry/styles/space';
1111
import {trackAnalytics} from 'sentry/utils/analytics';
@@ -31,7 +31,6 @@ import {ReadoutRibbon} from 'sentry/views/insights/common/components/ribbon';
3131
import {SampleDrawerBody} from 'sentry/views/insights/common/components/sampleDrawerBody';
3232
import {SampleDrawerHeaderTransaction} from 'sentry/views/insights/common/components/sampleDrawerHeaderTransaction';
3333
import {useSpanMetricsSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries';
34-
import {useInsightsEap} from 'sentry/views/insights/common/utils/useEap';
3534
import {getDurationChartTitle} from 'sentry/views/insights/common/views/spans/types';
3635
import {useSpanSamples} from 'sentry/views/insights/http/queries/useSpanSamples';
3736
import {InsightsSpanTagProvider} from 'sentry/views/insights/pages/insightsSpanTagProvider';
@@ -69,7 +68,6 @@ export function MessageSpanSamplesPanel() {
6968
});
7069
const {projects} = useProjects();
7170
const {selection} = usePageFilters();
72-
const useEap = useInsightsEap();
7371

7472
const project = projects.find(p => query.project === p.id);
7573

@@ -324,13 +322,12 @@ export function MessageSpanSamplesPanel() {
324322
</ModuleLayout.Full>
325323

326324
<ModuleLayout.Full>
327-
<SpanSearchQueryBuilder
325+
<EapSpanSearchQueryBuilderWrapper
328326
searchSource={`${ModuleName.QUEUE}-sample-panel`}
329327
initialQuery={query.spanSearchQuery}
330328
onSearch={handleSearch}
331329
placeholder={t('Search for span attributes')}
332330
projects={selection.projects}
333-
useEap={useEap}
334331
/>
335332
</ModuleLayout.Full>
336333

0 commit comments

Comments
 (0)