Skip to content

Commit

Permalink
Merge pull request #3712 from nspcc-dev/move-metrics
Browse files Browse the repository at this point in the history
*: move metric `neogo_version` out of pkg/network
  • Loading branch information
AnnaShaleva authored Dec 2, 2024
2 parents a3c2d82 + ebb7149 commit 6a7d2bc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
23 changes: 23 additions & 0 deletions cli/server/metrics.go
Original file line number Diff line number Diff line change
@@ -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,
)
}
2 changes: 1 addition & 1 deletion cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions pkg/network/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -72,7 +63,6 @@ func init() {
prometheus.MustRegister(
estimatedNetworkSize,
peersConnected,
neogoVersion,
serverID,
poolCount,
blockQueueLength,
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/network/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 6a7d2bc

Please sign in to comment.