diff --git a/cli/server/metrics.go b/cli/server/metrics.go new file mode 100644 index 000000000..ddea09dce --- /dev/null +++ b/cli/server/metrics.go @@ -0,0 +1,23 @@ +package server + +import ( + "github.com/prometheus/client_golang/prometheus" +) + +var neogoVersion = prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Help: "NeoGo version", + Name: "version", + Namespace: "neogo", + }, + []string{"version"}) + +func setNeoGoVersion(nodeVer string) { + neogoVersion.WithLabelValues(nodeVer).Add(1) +} + +func init() { + prometheus.MustRegister( + neogoVersion, + ) +} diff --git a/cli/server/server.go b/cli/server/server.go index 64af4c528..26a9cd686 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -506,7 +506,7 @@ func startServer(ctx *cli.Context) error { errChan := make(chan error) rpcServer := rpcsrv.New(chain, cfg.ApplicationConfiguration.RPC, serv, oracleSrv, log, errChan) serv.AddService(rpcServer) - + setNeoGoVersion(config.Version) serv.Start() if !cfg.ApplicationConfiguration.RPC.StartWhenSynchronized { // Run RPC server in a separate routine. This is necessary to avoid a potential diff --git a/pkg/network/prometheus.go b/pkg/network/prometheus.go index 3d2631947..5560ca90b 100644 --- a/pkg/network/prometheus.go +++ b/pkg/network/prometheus.go @@ -24,15 +24,6 @@ var ( Namespace: "neogo", }, ) - - neogoVersion = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Help: "NeoGo version", - Name: "version", - Namespace: "neogo", - }, - []string{"version"}) - serverID = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Help: "network server ID", @@ -72,7 +63,6 @@ func init() { prometheus.MustRegister( estimatedNetworkSize, peersConnected, - neogoVersion, serverID, poolCount, blockQueueLength, @@ -111,10 +101,6 @@ func updatePeersConnectedMetric(pConnected int) { peersConnected.Set(float64(pConnected)) } -func setNeoGoVersion(nodeVer string) { - neogoVersion.WithLabelValues(nodeVer).Add(1) -} - func setSeverID(id string) { serverID.WithLabelValues(id).Add(1) } diff --git a/pkg/network/server.go b/pkg/network/server.go index 0669112ca..e4d25485d 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -318,7 +318,6 @@ func (s *Server) Start() { for _, tr := range s.transports { go tr.Accept() } - setNeoGoVersion(config.Version) setSeverID(strconv.FormatUint(uint64(s.id), 10)) go s.run() }