hyperdht-stats
Version:
HyperDHT stats, with Prometheus support
36 lines (23 loc) • 755 B
Markdown
[](https://github.com/holepunchto/hyperdht) stats, with Prometheus support.
```
npm i hyperdht-stats
```
To use with Prometheus:
```
const Hyperdht = require('Hyperdht')
const DhtStats = require('hyperdht-stats')
const promClient = require('prom-client')
const dht = new Hyperdht()
const stats = new DhtStats(swarm)
stats.registerPrometheusMetrics(promClient)
// In practice metrics are exposed to a metrics scraper
// over a server, but to illustrate we just print them
const metrics = await promClient.register.metrics()
console.log(metrics)
```
`dhtStats.toString()` returns a string overview of all stats.
`dhtStats.toJson()` returns a JSON overview of all stats.