Simple in-memory metrics gathering for libp2p
Stores metrics in memory and periodically invokes a configured callback to receive them.
import { createLibp2p } from 'libp2p'
import { simpleMetrics } from '@libp2p/simple-metrics'
const node = await createLibp2p({
// ... other options
metrics: simpleMetrics({
onMetrics: (metrics) => {
// do something with metrics
}
}),
intervalMs: 1000 // default 1s
})
$ npm i @libp2p/simple-metrics
<script>
tagLoading this module through a script tag will make it's exports available as Libp2pSimpleMetrics
in the global namespace.
<script src="https://unpkg.com/@libp2p/simple-metrics/dist/index.min.js"></script>
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Stores metrics in memory and periodically invokes a configured callback to receive them.
Example