hyperswarm-stats 1.3.2 → 1.3.4
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 +16 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -21,7 +21,7 @@ class HyperswarmStats {
|
|
|
21
21
|
this._packetsReceivedOverClosedSwarmStreams += conn.rawStream?.packetsReceived || 0
|
|
22
22
|
this._retransmitsOfClosedSwarmStreams += conn.rawStream?.retransmits
|
|
23
23
|
this._fastRecoveriesOfClosedSwarmStreams += conn.rawStream?.fastRecoveries
|
|
24
|
-
this._rtoCountOfClosedSwarmStreams += conn.rawStream?.
|
|
24
|
+
this._rtoCountOfClosedSwarmStreams += conn.rawStream?.lifetimeRtoCount || 0
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -84,7 +84,7 @@ class HyperswarmStats {
|
|
|
84
84
|
getRTOCountAcrossAllStreams() {
|
|
85
85
|
let countFromCurrentConns = 0
|
|
86
86
|
for (const conn of this.swarm.connections) {
|
|
87
|
-
countFromCurrentConns += conn.rawStream?.
|
|
87
|
+
countFromCurrentConns += conn.rawStream?.lifetimeRtoCount || 0
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
return countFromCurrentConns + this._rtoCountOfClosedSwarmStreams
|
|
@@ -130,10 +130,15 @@ class HyperswarmStats {
|
|
|
130
130
|
return this.swarm.peers.size
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
get nrConnections() {
|
|
134
|
+
return this.swarm.connections.size
|
|
135
|
+
}
|
|
136
|
+
|
|
133
137
|
toJson() {
|
|
134
138
|
return {
|
|
135
139
|
dht: this.dhtStats.toJson(),
|
|
136
140
|
nrPeers: this.nrPeers,
|
|
141
|
+
nrConnections: this.nrConnections,
|
|
137
142
|
connects: JSON.parse(JSON.stringify(this.connects)), // quick-and-dirty deep copy
|
|
138
143
|
bytesTransmittedOverSwarmStreams: this.getBytesTransmittedAcrossAllStreams(),
|
|
139
144
|
bytesReceivedOverSwarmStreams: this.getBytesReceivedAcrossAllStreams(),
|
|
@@ -150,6 +155,7 @@ class HyperswarmStats {
|
|
|
150
155
|
toString() {
|
|
151
156
|
return `Hyperswarm Stats
|
|
152
157
|
- hyperswarm_nr_peers: ${this.nrPeers}
|
|
158
|
+
- hyperswarm_nr_connections: ${this.nrConnections}
|
|
153
159
|
- hyperswarm_client_connections_opened: ${this.connects.client.opened}
|
|
154
160
|
- hyperswarm_client_connections_closed: ${this.connects.client.closed}
|
|
155
161
|
- hyperswarm_client_connections_attempted: ${this.connects.client.attempted}
|
|
@@ -173,11 +179,18 @@ ${this.dhtStats.toString()}`
|
|
|
173
179
|
const self = this
|
|
174
180
|
new promClient.Gauge({
|
|
175
181
|
name: 'hyperswarm_nr_peers',
|
|
176
|
-
help: 'Number of
|
|
182
|
+
help: 'Number of swarm peers',
|
|
177
183
|
collect() {
|
|
178
184
|
this.set(self.nrPeers)
|
|
179
185
|
}
|
|
180
186
|
})
|
|
187
|
+
new promClient.Gauge({
|
|
188
|
+
name: 'hyperswarm_nr_connections',
|
|
189
|
+
help: 'Number of current connections of the swarm',
|
|
190
|
+
collect() {
|
|
191
|
+
this.set(self.nrConnections)
|
|
192
|
+
}
|
|
193
|
+
})
|
|
181
194
|
|
|
182
195
|
new promClient.Gauge({
|
|
183
196
|
name: 'hyperswarm_client_connections_opened',
|