hyperswarm-stats 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +43 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -32,6 +32,32 @@ class HyperswarmStats {
|
|
|
32
32
|
return this.swarm.dht.stats.queries
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
getAvgCongestionWindow () {
|
|
36
|
+
let totalCongestionWindow = 0
|
|
37
|
+
let count = 0
|
|
38
|
+
for (const conn of this.swarm.connections) {
|
|
39
|
+
if (conn.rawStream) {
|
|
40
|
+
count++
|
|
41
|
+
totalCongestionWindow += conn.rawStream.cwnd
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return totalCongestionWindow / count
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getAvgMTU () {
|
|
49
|
+
let totalMTU = 0
|
|
50
|
+
let count = 0
|
|
51
|
+
for (const conn of this.swarm.connections) {
|
|
52
|
+
if (conn.rawStream) {
|
|
53
|
+
count++
|
|
54
|
+
totalMTU += conn.rawStream.mtu
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return totalMTU / count
|
|
59
|
+
}
|
|
60
|
+
|
|
35
61
|
getBytesTransmittedAcrossAllStreams () {
|
|
36
62
|
let bytesFromCurrentConns = 0
|
|
37
63
|
for (const conn of this.swarm.connections) {
|
|
@@ -277,7 +303,7 @@ class HyperswarmStats {
|
|
|
277
303
|
name: 'dht_server_socket_packets_transmitted',
|
|
278
304
|
help: 'Total packets transmitted by the server socket of the DHT',
|
|
279
305
|
collect () {
|
|
280
|
-
this.set(self.
|
|
306
|
+
this.set(self.dhtServerSocketPacketsTransmitted)
|
|
281
307
|
}
|
|
282
308
|
})
|
|
283
309
|
new promClient.Gauge({ // eslint-disable-line no-new
|
|
@@ -323,6 +349,22 @@ class HyperswarmStats {
|
|
|
323
349
|
this.set(self.getPacketsReceivedAcrossAllStreams())
|
|
324
350
|
}
|
|
325
351
|
})
|
|
352
|
+
|
|
353
|
+
new promClient.Gauge({ // eslint-disable-line no-new
|
|
354
|
+
name: 'hyperswarm_avg_congestion_window',
|
|
355
|
+
help: 'Average size of the congestion window (over all hyperswarm connections)',
|
|
356
|
+
collect () {
|
|
357
|
+
this.set(self.getAvgCongestionWindow())
|
|
358
|
+
}
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
new promClient.Gauge({ // eslint-disable-line no-new
|
|
362
|
+
name: 'hyperswarm_avg_mtu',
|
|
363
|
+
help: 'Average size of the Maximum Transmission Unit (over all hyperswarm connections)',
|
|
364
|
+
collect () {
|
|
365
|
+
this.set(self.getAvgMTU())
|
|
366
|
+
}
|
|
367
|
+
})
|
|
326
368
|
}
|
|
327
369
|
}
|
|
328
370
|
|