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

Commit c026f03

Browse files
authored
fix: update component metric API use (#293)
Latest libp2p switches to `{ system, component, metric, name }` as input
1 parent d97701a commit c026f03

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/query/manager.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class QueryManager {
115115
try {
116116
log('query:start')
117117
this._queries++
118-
this._metrics && this._metrics.updateComponentMetric(`kad-dht-${this._lan ? 'lan' : 'wan'}`, METRIC_RUNNING_QUERIES, this._queries)
118+
this._metrics && this._metrics.updateComponentMetric({ component: `kad-dht-${this._lan ? 'lan' : 'wan'}`, metric: METRIC_RUNNING_QUERIES, value: this._queries })
119119

120120
if (peers.length === 0) {
121121
log.error('Running query with no peers')
@@ -161,7 +161,7 @@ class QueryManager {
161161
}
162162

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

166166
cleanUp.emit('cleanup')
167167
log(`query:done in ${Date.now() - (startTime || 0)}ms`)

src/routing-table/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class RoutingTable {
118118
timeoutController.clear()
119119
}
120120

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

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

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

199199
/**
@@ -206,7 +206,7 @@ class RoutingTable {
206206

207207
this.kb.remove(id)
208208

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

src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,5 @@ export interface Addressable {
161161
}
162162

163163
export interface Metrics {
164-
updateComponentMetric: (component: string, metric: string, value: number) => void
164+
updateComponentMetric: (options: { component: string, metric: string, value: number }) => void
165165
}

0 commit comments

Comments
 (0)