@@ -49,17 +49,14 @@ type MetricsSummaryResponse = {
4949} ;
5050
5151const buildMetricsWithDefaults = ( metrics : Partial < DataNodeMetrics > = { } ) : DataNodeMetrics =>
52- METRIC_SHORT_NAMES . reduce < DataNodeMetrics > ( ( acc , key ) => ( { ... acc , [ key ] : metrics [ key ] } ) , { } as DataNodeMetrics ) ;
52+ Object . fromEntries ( METRIC_SHORT_NAMES . map ( ( key ) => [ key , metrics [ key ] ] ) ) ;
5353
5454const toNodeMetric = ( response ?: MetricsSummaryResponse ) : NodeMetric | undefined => {
5555 if ( ! response ?. metrics ?. length ) {
5656 return undefined ;
5757 }
5858
59- return response . metrics . reduce < NodeMetric > (
60- ( acc , metric ) => ( { ...acc , [ metric . full_name ] : metric } ) ,
61- { } as NodeMetric ,
62- ) ;
59+ return Object . fromEntries ( response . metrics . map ( ( metric ) => [ metric . full_name , metric ] ) ) ;
6360} ;
6461
6562const extractMetrics = ( response ?: MetricsSummaryResponse ) : DataNodeMetrics => {
@@ -91,13 +88,7 @@ const fetchMetricsForHostnames = async (hostnames: string[]) => {
9188 hostnames . map ( async ( hostname ) => ( { hostname, response : await fetchMetrics ( hostname ) } ) ) ,
9289 ) ;
9390
94- return responses . reduce < Record < string , DataNodeMetrics > > (
95- ( acc , { hostname, response } ) => ( {
96- ...acc ,
97- [ hostname ] : extractMetrics ( response ) ,
98- } ) ,
99- { } ,
100- ) ;
91+ return Object . fromEntries ( responses . map ( ( { hostname, response } ) => [ hostname , extractMetrics ( response ) ] ) ) ;
10192} ;
10293
10394type UseAddMetricsToDataNodesOptions = {
0 commit comments