1
- import { useDiscoverQuery } from 'sentry/utils/discover/discoverQuery' ;
2
- import EventView from 'sentry/utils/discover/eventView' ;
3
1
import type { Sort } from 'sentry/utils/discover/fields' ;
4
- import { DiscoverDatasets } from 'sentry/utils/discover/types' ;
5
- import { useLocation } from 'sentry/utils/useLocation' ;
6
- import useOrganization from 'sentry/utils/useOrganization' ;
7
- import usePageFilters from 'sentry/utils/usePageFilters' ;
2
+ import { useSpansIndexed } from 'sentry/views/insights/common/queries/useDiscover' ;
8
3
import { SpanIndexedField } from 'sentry/views/insights/types' ;
9
4
10
- const { SPAN_DESCRIPTION , HTTP_RESPONSE_CONTENT_LENGTH , RAW_DOMAIN } = SpanIndexedField ;
11
-
12
5
type Options = {
6
+ referrer : string ;
13
7
enabled ?: boolean ;
14
8
limit ?: number ;
15
9
queryConditions ?: string [ ] ;
16
- referrer ?: string ;
17
10
sorts ?: Sort [ ] ;
18
11
} ;
19
12
@@ -24,55 +17,21 @@ export const useIndexedResourcesQuery = ({
24
17
referrer,
25
18
enabled = true ,
26
19
} : Options ) => {
27
- const pageFilters = usePageFilters ( ) ;
28
- const location = useLocation ( ) ;
29
- const { slug : orgSlug } = useOrganization ( ) ;
30
-
31
- // TODO - we should be using metrics data here
32
- const eventView = EventView . fromNewQueryWithPageFilters (
20
+ return useSpansIndexed (
33
21
{
34
22
fields : [
35
23
`any(id)` ,
36
- 'project' ,
37
- 'span.group' ,
38
- RAW_DOMAIN ,
39
- SPAN_DESCRIPTION ,
40
- `measurements. ${ HTTP_RESPONSE_CONTENT_LENGTH } ` ,
24
+ SpanIndexedField . PROJECT ,
25
+ SpanIndexedField . SPAN_GROUP ,
26
+ SpanIndexedField . RAW_DOMAIN ,
27
+ SpanIndexedField . SPAN_DESCRIPTION ,
28
+ SpanIndexedField . MEASUREMENT_HTTP_RESPONSE_CONTENT_LENGTH ,
41
29
] ,
42
- name : 'Indexed Resource Query' ,
43
- query : queryConditions . join ( ' ' ) ,
44
- version : 2 ,
45
- dataset : DiscoverDatasets . SPANS_INDEXED ,
46
- } ,
47
- pageFilters . selection
48
- ) ;
49
-
50
- if ( sorts ) {
51
- eventView . sorts = sorts ;
52
- }
53
-
54
- const result = useDiscoverQuery ( {
55
- eventView,
56
- limit,
57
- location,
58
- orgSlug,
59
- referrer,
60
- options : {
30
+ limit,
31
+ sorts,
32
+ search : queryConditions . join ( ' ' ) ,
61
33
enabled,
62
- refetchOnWindowFocus : false ,
63
34
} ,
64
- } ) ;
65
-
66
- const data =
67
- result ?. data ?. data . map ( row => ( {
68
- project : row . project as string ,
69
- 'transaction.id' : row [ 'transaction.id' ] as string ,
70
- [ SPAN_DESCRIPTION ] : row [ SPAN_DESCRIPTION ] ?. toString ( ) ,
71
- [ RAW_DOMAIN ] : row [ RAW_DOMAIN ] ?. toString ( ) ,
72
- 'measurements.http.response_content_length' : row [
73
- `measurements.${ HTTP_RESPONSE_CONTENT_LENGTH } `
74
- ] as number ,
75
- } ) ) ?? [ ] ;
76
-
77
- return { ...result , data} ;
35
+ referrer
36
+ ) ;
78
37
} ;
0 commit comments