Skip to content

Commit 60a5e6c

Browse files
authored
fix!: Update to new metrics interface (#502)
Updates to @libp2p/metrics v4 BREAKING CHANGE: updates to the new metrics interface
1 parent ca1e41c commit 60a5e6c

File tree

6 files changed

+11
-19
lines changed

6 files changed

+11
-19
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
"@libp2p/interface-peer-id": "^1.0.4",
170170
"@libp2p/interface-peer-store": "^1.2.0",
171171
"@libp2p/topology": "^3.0.0",
172-
"@libp2p/tracked-map": "^2.0.0",
172+
"@libp2p/tracked-map": "^3.0.0",
173173
"@multiformats/multiaddr": "^11.0.0",
174174
"@vascosantos/moving-average": "^1.1.0",
175175
"abortable-iterator": "^4.0.2",
@@ -190,12 +190,12 @@
190190
"varint-decoder": "^1.0.0"
191191
},
192192
"devDependencies": {
193-
"@chainsafe/libp2p-noise": "^9.0.0",
194-
"@libp2p/kad-dht": "^5.0.1",
193+
"@chainsafe/libp2p-noise": "^10.0.1",
194+
"@libp2p/kad-dht": "^6.0.0",
195195
"@libp2p/mplex": "^7.0.0",
196196
"@libp2p/peer-id": "^1.1.8",
197197
"@libp2p/peer-id-factory": "^1.0.8",
198-
"@libp2p/tcp": "^5.0.0",
198+
"@libp2p/tcp": "^6.0.0",
199199
"@nodeutils/defaults-deep": "^1.1.0",
200200
"@types/debug": "^4.1.5",
201201
"@types/stats-lite": "^2.2.0",
@@ -208,7 +208,7 @@
208208
"iso-random-stream": "^2.0.0",
209209
"it-all": "^2.0.0",
210210
"it-drain": "^2.0.0",
211-
"libp2p": "^0.40.0",
211+
"libp2p": "next",
212212
"lodash.difference": "^4.5.0",
213213
"lodash.flatten": "^4.4.0",
214214
"lodash.range": "^3.2.0",

src/decision-engine/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ export class DecisionEngine {
5151
// A list of of ledgers by their partner id
5252
/** @type {Map<string, Ledger>} */
5353
this.ledgerMap = trackedMap({
54-
system: 'ipfs',
55-
component: 'bitswap',
56-
metric: 'ledger-map',
54+
name: 'ipfs_bitswap_ledger_map',
5755
metrics: libp2p.metrics
5856
})
5957
this._running = false

src/stats/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ export class Stats extends EventEmitter {
5252

5353
/** @type {Map<string, Stat>} */
5454
this._peers = trackedMap({
55-
system: 'ipfs',
56-
component: 'bitswap',
57-
metric: 'stats-peers',
55+
name: 'ipfs_bitswap_stats_peers',
5856
metrics: libp2p.metrics
5957
})
6058
}

src/want-manager/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export class WantManager {
2222
constructor (peerId, network, stats, libp2p) {
2323
/** @type {Map<string, MsgQueue>} */
2424
this.peers = trackedMap({
25-
system: 'ipfs',
26-
component: 'bitswap',
27-
metric: 'want-manager-peers',
25+
name: 'ipfs_bitswap_want_manager_peers',
2826
metrics: libp2p.metrics
2927
})
3028
this.wantlist = new Wantlist(stats, libp2p)

src/wantlist/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ export class Wantlist {
3636
/** @type {Map<string, Entry>} */
3737
this.set = libp2p
3838
? trackedMap({
39-
system: 'ipfs',
40-
component: 'bitswap',
41-
metric: 'wantlist',
39+
name: 'ipfs_bitswap_wantlist',
4240
metrics: libp2p.metrics
4341
})
4442
: new Map()

test/utils/create-libp2p-node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import { tcp } from '@libp2p/tcp'
33
import { mplex } from '@libp2p/mplex'
4-
import { Noise } from '@chainsafe/libp2p-noise'
4+
import { noise } from '@chainsafe/libp2p-noise'
55
import { createLibp2p } from 'libp2p'
66
import { kadDHT } from '@libp2p/kad-dht'
77
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
@@ -34,7 +34,7 @@ export async function createLibp2pNode (options) {
3434
mplex()
3535
],
3636
connectionEncryption: [
37-
() => new Noise()
37+
noise()
3838
],
3939
dht: options.DHT
4040
? kadDHT({

0 commit comments

Comments
 (0)