Skip to content

Commit

Permalink
add typing
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 committed Nov 1, 2024
1 parent eed497b commit e59151e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/portalnetwork/src/util/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NetworkId, NetworkNames } from '../networks/types.js'
import type { PortalNetworkMetrics } from '../client/types.js'

const peers = (networks: NetworkId[]) => {
const metrics: Record<string, PromClient.Gauge> = {}
const metrics: Record<string, PromClient.Gauge<NetworkId>> = {}
for (const network of networks) {
const name = NetworkNames[network]
metrics[name + '_peers'] = new PromClient.Gauge({
Expand All @@ -19,8 +19,12 @@ const peers = (networks: NetworkId[]) => {
export const setupMetrics = (
networks: NetworkId[] = [NetworkId.HistoryNetwork],
): PortalNetworkMetrics => {
const peerMetrics = peers(networks) as Record<
keyof PortalNetworkMetrics,
PromClient.Gauge<NetworkId>
>
return {
...peers(networks),
...peerMetrics,
totalContentLookups: new PromClient.Gauge<string>({
name: 'ultralight_total_content_lookups',
help: 'total number of content lookups initiated',
Expand Down Expand Up @@ -93,5 +97,5 @@ export const setupMetrics = (
name: 'ultralight_db_size',
help: 'how many MBs are currently stored in the db',
}),
} as unknown as PortalNetworkMetrics
}
}

0 comments on commit e59151e

Please sign in to comment.