Skip to content

Commit e59151e

Browse files
committed
add typing
1 parent eed497b commit e59151e

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

packages/portalnetwork/src/util/metrics.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { NetworkId, NetworkNames } from '../networks/types.js'
55
import type { PortalNetworkMetrics } from '../client/types.js'
66

77
const peers = (networks: NetworkId[]) => {
8-
const metrics: Record<string, PromClient.Gauge> = {}
8+
const metrics: Record<string, PromClient.Gauge<NetworkId>> = {}
99
for (const network of networks) {
1010
const name = NetworkNames[network]
1111
metrics[name + '_peers'] = new PromClient.Gauge({
@@ -19,8 +19,12 @@ const peers = (networks: NetworkId[]) => {
1919
export const setupMetrics = (
2020
networks: NetworkId[] = [NetworkId.HistoryNetwork],
2121
): PortalNetworkMetrics => {
22+
const peerMetrics = peers(networks) as Record<
23+
keyof PortalNetworkMetrics,
24+
PromClient.Gauge<NetworkId>
25+
>
2226
return {
23-
...peers(networks),
27+
...peerMetrics,
2428
totalContentLookups: new PromClient.Gauge<string>({
2529
name: 'ultralight_total_content_lookups',
2630
help: 'total number of content lookups initiated',
@@ -93,5 +97,5 @@ export const setupMetrics = (
9397
name: 'ultralight_db_size',
9498
help: 'how many MBs are currently stored in the db',
9599
}),
96-
} as unknown as PortalNetworkMetrics
100+
}
97101
}

0 commit comments

Comments
 (0)