Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: move metric neogo_version out of pkg/network #3712

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it's useless change, but OK.

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
Loading