@@ -5,7 +5,7 @@ import { NetworkId, NetworkNames } from '../networks/types.js'
5
5
import type { PortalNetworkMetrics } from '../client/types.js'
6
6
7
7
const peers = ( networks : NetworkId [ ] ) => {
8
- const metrics : Record < string , PromClient . Gauge > = { }
8
+ const metrics : Record < string , PromClient . Gauge < NetworkId > > = { }
9
9
for ( const network of networks ) {
10
10
const name = NetworkNames [ network ]
11
11
metrics [ name + '_peers' ] = new PromClient . Gauge ( {
@@ -19,8 +19,13 @@ const peers = (networks: NetworkId[]) => {
19
19
export const setupMetrics = (
20
20
networks : NetworkId [ ] = [ NetworkId . HistoryNetwork ] ,
21
21
) : PortalNetworkMetrics => {
22
+ // This clever typing was provided by robots. Beware.
23
+ const peerMetrics = peers ( networks ) as Record <
24
+ keyof PortalNetworkMetrics ,
25
+ PromClient . Gauge < NetworkId >
26
+ >
22
27
return {
23
- ...peers ( networks ) ,
28
+ ...peerMetrics ,
24
29
totalContentLookups : new PromClient . Gauge < string > ( {
25
30
name : 'ultralight_total_content_lookups' ,
26
31
help : 'total number of content lookups initiated' ,
@@ -93,5 +98,5 @@ export const setupMetrics = (
93
98
name : 'ultralight_db_size' ,
94
99
help : 'how many MBs are currently stored in the db' ,
95
100
} ) ,
96
- } as unknown as PortalNetworkMetrics
101
+ }
97
102
}
0 commit comments