2019-10-29 17:51:17 +00:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Metric used in monitoring service.
|
|
|
|
var (
|
2022-10-12 19:29:55 +00:00
|
|
|
estimatedNetworkSize = prometheus.NewGauge(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Help: "Estimated network size",
|
|
|
|
Name: "network_size",
|
|
|
|
Namespace: "neogo",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2019-10-29 17:51:17 +00:00
|
|
|
peersConnected = prometheus.NewGauge(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Help: "Number of connected peers",
|
|
|
|
Name: "peers_connected",
|
|
|
|
Namespace: "neogo",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
servAndNodeVersion = prometheus.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Help: "Server and Node versions",
|
|
|
|
Name: "serv_node_version",
|
|
|
|
Namespace: "neogo",
|
|
|
|
},
|
|
|
|
[]string{"description", "value"},
|
|
|
|
)
|
|
|
|
|
|
|
|
poolCount = prometheus.NewGauge(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Help: "Number of available node addresses",
|
|
|
|
Name: "pool_count",
|
|
|
|
Namespace: "neogo",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
blockQueueLength = prometheus.NewGauge(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Help: "Block queue length",
|
|
|
|
Name: "block_queue_length",
|
|
|
|
Namespace: "neogo",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
prometheus.MustRegister(
|
2022-10-12 19:29:55 +00:00
|
|
|
estimatedNetworkSize,
|
2019-10-29 17:51:17 +00:00
|
|
|
peersConnected,
|
|
|
|
servAndNodeVersion,
|
|
|
|
poolCount,
|
|
|
|
blockQueueLength,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-10-12 19:29:55 +00:00
|
|
|
func updateNetworkSizeMetric(sz int) {
|
|
|
|
estimatedNetworkSize.Set(float64(sz))
|
|
|
|
}
|
|
|
|
|
2019-10-29 17:51:17 +00:00
|
|
|
func updateBlockQueueLenMetric(bqLen int) {
|
|
|
|
blockQueueLength.Set(float64(bqLen))
|
|
|
|
}
|
|
|
|
|
|
|
|
func updatePoolCountMetric(pCount int) {
|
|
|
|
poolCount.Set(float64(pCount))
|
|
|
|
}
|
|
|
|
|
|
|
|
func updatePeersConnectedMetric(pConnected int) {
|
|
|
|
peersConnected.Set(float64(pConnected))
|
|
|
|
}
|
|
|
|
func setServerAndNodeVersions(nodeVer string, serverID string) {
|
|
|
|
servAndNodeVersion.WithLabelValues("Node version: ", nodeVer).Add(0)
|
|
|
|
servAndNodeVersion.WithLabelValues("Server id: ", serverID).Add(0)
|
|
|
|
}
|