@@ -6,6 +6,7 @@ import Link from 'sentry/components/links/link';
6
6
import { getChartColorPalette } from 'sentry/constants/chartPalette' ;
7
7
import { IconExpand } from 'sentry/icons' ;
8
8
import { t } from 'sentry/locale' ;
9
+ import { formatAbbreviatedNumber } from 'sentry/utils/formatters' ;
9
10
import { useApiQuery } from 'sentry/utils/queryClient' ;
10
11
import { MutableSearch } from 'sentry/utils/tokenizeSearch' ;
11
12
import useOrganization from 'sentry/utils/useOrganization' ;
@@ -31,6 +32,7 @@ export function CachesWidget({query}: {query?: string}) {
31
32
const cachesRequest = useApiQuery < {
32
33
data : Array < {
33
34
'cache_miss_rate()' : number ;
35
+ 'count()' : number ;
34
36
'project.id' : string ;
35
37
transaction : string ;
36
38
} > ;
@@ -41,7 +43,7 @@ export function CachesWidget({query}: {query?: string}) {
41
43
query : {
42
44
...pageFilterChartParams ,
43
45
dataset : 'spansMetrics' ,
44
- field : [ 'transaction' , 'project.id' , 'cache_miss_rate()' ] ,
46
+ field : [ 'transaction' , 'project.id' , 'cache_miss_rate()' , 'count()' ] ,
45
47
query : `span.op:[cache.get_item,cache.get] ${ query } ` ,
46
48
sort : '-cache_miss_rate()' ,
47
49
per_page : 4 ,
@@ -117,26 +119,34 @@ export function CachesWidget({query}: {query?: string}) {
117
119
) ;
118
120
119
121
const footer = hasData && (
120
- < WidgetFooterTable >
121
- { cachesRequest . data ?. data . map ( ( item , index ) => (
122
- < Fragment key = { item . transaction } >
123
- < div >
124
- < SeriesColorIndicator
125
- style = { {
126
- backgroundColor : colorPalette [ index ] ,
127
- } }
128
- />
129
- </ div >
130
- < div >
131
- < Link
132
- to = { `/insights/backend/caches?project=${ item [ 'project.id' ] } &transaction=${ item . transaction } ` }
133
- >
134
- { item . transaction }
135
- </ Link >
136
- </ div >
137
- < span > { ( item [ 'cache_miss_rate()' ] * 100 ) . toFixed ( 2 ) } %</ span >
138
- </ Fragment >
139
- ) ) }
122
+ < WidgetFooterTable columns = { 4 } >
123
+ { cachesRequest . data ?. data . map ( ( item , index ) => {
124
+ const count = item [ 'count()' ] ;
125
+ const cacheMissRate = item [ 'cache_miss_rate()' ] ;
126
+ const missedCount = Math . floor ( count * cacheMissRate ) ;
127
+ return (
128
+ < Fragment key = { item . transaction } >
129
+ < div >
130
+ < SeriesColorIndicator
131
+ style = { {
132
+ backgroundColor : colorPalette [ index ] ,
133
+ } }
134
+ />
135
+ </ div >
136
+ < div >
137
+ < Link
138
+ to = { `/insights/backend/caches?project=${ item [ 'project.id' ] } &transaction=${ item . transaction } ` }
139
+ >
140
+ { item . transaction }
141
+ </ Link >
142
+ </ div >
143
+ < span >
144
+ { formatAbbreviatedNumber ( missedCount ) } / { formatAbbreviatedNumber ( count ) }
145
+ </ span >
146
+ < span > { ( cacheMissRate * 100 ) . toFixed ( 2 ) } %</ span >
147
+ </ Fragment >
148
+ ) ;
149
+ } ) }
140
150
</ WidgetFooterTable >
141
151
) ;
142
152
0 commit comments