Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
fix: update component metric API use (#293)
Browse files Browse the repository at this point in the history
Latest libp2p switches to `{ system, component, metric, name }` as input
  • Loading branch information
achingbrain authored Jan 19, 2022
1 parent d97701a commit c026f03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/query/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class QueryManager {
try {
log('query:start')
this._queries++
this._metrics && this._metrics.updateComponentMetric(`kad-dht-${this._lan ? 'lan' : 'wan'}`, METRIC_RUNNING_QUERIES, this._queries)
this._metrics && this._metrics.updateComponentMetric({ component: `kad-dht-${this._lan ? 'lan' : 'wan'}`, metric: METRIC_RUNNING_QUERIES, value: this._queries })

if (peers.length === 0) {
log.error('Running query with no peers')
Expand Down Expand Up @@ -161,7 +161,7 @@ class QueryManager {
}

this._queries--
this._metrics && this._metrics.updateComponentMetric(`kad-dht-${this._lan ? 'lan' : 'wan'}`, METRIC_RUNNING_QUERIES, this._queries)
this._metrics && this._metrics.updateComponentMetric({ component: `kad-dht-${this._lan ? 'lan' : 'wan'}`, metric: METRIC_RUNNING_QUERIES, value: this._queries })

cleanUp.emit('cleanup')
log(`query:done in ${Date.now() - (startTime || 0)}ms`)
Expand Down
6 changes: 3 additions & 3 deletions src/routing-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class RoutingTable {
timeoutController.clear()
}

this._metrics && this._metrics.updateComponentMetric(`kad-dht-${this._lan ? 'lan' : 'wan'}`, METRIC_ROUTING_TABLE_SIZE, this.size)
this._metrics && this._metrics.updateComponentMetric({ component: `kad-dht-${this._lan ? 'lan' : 'wan'}`, metric: METRIC_ROUTING_TABLE_SIZE, value: this.size })
}
})
)
Expand Down Expand Up @@ -193,7 +193,7 @@ class RoutingTable {

this._log('added %p with kad id %b', peer, id)

this._metrics && this._metrics.updateComponentMetric(`kad-dht-${this._lan ? 'lan' : 'wan'}`, METRIC_ROUTING_TABLE_SIZE, this.size)
this._metrics && this._metrics.updateComponentMetric({ component: `kad-dht-${this._lan ? 'lan' : 'wan'}`, metric: METRIC_ROUTING_TABLE_SIZE, value: this.size })
}

/**
Expand All @@ -206,7 +206,7 @@ class RoutingTable {

this.kb.remove(id)

this._metrics && this._metrics.updateComponentMetric(`kad-dht-${this._lan ? 'lan' : 'wan'}`, METRIC_ROUTING_TABLE_SIZE, this.size)
this._metrics && this._metrics.updateComponentMetric({ component: `kad-dht-${this._lan ? 'lan' : 'wan'}`, metric: METRIC_ROUTING_TABLE_SIZE, value: this.size })
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,5 @@ export interface Addressable {
}

export interface Metrics {
updateComponentMetric: (component: string, metric: string, value: number) => void
updateComponentMetric: (options: { component: string, metric: string, value: number }) => void
}

0 comments on commit c026f03

Please sign in to comment.