@@ -4,7 +4,7 @@ import keyBy from 'lodash/keyBy';
4
4
import { Button } from 'sentry/components/core/button' ;
5
5
import { CompactSelect } from 'sentry/components/core/compactSelect' ;
6
6
import { EventDrawerHeader } from 'sentry/components/events/eventDrawer' ;
7
- import { SpanSearchQueryBuilder } from 'sentry/components/performance/spanSearchQueryBuilder' ;
7
+ import { EapSpanSearchQueryBuilderWrapper } from 'sentry/components/performance/spanSearchQueryBuilder' ;
8
8
import { t } from 'sentry/locale' ;
9
9
import { trackAnalytics } from 'sentry/utils/analytics' ;
10
10
import { DurationUnit , RateUnit , SizeUnit } from 'sentry/utils/discover/fields' ;
@@ -32,18 +32,15 @@ import {SampleDrawerHeaderTransaction} from 'sentry/views/insights/common/compon
32
32
import {
33
33
useDiscoverOrEap ,
34
34
useEAPSpans ,
35
- useMetrics ,
36
35
useSpanMetrics ,
37
36
useSpansIndexed ,
38
37
} from 'sentry/views/insights/common/queries/useDiscover' ;
39
- import { useInsightsEap } from 'sentry/views/insights/common/utils/useEap' ;
40
38
import {
41
39
DataTitles ,
42
40
getThroughputTitle ,
43
41
} from 'sentry/views/insights/common/views/spans/types' ;
44
42
import { InsightsSpanTagProvider } from 'sentry/views/insights/pages/insightsSpanTagProvider' ;
45
43
import type {
46
- MetricsQueryFilters ,
47
44
SpanIndexedQueryFilters ,
48
45
SpanIndexedResponse ,
49
46
SpanMetricsQueryFilters ,
@@ -118,18 +115,23 @@ export function CacheSamplePanel() {
118
115
) ;
119
116
120
117
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
+ ) ;
122
128
123
129
const sampleFilters : SpanIndexedQueryFilters = {
124
130
...BASE_FILTERS ,
125
131
transaction : query . transaction ,
126
132
project_id : query . project ,
127
133
} ;
128
134
129
- const transactionIdField = useEap
130
- ? SpanIndexedField . TRANSACTION_SPAN_ID
131
- : SpanIndexedField . TRANSACTION_ID ;
132
-
133
135
const useIndexedCacheSpans = (
134
136
isCacheHit : SpanIndexedResponse [ 'cache.hit' ] ,
135
137
limit : number
@@ -152,7 +154,6 @@ export function CacheSamplePanel() {
152
154
SpanIndexedField . SPAN_OP ,
153
155
SpanIndexedField . CACHE_ITEM_SIZE ,
154
156
SpanIndexedField . TRACE ,
155
- ...( useEap ? [ ] : ( [ SpanIndexedField . TRANSACTION_ID ] as const ) ) ,
156
157
] ,
157
158
sorts : [ SPAN_SAMPLES_SORT ] ,
158
159
limit,
@@ -188,11 +189,10 @@ export function CacheSamplePanel() {
188
189
return [ ...( cacheHitSamples || [ ] ) , ...( cacheMissSamples || [ ] ) ] ;
189
190
} , [ cacheHitSamples , cacheMissSamples ] ) ;
190
191
191
- const transactionIds = cacheSamples ?. map ( span => span [ transactionIdField ] ) || [ ] ;
192
+ const transactionIds =
193
+ cacheSamples ?. map ( span => span [ SpanIndexedField . TRANSACTION_SPAN_ID ] ) || [ ] ;
192
194
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` ;
196
196
197
197
const {
198
198
data : transactionData ,
@@ -212,9 +212,11 @@ export function CacheSamplePanel() {
212
212
return cacheSamples . map ( span => ( {
213
213
...span ,
214
214
'transaction.duration' :
215
- transactionDurationsMap [ span [ transactionIdField ] ] ?. [ 'span.duration' ] ! ,
215
+ transactionDurationsMap [ span [ SpanIndexedField . TRANSACTION_SPAN_ID ] ] ?. [
216
+ 'span.duration'
217
+ ] ! ,
216
218
} ) ) ;
217
- } , [ cacheSamples , transactionData , transactionIdField ] ) ;
219
+ } , [ cacheSamples , transactionData ] ) ;
218
220
219
221
const spanSamplesById = useMemo ( ( ) => {
220
222
return keyBy ( spansWithDuration , 'id' ) ;
@@ -355,13 +357,12 @@ export function CacheSamplePanel() {
355
357
</ ModuleLayout . Half >
356
358
357
359
< ModuleLayout . Full >
358
- < SpanSearchQueryBuilder
360
+ < EapSpanSearchQueryBuilderWrapper
359
361
searchSource = { `${ ModuleName . CACHE } -sample-panel` }
360
362
initialQuery = { query . spanSearchQuery }
361
363
onSearch = { handleSearch }
362
364
placeholder = { t ( 'Search for span attributes' ) }
363
365
projects = { selection . projects }
364
- useEap = { useEap }
365
366
/>
366
367
</ ModuleLayout . Full >
367
368
@@ -431,38 +432,3 @@ const CACHE_STATUS_OPTIONS = [
431
432
label : t ( 'Miss' ) ,
432
433
} ,
433
434
] ;
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
- } ;
0 commit comments