status-go/metrics/node/metrics.go
Adam Babik 6da469140f
Refactor in-app metrics (#963)
Remove Prometheus and other metric types and use metrics package from go-ethereum.
2018-05-16 17:36:59 +02:00

23 lines
494 B
Go

package node
import (
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
)
var (
nodePeersGauge = metrics.NewRegisteredGauge("p2p/Peers", nil)
nodeMaxPeersGauge = metrics.NewRegisteredGauge("p2p/MaxPeers", nil)
)
func updateNodeMetrics(node *node.Node) {
server := node.Server()
if server == nil {
logger.Error("server not available")
return
}
nodePeersGauge.Update(int64(server.PeerCount()))
nodeMaxPeersGauge.Update(int64(server.MaxPeers))
}