hyperswarm-stats 1.1.3 → 1.2.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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/index.js +20 -0
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -26,3 +26,7 @@ stats.registerPrometheusMetrics(promClient)
26
26
  const metrics = await promClient.register.metrics()
27
27
  console.log(metrics)
28
28
  ```
29
+
30
+ ## Usage Without Prometheus
31
+
32
+ `swarmStats.toString()` returns a string overview of all hyperswarm and DHT stats.
package/index.js CHANGED
@@ -127,6 +127,26 @@ class HyperswarmStats {
127
127
  return this.swarm.peers.size
128
128
  }
129
129
 
130
+ toString () {
131
+ return `Hyperswarm Stats
132
+ - hyperswarm_nr_peers: ${this.nrPeers}
133
+ - hyperswarm_client_connections_opened: ${this.connects.client.opened}
134
+ - hyperswarm_client_connections_closed: ${this.connects.client.closed}
135
+ - hyperswarm_client_connections_attempted: ${this.connects.client.attempted}
136
+ - hyperswarm_server_connections_opened: ${this.connects.server.opened}
137
+ - hyperswarm_server_connections_closed: ${this.connects.server.closed}
138
+ - hyperswarm_total_bytes_transmitted_over_swarm_streams: ${this.getBytesTransmittedAcrossAllStreams()}
139
+ - hyperswarm_total_bytes_received_over_swarm_streams: ${this.getBytesReceivedAcrossAllStreams()}
140
+ - hyperswarm_total_packets_transmitted_over_swarm_streams: ${this.getPacketsTransmittedAcrossAllStreams()}
141
+ - hyperswarm_total_packets_received_over_swarm_streams: ${this.getPacketsReceivedAcrossAllStreams()}
142
+ - hyperswarm_avg_congestion_window: ${this.getAvgCongestionWindow()}
143
+ - hyperswarm_avg_mtu: ${this.getAvgMTU()}
144
+ - hyperswarm_total_retransmits_over_swarm_streams: ${this.getRetransmitsAcrossAllStreams()}
145
+ - hyperswarm_total_fast_recoveries_over_swarm_streams: ${this.getFastRecoveriesAcrossAllStreams()}
146
+ - hyperswarm_total_rto_count_over_swarm_streams: ${this.getRTOCountAcrossAllStreams()}
147
+ ${this.dhtStats.toString()}`
148
+ }
149
+
130
150
  registerPrometheusMetrics (promClient) {
131
151
  this.dhtStats.registerPrometheusMetrics(promClient)
132
152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperswarm-stats",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "Hyperswarm stats with prometheus support",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -32,6 +32,6 @@
32
32
  "standard": "^17.1.0"
33
33
  },
34
34
  "dependencies": {
35
- "hyperdht-stats": "1.0.0"
35
+ "hyperdht-stats": "^1.5.0"
36
36
  }
37
37
  }