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}) Copy
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})
Stores metrics in memory and periodically invokes a configured callback to receive them.
Example